com.sap.cds.feature.mt.SaasClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cds-feature-mt Show documentation
Show all versions of cds-feature-mt Show documentation
Multi tenancy feature for CDS Services Java
package com.sap.cds.feature.mt;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.BooleanNode;
import com.google.common.base.Objects;
import com.sap.cds.integration.cloudsdk.rest.client.JsonRestClient;
import com.sap.cds.services.environment.ServiceBinding;
import com.sap.cds.services.runtime.CdsRuntime;
import com.sap.cloud.sdk.cloudplatform.connectivity.OnBehalfOf;
/**
* Implementation of the SaaS Registry REST client.
*/
public class SaasClient extends JsonRestClient {
private static final Logger logger = LoggerFactory.getLogger(SaasClient.class);
// could be configurable via CdsProperties
private static final int PAGE_SIZE = 500;
private static final String TENANT_STATE = "state";
private static final String SAAS_REGISTRY = "saas-registry";
private static final String SAAS_MANAGER_BASE = "/saas-manager/v1/";
private static final String APPLICATION_TENANTS_PATH = SAAS_MANAGER_BASE + "application/subscriptions";
private static final String SERVICE_TENANTS_PATH = SAAS_MANAGER_BASE + "service/subscriptions?includeIndirectSubscriptions=true";
private final String urlPath;
public static Optional findBinding(CdsRuntime runtime) {
return runtime.getEnvironment().getServiceBindings().filter(b -> b.matches(null, SAAS_REGISTRY)).findFirst();
}
public SaasClient(ServiceBinding binding) {
super(getSaasUrl(binding), checkBinding(binding), OnBehalfOf.TECHNICAL_USER_PROVIDER);
this.urlPath = "service".equals(binding.getServicePlan()) ? SERVICE_TENANTS_PATH : APPLICATION_TENANTS_PATH;
}
/**
* Retrieves the tenant info of all subscribed tenants
*
* @return tenants info
*
* @throws IOException throws when any connection problems occur
*/
public List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy