Skip to content

Commit 4b847aa

Browse files
MongoCluster Microsoft.DocumentDb 2024-06-01-preview (#29330)
* 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]>
1 parent c1d839d commit 4b847aa

File tree

59 files changed

+5126
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+5126
-2
lines changed

specification/mongocluster/DocumentDB.MongoCluster.Management/FirewallRule.tsp

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ using Azure.ResourceManager;
33
using TypeSpec.Http;
44

55
namespace Microsoft.DocumentDB;
6+
67
/** Represents a mongo cluster firewall rule. */
78
@parentResource(MongoCluster)
89
model FirewallRule is ProxyResource<FirewallRuleProperties> {

specification/mongocluster/DocumentDB.MongoCluster.Management/MongoCluster.tsp

+148-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import "@azure-tools/typespec-client-generator-core";
33
using TypeSpec.Http;
44
using TypeSpec.OpenAPI;
55
using TypeSpec.Rest;
6+
using TypeSpec.Versioning;
67
using Azure.ResourceManager;
78
using Azure.ResourceManager.Private;
89
using Azure.ClientGenerator.Core;
@@ -55,8 +56,23 @@ interface MongoClusters {
5556
/** Check if mongo cluster name is available for use. */
5657
@action("checkMongoClusterNameAvailability")
5758
checkNameAvailability is checkLocalNameAvailability;
59+
/** Promotes a replica mongo cluster to a primary role. */
60+
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
61+
promote is ArmResourceActionNoResponseContentAsync<
62+
MongoCluster,
63+
PromoteReplicaRequest
64+
>;
5865
}
5966

67+
/** Identifier for a mongo cluster resource. */
68+
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
69+
scalar MongoClusterResourceId
70+
extends Azure.Core.armResourceIdentifier<[
71+
{
72+
type: "Microsoft.DocumentDB/mongoClusters",
73+
}
74+
]>;
75+
6076
/** The properties of a mongo cluster. */
6177
model MongoClusterProperties {
6278
/** The mode to create a mongo cluster. */
@@ -67,6 +83,11 @@ model MongoClusterProperties {
6783
@visibility("create")
6884
restoreParameters?: MongoClusterRestoreParameters;
6985

86+
/** The parameters to create a replica mongo cluster. */
87+
@visibility("create")
88+
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
89+
replicaParameters?: MongoClusterReplicaParameters;
90+
7091
/** The administrator's login for the mongo cluster. */
7192
@visibility("read", "create", "update")
7293
administratorLogin?: string;
@@ -105,6 +126,20 @@ model MongoClusterProperties {
105126
/** List of private endpoint connections. */
106127
@visibility("read")
107128
privateEndpointConnections?: PrivateEndpointConnection[];
129+
130+
/** List of private endpoint connections. */
131+
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
132+
previewFeatures?: PreviewFeature[];
133+
134+
/** The replication properties for the mongo cluster */
135+
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
136+
@visibility("read")
137+
replica?: ReplicationProperties;
138+
139+
/** The infrastructure version the cluster is provisioned on. */
140+
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
141+
@visibility("read")
142+
infrastructureVersion?: string;
108143
}
109144

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

117152
/** Create a mongo cluster from a restore point-in-time. */
118153
"PointInTimeRestore",
154+
155+
/** Create a replica cluster in distinct geographic region from the source cluster. */
156+
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
157+
"GeoReplica",
158+
159+
/** Create a replica cluster in the same geographic region as the source cluster. */
160+
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
161+
"Replica",
119162
}
120163

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

135178
/** Resource ID to locate the source cluster to restore */
136-
sourceResourceId?: string;
179+
@typeChangedFrom(Microsoft.DocumentDB.Versions.v2024_06_01_preview, string)
180+
sourceResourceId?: MongoClusterResourceId;
137181
}
138182

139183
/** Specification for a node group. */
@@ -180,6 +224,7 @@ model ConnectionString {
180224
}
181225

182226
/** The status of the Mongo cluster resource. */
227+
@clientName("MongoClusterStatus", "go")
183228
union MongoClusterStatus {
184229
string,
185230

@@ -215,3 +260,105 @@ union PublicNetworkAccess {
215260
/** If set, the private endpoints are the exclusive access method. */
216261
"Disabled",
217262
}
263+
264+
/** Preview features that can be enabled on a mongo cluster. */
265+
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
266+
union PreviewFeature {
267+
string,
268+
269+
/** 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. */
270+
"GeoReplicas",
271+
}
272+
273+
/** Parameters used for replica operations. */
274+
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
275+
model MongoClusterReplicaParameters {
276+
/** The id of the replication source cluster. */
277+
sourceResourceId: MongoClusterResourceId;
278+
279+
/** The location of the source cluster */
280+
sourceLocation: Azure.Core.azureLocation;
281+
}
282+
283+
/** Promote replica request properties. */
284+
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
285+
model PromoteReplicaRequest {
286+
/** The promote option to apply to the operation. */
287+
promoteOption: PromoteOption;
288+
289+
/** The mode to apply to the promote operation. Value is optional and default value is 'Switchover'. */
290+
mode?: PromoteMode;
291+
}
292+
293+
/** The option to apply to a promote operation. */
294+
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
295+
union PromoteOption {
296+
string,
297+
298+
/** 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. */
299+
"Forced",
300+
}
301+
302+
/** The mode to apply to a promote operation. */
303+
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
304+
union PromoteMode {
305+
string,
306+
307+
/** 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. */
308+
"Switchover",
309+
}
310+
311+
/** Replica properties of the mongo cluster. */
312+
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
313+
model ReplicationProperties {
314+
/** The resource id the source cluster for the replica cluster. */
315+
@visibility("read")
316+
sourceResourceId?: MongoClusterResourceId;
317+
318+
/** The replication role of the cluster */
319+
@visibility("read")
320+
role?: ReplicationRole;
321+
322+
/** The replication link state of the replica cluster. */
323+
@visibility("read")
324+
replicationState?: ReplicationState;
325+
}
326+
327+
/** Replication role of the mongo cluster. */
328+
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
329+
union ReplicationRole {
330+
string,
331+
332+
/** The cluster is a primary replica. */
333+
"Primary",
334+
335+
/** The cluster is a local asynchronous replica. */
336+
"AsyncReplica",
337+
338+
/** The cluster is a geo-asynchronous replica. */
339+
"GeoAsyncReplica",
340+
}
341+
342+
/** The state of the replication link between the replica and source cluster. */
343+
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
344+
union ReplicationState {
345+
string,
346+
347+
/** Replication link is active. */
348+
"Active",
349+
350+
/** Replica is catching-up with the primary. This can occur after the replica is created or after a promotion is triggered. */
351+
"Catchup",
352+
353+
/** Replica and replication link to the primary is being created. */
354+
"Provisioning",
355+
356+
/** Replication link is being updated due to a change on the replica or an upgrade. */
357+
"Updating",
358+
359+
/** Replication link is broken and the replica may need to be recreated. */
360+
"Broken",
361+
362+
/** Replication link is re-configuring due to a promotion event. */
363+
"Reconfiguring",
364+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using TypeSpec.Http;
2+
using TypeSpec.Rest;
3+
using TypeSpec.Versioning;
4+
using Azure.ResourceManager;
5+
6+
namespace Microsoft.DocumentDB;
7+
8+
/** Represents a mongo cluster replica. */
9+
@parentResource(MongoCluster)
10+
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
11+
model Replica is ProxyResource<MongoClusterProperties> {
12+
/** The name of the mongo cluster firewall rule. */
13+
@maxLength(40)
14+
@minLength(3)
15+
@pattern("^[a-z0-9]+(-[a-z0-9]+)*")
16+
@key("replicaName")
17+
@segment("replicas")
18+
@visibility("read")
19+
@path
20+
name: string;
21+
}
22+
23+
@armResourceOperations
24+
@added(Microsoft.DocumentDB.Versions.v2024_06_01_preview)
25+
interface Replicas {
26+
/** List all the replicas for the mongo cluster. */
27+
listByParent is ArmResourceListByParent<Replica>;
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{
2+
"operationId": "MongoClusters_CreateOrUpdate",
3+
"title": "Creates a new Mongo Cluster resource.",
4+
"parameters": {
5+
"subscriptionId": "ffffffff-ffff-ffff-ffff-ffffffffffff",
6+
"resourceGroupName": "TestResourceGroup",
7+
"mongoClusterName": "myMongoCluster",
8+
"api-version": "2024-06-01-preview",
9+
"resource": {
10+
"location": "westus2",
11+
"properties": {
12+
"administratorLogin": "mongoAdmin",
13+
"administratorLoginPassword": "password",
14+
"serverVersion": "5.0",
15+
"nodeGroupSpecs": [
16+
{
17+
"kind": "Shard",
18+
"sku": "M30",
19+
"diskSizeGB": 128,
20+
"enableHa": true,
21+
"nodeCount": 1
22+
}
23+
]
24+
}
25+
}
26+
},
27+
"responses": {
28+
"200": {
29+
"body": {
30+
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster",
31+
"name": "myMongoCluster",
32+
"type": "/Microsoft.DocumentDB/mongoClusters",
33+
"systemData": {
34+
"createdBy": "user1",
35+
"createdByType": "User",
36+
"createdAt": "2020-01-01T17:18:19.1234567Z",
37+
"lastModifiedBy": "user2",
38+
"lastModifiedByType": "User",
39+
"lastModifiedAt": "2020-01-02T17:18:19.1234567Z"
40+
},
41+
"properties": {
42+
"provisioningState": "Succeeded",
43+
"administratorLogin": "mongoAdmin",
44+
"serverVersion": "5.0",
45+
"nodeGroupSpecs": [
46+
{
47+
"kind": "Shard",
48+
"sku": "M30",
49+
"diskSizeGB": 128,
50+
"enableHa": true,
51+
"nodeCount": 3
52+
}
53+
],
54+
"previewFeatures": [],
55+
"infrastructureVersion": "1.0",
56+
"publicNetworkAccess": "Enabled",
57+
"connectionString": "mongodb+srv://<user>:<password>@myMongoCluster.mongocluster.cosmos.azure.com",
58+
"earliestRestoreTime": "2023-01-13T20:07:35Z"
59+
},
60+
"location": "westus2"
61+
}
62+
},
63+
"201": {
64+
"body": {
65+
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster",
66+
"name": "myMongoCluster",
67+
"type": "/Microsoft.DocumentDB/mongoClusters",
68+
"systemData": {
69+
"createdBy": "user1",
70+
"createdByType": "User",
71+
"createdAt": "2020-01-01T17:18:19.1234567Z",
72+
"lastModifiedBy": "user2",
73+
"lastModifiedByType": "User",
74+
"lastModifiedAt": "2020-01-02T17:18:19.1234567Z"
75+
},
76+
"properties": {
77+
"provisioningState": "InProgress",
78+
"administratorLogin": "mongoAdmin",
79+
"serverVersion": "5.0",
80+
"nodeGroupSpecs": [
81+
{
82+
"kind": "Shard",
83+
"sku": "M30",
84+
"diskSizeGB": 128,
85+
"enableHa": true,
86+
"nodeCount": 3
87+
}
88+
],
89+
"previewFeatures": [],
90+
"infrastructureVersion": "1.0",
91+
"publicNetworkAccess": "Enabled",
92+
"connectionString": "mongodb+srv://<user>:<password>@myMongoCluster.mongocluster.cosmos.azure.com",
93+
"earliestRestoreTime": "2023-01-13T20:07:35Z"
94+
},
95+
"location": "westus2"
96+
}
97+
}
98+
}
99+
}

0 commit comments

Comments
 (0)