Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.cosmos.fluent.models.MongoIndexKeys;
import java.io.IOException;
import java.util.List;

/**
* Cosmos DB MongoDB collection index key.
Expand All @@ -21,7 +19,7 @@ public final class MongoIndex implements JsonSerializable<MongoIndex> {
/*
* Cosmos DB MongoDB collection index keys
*/
private MongoIndexKeys innerKey;
private MongoIndexKeys key;

/*
* Cosmos DB MongoDB collection index key options
Expand All @@ -35,12 +33,23 @@ public MongoIndex() {
}

/**
* Get the innerKey property: Cosmos DB MongoDB collection index keys.
* Get the key property: Cosmos DB MongoDB collection index keys.
*
* @return the innerKey value.
* @return the key value.
*/
private MongoIndexKeys innerKey() {
return this.innerKey;
public MongoIndexKeys key() {
return this.key;
}

/**
* Set the key property: Cosmos DB MongoDB collection index keys.
*
* @param key the key value to set.
* @return the MongoIndex object itself.
*/
public MongoIndex withKey(MongoIndexKeys key) {
this.key = key;
return this;
}

/**
Expand All @@ -63,37 +72,14 @@ public MongoIndex withOptions(MongoIndexOptions options) {
return this;
}

/**
* Get the keys property: List of keys for each MongoDB collection in the Azure Cosmos DB service.
*
* @return the keys value.
*/
public List<String> keys() {
return this.innerKey() == null ? null : this.innerKey().keys();
}

/**
* Set the keys property: List of keys for each MongoDB collection in the Azure Cosmos DB service.
*
* @param keys the keys value to set.
* @return the MongoIndex object itself.
*/
public MongoIndex withKeys(List<String> keys) {
if (this.innerKey() == null) {
this.innerKey = new MongoIndexKeys();
}
this.innerKey().withKeys(keys);
return this;
}

/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (innerKey() != null) {
innerKey().validate();
if (key() != null) {
key().validate();
}
if (options() != null) {
options().validate();
Expand All @@ -106,7 +92,7 @@ public void validate() {
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeJsonField("key", this.innerKey);
jsonWriter.writeJsonField("key", this.key);
jsonWriter.writeJsonField("options", this.options);
return jsonWriter.writeEndObject();
}
Expand All @@ -127,7 +113,7 @@ public static MongoIndex fromJson(JsonReader jsonReader) throws IOException {
reader.nextToken();

if ("key".equals(fieldName)) {
deserializedMongoIndex.innerKey = MongoIndexKeys.fromJson(reader);
deserializedMongoIndex.key = MongoIndexKeys.fromJson(reader);
} else if ("options".equals(fieldName)) {
deserializedMongoIndex.options = MongoIndexOptions.fromJson(reader);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package com.azure.resourcemanager.cosmos.fluent.models;
package com.azure.resourcemanager.cosmos.models;

import com.azure.core.annotation.Fluent;
import com.azure.json.JsonReader;
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.azure.resourcemanager.cosmos.models.MongoDBCollectionCreateUpdateParameters;
import com.azure.resourcemanager.cosmos.models.MongoDBCollectionResource;
import com.azure.resourcemanager.cosmos.models.MongoIndex;
import com.azure.resourcemanager.cosmos.models.MongoIndexKeys;
import com.azure.resourcemanager.cosmos.models.MongoIndexOptions;
import java.util.Arrays;
import java.util.HashMap;
Expand All @@ -31,16 +32,12 @@ public static void cosmosDBMongoDBCollectionCreateUpdate(com.azure.resourcemanag
.createUpdateMongoDBCollection("rg1", "ddb1", "databaseName", "collectionName",
new MongoDBCollectionCreateUpdateParameters().withLocation("West US")
.withTags(mapOf())
.withResource(
new MongoDBCollectionResource().withId("collectionName")
.withShardKey(mapOf("testKey", "fakeTokenPlaceholder"))
.withIndexes(
Arrays.asList(
new MongoIndex()
.withOptions(
new MongoIndexOptions().withExpireAfterSeconds(100).withUnique(true))
.withKeys(Arrays.asList("_ts")),
new MongoIndex().withKeys(Arrays.asList("_id")))))
.withResource(new MongoDBCollectionResource().withId("collectionName")
.withShardKey(mapOf("testKey", "fakeTokenPlaceholder"))
.withIndexes(Arrays.asList(
new MongoIndex().withKey(new MongoIndexKeys().withKeys(Arrays.asList("_ts")))
.withOptions(new MongoIndexOptions().withExpireAfterSeconds(100).withUnique(true)),
new MongoIndex().withKey(new MongoIndexKeys().withKeys(Arrays.asList("_id"))))))
.withOptions(new CreateUpdateOptions()),
com.azure.core.util.Context.NONE);
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/cosmos/azure-resourcemanager-cosmos/tsp-location.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
directory: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/DocumentDB
commit: 9ee5902c9557817bc4a859ebc13f757515aac5d7
commit: 050576fbe2e66b311b5f72f30de27c0f04c7881d
repo: Azure/azure-rest-api-specs
additionalDirectories:
Loading