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

com.azure.resourcemanager.machinelearning.implementation.SchedulesImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for Machine Learning Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. These APIs allow end users to operate on Azure Machine Learning Workspace resources. Package tag package-2024-04.

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.machinelearning.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.machinelearning.fluent.SchedulesClient;
import com.azure.resourcemanager.machinelearning.fluent.models.ScheduleInner;
import com.azure.resourcemanager.machinelearning.models.Schedule;
import com.azure.resourcemanager.machinelearning.models.ScheduleListViewType;
import com.azure.resourcemanager.machinelearning.models.Schedules;

public final class SchedulesImpl implements Schedules {
    private static final ClientLogger LOGGER = new ClientLogger(SchedulesImpl.class);

    private final SchedulesClient innerClient;

    private final com.azure.resourcemanager.machinelearning.MachineLearningManager serviceManager;

    public SchedulesImpl(SchedulesClient innerClient,
        com.azure.resourcemanager.machinelearning.MachineLearningManager 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 ScheduleImpl(inner1, this.manager()));
    }

    public PagedIterable list(String resourceGroupName, String workspaceName, String skip,
        ScheduleListViewType listViewType, Context context) {
        PagedIterable inner
            = this.serviceClient().list(resourceGroupName, workspaceName, skip, listViewType, context);
        return ResourceManagerUtils.mapPage(inner, inner1 -> new ScheduleImpl(inner1, this.manager()));
    }

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

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

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

    public Schedule get(String resourceGroupName, String workspaceName, String name) {
        ScheduleInner inner = this.serviceClient().get(resourceGroupName, workspaceName, name);
        if (inner != null) {
            return new ScheduleImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

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

    private com.azure.resourcemanager.machinelearning.MachineLearningManager manager() {
        return this.serviceManager;
    }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy