Skip to content

Commit

Permalink
MongoCluster Microsoft.DocumentDb 2024-06-01-preview (#29330)
Browse files Browse the repository at this point in the history
* Initial 2024-06-01-preview changes

* Match breaking change fixes

* remove redundant file

* Compile changes

* style/linter fixes

* Add replica promotion and geo-replica scenario

* Linter/style fixes

* Fixes

* Fix: Spellcheck, ModelValidation, Advocado

* Fix promote async action, fix promote example, add reset password example.

* Add examples

* Fix examples

* Fix more examples

* prettier fixes

* Fix LintDiff warnings

* Fixes

* Fix example

* Update npm and redo tsv

* Changes

* address comments

* update scenario file

* Finalize basic scenario

* Add suppression for Azure/azure-openapi-validator#722

* Fix supression

* Fix typespec validations

* Override go SDK for MongoClusterStatus

* Convert to new AutoRest suppressions format.

* Update readme.md

---------

Co-authored-by: Roopesh Manda <[email protected]>
  • Loading branch information
olivertowers and rkmanda authored Aug 7, 2024
1 parent c1d839d commit 4b847aa
Show file tree
Hide file tree
Showing 59 changed files with 5,126 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ using Azure.ResourceManager;
using TypeSpec.Http;

namespace Microsoft.DocumentDB;

/** Represents a mongo cluster firewall rule. */
@parentResource(MongoCluster)
model FirewallRule is ProxyResource<FirewallRuleProperties> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import "@azure-tools/typespec-client-generator-core";
using TypeSpec.Http;
using TypeSpec.OpenAPI;
using TypeSpec.Rest;
using TypeSpec.Versioning;
using Azure.ResourceManager;
using Azure.ResourceManager.Private;
using Azure.ClientGenerator.Core;
Expand Down Expand Up @@ -55,8 +56,23 @@ interface MongoClusters {
/** Check if mongo cluster name is available for use. */
@action("checkMongoClusterNameAvailability")
checkNameAvailability is checkLocalNameAvailability;
/** Promotes a replica mongo cluster to a primary role. */
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
promote is ArmResourceActionNoResponseContentAsync<
MongoCluster,
PromoteReplicaRequest
>;
}

/** Identifier for a mongo cluster resource. */
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
scalar MongoClusterResourceId
extends Azure.Core.armResourceIdentifier<[
{
type: "Microsoft.DocumentDB/mongoClusters",
}
]>;

/** The properties of a mongo cluster. */
model MongoClusterProperties {
/** The mode to create a mongo cluster. */
Expand All @@ -67,6 +83,11 @@ model MongoClusterProperties {
@visibility("create")
restoreParameters?: MongoClusterRestoreParameters;

/** The parameters to create a replica mongo cluster. */
@visibility("create")
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
replicaParameters?: MongoClusterReplicaParameters;

/** The administrator's login for the mongo cluster. */
@visibility("read", "create", "update")
administratorLogin?: string;
Expand Down Expand Up @@ -105,6 +126,20 @@ model MongoClusterProperties {
/** List of private endpoint connections. */
@visibility("read")
privateEndpointConnections?: PrivateEndpointConnection[];

/** List of private endpoint connections. */
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
previewFeatures?: PreviewFeature[];

/** The replication properties for the mongo cluster */
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
@visibility("read")
replica?: ReplicationProperties;

/** The infrastructure version the cluster is provisioned on. */
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
@visibility("read")
infrastructureVersion?: string;
}

/** The mode that the Mongo Cluster is created with. */
Expand All @@ -116,6 +151,14 @@ union CreateMode {

/** Create a mongo cluster from a restore point-in-time. */
"PointInTimeRestore",

/** Create a replica cluster in distinct geographic region from the source cluster. */
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
"GeoReplica",

/** Create a replica cluster in the same geographic region as the source cluster. */
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
"Replica",
}

/** The kind of the node on the cluster. */
Expand All @@ -133,7 +176,8 @@ model MongoClusterRestoreParameters {
pointInTimeUTC?: utcDateTime;

/** Resource ID to locate the source cluster to restore */
sourceResourceId?: string;
@typeChangedFrom(Microsoft.DocumentDB.Versions.v2024_06_01_preview, string)
sourceResourceId?: MongoClusterResourceId;
}

/** Specification for a node group. */
Expand Down Expand Up @@ -180,6 +224,7 @@ model ConnectionString {
}

/** The status of the Mongo cluster resource. */
@clientName("MongoClusterStatus", "go")
union MongoClusterStatus {
string,

Expand Down Expand Up @@ -215,3 +260,105 @@ union PublicNetworkAccess {
/** If set, the private endpoints are the exclusive access method. */
"Disabled",
}

/** Preview features that can be enabled on a mongo cluster. */
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
union PreviewFeature {
string,

/** 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. */
"GeoReplicas",
}

/** Parameters used for replica operations. */
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
model MongoClusterReplicaParameters {
/** The id of the replication source cluster. */
sourceResourceId: MongoClusterResourceId;

/** The location of the source cluster */
sourceLocation: Azure.Core.azureLocation;
}

/** Promote replica request properties. */
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
model PromoteReplicaRequest {
/** 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;
}

/** The option to apply to a promote operation. */
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
union PromoteOption {
string,

/** 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. */
"Forced",
}

/** The mode to apply to a promote operation. */
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
union PromoteMode {
string,

/** 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. */
"Switchover",
}

/** Replica properties of the mongo cluster. */
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
model ReplicationProperties {
/** The resource id the source cluster for the replica cluster. */
@visibility("read")
sourceResourceId?: MongoClusterResourceId;

/** The replication role of the cluster */
@visibility("read")
role?: ReplicationRole;

/** The replication link state of the replica cluster. */
@visibility("read")
replicationState?: ReplicationState;
}

/** Replication role of the mongo cluster. */
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
union ReplicationRole {
string,

/** The cluster is a primary replica. */
"Primary",

/** The cluster is a local asynchronous replica. */
"AsyncReplica",

/** The cluster is a geo-asynchronous replica. */
"GeoAsyncReplica",
}

/** The state of the replication link between the replica and source cluster. */
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
union ReplicationState {
string,

/** Replication link is active. */
"Active",

/** Replica is catching-up with the primary. This can occur after the replica is created or after a promotion is triggered. */
"Catchup",

/** Replica and replication link to the primary is being created. */
"Provisioning",

/** Replication link is being updated due to a change on the replica or an upgrade. */
"Updating",

/** Replication link is broken and the replica may need to be recreated. */
"Broken",

/** Replication link is re-configuring due to a promotion event. */
"Reconfiguring",
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using TypeSpec.Http;
using TypeSpec.Rest;
using TypeSpec.Versioning;
using Azure.ResourceManager;

namespace Microsoft.DocumentDB;

/** Represents a mongo cluster replica. */
@parentResource(MongoCluster)
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
model Replica is ProxyResource<MongoClusterProperties> {
/** The name of the mongo cluster firewall rule. */
@maxLength(40)
@minLength(3)
@pattern("^[a-z0-9]+(-[a-z0-9]+)*")
@key("replicaName")
@segment("replicas")
@visibility("read")
@path
name: string;
}

@armResourceOperations
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
interface Replicas {
/** List all the replicas for the mongo cluster. */
listByParent is ArmResourceListByParent<Replica>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"operationId": "MongoClusters_CreateOrUpdate",
"title": "Creates a new Mongo Cluster resource.",
"parameters": {
"subscriptionId": "ffffffff-ffff-ffff-ffff-ffffffffffff",
"resourceGroupName": "TestResourceGroup",
"mongoClusterName": "myMongoCluster",
"api-version": "2024-06-01-preview",
"resource": {
"location": "westus2",
"properties": {
"administratorLogin": "mongoAdmin",
"administratorLoginPassword": "password",
"serverVersion": "5.0",
"nodeGroupSpecs": [
{
"kind": "Shard",
"sku": "M30",
"diskSizeGB": 128,
"enableHa": true,
"nodeCount": 1
}
]
}
}
},
"responses": {
"200": {
"body": {
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster",
"name": "myMongoCluster",
"type": "/Microsoft.DocumentDB/mongoClusters",
"systemData": {
"createdBy": "user1",
"createdByType": "User",
"createdAt": "2020-01-01T17:18:19.1234567Z",
"lastModifiedBy": "user2",
"lastModifiedByType": "User",
"lastModifiedAt": "2020-01-02T17:18:19.1234567Z"
},
"properties": {
"provisioningState": "Succeeded",
"administratorLogin": "mongoAdmin",
"serverVersion": "5.0",
"nodeGroupSpecs": [
{
"kind": "Shard",
"sku": "M30",
"diskSizeGB": 128,
"enableHa": true,
"nodeCount": 3
}
],
"previewFeatures": [],
"infrastructureVersion": "1.0",
"publicNetworkAccess": "Enabled",
"connectionString": "mongodb+srv://<user>:<password>@myMongoCluster.mongocluster.cosmos.azure.com",
"earliestRestoreTime": "2023-01-13T20:07:35Z"
},
"location": "westus2"
}
},
"201": {
"body": {
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster",
"name": "myMongoCluster",
"type": "/Microsoft.DocumentDB/mongoClusters",
"systemData": {
"createdBy": "user1",
"createdByType": "User",
"createdAt": "2020-01-01T17:18:19.1234567Z",
"lastModifiedBy": "user2",
"lastModifiedByType": "User",
"lastModifiedAt": "2020-01-02T17:18:19.1234567Z"
},
"properties": {
"provisioningState": "InProgress",
"administratorLogin": "mongoAdmin",
"serverVersion": "5.0",
"nodeGroupSpecs": [
{
"kind": "Shard",
"sku": "M30",
"diskSizeGB": 128,
"enableHa": true,
"nodeCount": 3
}
],
"previewFeatures": [],
"infrastructureVersion": "1.0",
"publicNetworkAccess": "Enabled",
"connectionString": "mongodb+srv://<user>:<password>@myMongoCluster.mongocluster.cosmos.azure.com",
"earliestRestoreTime": "2023-01-13T20:07:35Z"
},
"location": "westus2"
}
}
}
}
Loading

0 comments on commit 4b847aa

Please sign in to comment.