com.azure.resourcemanager.avs.implementation.CloudLinksImpl Maven / Gradle / Ivy
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.avs.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.avs.fluent.CloudLinksClient;
import com.azure.resourcemanager.avs.fluent.models.CloudLinkInner;
import com.azure.resourcemanager.avs.models.CloudLink;
import com.azure.resourcemanager.avs.models.CloudLinks;
public final class CloudLinksImpl implements CloudLinks {
private static final ClientLogger LOGGER = new ClientLogger(CloudLinksImpl.class);
private final CloudLinksClient innerClient;
private final com.azure.resourcemanager.avs.AvsManager serviceManager;
public CloudLinksImpl(CloudLinksClient innerClient, com.azure.resourcemanager.avs.AvsManager serviceManager) {
this.innerClient = innerClient;
this.serviceManager = serviceManager;
}
public PagedIterable list(String resourceGroupName, String privateCloudName) {
PagedIterable inner = this.serviceClient().list(resourceGroupName, privateCloudName);
return ResourceManagerUtils.mapPage(inner, inner1 -> new CloudLinkImpl(inner1, this.manager()));
}
public PagedIterable list(String resourceGroupName, String privateCloudName, Context context) {
PagedIterable inner = this.serviceClient().list(resourceGroupName, privateCloudName, context);
return ResourceManagerUtils.mapPage(inner, inner1 -> new CloudLinkImpl(inner1, this.manager()));
}
public Response getWithResponse(String resourceGroupName, String privateCloudName, String cloudLinkName,
Context context) {
Response inner
= this.serviceClient().getWithResponse(resourceGroupName, privateCloudName, cloudLinkName, context);
if (inner != null) {
return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
new CloudLinkImpl(inner.getValue(), this.manager()));
} else {
return null;
}
}
public CloudLink get(String resourceGroupName, String privateCloudName, String cloudLinkName) {
CloudLinkInner inner = this.serviceClient().get(resourceGroupName, privateCloudName, cloudLinkName);
if (inner != null) {
return new CloudLinkImpl(inner, this.manager());
} else {
return null;
}
}
public void delete(String resourceGroupName, String privateCloudName, String cloudLinkName) {
this.serviceClient().delete(resourceGroupName, privateCloudName, cloudLinkName);
}
public void delete(String resourceGroupName, String privateCloudName, String cloudLinkName, Context context) {
this.serviceClient().delete(resourceGroupName, privateCloudName, cloudLinkName, context);
}
public CloudLink 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 privateCloudName = ResourceManagerUtils.getValueFromIdByName(id, "privateClouds");
if (privateCloudName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'privateClouds'.", id)));
}
String cloudLinkName = ResourceManagerUtils.getValueFromIdByName(id, "cloudLinks");
if (cloudLinkName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'cloudLinks'.", id)));
}
return this.getWithResponse(resourceGroupName, privateCloudName, cloudLinkName, 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 privateCloudName = ResourceManagerUtils.getValueFromIdByName(id, "privateClouds");
if (privateCloudName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'privateClouds'.", id)));
}
String cloudLinkName = ResourceManagerUtils.getValueFromIdByName(id, "cloudLinks");
if (cloudLinkName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'cloudLinks'.", id)));
}
return this.getWithResponse(resourceGroupName, privateCloudName, cloudLinkName, 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 privateCloudName = ResourceManagerUtils.getValueFromIdByName(id, "privateClouds");
if (privateCloudName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'privateClouds'.", id)));
}
String cloudLinkName = ResourceManagerUtils.getValueFromIdByName(id, "cloudLinks");
if (cloudLinkName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'cloudLinks'.", id)));
}
this.delete(resourceGroupName, privateCloudName, cloudLinkName, 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 privateCloudName = ResourceManagerUtils.getValueFromIdByName(id, "privateClouds");
if (privateCloudName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'privateClouds'.", id)));
}
String cloudLinkName = ResourceManagerUtils.getValueFromIdByName(id, "cloudLinks");
if (cloudLinkName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'cloudLinks'.", id)));
}
this.delete(resourceGroupName, privateCloudName, cloudLinkName, context);
}
private CloudLinksClient serviceClient() {
return this.innerClient;
}
private com.azure.resourcemanager.avs.AvsManager manager() {
return this.serviceManager;
}
public CloudLinkImpl define(String name) {
return new CloudLinkImpl(name, this.manager());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy