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

com.azure.resourcemanager.avs.implementation.ScriptExecutionsImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for Avs Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Azure VMware Solution API. Package tag package-2023-09-01.

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.avs.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.avs.fluent.ScriptExecutionsClient;
import com.azure.resourcemanager.avs.fluent.models.ScriptExecutionInner;
import com.azure.resourcemanager.avs.models.ScriptExecution;
import com.azure.resourcemanager.avs.models.ScriptExecutions;
import com.azure.resourcemanager.avs.models.ScriptOutputStreamType;
import java.util.List;

public final class ScriptExecutionsImpl implements ScriptExecutions {
    private static final ClientLogger LOGGER = new ClientLogger(ScriptExecutionsImpl.class);

    private final ScriptExecutionsClient innerClient;

    private final com.azure.resourcemanager.avs.AvsManager serviceManager;

    public ScriptExecutionsImpl(ScriptExecutionsClient innerClient,
        com.azure.resourcemanager.avs.AvsManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

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

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

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

    public ScriptExecution get(String resourceGroupName, String privateCloudName, String scriptExecutionName) {
        ScriptExecutionInner inner = this.serviceClient().get(resourceGroupName, privateCloudName, scriptExecutionName);
        if (inner != null) {
            return new ScriptExecutionImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public void delete(String resourceGroupName, String privateCloudName, String scriptExecutionName) {
        this.serviceClient().delete(resourceGroupName, privateCloudName, scriptExecutionName);
    }

    public void delete(String resourceGroupName, String privateCloudName, String scriptExecutionName, Context context) {
        this.serviceClient().delete(resourceGroupName, privateCloudName, scriptExecutionName, context);
    }

    public Response getExecutionLogsWithResponse(String resourceGroupName, String privateCloudName,
        String scriptExecutionName, List scriptOutputStreamType, Context context) {
        Response inner = this.serviceClient()
            .getExecutionLogsWithResponse(resourceGroupName, privateCloudName, scriptExecutionName,
                scriptOutputStreamType, context);
        if (inner != null) {
            return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
                new ScriptExecutionImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public ScriptExecution getExecutionLogs(String resourceGroupName, String privateCloudName,
        String scriptExecutionName) {
        ScriptExecutionInner inner
            = this.serviceClient().getExecutionLogs(resourceGroupName, privateCloudName, scriptExecutionName);
        if (inner != null) {
            return new ScriptExecutionImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

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

    private com.azure.resourcemanager.avs.AvsManager manager() {
        return this.serviceManager;
    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy