com.azure.resourcemanager.machinelearning.implementation.ComponentVersionsImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-machinelearning Show documentation
Show all versions of azure-resourcemanager-machinelearning Show documentation
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.ComponentVersionsClient;
import com.azure.resourcemanager.machinelearning.fluent.models.ComponentVersionInner;
import com.azure.resourcemanager.machinelearning.models.ComponentVersion;
import com.azure.resourcemanager.machinelearning.models.ComponentVersions;
import com.azure.resourcemanager.machinelearning.models.DestinationAsset;
import com.azure.resourcemanager.machinelearning.models.ListViewType;
public final class ComponentVersionsImpl implements ComponentVersions {
private static final ClientLogger LOGGER = new ClientLogger(ComponentVersionsImpl.class);
private final ComponentVersionsClient innerClient;
private final com.azure.resourcemanager.machinelearning.MachineLearningManager serviceManager;
public ComponentVersionsImpl(ComponentVersionsClient innerClient,
com.azure.resourcemanager.machinelearning.MachineLearningManager serviceManager) {
this.innerClient = innerClient;
this.serviceManager = serviceManager;
}
public PagedIterable list(String resourceGroupName, String workspaceName, String name) {
PagedIterable inner = this.serviceClient().list(resourceGroupName, workspaceName, name);
return ResourceManagerUtils.mapPage(inner, inner1 -> new ComponentVersionImpl(inner1, this.manager()));
}
public PagedIterable list(String resourceGroupName, String workspaceName, String name,
String orderBy, Integer top, String skip, ListViewType listViewType, Context context) {
PagedIterable inner = this.serviceClient()
.list(resourceGroupName, workspaceName, name, orderBy, top, skip, listViewType, context);
return ResourceManagerUtils.mapPage(inner, inner1 -> new ComponentVersionImpl(inner1, this.manager()));
}
public Response deleteWithResponse(String resourceGroupName, String workspaceName, String name,
String version, Context context) {
return this.serviceClient().deleteWithResponse(resourceGroupName, workspaceName, name, version, context);
}
public void delete(String resourceGroupName, String workspaceName, String name, String version) {
this.serviceClient().delete(resourceGroupName, workspaceName, name, version);
}
public Response getWithResponse(String resourceGroupName, String workspaceName, String name,
String version, Context context) {
Response inner
= this.serviceClient().getWithResponse(resourceGroupName, workspaceName, name, version, context);
if (inner != null) {
return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(),
new ComponentVersionImpl(inner.getValue(), this.manager()));
} else {
return null;
}
}
public ComponentVersion get(String resourceGroupName, String workspaceName, String name, String version) {
ComponentVersionInner inner = this.serviceClient().get(resourceGroupName, workspaceName, name, version);
if (inner != null) {
return new ComponentVersionImpl(inner, this.manager());
} else {
return null;
}
}
public void publish(String resourceGroupName, String workspaceName, String name, String version,
DestinationAsset body) {
this.serviceClient().publish(resourceGroupName, workspaceName, name, version, body);
}
public void publish(String resourceGroupName, String workspaceName, String name, String version,
DestinationAsset body, Context context) {
this.serviceClient().publish(resourceGroupName, workspaceName, name, version, body, context);
}
public ComponentVersion 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, "components");
if (name == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'components'.", id)));
}
String version = ResourceManagerUtils.getValueFromIdByName(id, "versions");
if (version == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'versions'.", id)));
}
return this.getWithResponse(resourceGroupName, workspaceName, name, version, 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, "components");
if (name == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'components'.", id)));
}
String version = ResourceManagerUtils.getValueFromIdByName(id, "versions");
if (version == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'versions'.", id)));
}
return this.getWithResponse(resourceGroupName, workspaceName, name, version, 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, "components");
if (name == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'components'.", id)));
}
String version = ResourceManagerUtils.getValueFromIdByName(id, "versions");
if (version == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'versions'.", id)));
}
this.deleteWithResponse(resourceGroupName, workspaceName, name, version, 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 name = ResourceManagerUtils.getValueFromIdByName(id, "components");
if (name == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'components'.", id)));
}
String version = ResourceManagerUtils.getValueFromIdByName(id, "versions");
if (version == null) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException(
String.format("The resource ID '%s' is not valid. Missing path segment 'versions'.", id)));
}
return this.deleteWithResponse(resourceGroupName, workspaceName, name, version, context);
}
private ComponentVersionsClient serviceClient() {
return this.innerClient;
}
private com.azure.resourcemanager.machinelearning.MachineLearningManager manager() {
return this.serviceManager;
}
public ComponentVersionImpl define(String name) {
return new ComponentVersionImpl(name, this.manager());
}
}