All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.resourcemanager.securityinsights.implementation.IncidentsImpl Maven / Gradle / Ivy

Go to download

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.IncidentsClient;
import com.azure.resourcemanager.securityinsights.fluent.models.IncidentAlertListInner;
import com.azure.resourcemanager.securityinsights.fluent.models.IncidentBookmarkListInner;
import com.azure.resourcemanager.securityinsights.fluent.models.IncidentEntitiesResponseInner;
import com.azure.resourcemanager.securityinsights.fluent.models.IncidentInner;
import com.azure.resourcemanager.securityinsights.fluent.models.TeamInformationInner;
import com.azure.resourcemanager.securityinsights.models.Incident;
import com.azure.resourcemanager.securityinsights.models.IncidentAlertList;
import com.azure.resourcemanager.securityinsights.models.IncidentBookmarkList;
import com.azure.resourcemanager.securityinsights.models.IncidentEntitiesResponse;
import com.azure.resourcemanager.securityinsights.models.Incidents;
import com.azure.resourcemanager.securityinsights.models.ManualTriggerRequestBody;
import com.azure.resourcemanager.securityinsights.models.TeamInformation;
import com.azure.resourcemanager.securityinsights.models.TeamProperties;

public final class IncidentsImpl implements Incidents {
    private static final ClientLogger LOGGER = new ClientLogger(IncidentsImpl.class);

    private final IncidentsClient innerClient;

    private final com.azure.resourcemanager.securityinsights.SecurityInsightsManager serviceManager;

    public IncidentsImpl(IncidentsClient innerClient,
        com.azure.resourcemanager.securityinsights.SecurityInsightsManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response runPlaybookWithResponse(String resourceGroupName, String workspaceName,
        String incidentIdentifier, ManualTriggerRequestBody requestBody, Context context) {
        return this.serviceClient()
            .runPlaybookWithResponse(resourceGroupName, workspaceName, incidentIdentifier, requestBody, context);
    }

    public Object runPlaybook(String resourceGroupName, String workspaceName, String incidentIdentifier) {
        return this.serviceClient().runPlaybook(resourceGroupName, workspaceName, incidentIdentifier);
    }

    public PagedIterable list(String resourceGroupName, String workspaceName) {
        PagedIterable inner = this.serviceClient().list(resourceGroupName, workspaceName);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new IncidentImpl(inner1, this.manager()));
    }

    public PagedIterable list(String resourceGroupName, String workspaceName, String filter, String orderby,
        Integer top, String skipToken, Context context) {
        PagedIterable inner
            = this.serviceClient().list(resourceGroupName, workspaceName, filter, orderby, top, skipToken, context);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new IncidentImpl(inner1, this.manager()));
    }

    public Response getWithResponse(String resourceGroupName, String workspaceName, String incidentId,
        Context context) {
        Response inner
            = this.serviceClient().getWithResponse(resourceGroupName, workspaceName, incidentId, context);
        if (inner != null) {
            return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
                new IncidentImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public Incident get(String resourceGroupName, String workspaceName, String incidentId) {
        IncidentInner inner = this.serviceClient().get(resourceGroupName, workspaceName, incidentId);
        if (inner != null) {
            return new IncidentImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response deleteWithResponse(String resourceGroupName, String workspaceName, String incidentId,
        Context context) {
        return this.serviceClient().deleteWithResponse(resourceGroupName, workspaceName, incidentId, context);
    }

    public void delete(String resourceGroupName, String workspaceName, String incidentId) {
        this.serviceClient().delete(resourceGroupName, workspaceName, incidentId);
    }

    public Response createTeamWithResponse(String resourceGroupName, String workspaceName,
        String incidentId, TeamProperties teamProperties, Context context) {
        Response inner = this.serviceClient()
            .createTeamWithResponse(resourceGroupName, workspaceName, incidentId, teamProperties, context);
        if (inner != null) {
            return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
                new TeamInformationImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public TeamInformation createTeam(String resourceGroupName, String workspaceName, String incidentId,
        TeamProperties teamProperties) {
        TeamInformationInner inner
            = this.serviceClient().createTeam(resourceGroupName, workspaceName, incidentId, teamProperties);
        if (inner != null) {
            return new TeamInformationImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response listAlertsWithResponse(String resourceGroupName, String workspaceName,
        String incidentId, Context context) {
        Response inner
            = this.serviceClient().listAlertsWithResponse(resourceGroupName, workspaceName, incidentId, context);
        if (inner != null) {
            return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
                new IncidentAlertListImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public IncidentAlertList listAlerts(String resourceGroupName, String workspaceName, String incidentId) {
        IncidentAlertListInner inner = this.serviceClient().listAlerts(resourceGroupName, workspaceName, incidentId);
        if (inner != null) {
            return new IncidentAlertListImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response listBookmarksWithResponse(String resourceGroupName, String workspaceName,
        String incidentId, Context context) {
        Response inner
            = this.serviceClient().listBookmarksWithResponse(resourceGroupName, workspaceName, incidentId, context);
        if (inner != null) {
            return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
                new IncidentBookmarkListImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public IncidentBookmarkList listBookmarks(String resourceGroupName, String workspaceName, String incidentId) {
        IncidentBookmarkListInner inner
            = this.serviceClient().listBookmarks(resourceGroupName, workspaceName, incidentId);
        if (inner != null) {
            return new IncidentBookmarkListImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response listEntitiesWithResponse(String resourceGroupName, String workspaceName,
        String incidentId, Context context) {
        Response inner
            = this.serviceClient().listEntitiesWithResponse(resourceGroupName, workspaceName, incidentId, context);
        if (inner != null) {
            return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
                new IncidentEntitiesResponseImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public IncidentEntitiesResponse listEntities(String resourceGroupName, String workspaceName, String incidentId) {
        IncidentEntitiesResponseInner inner
            = this.serviceClient().listEntities(resourceGroupName, workspaceName, incidentId);
        if (inner != null) {
            return new IncidentEntitiesResponseImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Incident 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 incidentId = ResourceManagerUtils.getValueFromIdByName(id, "incidents");
        if (incidentId == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'incidents'.", id)));
        }
        return this.getWithResponse(resourceGroupName, workspaceName, incidentId, 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 incidentId = ResourceManagerUtils.getValueFromIdByName(id, "incidents");
        if (incidentId == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'incidents'.", id)));
        }
        return this.getWithResponse(resourceGroupName, workspaceName, incidentId, 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 incidentId = ResourceManagerUtils.getValueFromIdByName(id, "incidents");
        if (incidentId == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'incidents'.", id)));
        }
        this.deleteWithResponse(resourceGroupName, workspaceName, incidentId, 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 incidentId = ResourceManagerUtils.getValueFromIdByName(id, "incidents");
        if (incidentId == null) {
            throw LOGGER.logExceptionAsError(new IllegalArgumentException(
                String.format("The resource ID '%s' is not valid. Missing path segment 'incidents'.", id)));
        }
        return this.deleteWithResponse(resourceGroupName, workspaceName, incidentId, context);
    }

    private IncidentsClient serviceClient() {
        return this.innerClient;
    }

    private com.azure.resourcemanager.securityinsights.SecurityInsightsManager manager() {
        return this.serviceManager;
    }

    public IncidentImpl define(String name) {
        return new IncidentImpl(name, this.manager());
    }
}