com.azure.resourcemanager.migrationdiscoverysap.implementation.SapInstancesImpl 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.migrationdiscoverysap.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.migrationdiscoverysap.fluent.SapInstancesClient;
import com.azure.resourcemanager.migrationdiscoverysap.fluent.models.SapInstanceInner;
import com.azure.resourcemanager.migrationdiscoverysap.models.SapInstance;
import com.azure.resourcemanager.migrationdiscoverysap.models.SapInstances;
public final class SapInstancesImpl implements SapInstances {
private static final ClientLogger LOGGER = new ClientLogger(SapInstancesImpl.class);
private final SapInstancesClient innerClient;
private final com.azure.resourcemanager.migrationdiscoverysap.MigrationDiscoverySapManager serviceManager;
public SapInstancesImpl(SapInstancesClient innerClient,
com.azure.resourcemanager.migrationdiscoverysap.MigrationDiscoverySapManager serviceManager) {
this.innerClient = innerClient;
this.serviceManager = serviceManager;
}
public PagedIterable listBySapDiscoverySite(String resourceGroupName, String sapDiscoverySiteName) {
PagedIterable inner
= this.serviceClient().listBySapDiscoverySite(resourceGroupName, sapDiscoverySiteName);
return ResourceManagerUtils.mapPage(inner, inner1 -> new SapInstanceImpl(inner1, this.manager()));
}
public PagedIterable listBySapDiscoverySite(String resourceGroupName, String sapDiscoverySiteName,
Context context) {
PagedIterable inner
= this.serviceClient().listBySapDiscoverySite(resourceGroupName, sapDiscoverySiteName, context);
return ResourceManagerUtils.mapPage(inner, inner1 -> new SapInstanceImpl(inner1, this.manager()));
}
public Response getWithResponse(String resourceGroupName, String sapDiscoverySiteName,
String sapInstanceName, Context context) {
Response inner
= this.serviceClient().getWithResponse(resourceGroupName, sapDiscoverySiteName, sapInstanceName, context);
if (inner != null) {
return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
new SapInstanceImpl(inner.getValue(), this.manager()));
} else {
return null;
}
}
public SapInstance get(String resourceGroupName, String sapDiscoverySiteName, String sapInstanceName) {
SapInstanceInner inner = this.serviceClient().get(resourceGroupName, sapDiscoverySiteName, sapInstanceName);
if (inner != null) {
return new SapInstanceImpl(inner, this.manager());
} else {
return null;
}
}
public void delete(String resourceGroupName, String sapDiscoverySiteName, String sapInstanceName) {
this.serviceClient().delete(resourceGroupName, sapDiscoverySiteName, sapInstanceName);
}
public void delete(String resourceGroupName, String sapDiscoverySiteName, String sapInstanceName, Context context) {
this.serviceClient().delete(resourceGroupName, sapDiscoverySiteName, sapInstanceName, context);
}
public SapInstance 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 sapDiscoverySiteName = ResourceManagerUtils.getValueFromIdByName(id, "sapDiscoverySites");
if (sapDiscoverySiteName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'sapDiscoverySites'.", id)));
}
String sapInstanceName = ResourceManagerUtils.getValueFromIdByName(id, "sapInstances");
if (sapInstanceName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'sapInstances'.", id)));
}
return this.getWithResponse(resourceGroupName, sapDiscoverySiteName, sapInstanceName, 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 sapDiscoverySiteName = ResourceManagerUtils.getValueFromIdByName(id, "sapDiscoverySites");
if (sapDiscoverySiteName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'sapDiscoverySites'.", id)));
}
String sapInstanceName = ResourceManagerUtils.getValueFromIdByName(id, "sapInstances");
if (sapInstanceName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'sapInstances'.", id)));
}
return this.getWithResponse(resourceGroupName, sapDiscoverySiteName, sapInstanceName, 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 sapDiscoverySiteName = ResourceManagerUtils.getValueFromIdByName(id, "sapDiscoverySites");
if (sapDiscoverySiteName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'sapDiscoverySites'.", id)));
}
String sapInstanceName = ResourceManagerUtils.getValueFromIdByName(id, "sapInstances");
if (sapInstanceName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'sapInstances'.", id)));
}
this.delete(resourceGroupName, sapDiscoverySiteName, sapInstanceName, 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 sapDiscoverySiteName = ResourceManagerUtils.getValueFromIdByName(id, "sapDiscoverySites");
if (sapDiscoverySiteName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'sapDiscoverySites'.", id)));
}
String sapInstanceName = ResourceManagerUtils.getValueFromIdByName(id, "sapInstances");
if (sapInstanceName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'sapInstances'.", id)));
}
this.delete(resourceGroupName, sapDiscoverySiteName, sapInstanceName, context);
}
private SapInstancesClient serviceClient() {
return this.innerClient;
}
private com.azure.resourcemanager.migrationdiscoverysap.MigrationDiscoverySapManager manager() {
return this.serviceManager;
}
public SapInstanceImpl define(String name) {
return new SapInstanceImpl(name, this.manager());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy