com.azure.resourcemanager.mongocluster.implementation.MongoClustersImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-mongocluster Show documentation
Show all versions of azure-resourcemanager-mongocluster Show documentation
This package contains Microsoft Azure SDK for Mongo Cluster Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. 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.
The newest version!
// 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.implementation;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.Context;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.mongocluster.fluent.MongoClustersClient;
import com.azure.resourcemanager.mongocluster.fluent.models.CheckNameAvailabilityResponseInner;
import com.azure.resourcemanager.mongocluster.fluent.models.ListConnectionStringsResultInner;
import com.azure.resourcemanager.mongocluster.fluent.models.MongoClusterInner;
import com.azure.resourcemanager.mongocluster.models.CheckNameAvailabilityRequest;
import com.azure.resourcemanager.mongocluster.models.CheckNameAvailabilityResponse;
import com.azure.resourcemanager.mongocluster.models.ListConnectionStringsResult;
import com.azure.resourcemanager.mongocluster.models.MongoCluster;
import com.azure.resourcemanager.mongocluster.models.MongoClusters;
import com.azure.resourcemanager.mongocluster.models.PromoteReplicaRequest;
public final class MongoClustersImpl implements MongoClusters {
private static final ClientLogger LOGGER = new ClientLogger(MongoClustersImpl.class);
private final MongoClustersClient innerClient;
private final com.azure.resourcemanager.mongocluster.MongoClusterManager serviceManager;
public MongoClustersImpl(MongoClustersClient innerClient,
com.azure.resourcemanager.mongocluster.MongoClusterManager serviceManager) {
this.innerClient = innerClient;
this.serviceManager = serviceManager;
}
public Response getByResourceGroupWithResponse(String resourceGroupName, String mongoClusterName,
Context context) {
Response inner
= this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, mongoClusterName, context);
if (inner != null) {
return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
new MongoClusterImpl(inner.getValue(), this.manager()));
} else {
return null;
}
}
public MongoCluster getByResourceGroup(String resourceGroupName, String mongoClusterName) {
MongoClusterInner inner = this.serviceClient().getByResourceGroup(resourceGroupName, mongoClusterName);
if (inner != null) {
return new MongoClusterImpl(inner, this.manager());
} else {
return null;
}
}
public void deleteByResourceGroup(String resourceGroupName, String mongoClusterName) {
this.serviceClient().delete(resourceGroupName, mongoClusterName);
}
public void delete(String resourceGroupName, String mongoClusterName, Context context) {
this.serviceClient().delete(resourceGroupName, mongoClusterName, context);
}
public PagedIterable listByResourceGroup(String resourceGroupName) {
PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName);
return ResourceManagerUtils.mapPage(inner, inner1 -> new MongoClusterImpl(inner1, this.manager()));
}
public PagedIterable listByResourceGroup(String resourceGroupName, Context context) {
PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName, context);
return ResourceManagerUtils.mapPage(inner, inner1 -> new MongoClusterImpl(inner1, this.manager()));
}
public PagedIterable list() {
PagedIterable inner = this.serviceClient().list();
return ResourceManagerUtils.mapPage(inner, inner1 -> new MongoClusterImpl(inner1, this.manager()));
}
public PagedIterable list(Context context) {
PagedIterable inner = this.serviceClient().list(context);
return ResourceManagerUtils.mapPage(inner, inner1 -> new MongoClusterImpl(inner1, this.manager()));
}
public Response listConnectionStringsWithResponse(String resourceGroupName,
String mongoClusterName, Context context) {
Response inner
= this.serviceClient().listConnectionStringsWithResponse(resourceGroupName, mongoClusterName, context);
if (inner != null) {
return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
new ListConnectionStringsResultImpl(inner.getValue(), this.manager()));
} else {
return null;
}
}
public ListConnectionStringsResult listConnectionStrings(String resourceGroupName, String mongoClusterName) {
ListConnectionStringsResultInner inner
= this.serviceClient().listConnectionStrings(resourceGroupName, mongoClusterName);
if (inner != null) {
return new ListConnectionStringsResultImpl(inner, this.manager());
} else {
return null;
}
}
public Response checkNameAvailabilityWithResponse(String location,
CheckNameAvailabilityRequest body, Context context) {
Response inner
= this.serviceClient().checkNameAvailabilityWithResponse(location, body, context);
if (inner != null) {
return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
new CheckNameAvailabilityResponseImpl(inner.getValue(), this.manager()));
} else {
return null;
}
}
public CheckNameAvailabilityResponse checkNameAvailability(String location, CheckNameAvailabilityRequest body) {
CheckNameAvailabilityResponseInner inner = this.serviceClient().checkNameAvailability(location, body);
if (inner != null) {
return new CheckNameAvailabilityResponseImpl(inner, this.manager());
} else {
return null;
}
}
public void promote(String resourceGroupName, String mongoClusterName, PromoteReplicaRequest body) {
this.serviceClient().promote(resourceGroupName, mongoClusterName, body);
}
public void promote(String resourceGroupName, String mongoClusterName, PromoteReplicaRequest body,
Context context) {
this.serviceClient().promote(resourceGroupName, mongoClusterName, body, context);
}
public MongoCluster getById(String id) {
String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups");
if (resourceGroupName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id)));
}
String mongoClusterName = ResourceManagerUtils.getValueFromIdByName(id, "mongoClusters");
if (mongoClusterName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'mongoClusters'.", id)));
}
return this.getByResourceGroupWithResponse(resourceGroupName, mongoClusterName, Context.NONE).getValue();
}
public Response getByIdWithResponse(String id, Context context) {
String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups");
if (resourceGroupName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id)));
}
String mongoClusterName = ResourceManagerUtils.getValueFromIdByName(id, "mongoClusters");
if (mongoClusterName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'mongoClusters'.", id)));
}
return this.getByResourceGroupWithResponse(resourceGroupName, mongoClusterName, context);
}
public void deleteById(String id) {
String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups");
if (resourceGroupName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id)));
}
String mongoClusterName = ResourceManagerUtils.getValueFromIdByName(id, "mongoClusters");
if (mongoClusterName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'mongoClusters'.", id)));
}
this.delete(resourceGroupName, mongoClusterName, Context.NONE);
}
public void deleteByIdWithResponse(String id, Context context) {
String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups");
if (resourceGroupName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id)));
}
String mongoClusterName = ResourceManagerUtils.getValueFromIdByName(id, "mongoClusters");
if (mongoClusterName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'mongoClusters'.", id)));
}
this.delete(resourceGroupName, mongoClusterName, context);
}
private MongoClustersClient serviceClient() {
return this.innerClient;
}
private com.azure.resourcemanager.mongocluster.MongoClusterManager manager() {
return this.serviceManager;
}
public MongoClusterImpl define(String name) {
return new MongoClusterImpl(name, this.manager());
}
}