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

com.emc.vipr.client.core.VirtualDataCenters Maven / Gradle / Ivy

There is a newer version: 3.5.0.0
Show newest version
/*
 * Copyright (c) 2015 EMC Corporation
 * All Rights Reserved
 */
package com.emc.vipr.client.core;

import com.emc.storageos.model.NamedRelatedResourceRep;
import com.emc.storageos.model.TaskResourceRep;
import com.emc.storageos.model.vdc.*;
import com.emc.vipr.client.Task;
import com.emc.vipr.client.Tasks;
import com.emc.vipr.client.ViPRCoreClient;
import com.emc.vipr.client.core.filters.ResourceFilter;
import com.emc.vipr.client.core.impl.PathConstants;
import com.emc.vipr.client.impl.RestClient;
import com.sun.jersey.api.client.ClientResponse;

import java.net.URI;
import java.util.List;
import java.util.Properties;

import static com.emc.vipr.client.core.util.ResourceUtils.defaultList;

/**
 * VDC resources.
 * 

* Base URL: /vdc */ public class VirtualDataCenters extends AbstractCoreResources implements TopLevelResources { private static final String EXPECTED_VERSION_QUERY_PARAM = "expect_version"; public VirtualDataCenters(ViPRCoreClient parent, RestClient client) { super(parent, client, VirtualDataCenterRestRep.class, PathConstants.VDC_URL); } @Override public VirtualDataCenters withInactive(boolean inactive) { return (VirtualDataCenters) super.withInactive(inactive); } public List list() { VirtualDataCenterList response = client.get(VirtualDataCenterList.class, PathConstants.VDC_URL); return defaultList(response.getVirtualDataCenters()); } /** * Creates a vdc. *

* API Call: POST /vdc/ * * @param input * the vdc configuration. * @return Task VirtualDataCenterRestRep the task to create the vdc. */ public Task create(VirtualDataCenterAddParam input) { return postTask(input, PathConstants.VDC_URL); } /** * Updates a vdc. *

* API Call: PUT /vdc/{id} * * @param id * the ID of the vdc to update. * @param input * the vdc configuration. * @return Task VirtualDataCenterRestRep the task to update the vdc. */ public Task update(URI id, VirtualDataCenterModifyParam input) { return putTask(input, getIdUrl(), id); } /** * Deletes the given vdc by ID. *

* API Call: DELETE /vdc/{id} * * @param id * the ID of the vdc to delete. * @return Task VirtualDataCenterRestRep the task to delete the vdc. */ public Task delete(URI id) { TaskResourceRep task = client.delete(TaskResourceRep.class, getIdUrl(), id); return new Task(client, task, resourceClass); } /** * Reconnects the given vdc by ID. *

* API Call: POST /vdc/{id}/reconnect * * @param id * the ID of the vdc to reconnect. * @return Task VirtualDataCenterRestRep the task to reconnect the vdc. */ public Task reconnect(URI id) { return postTask(getReconnectUrl(), id); } /** * Disconnects the given vdc by ID. *

* API Call: POST /vdc/{id}/disconnect * * @param id * the ID of the vdc to disconnect. * @return Task VirtualDataCenterRestRep the task to disconnect the vdc. */ public Task disconnect(URI id) { return postTask(getDisconnectUrl(), id); } /** * gets the secret key. *

* API Call: POST /vdc/secret-key * * @return VirtualDataCenterSecretKeyRestRep the vdc secret * key response. */ public VirtualDataCenterSecretKeyRestRep getSecretKey() { return client.get(VirtualDataCenterSecretKeyRestRep.class, PathConstants.VDC_SECRET_KEY_URL); } /** * Gets the URL for disconnecting a vdc. * * @return the disconnect URL. */ protected String getDisconnectUrl() { return String.format(PathConstants.DISCONNECT_URL_FORMAT, baseUrl); } /** * Gets the URL for reconnecting a vdc. * * @return the reconnect URL. */ protected String getReconnectUrl() { return String.format(PathConstants.RECONNECT_URL_FORMAT, baseUrl); } @Override public List getAll() { return getByRefs(list()); } @Override public List getAll(ResourceFilter filter) { return getByRefs(list(), filter); } public Tasks getTasks(URI id) { return doGetTasks(id); } /** * A VDC compatibility check to see of all the VDCs in the federation are in the * minimum expected version or not. This can be used in the UI to restrict a * view of a feature. * * * API Call: GET /vdc/check-compatibility?expect_version={expectedVersion} * * @param expectedVersion minimum expected version of all the VDCs in the federation. * * @return true if the all the VDCs are in equal or higher version of the expectedVersion * otherwise false. */ public boolean isCompatibleVDCVersion(String expectedVersion) { Properties queryParams = new Properties(); queryParams.put(EXPECTED_VERSION_QUERY_PARAM, expectedVersion); ClientResponse resp = client.get(ClientResponse.class, PathConstants.CHECK_COMPATIBLE_VDC_URL, queryParams); return Boolean.parseBoolean(resp.getEntity(String.class)); } /** * A check to see if the setup is geo-distributed multi-vdc setup. * This can be used in the UI to restrict a view of a feature. * * * API Call: GET /vdc/check-geo-distributed * * @return true if the setup is geo-distributed/multi-vdc setup * otherwise false. */ public boolean isGeoSetup() { ClientResponse resp = client.get(ClientResponse.class, PathConstants.CHECK_IS_GEO_DISTRIBUTED_VDC_URL); return Boolean.parseBoolean(resp.getEntity(String.class)); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy