com.azure.resourcemanager.mongocluster.implementation.FirewallRulesImpl 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.FirewallRulesClient;
import com.azure.resourcemanager.mongocluster.fluent.models.FirewallRuleInner;
import com.azure.resourcemanager.mongocluster.models.FirewallRule;
import com.azure.resourcemanager.mongocluster.models.FirewallRules;
public final class FirewallRulesImpl implements FirewallRules {
private static final ClientLogger LOGGER = new ClientLogger(FirewallRulesImpl.class);
private final FirewallRulesClient innerClient;
private final com.azure.resourcemanager.mongocluster.MongoClusterManager serviceManager;
public FirewallRulesImpl(FirewallRulesClient innerClient,
com.azure.resourcemanager.mongocluster.MongoClusterManager serviceManager) {
this.innerClient = innerClient;
this.serviceManager = serviceManager;
}
public Response getWithResponse(String resourceGroupName, String mongoClusterName,
String firewallRuleName, Context context) {
Response inner
= this.serviceClient().getWithResponse(resourceGroupName, mongoClusterName, firewallRuleName, context);
if (inner != null) {
return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
new FirewallRuleImpl(inner.getValue(), this.manager()));
} else {
return null;
}
}
public FirewallRule get(String resourceGroupName, String mongoClusterName, String firewallRuleName) {
FirewallRuleInner inner = this.serviceClient().get(resourceGroupName, mongoClusterName, firewallRuleName);
if (inner != null) {
return new FirewallRuleImpl(inner, this.manager());
} else {
return null;
}
}
public void delete(String resourceGroupName, String mongoClusterName, String firewallRuleName) {
this.serviceClient().delete(resourceGroupName, mongoClusterName, firewallRuleName);
}
public void delete(String resourceGroupName, String mongoClusterName, String firewallRuleName, Context context) {
this.serviceClient().delete(resourceGroupName, mongoClusterName, firewallRuleName, context);
}
public PagedIterable listByMongoCluster(String resourceGroupName, String mongoClusterName) {
PagedIterable inner
= this.serviceClient().listByMongoCluster(resourceGroupName, mongoClusterName);
return ResourceManagerUtils.mapPage(inner, inner1 -> new FirewallRuleImpl(inner1, this.manager()));
}
public PagedIterable listByMongoCluster(String resourceGroupName, String mongoClusterName,
Context context) {
PagedIterable inner
= this.serviceClient().listByMongoCluster(resourceGroupName, mongoClusterName, context);
return ResourceManagerUtils.mapPage(inner, inner1 -> new FirewallRuleImpl(inner1, this.manager()));
}
public FirewallRule 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)));
}
String firewallRuleName = ResourceManagerUtils.getValueFromIdByName(id, "firewallRules");
if (firewallRuleName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'firewallRules'.", id)));
}
return this.getWithResponse(resourceGroupName, mongoClusterName, firewallRuleName, 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)));
}
String firewallRuleName = ResourceManagerUtils.getValueFromIdByName(id, "firewallRules");
if (firewallRuleName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'firewallRules'.", id)));
}
return this.getWithResponse(resourceGroupName, mongoClusterName, firewallRuleName, 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)));
}
String firewallRuleName = ResourceManagerUtils.getValueFromIdByName(id, "firewallRules");
if (firewallRuleName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'firewallRules'.", id)));
}
this.delete(resourceGroupName, mongoClusterName, firewallRuleName, 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)));
}
String firewallRuleName = ResourceManagerUtils.getValueFromIdByName(id, "firewallRules");
if (firewallRuleName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'firewallRules'.", id)));
}
this.delete(resourceGroupName, mongoClusterName, firewallRuleName, context);
}
private FirewallRulesClient serviceClient() {
return this.innerClient;
}
private com.azure.resourcemanager.mongocluster.MongoClusterManager manager() {
return this.serviceManager;
}
public FirewallRuleImpl define(String name) {
return new FirewallRuleImpl(name, this.manager());
}
}