Skip to content

Commit ac3db63

Browse files
Add new API version 2024-03-01-preview for Microsoft.DocumentDB mongocluster (#27733)
* Generate new Service for cosmosdbmongoclusters * Add cosmosdbmongoclusters service for Microsoft.DocumentDB RP. Includes TypeSpec definitions, examples, scenario tests and generated Swagger API files * First phase of renaming to mongocluster in files only * Rename example files, cleanup additional name changes * Rename folder * removed the old examples * Remove plural MongoClusters * Move typespec to DocumentDB.MongoCluster.Management * move mongoclusters->mongocluster for the service folder * Fix plural resource type * Final renames * Add private link and private endpoint resources * Rename * Fix examples * Fix examples * Add Accepted/202 pattern for firewall and PEC. Add correct async headers to examples. * Fix LROHeaders and example names * Remove Accepted 202 support for firewall/PEC create - to be added in future api release * Fix new line * Fixes * Auto-correct * Fix scenario tests * Add Accepted/202 pattern for firewall and PEC. Add correct async headers to examples. * Fix LROHeaders and example names * Adding accepted response handling * Add results of last compile * Fix formatting --------- Co-authored-by: madhura <[email protected]>
1 parent b627f6c commit ac3db63

File tree

61 files changed

+4713
-0
lines changed

Some content is hidden

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

61 files changed

+4713
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
env.json
2+
package-lock.json
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import "@azure-tools/typespec-azure-core";
2+
import "@azure-tools/typespec-azure-resource-manager";
3+
import "@typespec/rest";
4+
import "./common.tsp";
5+
import "./MongoCluster.tsp";
6+
7+
using TypeSpec.Rest;
8+
using Azure.ResourceManager;
9+
using Azure.ResourceManager.Foundations;
10+
using TypeSpec.Http;
11+
12+
namespace Microsoft.DocumentDB;
13+
@doc("Represents a mongo cluster firewall rule.")
14+
@parentResource(MongoCluster)
15+
model FirewallRule is ProxyResource<FirewallRuleProperties> {
16+
@doc("The name of the mongo cluster firewall rule.")
17+
@maxLength(80)
18+
@minLength(1)
19+
@pattern("^[a-zA-Z0-9][-_.a-zA-Z0-9]*")
20+
@key("firewallRuleName")
21+
@segment("firewallRules")
22+
@visibility("read")
23+
@path
24+
name: string;
25+
}
26+
27+
@doc("The properties of a mongo cluster firewall rule.")
28+
model FirewallRuleProperties {
29+
@doc("The provisioning state of the firewall rule.")
30+
@visibility("read")
31+
provisioningState?: ProvisioningState;
32+
33+
@doc("The start IP address of the mongo cluster firewall rule. Must be IPv4 format.")
34+
@pattern("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$")
35+
startIpAddress: string;
36+
37+
@doc("The end IP address of the mongo cluster firewall rule. Must be IPv4 format.")
38+
@pattern("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$")
39+
endIpAddress: string;
40+
}
41+
42+
@armResourceOperations
43+
interface FirewallRules {
44+
@doc("Gets information about a mongo cluster firewall rule.")
45+
get is ArmResourceRead<FirewallRule>;
46+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-put-operation-response-codes" "Need to support existing 202 response for PUT operations"
47+
@doc("Creates a new firewall rule or updates an existing firewall rule on a mongo cluster.")
48+
createOrUpdate is Operations.ArmResourceCreateOrUpdateWithAcceptedAsync<FirewallRule>;
49+
@doc("Deletes a mongo cluster firewall rule.")
50+
delete is ArmResourceDeleteWithoutOkAsync<FirewallRule>;
51+
@doc("List all the firewall rules in a given mongo cluster.")
52+
listByParent is ArmResourceListByParent<FirewallRule>;
53+
}
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
import "@azure-tools/typespec-azure-core";
2+
import "@azure-tools/typespec-azure-resource-manager";
3+
import "@azure-tools/typespec-client-generator-core";
4+
import "@typespec/openapi";
5+
import "@typespec/rest";
6+
import "./common.tsp";
7+
8+
using TypeSpec.Http;
9+
using TypeSpec.OpenAPI;
10+
using TypeSpec.Rest;
11+
using Azure.ResourceManager;
12+
using Azure.ResourceManager.Foundations;
13+
using Azure.ResourceManager.Private;
14+
using Azure.ClientGenerator.Core;
15+
16+
namespace Microsoft.DocumentDB;
17+
@doc("Represents a mongo cluster resource.")
18+
model MongoCluster is TrackedResource<MongoClusterProperties> {
19+
@doc("The name of the mongo cluster.")
20+
@maxLength(40)
21+
@minLength(3)
22+
@pattern("^[a-z0-9]+(-[a-z0-9]+)*")
23+
@key("mongoClusterName")
24+
@segment("mongoClusters")
25+
@visibility("read")
26+
@path
27+
name: string;
28+
}
29+
30+
@armResourceOperations
31+
interface MongoClusters {
32+
@doc("Gets information about a mongo cluster.")
33+
get is ArmResourceRead<MongoCluster>;
34+
@doc("Create or update a mongo cluster. Update overwrites all properties for the resource. To only modify some of the properties, use PATCH.")
35+
createOrUpdate is ArmResourceCreateOrUpdateAsync<MongoCluster>;
36+
@doc("Updates an existing mongo cluster. The request body can contain one to many of the properties present in the normal mongo cluster definition.")
37+
update is ArmResourcePatchAsync<MongoCluster, MongoClusterProperties>;
38+
@doc("Deletes a mongo cluster.")
39+
delete is ArmResourceDeleteWithoutOkAsync<MongoCluster>;
40+
@doc("List all the mongo clusters in a given resource group.")
41+
listByResourceGroup is ArmResourceListByParent<MongoCluster>;
42+
@doc("List all the mongo clusters in a given subscription.")
43+
list is ArmListBySubscription<MongoCluster>;
44+
@doc("List mongo cluster connection strings. This includes the default connection string using SCRAM-SHA-256, as well as other connection strings supported by the cluster.")
45+
listConnectionStrings is ArmResourceActionSync<
46+
MongoCluster,
47+
void,
48+
ListConnectionStringsResult
49+
>;
50+
@doc("Check if mongo cluster name is available for use.")
51+
@action("checkMongoClusterNameAvailability")
52+
checkNameAvailability is checkLocalNameAvailability;
53+
}
54+
55+
@doc("The properties of a mongo cluster.")
56+
model MongoClusterProperties {
57+
@doc("The mode to create a mongo cluster.")
58+
@visibility("create")
59+
createMode?: CreateMode;
60+
61+
@doc("The parameters to create a point-in-time restore mongo cluster.")
62+
@visibility("create")
63+
restoreParameters?: MongoClusterRestoreParameters;
64+
65+
@doc("The administrator's login for the mongo cluster.")
66+
@visibility("read", "create", "update")
67+
administratorLogin?: string;
68+
69+
@doc("The password of the administrator login.")
70+
@visibility("create", "update")
71+
@secret
72+
administratorLoginPassword?: string;
73+
74+
@doc("The Mongo DB server version. Defaults to the latest available version if not specified.")
75+
serverVersion?: string;
76+
77+
@doc("The default mongo connection string for the cluster.")
78+
@visibility("read")
79+
connectionString?: string;
80+
81+
@doc("Earliest restore timestamp in UTC ISO8601 format.")
82+
@visibility("read")
83+
earliestRestoreTime?: string;
84+
85+
@doc("The provisioning state of the mongo cluster.")
86+
@visibility("read")
87+
provisioningState?: ProvisioningState;
88+
89+
@doc("The status of the mongo cluster.")
90+
@visibility("read")
91+
clusterStatus?: MongoClusterStatus;
92+
93+
@doc("Whether or not public endpoint access is allowed for this mongo cluster.")
94+
publicNetworkAccess?: PublicNetworkAccess;
95+
96+
@doc("The list of node group specs in the cluster.")
97+
@extension("x-ms-identifiers", [])
98+
nodeGroupSpecs?: NodeGroupSpec[];
99+
100+
@doc("List of private endpoint connections.")
101+
@visibility("read")
102+
privateEndpointConnections?: PrivateEndpointConnection[];
103+
}
104+
105+
@doc("The mode that the Mongo Cluster is created with.")
106+
union CreateMode {
107+
string,
108+
109+
@doc("Create a new mongo cluster.")
110+
"Default",
111+
112+
@doc("Create a mongo cluster from a restore point-in-time.")
113+
"PointInTimeRestore",
114+
}
115+
116+
@doc("The kind of the node on the cluster.")
117+
union NodeKind {
118+
string,
119+
120+
@doc("The node is a shard kind.")
121+
"Shard",
122+
}
123+
124+
@doc("Parameters used for restore operations")
125+
model MongoClusterRestoreParameters {
126+
#suppress "@azure-tools/typespec-azure-core/casing-style" "Capitialized acronym in the property name."
127+
@doc("UTC point in time to restore a mongo cluster")
128+
pointInTimeUTC?: utcDateTime;
129+
130+
@doc("Resource ID to locate the source cluster to restore")
131+
sourceResourceId?: string;
132+
}
133+
134+
@doc("Specification for a node group.")
135+
model NodeGroupSpec is NodeGroupProperties {
136+
@doc("The node type deployed in the node group.")
137+
kind?: NodeKind;
138+
139+
@doc("The number of nodes in the node group.")
140+
nodeCount?: int32;
141+
}
142+
143+
@doc("The properties of the node group on a cluster.")
144+
model NodeGroupProperties {
145+
@doc("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'.")
146+
sku?: string;
147+
148+
#suppress "@azure-tools/typespec-azure-core/casing-style" "Capitialized acronym in the property name."
149+
@doc("The disk storage size for the node group in GB. Example values: 128, 256, 512, 1024.")
150+
diskSizeGB?: int64;
151+
152+
@doc("Whether high availability is enabled on the node group.")
153+
enableHa?: boolean;
154+
}
155+
156+
@doc("The connection strings for the given mongo cluster.")
157+
model ListConnectionStringsResult {
158+
@doc("An array that contains the connection strings for a mongo cluster.")
159+
@visibility("read")
160+
@extension("x-ms-identifiers", [])
161+
connectionStrings?: ConnectionString[];
162+
}
163+
164+
@doc("Connection string for the mongo cluster")
165+
model ConnectionString {
166+
#suppress "@azure-tools/typespec-azure-core/property-name-conflict" "https://github.com/Azure/typespec-azure/issues/417"
167+
@doc("Value of the connection string")
168+
@visibility("read")
169+
@clientName("uri", "csharp")
170+
connectionString?: string;
171+
172+
@doc("Description of the connection string")
173+
@visibility("read")
174+
description?: string;
175+
}
176+
177+
@doc("The status of the Mongo cluster resource.")
178+
union MongoClusterStatus {
179+
string,
180+
181+
@doc("The mongo cluster resource is ready for use.")
182+
"Ready",
183+
184+
@doc("The mongo cluster resource is being provisioned.")
185+
"Provisioning",
186+
187+
@doc("The mongo cluster resource is being updated.")
188+
"Updating",
189+
190+
@doc("The mongo cluster resource is being started.")
191+
"Starting",
192+
193+
@doc("The mongo cluster resource is being stopped.")
194+
"Stopping",
195+
196+
@doc("The mongo cluster resource is stopped.")
197+
"Stopped",
198+
199+
@doc("The mongo cluster resource is being dropped.")
200+
"Dropping",
201+
}
202+
203+
@doc("Whether or not public endpoint access is allowed for this Mongo cluster. Value is optional and default value is 'Enabled'")
204+
union PublicNetworkAccess {
205+
string,
206+
207+
@doc("If set, mongo cluster can be accessed through private and public methods.")
208+
"Enabled",
209+
210+
@doc("If set, the private endpoints are the exclusive access method.")
211+
"Disabled",
212+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import "@typespec/http";
2+
import "@typespec/rest";
3+
import "@azure-tools/typespec-azure-core";
4+
import "@azure-tools/typespec-azure-resource-manager";
5+
import "./common.tsp";
6+
import "./MongoCluster.tsp";
7+
8+
using TypeSpec.Http;
9+
using TypeSpec.Rest;
10+
using Azure.ResourceManager;
11+
12+
namespace Microsoft.DocumentDB;
13+
14+
@parentResource(MongoCluster)
15+
model PrivateEndpointConnectionResource
16+
is ProxyResource<PrivateEndpointConnectionProperties> {
17+
...PrivateEndpointConnectionParameter;
18+
}
19+
20+
@armResourceOperations(PrivateEndpointConnectionResource)
21+
interface PrivateEndpointConnections {
22+
/** List existing private connections */
23+
listConnections is ArmResourceListByParent<PrivateEndpointConnectionResource>;
24+
/** Get a specific private connection */
25+
get is ArmResourceRead<PrivateEndpointConnectionResource>;
26+
/** Create a Private endpoint connection */
27+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-put-operation-response-codes" "Need to support existing 202 response for PUT operations"
28+
create is Operations.ArmResourceCreateOrUpdateWithAcceptedAsync<PrivateEndpointConnectionResource>;
29+
/** Delete the private endpoint connection */
30+
delete is ArmResourceDeleteWithoutOkAsync<PrivateEndpointConnectionResource>;
31+
}
32+
33+
#suppress "@azure-tools/typespec-providerhub-controller/no-resource-operations" "Expected for private links"
34+
@parentResource(MongoCluster)
35+
model PrivateLinkResource is ProxyResource<PrivateLinkResourceProperties> {
36+
...PrivateLinkResourceParameter;
37+
}
38+
39+
@armResourceOperations(PrivateLinkResource)
40+
interface PrivateLinks {
41+
/** list private links on the given resource */
42+
list is ArmResourceListByParent<PrivateLinkResource>;
43+
}

0 commit comments

Comments
 (0)