Skip to content

Commit

Permalink
Add new API version 2024-03-01-preview for Microsoft.DocumentDB mongo…
Browse files Browse the repository at this point in the history
…cluster (#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 <56606095+madhura-np@users.noreply.github.com>
  • Loading branch information
olivertowers and madhura-np committed May 13, 2024
1 parent b627f6c commit ac3db63
Show file tree
Hide file tree
Showing 61 changed files with 4,713 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
env.json
package-lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/rest";
import "./common.tsp";
import "./MongoCluster.tsp";

using TypeSpec.Rest;
using Azure.ResourceManager;
using Azure.ResourceManager.Foundations;
using TypeSpec.Http;

namespace Microsoft.DocumentDB;
@doc("Represents a mongo cluster firewall rule.")
@parentResource(MongoCluster)
model FirewallRule is ProxyResource<FirewallRuleProperties> {
@doc("The name of the mongo cluster firewall rule.")
@maxLength(80)
@minLength(1)
@pattern("^[a-zA-Z0-9][-_.a-zA-Z0-9]*")
@key("firewallRuleName")
@segment("firewallRules")
@visibility("read")
@path
name: string;
}

@doc("The properties of a mongo cluster firewall rule.")
model FirewallRuleProperties {
@doc("The provisioning state of the firewall rule.")
@visibility("read")
provisioningState?: ProvisioningState;

@doc("The start IP address of the mongo cluster firewall rule. Must be IPv4 format.")
@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])$")
startIpAddress: string;

@doc("The end IP address of the mongo cluster firewall rule. Must be IPv4 format.")
@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])$")
endIpAddress: string;
}

