com.azure.resourcemanager.security.implementation.DevOpsPolicyAssignmentsImpl 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.DevOpsPolicyAssignmentsClient;
import com.azure.resourcemanager.security.fluent.models.DevOpsPolicyAssignmentInner;
import com.azure.resourcemanager.security.models.DevOpsPolicyAssignment;
import com.azure.resourcemanager.security.models.DevOpsPolicyAssignments;
public final class DevOpsPolicyAssignmentsImpl implements DevOpsPolicyAssignments {
private static final ClientLogger LOGGER = new ClientLogger(DevOpsPolicyAssignmentsImpl.class);
private final DevOpsPolicyAssignmentsClient innerClient;
private final com.azure.resourcemanager.security.SecurityManager serviceManager;
public DevOpsPolicyAssignmentsImpl(DevOpsPolicyAssignmentsClient innerClient,
com.azure.resourcemanager.security.SecurityManager serviceManager) {
this.innerClient = innerClient;
this.serviceManager = serviceManager;
}
public PagedIterable list(String resourceGroupName, String securityConnectorName) {
PagedIterable inner
= this.serviceClient().list(resourceGroupName, securityConnectorName);
return ResourceManagerUtils.mapPage(inner, inner1 -> new DevOpsPolicyAssignmentImpl(inner1, this.manager()));
}
public PagedIterable list(String resourceGroupName, String securityConnectorName,
String devOpsPolicyType, String resourceId, Context context) {
PagedIterable inner = this.serviceClient()
.list(resourceGroupName, securityConnectorName, devOpsPolicyType, resourceId, context);
return ResourceManagerUtils.mapPage(inner, inner1 -> new DevOpsPolicyAssignmentImpl(inner1, this.manager()));
}
public Response getWithResponse(String resourceGroupName, String securityConnectorName,
String policyAssignmentId, Context context) {
Response inner = this.serviceClient()
.getWithResponse(resourceGroupName, securityConnectorName, policyAssignmentId, context);
if (inner != null) {
return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
new DevOpsPolicyAssignmentImpl(inner.getValue(), this.manager()));
} else {
return null;
}
}
public DevOpsPolicyAssignment get(String resourceGroupName, String securityConnectorName,
String policyAssignmentId) {
DevOpsPolicyAssignmentInner inner
= this.serviceClient().get(resourceGroupName, securityConnectorName, policyAssignmentId);
if (inner != null) {
return new DevOpsPolicyAssignmentImpl(inner, this.manager());
} else {
return null;
}
}
public void delete(String resourceGroupName, String securityConnectorName, String policyAssignmentId) {
this.serviceClient().delete(resourceGroupName, securityConnectorName, policyAssignmentId);
}
public void delete(String resourceGroupName, String securityConnectorName, String policyAssignmentId,
Context context) {
this.serviceClient().delete(resourceGroupName, securityConnectorName, policyAssignmentId, context);
}
public DevOpsPolicyAssignment 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 securityConnectorName = ResourceManagerUtils.getValueFromIdByName(id, "securityConnectors");
if (securityConnectorName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'securityConnectors'.", id)));
}
String policyAssignmentId = ResourceManagerUtils.getValueFromIdByName(id, "policyAssignments");
if (policyAssignmentId == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'policyAssignments'.", id)));
}
return this.getWithResponse(resourceGroupName, securityConnectorName, policyAssignmentId, 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 securityConnectorName = ResourceManagerUtils.getValueFromIdByName(id, "securityConnectors");
if (securityConnectorName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'securityConnectors'.", id)));
}
String policyAssignmentId = ResourceManagerUtils.getValueFromIdByName(id, "policyAssignments");
if (policyAssignmentId == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'policyAssignments'.", id)));
}
return this.getWithResponse(resourceGroupName, securityConnectorName, policyAssignmentId, 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 securityConnectorName = ResourceManagerUtils.getValueFromIdByName(id, "securityConnectors");
if (securityConnectorName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'securityConnectors'.", id)));
}
String policyAssignmentId = ResourceManagerUtils.getValueFromIdByName(id, "policyAssignments");
if (policyAssignmentId == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'policyAssignments'.", id)));
}
this.delete(resourceGroupName, securityConnectorName, policyAssignmentId, 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 securityConnectorName = ResourceManagerUtils.getValueFromIdByName(id, "securityConnectors");
if (securityConnectorName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'securityConnectors'.", id)));
}
String policyAssignmentId = ResourceManagerUtils.getValueFromIdByName(id, "policyAssignments");
if (policyAssignmentId == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'policyAssignments'.", id)));
}
this.delete(resourceGroupName, securityConnectorName, policyAssignmentId, context);
}
private DevOpsPolicyAssignmentsClient serviceClient() {
return this.innerClient;
}
private com.azure.resourcemanager.security.SecurityManager manager() {
return this.serviceManager;
}
public DevOpsPolicyAssignmentImpl define(String name) {
return new DevOpsPolicyAssignmentImpl(name, this.manager());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy