Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.tenant;
import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap;
import com.yahoo.config.provision.TenantName;
import com.yahoo.vespa.hosted.controller.api.integration.billing.PlanId;
import com.yahoo.vespa.hosted.controller.api.integration.secrets.TenantSecretStore;
import com.yahoo.vespa.hosted.controller.api.role.SimplePrincipal;
import java.security.Principal;
import java.security.PublicKey;
import java.time.Instant;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
/**
* A paying tenant in a Vespa cloud service.
*
* @author jonmv
*/
public class CloudTenant extends Tenant {
private final Optional creator;
private final BiMap developerKeys;
private final TenantInfo info;
private final List tenantSecretStores;
private final ArchiveAccess archiveAccess;
private final Optional invalidateUserSessionsBefore;
private final Optional billingReference;
private final PlanId planId;
/** Public for the serialization layer — do not use! */
public CloudTenant(TenantName name, Instant createdAt, LastLoginInfo lastLoginInfo, Optional creator,
BiMap developerKeys, TenantInfo info,
List tenantSecretStores, ArchiveAccess archiveAccess,
Optional invalidateUserSessionsBefore, Instant tenantRoleLastMaintained,
List cloudAccounts, Optional billingReference,
PlanId planId) {
super(name, createdAt, lastLoginInfo, Optional.empty(), tenantRoleLastMaintained, cloudAccounts);
this.creator = creator;
this.developerKeys = developerKeys;
this.info = Objects.requireNonNull(info);
this.tenantSecretStores = tenantSecretStores;
this.archiveAccess = Objects.requireNonNull(archiveAccess);
this.invalidateUserSessionsBefore = invalidateUserSessionsBefore;
this.billingReference = Objects.requireNonNull(billingReference);
this.planId = Objects.requireNonNull(planId);
}
/** Creates a tenant with the given name, provided it passes validation. */
public static CloudTenant create(TenantName tenantName, Instant createdAt, Principal creator) {
// Initialize with creator as verified contact
var info = TenantInfo.empty().withContacts(new TenantContacts(List.of(
new TenantContacts.EmailContact(
List.of(TenantContacts.Audience.TENANT, TenantContacts.Audience.NOTIFICATIONS),
new Email(creator.getName(), true)))));
return new CloudTenant(requireName(tenantName),
createdAt,
LastLoginInfo.EMPTY,
Optional.ofNullable(creator).map(SimplePrincipal::of),
ImmutableBiMap.of(), info, List.of(), new ArchiveAccess(), Optional.empty(),
Instant.EPOCH, List.of(), Optional.empty(), PlanId.from("none"));
}
/** The user that created the tenant */
public Optional creator() {
return creator;
}
/** Legal name, addresses etc */
public TenantInfo info() {
return info;
}
/** Returns the set of developer keys and their corresponding developers for this tenant. */
public BiMap developerKeys() { return developerKeys; }
/** List of configured secret stores */
public List tenantSecretStores() {
return tenantSecretStores;
}
/**
* Role or member that is allowed to access archive bucket (log, dump)
*
* For AWS is this the IAM role
* For GCP it is a GCP member
*/
public ArchiveAccess archiveAccess() {
return archiveAccess;
}
/** Returns instant before which all user sessions that have access to this tenant must be refreshed */
public Optional invalidateUserSessionsBefore() {
return invalidateUserSessionsBefore;
}
public Optional billingReference() {
return billingReference;
}
public PlanId planId() { return planId; }
@Override
public Type type() {
return Type.cloud;
}
}