Search in sources :

Example 1 with Property

use of com.yahoo.vespa.hosted.controller.api.identifiers.Property in project vespa by vespa-engine.

the class ControllerTester method createTenant.

public TenantId createTenant(String tenantName, String domainName, Long propertyId) {
    TenantId id = new TenantId(tenantName);
    Optional<Tenant> existing = controller().tenants().tenant(id);
    if (existing.isPresent())
        return id;
    Tenant tenant = Tenant.createAthensTenant(id, createDomain(domainName), new Property("app1Property"), propertyId == null ? Optional.empty() : Optional.of(new PropertyId(propertyId.toString())));
    controller().tenants().createAthenzTenant(tenant, TestIdentities.userNToken);
    assertNotNull(controller().tenants().tenant(id));
    return id;
}
Also used : TenantId(com.yahoo.vespa.hosted.controller.api.identifiers.TenantId) Tenant(com.yahoo.vespa.hosted.controller.api.Tenant) Property(com.yahoo.vespa.hosted.controller.api.identifiers.Property) PropertyId(com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId)

Example 2 with Property

use of com.yahoo.vespa.hosted.controller.api.identifiers.Property in project vespa by vespa-engine.

the class ApplicationApiHandler method updateTenant.

private HttpResponse updateTenant(String tenantName, HttpRequest request) {
    Optional<Tenant> existingTenant = controller.tenants().tenant(new TenantId(tenantName));
    if (!existingTenant.isPresent())
        return ErrorResponse.notFoundError("Tenant '" + tenantName + "' does not exist");
    ;
    Inspector requestData = toSlime(request.getData()).get();
    Tenant updatedTenant;
    switch(existingTenant.get().tenantType()) {
        case USER:
            {
                throw new BadRequestException("Cannot set property or OpsDB user group for user tenant");
            }
        case ATHENS:
            {
                updatedTenant = Tenant.createAthensTenant(new TenantId(tenantName), new AthenzDomain(mandatory("athensDomain", requestData).asString()), new Property(mandatory("property", requestData).asString()), optional("propertyId", requestData).map(PropertyId::new));
                controller.tenants().updateTenant(updatedTenant, getUserPrincipal(request).getNToken());
                break;
            }
        default:
            {
                throw new BadRequestException("Unknown tenant type: " + existingTenant.get().tenantType());
            }
    }
    return tenant(updatedTenant, request, true);
}
Also used : TenantId(com.yahoo.vespa.hosted.controller.api.identifiers.TenantId) Tenant(com.yahoo.vespa.hosted.controller.api.Tenant) AthenzDomain(com.yahoo.vespa.athenz.api.AthenzDomain) Inspector(com.yahoo.slime.Inspector) BadRequestException(javax.ws.rs.BadRequestException) Property(com.yahoo.vespa.hosted.controller.api.identifiers.Property)

Example 3 with Property

use of com.yahoo.vespa.hosted.controller.api.identifiers.Property in project vespa by vespa-engine.

the class ApplicationApiHandler method properties.

private HttpResponse properties() {
    Slime slime = new Slime();
    Cursor response = slime.setObject();
    Cursor array = response.setArray("properties");
    for (Map.Entry<PropertyId, Property> entry : controller.fetchPropertyList().entrySet()) {
        Cursor propertyObject = array.addObject();
        propertyObject.setString("propertyid", entry.getKey().id());
        propertyObject.setString("property", entry.getValue().id());
    }
    return new SlimeJsonResponse(slime);
}
Also used : SlimeJsonResponse(com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse) Slime(com.yahoo.slime.Slime) Cursor(com.yahoo.slime.Cursor) Map(java.util.Map) Property(com.yahoo.vespa.hosted.controller.api.identifiers.Property) PropertyId(com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId)

Example 4 with Property

use of com.yahoo.vespa.hosted.controller.api.identifiers.Property in project vespa by vespa-engine.

the class ContainerControllerTester method createApplication.

public Application createApplication(String athensDomain, String tenant, String application) {
    AthenzDomain domain1 = addTenantAthenzDomain(athensDomain, "mytenant");
    controller().tenants().createAthenzTenant(Tenant.createAthensTenant(new TenantId(tenant), domain1, new Property("property1"), Optional.of(new PropertyId("1234"))), TestIdentities.userNToken);
    ApplicationId app = ApplicationId.from(tenant, application, "default");
    return controller().applications().createApplication(app, Optional.of(TestIdentities.userNToken));
}
Also used : TenantId(com.yahoo.vespa.hosted.controller.api.identifiers.TenantId) AthenzDomain(com.yahoo.vespa.athenz.api.AthenzDomain) ApplicationId(com.yahoo.config.provision.ApplicationId) Property(com.yahoo.vespa.hosted.controller.api.identifiers.Property) PropertyId(com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId)

Example 5 with Property

use of com.yahoo.vespa.hosted.controller.api.identifiers.Property in project vespa by vespa-engine.

the class MemoryEntityService method listProperties.

@Override
public Map<PropertyId, Property> listProperties() {
    Map<PropertyId, Property> properties = new HashMap<>();
    properties.put(new PropertyId("1234"), new Property("foo"));
    properties.put(new PropertyId("4321"), new Property("bar"));
    return Collections.unmodifiableMap(properties);
}
Also used : HashMap(java.util.HashMap) Property(com.yahoo.vespa.hosted.controller.api.identifiers.Property) PropertyId(com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId)

Aggregations

Property (com.yahoo.vespa.hosted.controller.api.identifiers.Property)5 PropertyId (com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId)4 TenantId (com.yahoo.vespa.hosted.controller.api.identifiers.TenantId)3 AthenzDomain (com.yahoo.vespa.athenz.api.AthenzDomain)2 Tenant (com.yahoo.vespa.hosted.controller.api.Tenant)2 ApplicationId (com.yahoo.config.provision.ApplicationId)1 Cursor (com.yahoo.slime.Cursor)1 Inspector (com.yahoo.slime.Inspector)1 Slime (com.yahoo.slime.Slime)1 SlimeJsonResponse (com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 BadRequestException (javax.ws.rs.BadRequestException)1