diff --git a/sdk/resourcemanager/mongocluster/armmongocluster/CHANGELOG.md b/sdk/resourcemanager/mongocluster/armmongocluster/CHANGELOG.md index ef7b9daa3a52..89e49931a0ed 100644 --- a/sdk/resourcemanager/mongocluster/armmongocluster/CHANGELOG.md +++ b/sdk/resourcemanager/mongocluster/armmongocluster/CHANGELOG.md @@ -1,5 +1,45 @@ # Release History +## 1.0.0 (2024-09-25) +### Breaking Changes + +- Type of `Properties.ClusterStatus` has been changed from `*MongoClusterStatus` to `*Status` +- Enum `MongoClusterStatus` has been removed +- Enum `NodeKind` has been removed +- Struct `NodeGroupSpec` has been removed +- Field `AdministratorLogin`, `AdministratorLoginPassword`, `EarliestRestoreTime`, `NodeGroupSpecs` of struct `Properties` has been removed +- Field `AdministratorLogin`, `AdministratorLoginPassword`, `NodeGroupSpecs` of struct `UpdateProperties` has been removed + +### Features Added + +- New value `CreateModeGeoReplica`, `CreateModeReplica` added to enum type `CreateMode` +- New enum type `HighAvailabilityMode` with values `HighAvailabilityModeDisabled`, `HighAvailabilityModeSameZone`, `HighAvailabilityModeZoneRedundantPreferred` +- New enum type `PreviewFeature` with values `PreviewFeatureGeoReplicas` +- New enum type `PromoteMode` with values `PromoteModeSwitchover` +- New enum type `PromoteOption` with values `PromoteOptionForced` +- New enum type `ReplicationRole` with values `ReplicationRoleAsyncReplica`, `ReplicationRoleGeoAsyncReplica`, `ReplicationRolePrimary` +- New enum type `ReplicationState` with values `ReplicationStateActive`, `ReplicationStateBroken`, `ReplicationStateCatchup`, `ReplicationStateProvisioning`, `ReplicationStateReconfiguring`, `ReplicationStateUpdating` +- New enum type `Status` with values `StatusDropping`, `StatusProvisioning`, `StatusReady`, `StatusStarting`, `StatusStopped`, `StatusStopping`, `StatusUpdating` +- New function `*ClientFactory.NewReplicasClient() *ReplicasClient` +- New function `*MongoClustersClient.BeginPromote(context.Context, string, string, PromoteReplicaRequest, *MongoClustersClientBeginPromoteOptions) (*runtime.Poller[MongoClustersClientPromoteResponse], error)` +- New function `NewReplicasClient(string, azcore.TokenCredential, *arm.ClientOptions) (*ReplicasClient, error)` +- New function `*ReplicasClient.NewListByParentPager(string, string, *ReplicasClientListByParentOptions) *runtime.Pager[ReplicasClientListByParentResponse]` +- New struct `AdministratorProperties` +- New struct `BackupProperties` +- New struct `ComputeProperties` +- New struct `HighAvailabilityProperties` +- New struct `PromoteReplicaRequest` +- New struct `Replica` +- New struct `ReplicaListResult` +- New struct `ReplicaParameters` +- New struct `ReplicationProperties` +- New struct `ShardingProperties` +- New struct `StorageProperties` +- New field `Name` in struct `ConnectionString` +- New field `Administrator`, `Backup`, `Compute`, `HighAvailability`, `InfrastructureVersion`, `PreviewFeatures`, `Replica`, `ReplicaParameters`, `Sharding`, `Storage` in struct `Properties` +- New field `Administrator`, `Backup`, `Compute`, `HighAvailability`, `PreviewFeatures`, `Sharding`, `Storage` in struct `UpdateProperties` + + ## 0.1.0 (2024-07-05) ### Other Changes diff --git a/sdk/resourcemanager/mongocluster/armmongocluster/client_factory.go b/sdk/resourcemanager/mongocluster/armmongocluster/client_factory.go index e11c5b4349ff..c7773e0f4cb9 100644 --- a/sdk/resourcemanager/mongocluster/armmongocluster/client_factory.go +++ b/sdk/resourcemanager/mongocluster/armmongocluster/client_factory.go @@ -70,3 +70,11 @@ func (c *ClientFactory) NewPrivateLinksClient() *PrivateLinksClient { internal: c.internal, } } + +// NewReplicasClient creates a new instance of ReplicasClient. +func (c *ClientFactory) NewReplicasClient() *ReplicasClient { + return &ReplicasClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/mongocluster/armmongocluster/constants.go b/sdk/resourcemanager/mongocluster/armmongocluster/constants.go index f208f7874a40..3825305212aa 100644 --- a/sdk/resourcemanager/mongocluster/armmongocluster/constants.go +++ b/sdk/resourcemanager/mongocluster/armmongocluster/constants.go @@ -6,7 +6,7 @@ package armmongocluster const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster" - moduleVersion = "v0.1.0" + moduleVersion = "v1.0.0" ) // ActionType - Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. @@ -48,15 +48,21 @@ type CreateMode string const ( // CreateModeDefault - Create a new mongo cluster. CreateModeDefault CreateMode = "Default" + // CreateModeGeoReplica - Create a replica cluster in distinct geographic region from the source cluster. + CreateModeGeoReplica CreateMode = "GeoReplica" // CreateModePointInTimeRestore - Create a mongo cluster from a restore point-in-time. CreateModePointInTimeRestore CreateMode = "PointInTimeRestore" + // CreateModeReplica - Create a replica cluster in the same geographic region as the source cluster. + CreateModeReplica CreateMode = "Replica" ) // PossibleCreateModeValues returns the possible values for the CreateMode const type. func PossibleCreateModeValues() []CreateMode { return []CreateMode{ CreateModeDefault, + CreateModeGeoReplica, CreateModePointInTimeRestore, + CreateModeReplica, } } @@ -84,51 +90,27 @@ func PossibleCreatedByTypeValues() []CreatedByType { } } -// MongoClusterStatus - The status of the Mongo cluster resource. -type MongoClusterStatus string +// HighAvailabilityMode - The high availability modes for a cluster. +type HighAvailabilityMode string const ( - // MongoClusterStatusDropping - The mongo cluster resource is being dropped. - MongoClusterStatusDropping MongoClusterStatus = "Dropping" - // MongoClusterStatusProvisioning - The mongo cluster resource is being provisioned. - MongoClusterStatusProvisioning MongoClusterStatus = "Provisioning" - // MongoClusterStatusReady - The mongo cluster resource is ready for use. - MongoClusterStatusReady MongoClusterStatus = "Ready" - // MongoClusterStatusStarting - The mongo cluster resource is being started. - MongoClusterStatusStarting MongoClusterStatus = "Starting" - // MongoClusterStatusStopped - The mongo cluster resource is stopped. - MongoClusterStatusStopped MongoClusterStatus = "Stopped" - // MongoClusterStatusStopping - The mongo cluster resource is being stopped. - MongoClusterStatusStopping MongoClusterStatus = "Stopping" - // MongoClusterStatusUpdating - The mongo cluster resource is being updated. - MongoClusterStatusUpdating MongoClusterStatus = "Updating" + // HighAvailabilityModeDisabled - High availability mode is disabled. This mode is can see availability impact during faults + // or maintenance and is not recommended for production. + HighAvailabilityModeDisabled HighAvailabilityMode = "Disabled" + // HighAvailabilityModeSameZone - High availability mode is enabled, where each server in a shard is placed in the same availability + // zone. + HighAvailabilityModeSameZone HighAvailabilityMode = "SameZone" + // HighAvailabilityModeZoneRedundantPreferred - High availability mode is enabled and preferences ZoneRedundant if availability + // zones capacity is available in the region, otherwise falls-back to provisioning with SameZone. + HighAvailabilityModeZoneRedundantPreferred HighAvailabilityMode = "ZoneRedundantPreferred" ) -// PossibleMongoClusterStatusValues returns the possible values for the MongoClusterStatus const type. -func PossibleMongoClusterStatusValues() []MongoClusterStatus { - return []MongoClusterStatus{ - MongoClusterStatusDropping, - MongoClusterStatusProvisioning, - MongoClusterStatusReady, - MongoClusterStatusStarting, - MongoClusterStatusStopped, - MongoClusterStatusStopping, - MongoClusterStatusUpdating, - } -} - -// NodeKind - The kind of the node on the cluster. -type NodeKind string - -const ( - // NodeKindShard - The node is a shard kind. - NodeKindShard NodeKind = "Shard" -) - -// PossibleNodeKindValues returns the possible values for the NodeKind const type. -func PossibleNodeKindValues() []NodeKind { - return []NodeKind{ - NodeKindShard, +// PossibleHighAvailabilityModeValues returns the possible values for the HighAvailabilityMode const type. +func PossibleHighAvailabilityModeValues() []HighAvailabilityMode { + return []HighAvailabilityMode{ + HighAvailabilityModeDisabled, + HighAvailabilityModeSameZone, + HighAvailabilityModeZoneRedundantPreferred, } } @@ -154,6 +136,22 @@ func PossibleOriginValues() []Origin { } } +// PreviewFeature - Preview features that can be enabled on a mongo cluster. +type PreviewFeature string + +const ( + // PreviewFeatureGeoReplicas - Enables geo replicas preview feature. The feature must be set at create-time on new cluster + // to enable linking a geo-replica cluster to it. + PreviewFeatureGeoReplicas PreviewFeature = "GeoReplicas" +) + +// PossiblePreviewFeatureValues returns the possible values for the PreviewFeature const type. +func PossiblePreviewFeatureValues() []PreviewFeature { + return []PreviewFeature{ + PreviewFeatureGeoReplicas, + } +} + // PrivateEndpointConnectionProvisioningState - The current provisioning state. type PrivateEndpointConnectionProvisioningState string @@ -199,6 +197,38 @@ func PossiblePrivateEndpointServiceConnectionStatusValues() []PrivateEndpointSer } } +// PromoteMode - The mode to apply to a promote operation. +type PromoteMode string + +const ( + // PromoteModeSwitchover - Promotion will switch the current replica cluster to the primary role and the original primary + // will be switched to a replica role, maintaining the replication link. + PromoteModeSwitchover PromoteMode = "Switchover" +) + +// PossiblePromoteModeValues returns the possible values for the PromoteMode const type. +func PossiblePromoteModeValues() []PromoteMode { + return []PromoteMode{ + PromoteModeSwitchover, + } +} + +// PromoteOption - The option to apply to a promote operation. +type PromoteOption string + +const ( + // PromoteOptionForced - Promote option forces the promotion without waiting for the replica to be caught up to the primary. + // This can result in data-loss so should only be used during disaster recovery scenarios. + PromoteOptionForced PromoteOption = "Forced" +) + +// PossiblePromoteOptionValues returns the possible values for the PromoteOption const type. +func PossiblePromoteOptionValues() []PromoteOption { + return []PromoteOption{ + PromoteOptionForced, + } +} + // ProvisioningState - The provisioning state of the last accepted operation. type ProvisioningState string @@ -247,3 +277,88 @@ func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { PublicNetworkAccessEnabled, } } + +// ReplicationRole - Replication role of the mongo cluster. +type ReplicationRole string + +const ( + // ReplicationRoleAsyncReplica - The cluster is a local asynchronous replica. + ReplicationRoleAsyncReplica ReplicationRole = "AsyncReplica" + // ReplicationRoleGeoAsyncReplica - The cluster is a geo-asynchronous replica. + ReplicationRoleGeoAsyncReplica ReplicationRole = "GeoAsyncReplica" + // ReplicationRolePrimary - The cluster is a primary replica. + ReplicationRolePrimary ReplicationRole = "Primary" +) + +// PossibleReplicationRoleValues returns the possible values for the ReplicationRole const type. +func PossibleReplicationRoleValues() []ReplicationRole { + return []ReplicationRole{ + ReplicationRoleAsyncReplica, + ReplicationRoleGeoAsyncReplica, + ReplicationRolePrimary, + } +} + +// ReplicationState - The state of the replication link between the replica and source cluster. +type ReplicationState string + +const ( + // ReplicationStateActive - Replication link is active. + ReplicationStateActive ReplicationState = "Active" + // ReplicationStateBroken - Replication link is broken and the replica may need to be recreated. + ReplicationStateBroken ReplicationState = "Broken" + // ReplicationStateCatchup - Replica is catching-up with the primary. This can occur after the replica is created or after + // a promotion is triggered. + ReplicationStateCatchup ReplicationState = "Catchup" + // ReplicationStateProvisioning - Replica and replication link to the primary is being created. + ReplicationStateProvisioning ReplicationState = "Provisioning" + // ReplicationStateReconfiguring - Replication link is re-configuring due to a promotion event. + ReplicationStateReconfiguring ReplicationState = "Reconfiguring" + // ReplicationStateUpdating - Replication link is being updated due to a change on the replica or an upgrade. + ReplicationStateUpdating ReplicationState = "Updating" +) + +// PossibleReplicationStateValues returns the possible values for the ReplicationState const type. +func PossibleReplicationStateValues() []ReplicationState { + return []ReplicationState{ + ReplicationStateActive, + ReplicationStateBroken, + ReplicationStateCatchup, + ReplicationStateProvisioning, + ReplicationStateReconfiguring, + ReplicationStateUpdating, + } +} + +// Status - The status of the Mongo cluster resource. +type Status string + +const ( + // StatusDropping - The mongo cluster resource is being dropped. + StatusDropping Status = "Dropping" + // StatusProvisioning - The mongo cluster resource is being provisioned. + StatusProvisioning Status = "Provisioning" + // StatusReady - The mongo cluster resource is ready for use. + StatusReady Status = "Ready" + // StatusStarting - The mongo cluster resource is being started. + StatusStarting Status = "Starting" + // StatusStopped - The mongo cluster resource is stopped. + StatusStopped Status = "Stopped" + // StatusStopping - The mongo cluster resource is being stopped. + StatusStopping Status = "Stopping" + // StatusUpdating - The mongo cluster resource is being updated. + StatusUpdating Status = "Updating" +) + +// PossibleStatusValues returns the possible values for the Status const type. +func PossibleStatusValues() []Status { + return []Status{ + StatusDropping, + StatusProvisioning, + StatusReady, + StatusStarting, + StatusStopped, + StatusStopping, + StatusUpdating, + } +} diff --git a/sdk/resourcemanager/mongocluster/armmongocluster/fake/mongoclusters_server.go b/sdk/resourcemanager/mongocluster/armmongocluster/fake/mongoclusters_server.go index fa323bea32ef..282e05f31b53 100644 --- a/sdk/resourcemanager/mongocluster/armmongocluster/fake/mongoclusters_server.go +++ b/sdk/resourcemanager/mongocluster/armmongocluster/fake/mongoclusters_server.go @@ -48,6 +48,10 @@ type MongoClustersServer struct { // HTTP status codes to indicate success: http.StatusOK ListConnectionStrings func(ctx context.Context, resourceGroupName string, mongoClusterName string, options *armmongocluster.MongoClustersClientListConnectionStringsOptions) (resp azfake.Responder[armmongocluster.MongoClustersClientListConnectionStringsResponse], errResp azfake.ErrorResponder) + // BeginPromote is the fake for method MongoClustersClient.BeginPromote + // HTTP status codes to indicate success: http.StatusAccepted + BeginPromote func(ctx context.Context, resourceGroupName string, mongoClusterName string, body armmongocluster.PromoteReplicaRequest, options *armmongocluster.MongoClustersClientBeginPromoteOptions) (resp azfake.PollerResponder[armmongocluster.MongoClustersClientPromoteResponse], errResp azfake.ErrorResponder) + // BeginUpdate is the fake for method MongoClustersClient.BeginUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted BeginUpdate func(ctx context.Context, resourceGroupName string, mongoClusterName string, properties armmongocluster.Update, options *armmongocluster.MongoClustersClientBeginUpdateOptions) (resp azfake.PollerResponder[armmongocluster.MongoClustersClientUpdateResponse], errResp azfake.ErrorResponder) @@ -63,6 +67,7 @@ func NewMongoClustersServerTransport(srv *MongoClustersServer) *MongoClustersSer beginDelete: newTracker[azfake.PollerResponder[armmongocluster.MongoClustersClientDeleteResponse]](), newListPager: newTracker[azfake.PagerResponder[armmongocluster.MongoClustersClientListResponse]](), newListByResourceGroupPager: newTracker[azfake.PagerResponder[armmongocluster.MongoClustersClientListByResourceGroupResponse]](), + beginPromote: newTracker[azfake.PollerResponder[armmongocluster.MongoClustersClientPromoteResponse]](), beginUpdate: newTracker[azfake.PollerResponder[armmongocluster.MongoClustersClientUpdateResponse]](), } } @@ -75,6 +80,7 @@ type MongoClustersServerTransport struct { beginDelete *tracker[azfake.PollerResponder[armmongocluster.MongoClustersClientDeleteResponse]] newListPager *tracker[azfake.PagerResponder[armmongocluster.MongoClustersClientListResponse]] newListByResourceGroupPager *tracker[azfake.PagerResponder[armmongocluster.MongoClustersClientListByResourceGroupResponse]] + beginPromote *tracker[azfake.PollerResponder[armmongocluster.MongoClustersClientPromoteResponse]] beginUpdate *tracker[azfake.PollerResponder[armmongocluster.MongoClustersClientUpdateResponse]] } @@ -108,6 +114,8 @@ func (m *MongoClustersServerTransport) dispatchToMethodFake(req *http.Request, m resp, err = m.dispatchNewListByResourceGroupPager(req) case "MongoClustersClient.ListConnectionStrings": resp, err = m.dispatchListConnectionStrings(req) + case "MongoClustersClient.BeginPromote": + resp, err = m.dispatchBeginPromote(req) case "MongoClustersClient.BeginUpdate": resp, err = m.dispatchBeginUpdate(req) default: @@ -378,6 +386,54 @@ func (m *MongoClustersServerTransport) dispatchListConnectionStrings(req *http.R return resp, nil } +func (m *MongoClustersServerTransport) dispatchBeginPromote(req *http.Request) (*http.Response, error) { + if m.srv.BeginPromote == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginPromote not implemented")} + } + beginPromote := m.beginPromote.get(req) + if beginPromote == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DocumentDB/mongoClusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/promote` + 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[armmongocluster.PromoteReplicaRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + mongoClusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("mongoClusterName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.BeginPromote(req.Context(), resourceGroupNameParam, mongoClusterNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginPromote = &respr + m.beginPromote.add(req, beginPromote) + } + + resp, err := server.PollerResponderNext(beginPromote, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted}, resp.StatusCode) { + m.beginPromote.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginPromote) { + m.beginPromote.remove(req) + } + + return resp, nil +} + func (m *MongoClustersServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { if m.srv.BeginUpdate == nil { return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} diff --git a/sdk/resourcemanager/mongocluster/armmongocluster/fake/replicas_server.go b/sdk/resourcemanager/mongocluster/armmongocluster/fake/replicas_server.go new file mode 100644 index 000000000000..380cc5823b3d --- /dev/null +++ b/sdk/resourcemanager/mongocluster/armmongocluster/fake/replicas_server.go @@ -0,0 +1,108 @@ +// 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/mongocluster/armmongocluster" + "net/http" + "net/url" + "regexp" +) + +// ReplicasServer is a fake server for instances of the armmongocluster.ReplicasClient type. +type ReplicasServer struct { + // NewListByParentPager is the fake for method ReplicasClient.NewListByParentPager + // HTTP status codes to indicate success: http.StatusOK + NewListByParentPager func(resourceGroupName string, mongoClusterName string, options *armmongocluster.ReplicasClientListByParentOptions) (resp azfake.PagerResponder[armmongocluster.ReplicasClientListByParentResponse]) +} + +// NewReplicasServerTransport creates a new instance of ReplicasServerTransport with the provided implementation. +// The returned ReplicasServerTransport instance is connected to an instance of armmongocluster.ReplicasClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewReplicasServerTransport(srv *ReplicasServer) *ReplicasServerTransport { + return &ReplicasServerTransport{ + srv: srv, + newListByParentPager: newTracker[azfake.PagerResponder[armmongocluster.ReplicasClientListByParentResponse]](), + } +} + +// ReplicasServerTransport connects instances of armmongocluster.ReplicasClient to instances of ReplicasServer. +// Don't use this type directly, use NewReplicasServerTransport instead. +type ReplicasServerTransport struct { + srv *ReplicasServer + newListByParentPager *tracker[azfake.PagerResponder[armmongocluster.ReplicasClientListByParentResponse]] +} + +// Do implements the policy.Transporter interface for ReplicasServerTransport. +func (r *ReplicasServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return r.dispatchToMethodFake(req, method) +} + +func (r *ReplicasServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + var resp *http.Response + var err error + + switch method { + case "ReplicasClient.NewListByParentPager": + resp, err = r.dispatchNewListByParentPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + return resp, err +} + +func (r *ReplicasServerTransport) dispatchNewListByParentPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListByParentPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByParentPager not implemented")} + } + newListByParentPager := r.newListByParentPager.get(req) + if newListByParentPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DocumentDB/mongoClusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replicas` + 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 + } + mongoClusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("mongoClusterName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewListByParentPager(resourceGroupNameParam, mongoClusterNameParam, nil) + newListByParentPager = &resp + r.newListByParentPager.add(req, newListByParentPager) + server.PagerResponderInjectNextLinks(newListByParentPager, req, func(page *armmongocluster.ReplicasClientListByParentResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByParentPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListByParentPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByParentPager) { + r.newListByParentPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/mongocluster/armmongocluster/fake/server_factory.go b/sdk/resourcemanager/mongocluster/armmongocluster/fake/server_factory.go index 45e92750d801..b812f1fc24df 100644 --- a/sdk/resourcemanager/mongocluster/armmongocluster/fake/server_factory.go +++ b/sdk/resourcemanager/mongocluster/armmongocluster/fake/server_factory.go @@ -29,6 +29,9 @@ type ServerFactory struct { // PrivateLinksServer contains the fakes for client PrivateLinksClient PrivateLinksServer PrivateLinksServer + + // ReplicasServer contains the fakes for client ReplicasClient + ReplicasServer ReplicasServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -50,6 +53,7 @@ type ServerFactoryTransport struct { trOperationsServer *OperationsServerTransport trPrivateEndpointConnectionsServer *PrivateEndpointConnectionsServerTransport trPrivateLinksServer *PrivateLinksServerTransport + trReplicasServer *ReplicasServerTransport } // Do implements the policy.Transporter interface for ServerFactoryTransport. @@ -86,6 +90,9 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "PrivateLinksClient": initServer(s, &s.trPrivateLinksServer, func() *PrivateLinksServerTransport { return NewPrivateLinksServerTransport(&s.srv.PrivateLinksServer) }) resp, err = s.trPrivateLinksServer.Do(req) + case "ReplicasClient": + initServer(s, &s.trReplicasServer, func() *ReplicasServerTransport { return NewReplicasServerTransport(&s.srv.ReplicasServer) }) + resp, err = s.trReplicasServer.Do(req) default: err = fmt.Errorf("unhandled client %s", client) } diff --git a/sdk/resourcemanager/mongocluster/armmongocluster/firewallrules_client.go b/sdk/resourcemanager/mongocluster/armmongocluster/firewallrules_client.go index a3c21eb28284..6796ca9e9b9c 100644 --- a/sdk/resourcemanager/mongocluster/armmongocluster/firewallrules_client.go +++ b/sdk/resourcemanager/mongocluster/armmongocluster/firewallrules_client.go @@ -42,7 +42,7 @@ func NewFirewallRulesClient(subscriptionID string, credential azcore.TokenCreden // BeginCreateOrUpdate - Creates a new firewall rule or updates an existing firewall rule on a mongo cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - mongoClusterName - The name of the mongo cluster. // - firewallRuleName - The name of the mongo cluster firewall rule. @@ -70,7 +70,7 @@ func (client *FirewallRulesClient) BeginCreateOrUpdate(ctx context.Context, reso // CreateOrUpdate - Creates a new firewall rule or updates an existing firewall rule on a mongo cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 func (client *FirewallRulesClient) createOrUpdate(ctx context.Context, resourceGroupName string, mongoClusterName string, firewallRuleName string, resource FirewallRule, options *FirewallRulesClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "FirewallRulesClient.BeginCreateOrUpdate" @@ -116,7 +116,7 @@ func (client *FirewallRulesClient) createOrUpdateCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-03-01-preview") + reqQP.Set("api-version", "2024-07-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} req.Raw().Header["Content-Type"] = []string{"application/json"} @@ -129,7 +129,7 @@ func (client *FirewallRulesClient) createOrUpdateCreateRequest(ctx context.Conte // BeginDelete - Deletes a mongo cluster firewall rule. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - mongoClusterName - The name of the mongo cluster. // - firewallRuleName - The name of the mongo cluster firewall rule. @@ -155,7 +155,7 @@ func (client *FirewallRulesClient) BeginDelete(ctx context.Context, resourceGrou // Delete - Deletes a mongo cluster firewall rule. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 func (client *FirewallRulesClient) deleteOperation(ctx context.Context, resourceGroupName string, mongoClusterName string, firewallRuleName string, options *FirewallRulesClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "FirewallRulesClient.BeginDelete" @@ -201,7 +201,7 @@ func (client *FirewallRulesClient) deleteCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-03-01-preview") + reqQP.Set("api-version", "2024-07-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -210,7 +210,7 @@ func (client *FirewallRulesClient) deleteCreateRequest(ctx context.Context, reso // Get - Gets information about a mongo cluster firewall rule. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - mongoClusterName - The name of the mongo cluster. // - firewallRuleName - The name of the mongo cluster firewall rule. @@ -261,7 +261,7 @@ func (client *FirewallRulesClient) getCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-03-01-preview") + reqQP.Set("api-version", "2024-07-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -278,7 +278,7 @@ func (client *FirewallRulesClient) getHandleResponse(resp *http.Response) (Firew // NewListByMongoClusterPager - List all the firewall rules in a given mongo cluster. // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - mongoClusterName - The name of the mongo cluster. // - options - FirewallRulesClientListByMongoClusterOptions contains the optional parameters for the FirewallRulesClient.NewListByMongoClusterPager @@ -326,7 +326,7 @@ func (client *FirewallRulesClient) listByMongoClusterCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-03-01-preview") + reqQP.Set("api-version", "2024-07-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/mongocluster/armmongocluster/models.go b/sdk/resourcemanager/mongocluster/armmongocluster/models.go index 2e4009b03995..9494835cd5da 100644 --- a/sdk/resourcemanager/mongocluster/armmongocluster/models.go +++ b/sdk/resourcemanager/mongocluster/armmongocluster/models.go @@ -6,6 +6,21 @@ package armmongocluster import "time" +// AdministratorProperties - The local administrator login properties. +type AdministratorProperties struct { + // The administrator password. + Password *string + + // The administrator user name. + UserName *string +} + +// BackupProperties - The backup properties of the cluster. This includes the earliest restore time and retention settings. +type BackupProperties struct { + // READ-ONLY; Earliest restore timestamp in UTC ISO8601 format. + EarliestRestoreTime *string +} + // CheckNameAvailabilityRequest - The check availability request body. type CheckNameAvailabilityRequest struct { // The name of the resource for which availability needs to be checked. @@ -27,6 +42,14 @@ type CheckNameAvailabilityResponse struct { Reason *CheckNameAvailabilityReason } +// ComputeProperties - The compute properties of the cluster. This includes the virtual-cores/memory and scaling options applied +// to servers in the cluster. +type ComputeProperties struct { + // The compute tier to assign to the cluster, where each tier maps to a virtual-core and memory size. Example values: 'M30', + // 'M40'. + Tier *string +} + // ConnectionString - Connection string for the mongo cluster type ConnectionString struct { // READ-ONLY; Value of the connection string @@ -34,6 +57,9 @@ type ConnectionString struct { // READ-ONLY; Description of the connection string Description *string + + // READ-ONLY; Name of the connection string. + Name *string } // FirewallRule - Represents a mongo cluster firewall rule. @@ -75,6 +101,12 @@ type FirewallRuleProperties struct { ProvisioningState *ProvisioningState } +// HighAvailabilityProperties - The high availability properties of the cluster. +type HighAvailabilityProperties struct { + // The target high availability mode requested for the cluster. + TargetMode *HighAvailabilityMode +} + // ListConnectionStringsResult - The connection strings for the given mongo cluster. type ListConnectionStringsResult struct { // READ-ONLY; An array that contains the connection strings for a mongo cluster. @@ -114,31 +146,12 @@ type MongoCluster struct { Type *string } -// NodeGroupSpec - Specification for a node group. -type NodeGroupSpec struct { - // The disk storage size for the node group in GB. Example values: 128, 256, 512, 1024. - DiskSizeGB *int64 - - // Whether high availability is enabled on the node group. - EnableHa *bool - - // The node type deployed in the node group. - Kind *NodeKind - - // The number of nodes in the node group. - NodeCount *int32 - - // The resource sku for the node group. This defines the size of CPU and memory that is provisioned for each node. Example - // values: 'M30', 'M40'. - SKU *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 - // Localized display information for this particular operation. + // 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 @@ -156,17 +169,19 @@ type Operation struct { // OperationDisplay - Localized display information for and operation. type OperationDisplay struct { - // The short, localized friendly description of the operation; suitable for tool tips and detailed views. + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. Description *string - // The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", - // "Restart Virtual Machine". + // 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 - // The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". Provider *string - // The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". Resource *string } @@ -299,43 +314,118 @@ type PrivateLinkServiceConnectionState struct { Status *PrivateEndpointServiceConnectionStatus } +// PromoteReplicaRequest - Promote replica request properties. +type PromoteReplicaRequest struct { + // REQUIRED; The promote option to apply to the operation. + PromoteOption *PromoteOption + + // The mode to apply to the promote operation. Value is optional and default value is 'Switchover'. + Mode *PromoteMode +} + // Properties - The properties of a mongo cluster. type Properties struct { - // The administrator's login for the mongo cluster. - AdministratorLogin *string + // The local administrator properties for the mongo cluster. + Administrator *AdministratorProperties + + // The backup properties of the mongo cluster. + Backup *BackupProperties - // The password of the administrator login. - AdministratorLoginPassword *string + // The compute properties of the mongo cluster. + Compute *ComputeProperties // The mode to create a mongo cluster. CreateMode *CreateMode - // The list of node group specs in the cluster. - NodeGroupSpecs []*NodeGroupSpec + // The high availability properties of the mongo cluster. + HighAvailability *HighAvailabilityProperties + + // List of private endpoint connections. + PreviewFeatures []*PreviewFeature // Whether or not public endpoint access is allowed for this mongo cluster. PublicNetworkAccess *PublicNetworkAccess + // The parameters to create a replica mongo cluster. + ReplicaParameters *ReplicaParameters + // The parameters to create a point-in-time restore mongo cluster. RestoreParameters *RestoreParameters // The Mongo DB server version. Defaults to the latest available version if not specified. ServerVersion *string + // The sharding properties of the mongo cluster. + Sharding *ShardingProperties + + // The storage properties of the mongo cluster. + Storage *StorageProperties + // READ-ONLY; The status of the mongo cluster. - ClusterStatus *MongoClusterStatus + ClusterStatus *Status // READ-ONLY; The default mongo connection string for the cluster. ConnectionString *string - // READ-ONLY; Earliest restore timestamp in UTC ISO8601 format. - EarliestRestoreTime *string + // READ-ONLY; The infrastructure version the cluster is provisioned on. + InfrastructureVersion *string // READ-ONLY; List of private endpoint connections. PrivateEndpointConnections []*PrivateEndpointConnection // READ-ONLY; The provisioning state of the mongo cluster. ProvisioningState *ProvisioningState + + // READ-ONLY; The replication properties for the mongo cluster + Replica *ReplicationProperties +} + +// Replica - Represents a mongo cluster replica. +type Replica struct { + // The resource-specific properties for this resource. + Properties *Properties + + // READ-ONLY; The name of the mongo cluster firewall rule. + 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 +} + +// ReplicaListResult - The response of a Replica list operation. +type ReplicaListResult struct { + // REQUIRED; The Replica items on this page + Value []*Replica + + // The link to the next page of items + NextLink *string +} + +// ReplicaParameters - Parameters used for replica operations. +type ReplicaParameters struct { + // REQUIRED; The location of the source cluster + SourceLocation *string + + // REQUIRED; The id of the replication source cluster. + SourceResourceID *string +} + +// ReplicationProperties - Replica properties of the mongo cluster. +type ReplicationProperties struct { + // READ-ONLY; The replication link state of the replica cluster. + ReplicationState *ReplicationState + + // READ-ONLY; The replication role of the cluster + Role *ReplicationRole + + // READ-ONLY; The resource id the source cluster for the replica cluster. + SourceResourceID *string } // RestoreParameters - Parameters used for restore operations @@ -347,6 +437,20 @@ type RestoreParameters struct { SourceResourceID *string } +// ShardingProperties - The sharding properties of the cluster. This includes the shard count and scaling options for the +// cluster. +type ShardingProperties struct { + // Number of shards to provision on the cluster. + ShardCount *int32 +} + +// StorageProperties - The storage properties of the cluster. This includes the data storage size and scaling applied to servers +// in the cluster. +type StorageProperties struct { + // The size of the data disk assigned to each server. + SizeGb *int64 +} + // SystemData - Metadata pertaining to creation and last modification of the resource. type SystemData struct { // The timestamp of resource creation (UTC). @@ -370,7 +474,7 @@ type SystemData struct { // Update - The type used for update operations of the MongoCluster. type Update struct { - // The updatable properties of the MongoCluster. + // The resource-specific properties for this resource. Properties *UpdateProperties // Resource tags. @@ -379,18 +483,30 @@ type Update struct { // UpdateProperties - The updatable properties of the MongoCluster. type UpdateProperties struct { - // The administrator's login for the mongo cluster. - AdministratorLogin *string + // The local administrator properties for the mongo cluster. + Administrator *AdministratorProperties - // The password of the administrator login. - AdministratorLoginPassword *string + // The backup properties of the mongo cluster. + Backup *BackupProperties - // The list of node group specs in the cluster. - NodeGroupSpecs []*NodeGroupSpec + // The compute properties of the mongo cluster. + Compute *ComputeProperties + + // The high availability properties of the mongo cluster. + HighAvailability *HighAvailabilityProperties + + // List of private endpoint connections. + PreviewFeatures []*PreviewFeature // Whether or not public endpoint access is allowed for this mongo cluster. PublicNetworkAccess *PublicNetworkAccess // The Mongo DB server version. Defaults to the latest available version if not specified. ServerVersion *string + + // The sharding properties of the mongo cluster. + Sharding *ShardingProperties + + // The storage properties of the mongo cluster. + Storage *StorageProperties } diff --git a/sdk/resourcemanager/mongocluster/armmongocluster/models_serde.go b/sdk/resourcemanager/mongocluster/armmongocluster/models_serde.go index ab32587130b2..fba590971cba 100644 --- a/sdk/resourcemanager/mongocluster/armmongocluster/models_serde.go +++ b/sdk/resourcemanager/mongocluster/armmongocluster/models_serde.go @@ -11,6 +11,64 @@ import ( "reflect" ) +// MarshalJSON implements the json.Marshaller interface for type AdministratorProperties. +func (a AdministratorProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "password", a.Password) + populate(objectMap, "userName", a.UserName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AdministratorProperties. +func (a *AdministratorProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "password": + err = unpopulate(val, "Password", &a.Password) + delete(rawMsg, key) + case "userName": + err = unpopulate(val, "UserName", &a.UserName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BackupProperties. +func (b BackupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "earliestRestoreTime", b.EarliestRestoreTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BackupProperties. +func (b *BackupProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "earliestRestoreTime": + err = unpopulate(val, "EarliestRestoreTime", &b.EarliestRestoreTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityRequest. func (c CheckNameAvailabilityRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -77,11 +135,39 @@ func (c *CheckNameAvailabilityResponse) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ComputeProperties. +func (c ComputeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tier", c.Tier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ComputeProperties. +func (c *ComputeProperties) 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 "tier": + err = unpopulate(val, "Tier", &c.Tier) + 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 ConnectionString. func (c ConnectionString) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "connectionString", c.ConnectionString) populate(objectMap, "description", c.Description) + populate(objectMap, "name", c.Name) return json.Marshal(objectMap) } @@ -100,6 +186,9 @@ func (c *ConnectionString) UnmarshalJSON(data []byte) error { case "description": err = unpopulate(val, "Description", &c.Description) delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) @@ -217,6 +306,33 @@ func (f *FirewallRuleProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type HighAvailabilityProperties. +func (h HighAvailabilityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "targetMode", h.TargetMode) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HighAvailabilityProperties. +func (h *HighAvailabilityProperties) 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", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "targetMode": + err = unpopulate(val, "TargetMode", &h.TargetMode) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ListConnectionStringsResult. func (l ListConnectionStringsResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -326,49 +442,6 @@ func (m *MongoCluster) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type NodeGroupSpec. -func (n NodeGroupSpec) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "diskSizeGB", n.DiskSizeGB) - populate(objectMap, "enableHa", n.EnableHa) - populate(objectMap, "kind", n.Kind) - populate(objectMap, "nodeCount", n.NodeCount) - populate(objectMap, "sku", n.SKU) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type NodeGroupSpec. -func (n *NodeGroupSpec) 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", n, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "diskSizeGB": - err = unpopulate(val, "DiskSizeGB", &n.DiskSizeGB) - delete(rawMsg, key) - case "enableHa": - err = unpopulate(val, "EnableHa", &n.EnableHa) - delete(rawMsg, key) - case "kind": - err = unpopulate(val, "Kind", &n.Kind) - delete(rawMsg, key) - case "nodeCount": - err = unpopulate(val, "NodeCount", &n.NodeCount) - delete(rawMsg, key) - case "sku": - err = unpopulate(val, "SKU", &n.SKU) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", n, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type Operation. func (o Operation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -809,21 +882,58 @@ func (p *PrivateLinkServiceConnectionState) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type PromoteReplicaRequest. +func (p PromoteReplicaRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "mode", p.Mode) + populate(objectMap, "promoteOption", p.PromoteOption) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PromoteReplicaRequest. +func (p *PromoteReplicaRequest) 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 "mode": + err = unpopulate(val, "Mode", &p.Mode) + delete(rawMsg, key) + case "promoteOption": + err = unpopulate(val, "PromoteOption", &p.PromoteOption) + 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 Properties. func (p Properties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "administratorLogin", p.AdministratorLogin) - populate(objectMap, "administratorLoginPassword", p.AdministratorLoginPassword) + populate(objectMap, "administrator", p.Administrator) + populate(objectMap, "backup", p.Backup) populate(objectMap, "clusterStatus", p.ClusterStatus) + populate(objectMap, "compute", p.Compute) populate(objectMap, "connectionString", p.ConnectionString) populate(objectMap, "createMode", p.CreateMode) - populate(objectMap, "earliestRestoreTime", p.EarliestRestoreTime) - populate(objectMap, "nodeGroupSpecs", p.NodeGroupSpecs) + populate(objectMap, "highAvailability", p.HighAvailability) + populate(objectMap, "infrastructureVersion", p.InfrastructureVersion) + populate(objectMap, "previewFeatures", p.PreviewFeatures) populate(objectMap, "privateEndpointConnections", p.PrivateEndpointConnections) populate(objectMap, "provisioningState", p.ProvisioningState) populate(objectMap, "publicNetworkAccess", p.PublicNetworkAccess) + populate(objectMap, "replica", p.Replica) + populate(objectMap, "replicaParameters", p.ReplicaParameters) populate(objectMap, "restoreParameters", p.RestoreParameters) populate(objectMap, "serverVersion", p.ServerVersion) + populate(objectMap, "sharding", p.Sharding) + populate(objectMap, "storage", p.Storage) return json.Marshal(objectMap) } @@ -836,26 +946,32 @@ func (p *Properties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "administratorLogin": - err = unpopulate(val, "AdministratorLogin", &p.AdministratorLogin) + case "administrator": + err = unpopulate(val, "Administrator", &p.Administrator) delete(rawMsg, key) - case "administratorLoginPassword": - err = unpopulate(val, "AdministratorLoginPassword", &p.AdministratorLoginPassword) + case "backup": + err = unpopulate(val, "Backup", &p.Backup) delete(rawMsg, key) case "clusterStatus": err = unpopulate(val, "ClusterStatus", &p.ClusterStatus) delete(rawMsg, key) + case "compute": + err = unpopulate(val, "Compute", &p.Compute) + delete(rawMsg, key) case "connectionString": err = unpopulate(val, "ConnectionString", &p.ConnectionString) delete(rawMsg, key) case "createMode": err = unpopulate(val, "CreateMode", &p.CreateMode) delete(rawMsg, key) - case "earliestRestoreTime": - err = unpopulate(val, "EarliestRestoreTime", &p.EarliestRestoreTime) + case "highAvailability": + err = unpopulate(val, "HighAvailability", &p.HighAvailability) + delete(rawMsg, key) + case "infrastructureVersion": + err = unpopulate(val, "InfrastructureVersion", &p.InfrastructureVersion) delete(rawMsg, key) - case "nodeGroupSpecs": - err = unpopulate(val, "NodeGroupSpecs", &p.NodeGroupSpecs) + case "previewFeatures": + err = unpopulate(val, "PreviewFeatures", &p.PreviewFeatures) delete(rawMsg, key) case "privateEndpointConnections": err = unpopulate(val, "PrivateEndpointConnections", &p.PrivateEndpointConnections) @@ -866,12 +982,24 @@ func (p *Properties) UnmarshalJSON(data []byte) error { case "publicNetworkAccess": err = unpopulate(val, "PublicNetworkAccess", &p.PublicNetworkAccess) delete(rawMsg, key) + case "replica": + err = unpopulate(val, "Replica", &p.Replica) + delete(rawMsg, key) + case "replicaParameters": + err = unpopulate(val, "ReplicaParameters", &p.ReplicaParameters) + delete(rawMsg, key) case "restoreParameters": err = unpopulate(val, "RestoreParameters", &p.RestoreParameters) delete(rawMsg, key) case "serverVersion": err = unpopulate(val, "ServerVersion", &p.ServerVersion) delete(rawMsg, key) + case "sharding": + err = unpopulate(val, "Sharding", &p.Sharding) + delete(rawMsg, key) + case "storage": + err = unpopulate(val, "Storage", &p.Storage) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", p, err) @@ -880,6 +1008,146 @@ func (p *Properties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type Replica. +func (r Replica) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Replica. +func (r *Replica) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReplicaListResult. +func (r ReplicaListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReplicaListResult. +func (r *ReplicaListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReplicaParameters. +func (r ReplicaParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "sourceLocation", r.SourceLocation) + populate(objectMap, "sourceResourceId", r.SourceResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReplicaParameters. +func (r *ReplicaParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "sourceLocation": + err = unpopulate(val, "SourceLocation", &r.SourceLocation) + delete(rawMsg, key) + case "sourceResourceId": + err = unpopulate(val, "SourceResourceID", &r.SourceResourceID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReplicationProperties. +func (r ReplicationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "replicationState", r.ReplicationState) + populate(objectMap, "role", r.Role) + populate(objectMap, "sourceResourceId", r.SourceResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReplicationProperties. +func (r *ReplicationProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "replicationState": + err = unpopulate(val, "ReplicationState", &r.ReplicationState) + delete(rawMsg, key) + case "role": + err = unpopulate(val, "Role", &r.Role) + delete(rawMsg, key) + case "sourceResourceId": + err = unpopulate(val, "SourceResourceID", &r.SourceResourceID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type RestoreParameters. func (r RestoreParameters) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -911,6 +1179,60 @@ func (r *RestoreParameters) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ShardingProperties. +func (s ShardingProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "shardCount", s.ShardCount) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ShardingProperties. +func (s *ShardingProperties) 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 "shardCount": + err = unpopulate(val, "ShardCount", &s.ShardCount) + 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 StorageProperties. +func (s StorageProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "sizeGb", s.SizeGb) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageProperties. +func (s *StorageProperties) 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 "sizeGb": + err = unpopulate(val, "SizeGb", &s.SizeGb) + 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) @@ -992,11 +1314,15 @@ func (u *Update) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type UpdateProperties. func (u UpdateProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "administratorLogin", u.AdministratorLogin) - populate(objectMap, "administratorLoginPassword", u.AdministratorLoginPassword) - populate(objectMap, "nodeGroupSpecs", u.NodeGroupSpecs) + populate(objectMap, "administrator", u.Administrator) + populate(objectMap, "backup", u.Backup) + populate(objectMap, "compute", u.Compute) + populate(objectMap, "highAvailability", u.HighAvailability) + populate(objectMap, "previewFeatures", u.PreviewFeatures) populate(objectMap, "publicNetworkAccess", u.PublicNetworkAccess) populate(objectMap, "serverVersion", u.ServerVersion) + populate(objectMap, "sharding", u.Sharding) + populate(objectMap, "storage", u.Storage) return json.Marshal(objectMap) } @@ -1009,14 +1335,20 @@ func (u *UpdateProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "administratorLogin": - err = unpopulate(val, "AdministratorLogin", &u.AdministratorLogin) + case "administrator": + err = unpopulate(val, "Administrator", &u.Administrator) delete(rawMsg, key) - case "administratorLoginPassword": - err = unpopulate(val, "AdministratorLoginPassword", &u.AdministratorLoginPassword) + case "backup": + err = unpopulate(val, "Backup", &u.Backup) delete(rawMsg, key) - case "nodeGroupSpecs": - err = unpopulate(val, "NodeGroupSpecs", &u.NodeGroupSpecs) + case "compute": + err = unpopulate(val, "Compute", &u.Compute) + delete(rawMsg, key) + case "highAvailability": + err = unpopulate(val, "HighAvailability", &u.HighAvailability) + delete(rawMsg, key) + case "previewFeatures": + err = unpopulate(val, "PreviewFeatures", &u.PreviewFeatures) delete(rawMsg, key) case "publicNetworkAccess": err = unpopulate(val, "PublicNetworkAccess", &u.PublicNetworkAccess) @@ -1024,6 +1356,12 @@ func (u *UpdateProperties) UnmarshalJSON(data []byte) error { case "serverVersion": err = unpopulate(val, "ServerVersion", &u.ServerVersion) delete(rawMsg, key) + case "sharding": + err = unpopulate(val, "Sharding", &u.Sharding) + delete(rawMsg, key) + case "storage": + err = unpopulate(val, "Storage", &u.Storage) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", u, err) diff --git a/sdk/resourcemanager/mongocluster/armmongocluster/mongoclusters_client.go b/sdk/resourcemanager/mongocluster/armmongocluster/mongoclusters_client.go index 91ecf8f59bc3..14410d6a7eab 100644 --- a/sdk/resourcemanager/mongocluster/armmongocluster/mongoclusters_client.go +++ b/sdk/resourcemanager/mongocluster/armmongocluster/mongoclusters_client.go @@ -42,7 +42,7 @@ func NewMongoClustersClient(subscriptionID string, credential azcore.TokenCreden // CheckNameAvailability - Check if mongo cluster name is available for use. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 // - location - The location name. // - body - The CheckAvailability request // - options - MongoClustersClientCheckNameAvailabilityOptions contains the optional parameters for the MongoClustersClient.CheckNameAvailability @@ -85,7 +85,7 @@ func (client *MongoClustersClient) checkNameAvailabilityCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-03-01-preview") + reqQP.Set("api-version", "2024-07-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} req.Raw().Header["Content-Type"] = []string{"application/json"} @@ -108,7 +108,7 @@ func (client *MongoClustersClient) checkNameAvailabilityHandleResponse(resp *htt // some of the properties, use PATCH. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - mongoClusterName - The name of the mongo cluster. // - resource - Resource create parameters. @@ -136,7 +136,7 @@ func (client *MongoClustersClient) BeginCreateOrUpdate(ctx context.Context, reso // of the properties, use PATCH. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 func (client *MongoClustersClient) createOrUpdate(ctx context.Context, resourceGroupName string, mongoClusterName string, resource MongoCluster, options *MongoClustersClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "MongoClustersClient.BeginCreateOrUpdate" @@ -178,7 +178,7 @@ func (client *MongoClustersClient) createOrUpdateCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-03-01-preview") + reqQP.Set("api-version", "2024-07-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} req.Raw().Header["Content-Type"] = []string{"application/json"} @@ -191,7 +191,7 @@ func (client *MongoClustersClient) createOrUpdateCreateRequest(ctx context.Conte // BeginDelete - Deletes a mongo cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - mongoClusterName - The name of the mongo cluster. // - options - MongoClustersClientBeginDeleteOptions contains the optional parameters for the MongoClustersClient.BeginDelete @@ -216,7 +216,7 @@ func (client *MongoClustersClient) BeginDelete(ctx context.Context, resourceGrou // Delete - Deletes a mongo cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 func (client *MongoClustersClient) deleteOperation(ctx context.Context, resourceGroupName string, mongoClusterName string, options *MongoClustersClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "MongoClustersClient.BeginDelete" @@ -258,7 +258,7 @@ func (client *MongoClustersClient) deleteCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-03-01-preview") + reqQP.Set("api-version", "2024-07-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -267,7 +267,7 @@ func (client *MongoClustersClient) deleteCreateRequest(ctx context.Context, reso // Get - Gets information about a mongo cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - mongoClusterName - The name of the mongo cluster. // - options - MongoClustersClientGetOptions contains the optional parameters for the MongoClustersClient.Get method. @@ -313,7 +313,7 @@ func (client *MongoClustersClient) getCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-03-01-preview") + reqQP.Set("api-version", "2024-07-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -330,7 +330,7 @@ func (client *MongoClustersClient) getHandleResponse(resp *http.Response) (Mongo // NewListPager - List all the mongo clusters in a given subscription. // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 // - options - MongoClustersClientListOptions contains the optional parameters for the MongoClustersClient.NewListPager method. func (client *MongoClustersClient) NewListPager(options *MongoClustersClientListOptions) *runtime.Pager[MongoClustersClientListResponse] { return runtime.NewPager(runtime.PagingHandler[MongoClustersClientListResponse]{ @@ -367,7 +367,7 @@ func (client *MongoClustersClient) listCreateRequest(ctx context.Context, _ *Mon return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-03-01-preview") + reqQP.Set("api-version", "2024-07-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -384,7 +384,7 @@ func (client *MongoClustersClient) listHandleResponse(resp *http.Response) (Mong // NewListByResourceGroupPager - List all the mongo clusters in a given resource group. // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - MongoClustersClientListByResourceGroupOptions contains the optional parameters for the MongoClustersClient.NewListByResourceGroupPager // method. @@ -427,7 +427,7 @@ func (client *MongoClustersClient) listByResourceGroupCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-03-01-preview") + reqQP.Set("api-version", "2024-07-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -446,7 +446,7 @@ func (client *MongoClustersClient) listByResourceGroupHandleResponse(resp *http. // as well as other connection strings supported by the cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - mongoClusterName - The name of the mongo cluster. // - options - MongoClustersClientListConnectionStringsOptions contains the optional parameters for the MongoClustersClient.ListConnectionStrings @@ -493,7 +493,7 @@ func (client *MongoClustersClient) listConnectionStringsCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-03-01-preview") + reqQP.Set("api-version", "2024-07-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -508,11 +508,92 @@ func (client *MongoClustersClient) listConnectionStringsHandleResponse(resp *htt return result, nil } +// BeginPromote - Promotes a replica mongo cluster to a primary role. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-07-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mongoClusterName - The name of the mongo cluster. +// - body - The content of the action request +// - options - MongoClustersClientBeginPromoteOptions contains the optional parameters for the MongoClustersClient.BeginPromote +// method. +func (client *MongoClustersClient) BeginPromote(ctx context.Context, resourceGroupName string, mongoClusterName string, body PromoteReplicaRequest, options *MongoClustersClientBeginPromoteOptions) (*runtime.Poller[MongoClustersClientPromoteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.promote(ctx, resourceGroupName, mongoClusterName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[MongoClustersClientPromoteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[MongoClustersClientPromoteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Promote - Promotes a replica mongo cluster to a primary role. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-07-01 +func (client *MongoClustersClient) promote(ctx context.Context, resourceGroupName string, mongoClusterName string, body PromoteReplicaRequest, options *MongoClustersClientBeginPromoteOptions) (*http.Response, error) { + var err error + const operationName = "MongoClustersClient.BeginPromote" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.promoteCreateRequest(ctx, resourceGroupName, mongoClusterName, body, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// promoteCreateRequest creates the Promote request. +func (client *MongoClustersClient) promoteCreateRequest(ctx context.Context, resourceGroupName string, mongoClusterName string, body PromoteReplicaRequest, _ *MongoClustersClientBeginPromoteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/promote" + 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 mongoClusterName == "" { + return nil, errors.New("parameter mongoClusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{mongoClusterName}", url.PathEscape(mongoClusterName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + // BeginUpdate - Updates an existing mongo cluster. The request body can contain one to many of the properties present in // the normal mongo cluster definition. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - mongoClusterName - The name of the mongo cluster. // - properties - The resource properties to be updated. @@ -539,7 +620,7 @@ func (client *MongoClustersClient) BeginUpdate(ctx context.Context, resourceGrou // mongo cluster definition. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 func (client *MongoClustersClient) update(ctx context.Context, resourceGroupName string, mongoClusterName string, properties Update, options *MongoClustersClientBeginUpdateOptions) (*http.Response, error) { var err error const operationName = "MongoClustersClient.BeginUpdate" @@ -581,7 +662,7 @@ func (client *MongoClustersClient) updateCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-03-01-preview") + reqQP.Set("api-version", "2024-07-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} req.Raw().Header["Content-Type"] = []string{"application/json"} diff --git a/sdk/resourcemanager/mongocluster/armmongocluster/operations_client.go b/sdk/resourcemanager/mongocluster/armmongocluster/operations_client.go index e63291b6e416..92c1aa08839c 100644 --- a/sdk/resourcemanager/mongocluster/armmongocluster/operations_client.go +++ b/sdk/resourcemanager/mongocluster/armmongocluster/operations_client.go @@ -35,7 +35,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // NewListPager - List the operations for the provider // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 // - 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]{ @@ -68,7 +68,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, _ *Operat return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-03-01-preview") + reqQP.Set("api-version", "2024-07-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/mongocluster/armmongocluster/options.go b/sdk/resourcemanager/mongocluster/armmongocluster/options.go index 4a8aa0f4497a..8f6ec748f68b 100644 --- a/sdk/resourcemanager/mongocluster/armmongocluster/options.go +++ b/sdk/resourcemanager/mongocluster/armmongocluster/options.go @@ -41,6 +41,12 @@ type MongoClustersClientBeginDeleteOptions struct { ResumeToken string } +// MongoClustersClientBeginPromoteOptions contains the optional parameters for the MongoClustersClient.BeginPromote method. +type MongoClustersClientBeginPromoteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + // MongoClustersClientBeginUpdateOptions contains the optional parameters for the MongoClustersClient.BeginUpdate method. type MongoClustersClientBeginUpdateOptions struct { // Resumes the long-running operation from the provided token. @@ -111,3 +117,8 @@ type PrivateEndpointConnectionsClientListByMongoClusterOptions struct { type PrivateLinksClientListByMongoClusterOptions struct { // placeholder for future optional parameters } + +// ReplicasClientListByParentOptions contains the optional parameters for the ReplicasClient.NewListByParentPager method. +type ReplicasClientListByParentOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/mongocluster/armmongocluster/privateendpointconnections_client.go b/sdk/resourcemanager/mongocluster/armmongocluster/privateendpointconnections_client.go index bf7b76fb5418..4a4bce2e5469 100644 --- a/sdk/resourcemanager/mongocluster/armmongocluster/privateendpointconnections_client.go +++ b/sdk/resourcemanager/mongocluster/armmongocluster/privateendpointconnections_client.go @@ -42,7 +42,7 @@ func NewPrivateEndpointConnectionsClient(subscriptionID string, credential azcor // BeginCreate - Create a Private endpoint connection // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - mongoClusterName - The name of the mongo cluster. // - privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource. @@ -70,7 +70,7 @@ func (client *PrivateEndpointConnectionsClient) BeginCreate(ctx context.Context, // Create - Create a Private endpoint connection // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 func (client *PrivateEndpointConnectionsClient) create(ctx context.Context, resourceGroupName string, mongoClusterName string, privateEndpointConnectionName string, resource PrivateEndpointConnectionResource, options *PrivateEndpointConnectionsClientBeginCreateOptions) (*http.Response, error) { var err error const operationName = "PrivateEndpointConnectionsClient.BeginCreate" @@ -116,7 +116,7 @@ func (client *PrivateEndpointConnectionsClient) createCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-03-01-preview") + reqQP.Set("api-version", "2024-07-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} req.Raw().Header["Content-Type"] = []string{"application/json"} @@ -129,7 +129,7 @@ func (client *PrivateEndpointConnectionsClient) createCreateRequest(ctx context. // BeginDelete - Delete the private endpoint connection // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - mongoClusterName - The name of the mongo cluster. // - privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource. @@ -155,7 +155,7 @@ func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, // Delete - Delete the private endpoint connection // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 func (client *PrivateEndpointConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, mongoClusterName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "PrivateEndpointConnectionsClient.BeginDelete" @@ -201,7 +201,7 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-03-01-preview") + reqQP.Set("api-version", "2024-07-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -210,7 +210,7 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. // Get - Get a specific private connection // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - mongoClusterName - The name of the mongo cluster. // - privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource. @@ -262,7 +262,7 @@ func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-03-01-preview") + reqQP.Set("api-version", "2024-07-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -279,7 +279,7 @@ func (client *PrivateEndpointConnectionsClient) getHandleResponse(resp *http.Res // NewListByMongoClusterPager - List existing private connections // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - mongoClusterName - The name of the mongo cluster. // - options - PrivateEndpointConnectionsClientListByMongoClusterOptions contains the optional parameters for the PrivateEndpointConnectionsClient.NewListByMongoClusterPager @@ -327,7 +327,7 @@ func (client *PrivateEndpointConnectionsClient) listByMongoClusterCreateRequest( return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-03-01-preview") + reqQP.Set("api-version", "2024-07-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/mongocluster/armmongocluster/privatelinks_client.go b/sdk/resourcemanager/mongocluster/armmongocluster/privatelinks_client.go index 20bc16490481..840e98926789 100644 --- a/sdk/resourcemanager/mongocluster/armmongocluster/privatelinks_client.go +++ b/sdk/resourcemanager/mongocluster/armmongocluster/privatelinks_client.go @@ -41,7 +41,7 @@ func NewPrivateLinksClient(subscriptionID string, credential azcore.TokenCredent // NewListByMongoClusterPager - list private links on the given resource // -// Generated from API version 2024-03-01-preview +// Generated from API version 2024-07-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - mongoClusterName - The name of the mongo cluster. // - options - PrivateLinksClientListByMongoClusterOptions contains the optional parameters for the PrivateLinksClient.NewListByMongoClusterPager @@ -89,7 +89,7 @@ func (client *PrivateLinksClient) listByMongoClusterCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-03-01-preview") + reqQP.Set("api-version", "2024-07-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/mongocluster/armmongocluster/replicas_client.go b/sdk/resourcemanager/mongocluster/armmongocluster/replicas_client.go new file mode 100644 index 000000000000..61edf522a6f5 --- /dev/null +++ b/sdk/resourcemanager/mongocluster/armmongocluster/replicas_client.go @@ -0,0 +1,105 @@ +// 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 armmongocluster + +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" +) + +// ReplicasClient contains the methods for the Replicas group. +// Don't use this type directly, use NewReplicasClient() instead. +type ReplicasClient struct { + internal *arm.Client + subscriptionID string +} + +// NewReplicasClient creates a new instance of ReplicasClient 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 NewReplicasClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ReplicasClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ReplicasClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// NewListByParentPager - List all the replicas for the mongo cluster. +// +// Generated from API version 2024-07-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - mongoClusterName - The name of the mongo cluster. +// - options - ReplicasClientListByParentOptions contains the optional parameters for the ReplicasClient.NewListByParentPager +// method. +func (client *ReplicasClient) NewListByParentPager(resourceGroupName string, mongoClusterName string, options *ReplicasClientListByParentOptions) *runtime.Pager[ReplicasClientListByParentResponse] { + return runtime.NewPager(runtime.PagingHandler[ReplicasClientListByParentResponse]{ + More: func(page ReplicasClientListByParentResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ReplicasClientListByParentResponse) (ReplicasClientListByParentResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ReplicasClient.NewListByParentPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByParentCreateRequest(ctx, resourceGroupName, mongoClusterName, options) + }, nil) + if err != nil { + return ReplicasClientListByParentResponse{}, err + } + return client.listByParentHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByParentCreateRequest creates the ListByParent request. +func (client *ReplicasClient) listByParentCreateRequest(ctx context.Context, resourceGroupName string, mongoClusterName string, _ *ReplicasClientListByParentOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/replicas" + 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 mongoClusterName == "" { + return nil, errors.New("parameter mongoClusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{mongoClusterName}", url.PathEscape(mongoClusterName)) + 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-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByParentHandleResponse handles the ListByParent response. +func (client *ReplicasClient) listByParentHandleResponse(resp *http.Response) (ReplicasClientListByParentResponse, error) { + result := ReplicasClientListByParentResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ReplicaListResult); err != nil { + return ReplicasClientListByParentResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/mongocluster/armmongocluster/responses.go b/sdk/resourcemanager/mongocluster/armmongocluster/responses.go index 52e99042319e..eaf38c9726cb 100644 --- a/sdk/resourcemanager/mongocluster/armmongocluster/responses.go +++ b/sdk/resourcemanager/mongocluster/armmongocluster/responses.go @@ -68,6 +68,11 @@ type MongoClustersClientListResponse struct { ListResult } +// MongoClustersClientPromoteResponse contains the response from method MongoClustersClient.BeginPromote. +type MongoClustersClientPromoteResponse struct { + // placeholder for future response values +} + // MongoClustersClientUpdateResponse contains the response from method MongoClustersClient.BeginUpdate. type MongoClustersClientUpdateResponse struct { // Represents a mongo cluster resource. @@ -108,3 +113,9 @@ type PrivateLinksClientListByMongoClusterResponse struct { // The response of a PrivateLinkResource list operation. PrivateLinkResourceListResult } + +// ReplicasClientListByParentResponse contains the response from method ReplicasClient.NewListByParentPager. +type ReplicasClientListByParentResponse struct { + // The response of a Replica list operation. + ReplicaListResult +} diff --git a/sdk/resourcemanager/mongocluster/armmongocluster/tsp-location.yaml b/sdk/resourcemanager/mongocluster/armmongocluster/tsp-location.yaml index 6f51513426e4..cc9b21805024 100644 --- a/sdk/resourcemanager/mongocluster/armmongocluster/tsp-location.yaml +++ b/sdk/resourcemanager/mongocluster/armmongocluster/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/mongocluster/DocumentDB.MongoCluster.Management -commit: 87a08b955c257c773a3bd42553c718d4b1092955 -repo: https://github.com/Azure/azure-rest-api-specs -additionalDirectories: +commit: 164057f2357caad20cab30011df32d60d0cc6bdc +repo: Azure/azure-rest-api-specs +additionalDirectories: \ No newline at end of file