com.azure.resourcemanager.securityinsights.implementation.BookmarksImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-securityinsights Show documentation
Show all versions of azure-resourcemanager-securityinsights Show documentation
This package contains Microsoft Azure SDK for SecurityInsights Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. API spec for Microsoft.SecurityInsights (Azure Security Insights) resource provider. Package tag package-preview-2022-09.
The newest version!
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.securityinsights.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.securityinsights.fluent.BookmarksClient;
import com.azure.resourcemanager.securityinsights.fluent.models.BookmarkInner;
import com.azure.resourcemanager.securityinsights.models.Bookmark;
import com.azure.resourcemanager.securityinsights.models.Bookmarks;
public final class BookmarksImpl implements Bookmarks {
private static final ClientLogger LOGGER = new ClientLogger(BookmarksImpl.class);
private final BookmarksClient innerClient;
private final com.azure.resourcemanager.securityinsights.SecurityInsightsManager serviceManager;
public BookmarksImpl(BookmarksClient innerClient,
com.azure.resourcemanager.securityinsights.SecurityInsightsManager serviceManager) {
this.innerClient = innerClient;
this.serviceManager = serviceManager;
}
public PagedIterable list(String resourceGroupName, String workspaceName) {
PagedIterable inner = this.serviceClient().list(resourceGroupName, workspaceName);
return ResourceManagerUtils.mapPage(inner, inner1 -> new BookmarkImpl(inner1, this.manager()));
}
public PagedIterable list(String resourceGroupName, String workspaceName, Context context) {
PagedIterable inner = this.serviceClient().list(resourceGroupName, workspaceName, context);
return ResourceManagerUtils.mapPage(inner, inner1 -> new BookmarkImpl(inner1, this.manager()));
}
public Response getWithResponse(String resourceGroupName, String workspaceName, String bookmarkId,
Context context) {
Response inner
= this.serviceClient().getWithResponse(resourceGroupName, workspaceName, bookmarkId, context);
if (inner != null) {
return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
new BookmarkImpl(inner.getValue(), this.manager()));
} else {
return null;
}
}
public Bookmark get(String resourceGroupName, String workspaceName, String bookmarkId) {
BookmarkInner inner = this.serviceClient().get(resourceGroupName, workspaceName, bookmarkId);
if (inner != null) {
return new BookmarkImpl(inner, this.manager());
} else {
return null;
}
}
public Response deleteWithResponse(String resourceGroupName, String workspaceName, String bookmarkId,
Context context) {
return this.serviceClient().deleteWithResponse(resourceGroupName, workspaceName, bookmarkId, context);
}
public void delete(String resourceGroupName, String workspaceName, String bookmarkId) {
this.serviceClient().delete(resourceGroupName, workspaceName, bookmarkId);
}
public Bookmark 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 workspaceName = ResourceManagerUtils.getValueFromIdByName(id, "workspaces");
if (workspaceName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'workspaces'.", id)));
}
String bookmarkId = ResourceManagerUtils.getValueFromIdByName(id, "bookmarks");
if (bookmarkId == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'bookmarks'.", id)));
}
return this.getWithResponse(resourceGroupName, workspaceName, bookmarkId, 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 workspaceName = ResourceManagerUtils.getValueFromIdByName(id, "workspaces");
if (workspaceName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'workspaces'.", id)));
}
String bookmarkId = ResourceManagerUtils.getValueFromIdByName(id, "bookmarks");
if (bookmarkId == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'bookmarks'.", id)));
}
return this.getWithResponse(resourceGroupName, workspaceName, bookmarkId, 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 workspaceName = ResourceManagerUtils.getValueFromIdByName(id, "workspaces");
if (workspaceName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'workspaces'.", id)));
}
String bookmarkId = ResourceManagerUtils.getValueFromIdByName(id, "bookmarks");
if (bookmarkId == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'bookmarks'.", id)));
}
this.deleteWithResponse(resourceGroupName, workspaceName, bookmarkId, Context.NONE);
}
public Response 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 workspaceName = ResourceManagerUtils.getValueFromIdByName(id, "workspaces");
if (workspaceName == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'workspaces'.", id)));
}
String bookmarkId = ResourceManagerUtils.getValueFromIdByName(id, "bookmarks");
if (bookmarkId == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'bookmarks'.", id)));
}
return this.deleteWithResponse(resourceGroupName, workspaceName, bookmarkId, context);
}
private BookmarksClient serviceClient() {
return this.innerClient;
}
private com.azure.resourcemanager.securityinsights.SecurityInsightsManager manager() {
return this.serviceManager;
}
public BookmarkImpl define(String name) {
return new BookmarkImpl(name, this.manager());
}
}