
com.azure.resourcemanager.security.implementation.CustomRecommendationsImpl 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.security.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.security.fluent.CustomRecommendationsClient;
import com.azure.resourcemanager.security.fluent.models.CustomRecommendationInner;
import com.azure.resourcemanager.security.models.CustomRecommendation;
import com.azure.resourcemanager.security.models.CustomRecommendations;
public final class CustomRecommendationsImpl implements CustomRecommendations {
private static final ClientLogger LOGGER = new ClientLogger(CustomRecommendationsImpl.class);
private final CustomRecommendationsClient innerClient;
private final com.azure.resourcemanager.security.SecurityManager serviceManager;
public CustomRecommendationsImpl(CustomRecommendationsClient innerClient,
com.azure.resourcemanager.security.SecurityManager serviceManager) {
this.innerClient = innerClient;
this.serviceManager = serviceManager;
}
public PagedIterable list(String scope) {
PagedIterable inner = this.serviceClient().list(scope);
return ResourceManagerUtils.mapPage(inner, inner1 -> new CustomRecommendationImpl(inner1, this.manager()));
}
public PagedIterable list(String scope, Context context) {
PagedIterable inner = this.serviceClient().list(scope, context);
return ResourceManagerUtils.mapPage(inner, inner1 -> new CustomRecommendationImpl(inner1, this.manager()));
}
public Response getWithResponse(String scope, String customRecommendationName,
Context context) {
Response inner
= this.serviceClient().getWithResponse(scope, customRecommendationName, context);
if (inner != null) {
return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
new CustomRecommendationImpl(inner.getValue(), this.manager()));
} else {
return null;
}
}
public CustomRecommendation get(String scope, String customRecommendationName) {
CustomRecommendationInner inner = this.serviceClient().get(scope, customRecommendationName);
if (inner != null) {
return new CustomRecommendationImpl(inner, this.manager());
} else {
return null;
}
}
public Response deleteByResourceGroupWithResponse(String scope, String customRecommendationName,
Context context) {
return this.serviceClient().deleteWithResponse(scope, customRecommendationName, context);
}
public void deleteByResourceGroup(String scope, String customRecommendationName) {
this.serviceClient().delete(scope, customRecommendationName);
}
public CustomRecommendation getById(String id) {
String scope = ResourceManagerUtils.getValueFromIdByParameterName(id,
"/{scope}/providers/Microsoft.Security/customRecommendations/{customRecommendationName}", "scope");
if (scope == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'scope'.", id)));
}
String customRecommendationName = ResourceManagerUtils.getValueFromIdByParameterName(id,
"/{scope}/providers/Microsoft.Security/customRecommendations/{customRecommendationName}",
"customRecommendationName");
if (customRecommendationName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'customRecommendations'.", id)));
}
return this.getWithResponse(scope, customRecommendationName, Context.NONE).getValue();
}
public Response getByIdWithResponse(String id, Context context) {
String scope = ResourceManagerUtils.getValueFromIdByParameterName(id,
"/{scope}/providers/Microsoft.Security/customRecommendations/{customRecommendationName}", "scope");
if (scope == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'scope'.", id)));
}
String customRecommendationName = ResourceManagerUtils.getValueFromIdByParameterName(id,
"/{scope}/providers/Microsoft.Security/customRecommendations/{customRecommendationName}",
"customRecommendationName");
if (customRecommendationName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'customRecommendations'.", id)));
}
return this.getWithResponse(scope, customRecommendationName, context);
}
public void deleteById(String id) {
String scope = ResourceManagerUtils.getValueFromIdByParameterName(id,
"/{scope}/providers/Microsoft.Security/customRecommendations/{customRecommendationName}", "scope");
if (scope == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'scope'.", id)));
}
String customRecommendationName = ResourceManagerUtils.getValueFromIdByParameterName(id,
"/{scope}/providers/Microsoft.Security/customRecommendations/{customRecommendationName}",
"customRecommendationName");
if (customRecommendationName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'customRecommendations'.", id)));
}
this.deleteByResourceGroupWithResponse(scope, customRecommendationName, Context.NONE);
}
public Response deleteByIdWithResponse(String id, Context context) {
String scope = ResourceManagerUtils.getValueFromIdByParameterName(id,
"/{scope}/providers/Microsoft.Security/customRecommendations/{customRecommendationName}", "scope");
if (scope == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'scope'.", id)));
}
String customRecommendationName = ResourceManagerUtils.getValueFromIdByParameterName(id,
"/{scope}/providers/Microsoft.Security/customRecommendations/{customRecommendationName}",
"customRecommendationName");
if (customRecommendationName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'customRecommendations'.", id)));
}
return this.deleteByResourceGroupWithResponse(scope, customRecommendationName, context);
}
private CustomRecommendationsClient serviceClient() {
return this.innerClient;
}
private com.azure.resourcemanager.security.SecurityManager manager() {
return this.serviceManager;
}
public CustomRecommendationImpl define(String name) {
return new CustomRecommendationImpl(name, this.manager());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy