Skip to content

Commit

Permalink
CodeGen from PR 3491 in test-repo-billy/azure-rest-api-specs
Browse files Browse the repository at this point in the history
Merge 2e855aa0bd1b8136d52cb530a82480c298865cfc into 2b91022c223ed3618c268c750f831b76fe0f4fb5
  • Loading branch information
SDKAuto committed Aug 29, 2024
1 parent 261f322 commit b3a649f
Show file tree
Hide file tree
Showing 103 changed files with 3,635 additions and 665 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Release History

## 1.0.0-beta.2 (Unreleased)
## 1.0.0-beta.1 (2024-08-29)

- Azure Resource Manager Mongo Cluster client library for Java. This package contains Microsoft Azure SDK for Mongo Cluster Management SDK. The Microsoft Azure management API provides create, read, update, and delete functionality for Azure Cosmos DB for MongoDB vCore resources including clusters and firewall rules. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt).

### Features Added

Expand Down
13 changes: 5 additions & 8 deletions sdk/mongocluster/azure-resourcemanager-mongocluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Various documentation is available to help you get started
<dependency>
<groupId>com.azure.resourcemanager</groupId>
<artifactId>azure-resourcemanager-mongocluster</artifactId>
<version>1.0.0-beta.1</version>
<version>1.0.0-beta.2</version>
</dependency>
```
[//]: # ({x-version-update-end})
Expand All @@ -45,15 +45,11 @@ Azure Management Libraries require a `TokenCredential` implementation for authen

### Authentication

By default, Microsoft Entra ID token authentication depends on correct configuration of the following environment variables.
Microsoft Entra ID token authentication relies on the [credential class][azure_identity_credentials] from [Azure Identity][azure_identity] package.

- `AZURE_CLIENT_ID` for Azure client ID.
- `AZURE_TENANT_ID` for Azure tenant ID.
- `AZURE_CLIENT_SECRET` or `AZURE_CLIENT_CERTIFICATE_PATH` for client secret or client certificate.
Azure subscription ID can be configured via `AZURE_SUBSCRIPTION_ID` environment variable.

In addition, Azure subscription ID can be configured via `AZURE_SUBSCRIPTION_ID` environment variable.

With above configuration, `azure` client can be authenticated using the following code:
Assuming the use of the `DefaultAzureCredential` credential class, the client can be authenticated using the following code:

```java
AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);
Expand Down Expand Up @@ -97,6 +93,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For m
[jdk]: https://learn.microsoft.com/azure/developer/java/fundamentals/
[azure_subscription]: https://azure.microsoft.com/free/
[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity
[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/identity/azure-identity#credentials
[azure_core_http_netty]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core-http-netty
[authenticate]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/AUTH.md
[design]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/DESIGN.md
Expand Down
272 changes: 221 additions & 51 deletions sdk/mongocluster/azure-resourcemanager-mongocluster/SAMPLE.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@
import com.azure.resourcemanager.mongocluster.implementation.OperationsImpl;
import com.azure.resourcemanager.mongocluster.implementation.PrivateEndpointConnectionsImpl;
import com.azure.resourcemanager.mongocluster.implementation.PrivateLinksImpl;
import com.azure.resourcemanager.mongocluster.implementation.ReplicasImpl;
import com.azure.resourcemanager.mongocluster.models.FirewallRules;
import com.azure.resourcemanager.mongocluster.models.MongoClusters;
import com.azure.resourcemanager.mongocluster.models.Operations;
import com.azure.resourcemanager.mongocluster.models.PrivateEndpointConnections;
import com.azure.resourcemanager.mongocluster.models.PrivateLinks;
import com.azure.resourcemanager.mongocluster.models.Replicas;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
Expand All @@ -58,6 +60,8 @@ public final class MongoClusterManager {

private PrivateLinks privateLinks;

private Replicas replicas;

private final DocumentDBClient clientObject;

private MongoClusterManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) {
Expand Down Expand Up @@ -329,6 +333,18 @@ public PrivateLinks privateLinks() {
return privateLinks;
}

/**
* Gets the resource collection API of Replicas.
*
* @return Resource collection API of Replicas.
*/
public Replicas replicas() {
if (this.replicas == null) {
this.replicas = new ReplicasImpl(clientObject.getReplicas(), this);
}
return replicas;
}

/**
* Gets wrapped service client DocumentDBClient providing direct access to the underlying auto-generated API
* implementation, based on Azure REST API.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,11 @@ public interface DocumentDBClient {
* @return the PrivateLinksClient object.
*/
PrivateLinksClient getPrivateLinks();

/**
* Gets the ReplicasClient object to access its operations.
*
* @return the ReplicasClient object.
*/
ReplicasClient getReplicas();
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.azure.resourcemanager.mongocluster.fluent.models.MongoClusterInner;
import com.azure.resourcemanager.mongocluster.models.CheckNameAvailabilityRequest;
import com.azure.resourcemanager.mongocluster.models.MongoClusterUpdate;
import com.azure.resourcemanager.mongocluster.models.PromoteReplicaRequest;

/**
* An instance of this class provides access to all the operations defined in MongoClustersClient.
Expand Down Expand Up @@ -335,4 +336,62 @@ Response<CheckNameAvailabilityResponseInner> checkNameAvailabilityWithResponse(S
*/
@ServiceMethod(returns = ReturnType.SINGLE)
CheckNameAvailabilityResponseInner checkNameAvailability(String location, CheckNameAvailabilityRequest body);

/**
* Promotes a replica mongo cluster to a primary role.
*
* @param resourceGroupName The name of the resource group. The name is case insensitive.
* @param mongoClusterName The name of the mongo cluster.
* @param body The content of the action request.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the {@link SyncPoller} for polling of long-running operation.
*/
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
SyncPoller<PollResult<Void>, Void> beginPromote(String resourceGroupName, String mongoClusterName,
PromoteReplicaRequest body);

/**
* Promotes a replica mongo cluster to a primary role.
*
* @param resourceGroupName The name of the resource group. The name is case insensitive.
* @param mongoClusterName The name of the mongo cluster.
* @param body The content of the action request.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the {@link SyncPoller} for polling of long-running operation.
*/
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
SyncPoller<PollResult<Void>, Void> beginPromote(String resourceGroupName, String mongoClusterName,
PromoteReplicaRequest body, Context context);

/**
* Promotes a replica mongo cluster to a primary role.
*
* @param resourceGroupName The name of the resource group. The name is case insensitive.
* @param mongoClusterName The name of the mongo cluster.
* @param body The content of the action request.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
void promote(String resourceGroupName, String mongoClusterName, PromoteReplicaRequest body);

/**
* Promotes a replica mongo cluster to a primary role.
*
* @param resourceGroupName The name of the resource group. The name is case insensitive.
* @param mongoClusterName The name of the mongo cluster.
* @param body The content of the action request.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
void promote(String resourceGroupName, String mongoClusterName, PromoteReplicaRequest body, Context context);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package com.azure.resourcemanager.mongocluster.fluent;

import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.util.Context;
import com.azure.resourcemanager.mongocluster.fluent.models.ReplicaInner;

/**
* An instance of this class provides access to all the operations defined in ReplicasClient.
*/
public interface ReplicasClient {
/**
* List all the replicas for the mongo cluster.
*
* @param resourceGroupName The name of the resource group. The name is case insensitive.
* @param mongoClusterName The name of the mongo cluster.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the response of a Replica list operation as paginated response with {@link PagedIterable}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
PagedIterable<ReplicaInner> listByParent(String resourceGroupName, String mongoClusterName);

/**
* List all the replicas for the mongo cluster.
*
* @param resourceGroupName The name of the resource group. The name is case insensitive.
* @param mongoClusterName The name of the mongo cluster.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the response of a Replica list operation as paginated response with {@link PagedIterable}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
PagedIterable<ReplicaInner> listByParent(String resourceGroupName, String mongoClusterName, Context context);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

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

import com.azure.core.annotation.Immutable;
import com.azure.core.management.ProxyResource;
import com.azure.core.management.SystemData;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.mongocluster.models.MongoClusterProperties;
import java.io.IOException;

/**
* Represents a mongo cluster replica.
*/
@Immutable
public final class ReplicaInner extends ProxyResource {
/*
* The resource-specific properties for this resource.
*/
private MongoClusterProperties properties;

/*
* Azure Resource Manager metadata containing createdBy and modifiedBy information.
*/
private SystemData systemData;

/*
* The type of the resource.
*/
private String type;

/*
* The name of the resource.
*/
private String name;

/*
* Fully qualified resource Id for the resource.
*/
private String id;

/**
* Creates an instance of ReplicaInner class.
*/
private ReplicaInner() {
}

/**
* Get the properties property: The resource-specific properties for this resource.
*
* @return the properties value.
*/
public MongoClusterProperties properties() {
return this.properties;
}

/**
* Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information.
*
* @return the systemData value.
*/
public SystemData systemData() {
return this.systemData;
}

/**
* Get the type property: The type of the resource.
*
* @return the type value.
*/
@Override
public String type() {
return this.type;
}

/**
* Get the name property: The name of the resource.
*
* @return the name value.
*/
@Override
public String name() {
return this.name;
}

/**
* Get the id property: Fully qualified resource Id for the resource.
*
* @return the id value.
*/
@Override
public String id() {
return this.id;
}

/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (properties() != null) {
properties().validate();
}
}

/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeJsonField("properties", this.properties);
return jsonWriter.writeEndObject();
}

/**
* Reads an instance of ReplicaInner from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of ReplicaInner if the JsonReader was pointing to an instance of it, or null if it was
* pointing to JSON null.
* @throws IllegalStateException If the deserialized JSON object was missing any required properties.
* @throws IOException If an error occurs while reading the ReplicaInner.
*/
public static ReplicaInner fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
ReplicaInner deserializedReplicaInner = new ReplicaInner();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();

if ("id".equals(fieldName)) {
deserializedReplicaInner.id = reader.getString();
} else if ("name".equals(fieldName)) {
deserializedReplicaInner.name = reader.getString();
} else if ("type".equals(fieldName)) {
deserializedReplicaInner.type = reader.getString();
} else if ("properties".equals(fieldName)) {
deserializedReplicaInner.properties = MongoClusterProperties.fromJson(reader);
} else if ("systemData".equals(fieldName)) {
deserializedReplicaInner.systemData = SystemData.fromJson(reader);
} else {
reader.skipChildren();
}
}

return deserializedReplicaInner;
});
}
}
Loading

0 comments on commit b3a649f

Please sign in to comment.