@armResourceOperations
interface FirewallRules {
@doc("Gets information about a mongo cluster firewall rule.")
get is ArmResourceRead<FirewallRule>;
#suppress "@azure-tools/typespec-azure-resource-manager/arm-put-operation-response-codes" "Need to support existing 202 response for PUT operations"
@doc("Creates a new firewall rule or updates an existing firewall rule on a mongo cluster.")
createOrUpdate is Operations.ArmResourceCreateOrUpdateWithAcceptedAsync<FirewallRule>;
@doc("Deletes a mongo cluster firewall rule.")
delete is ArmResourceDeleteWithoutOkAsync<FirewallRule>;
@doc("List all the firewall rules in a given mongo cluster.")
listByParent is ArmResourceListByParent<FirewallRule>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@azure-tools/typespec-client-generator-core";
import "@typespec/openapi";
import "@typespec/rest";
import "./common.tsp";

using TypeSpec.Http;
using TypeSpec.OpenAPI;
using TypeSpec.Rest;
using Azure.ResourceManager;
using Azure.ResourceManager.Foundations;
using Azure.ResourceManager.Private;
using Azure.ClientGenerator.Core;

namespace Microsoft.DocumentDB;
@doc("Represents a mongo cluster resource.")
model MongoCluster is TrackedResource<MongoClusterProperties> {
@doc("The name of the mongo cluster.")
@maxLength(40)
@minLength(3)
@pattern("^[a-z0-9]+(-[a-z0-9]+)*")
@key("mongoClusterName")
@segment("mongoClusters")
@visibility("read")
@path
name: string;
}

@armResourceOperations
interface MongoClusters {
@doc("Gets information about a mongo cluster.")
get is ArmResourceRead<MongoCluster>;
@doc("Create or update a mongo cluster. Update overwrites all properties for the resource. To only modify some of the properties, use PATCH.")
createOrUpdate is ArmResourceCreateOrUpdateAsync<MongoCluster>;
@doc("Updates an existing mongo cluster. The request body can contain one to many of the properties present in the normal mongo cluster definition.")
update is ArmResourcePatchAsync<MongoCluster, MongoClusterProperties>;
@doc("Deletes a mongo cluster.")
delete is ArmResourceDeleteWithoutOkAsync<MongoCluster>;
@doc("List all the mongo clusters in a given resource group.")
listByResourceGroup is ArmResourceListByParent<MongoCluster>;
@doc("List all the mongo clusters in a given subscription.")
list is ArmListBySubscription<MongoCluster>;
@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.")
listConnectionStrings is ArmResourceActionSync<
MongoCluster,
void,
ListConnectionStringsResult
>;
@doc("Check if mongo cluster name is available for use.")
@action("checkMongoClusterNameAvailability")
checkNameAvailability is checkLocalNameAvailability;
}

@doc("The properties of a mongo cluster.")
model MongoClusterProperties {
@doc("The mode to create a mongo cluster.")
@visibility("create")
createMode?: CreateMode;

@doc("The parameters to create a point-in-time restore mongo cluster.")
@visibility("create")
restoreParameters?: MongoClusterRestoreParameters;

@doc("The administrator's login for the mongo cluster.")
@visibility("read", "create", "update")
administratorLogin?: string;

@doc("The password of the administrator login.")
@visibility("create", "update")
@secret
administratorLoginPassword?: string;

@doc("The Mongo DB server version. Defaults to the latest available version if not specified.")
serverVersion?: string;

@doc("The default mongo connection string for the cluster.")
@visibility("read")
connectionString?: string;

@doc("Earliest restore timestamp in UTC ISO8601 format.")
@visibility("read")
earliestRestoreTime?: string;

@doc("The provisioning state of the mongo cluster.")
@visibility("read")
provisioningState?: ProvisioningState;

@doc("The status of the mongo cluster.")
@visibility("read")
clusterStatus?: MongoClusterStatus;

@doc("Whether or not public endpoint access is allowed for this mongo cluster.")
publicNetworkAccess?: PublicNetworkAccess;

@doc("The list of node group specs in the cluster.")
@extension("x-ms-identifiers", [])
nodeGroupSpecs?: NodeGroupSpec[];

@doc("List of private endpoint connections.")
@visibility("read")
privateEndpointConnections?: PrivateEndpointConnection[];
}

@doc("The mode that the Mongo Cluster is created with.")
union CreateMode {
string,

@doc("Create a new mongo cluster.")
"Default",

@doc("Create a mongo cluster from a restore point-in-time.")
"PointInTimeRestore",
}

@doc("The kind of the node on the cluster.")
union NodeKind {
string,

@doc("The node is a shard kind.")
"Shard",
}

@doc("Parameters used for restore operations")
model MongoClusterRestoreParameters {
#suppress "@azure-tools/typespec-azure-core/casing-style" "Capitialized acronym in the property name."
@doc("UTC point in time to restore a mongo cluster")
pointInTimeUTC?: utcDateTime;

@doc("Resource ID to locate the source cluster to restore")
sourceResourceId?: string;
}

@doc("Specification for a node group.")
model NodeGroupSpec is NodeGroupProperties {
@doc("The node type deployed in the node group.")
kind?: NodeKind;

@doc("The number of nodes in the node group.")
nodeCount?: int32;
}

@doc("The properties of the node group on a cluster.")
model NodeGroupProperties {
@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'.")
sku?: string;

#suppress "@azure-tools/typespec-azure-core/casing-style" "Capitialized acronym in the property name."
@doc("The disk storage size for the node group in GB. Example values: 128, 256, 512, 1024.")
diskSizeGB?: int64;

@doc("Whether high availability is enabled on the node group.")
enableHa?: boolean;
}

@doc("The connection strings for the given mongo cluster.")
model ListConnectionStringsResult {
@doc("An array that contains the connection strings for a mongo cluster.")
@visibility("read")
@extension("x-ms-identifiers", [])
connectionStrings?: ConnectionString[];
}

@doc("Connection string for the mongo cluster")
model ConnectionString {
#suppress "@azure-tools/typespec-azure-core/property-name-conflict" "https://github.com/Azure/typespec-azure/issues/417"
@doc("Value of the connection string")
@visibility("read")
@clientName("uri", "csharp")
connectionString?: string;

@doc("Description of the connection string")
@visibility("read")
description?: string;
}

@doc("The status of the Mongo cluster resource.")
union MongoClusterStatus {
string,

@doc("The mongo cluster resource is ready for use.")
"Ready",

@doc("The mongo cluster resource is being provisioned.")
"Provisioning",

@doc("The mongo cluster resource is being updated.")
"Updating",

@doc("The mongo cluster resource is being started.")
"Starting",

@doc("The mongo cluster resource is being stopped.")
"Stopping",

@doc("The mongo cluster resource is stopped.")
"Stopped",

@doc("The mongo cluster resource is being dropped.")
"Dropping",
}

@doc("Whether or not public endpoint access is allowed for this Mongo cluster. Value is optional and default value is 'Enabled'")
union PublicNetworkAccess {
string,

@doc("If set, mongo cluster can be accessed through private and public methods.")
"Enabled",

@doc("If set, the private endpoints are the exclusive access method.")
"Disabled",
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import "@typespec/http";
import "@typespec/rest";
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "./common.tsp";
import "./MongoCluster.tsp";

using TypeSpec.Http;
using TypeSpec.Rest;
using Azure.ResourceManager;

namespace Microsoft.DocumentDB;

@parentResource(MongoCluster)
model PrivateEndpointConnectionResource
is ProxyResource<PrivateEndpointConnectionProperties> {
...PrivateEndpointConnectionParameter;
}

@armResourceOperations(PrivateEndpointConnectionResource)
interface PrivateEndpointConnections {
/** List existing private connections */
listConnections is ArmResourceListByParent<PrivateEndpointConnectionResource>;
/** Get a specific private connection */
get is ArmResourceRead<PrivateEndpointConnectionResource>;
/** Create a Private endpoint connection */
#suppress "@azure-tools/typespec-azure-resource-manager/arm-put-operation-response-codes" "Need to support existing 202 response for PUT operations"
create is Operations.ArmResourceCreateOrUpdateWithAcceptedAsync<PrivateEndpointConnectionResource>;
/** Delete the private endpoint connection */
delete is ArmResourceDeleteWithoutOkAsync<PrivateEndpointConnectionResource>;
}

#suppress "@azure-tools/typespec-providerhub-controller/no-resource-operations" "Expected for private links"
@parentResource(MongoCluster)
model PrivateLinkResource is ProxyResource<PrivateLinkResourceProperties> {
...PrivateLinkResourceParameter;
}

@armResourceOperations(PrivateLinkResource)
interface PrivateLinks {
/** list private links on the given resource */
list is ArmResourceListByParent<PrivateLinkResource>;
}

0 comments on commit ac3db63

Please sign in to comment.