Skip to content
Permalink
Browse files
Added LogDelivery
  • Loading branch information
Agnello Staibano authored and nacx committed Jun 21, 2016
1 parent cef547f commit 18e50b60ba734d98a690613bafdfe92f0fc4b3e3
Showing 9 changed files with 135 additions and 9 deletions.
@@ -59,29 +59,37 @@ public abstract class CreateService {
*/
public abstract String getFlavorId();

/**
* @see Builder#logDelivery(LogDelivery)
*/
public abstract LogDelivery getLogDelivery();

public static Builder builder() {
return new AutoValue_CreateService.Builder().caching(null).restrictions(null);
}

public Builder toBuilder() {
return builder()
.name(getName())
.domains(getDomains())
.origins(getOrigins())
.caching(getCaching())
.restrictions(getRestrictions())
.flavorId(getFlavorId());
.flavorId(getFlavorId())
.logDelivery(getLogDelivery());
}

@SerializedNames({ "name", "domains", "origins", "caching", "restrictions", "flavor_id" })
@SerializedNames({ "name", "domains", "origins", "caching", "restrictions", "flavor_id", "log_delivery" })
private static CreateService create(String name, List<Domain> domains, List<Origin> origins, List<Caching> caching,
List<Restriction> restrictions, String flavorId) {
List<Restriction> restrictions, String flavorId, LogDelivery logDelivery) {
return builder()
.name(name)
.domains(domains)
.origins(origins)
.caching(caching)
.restrictions(restrictions)
.flavorId(flavorId).build();
.flavorId(flavorId)
.logDelivery(logDelivery).build();
}

public static final class Builder {
@@ -91,6 +99,7 @@ public static final class Builder {
private List<Caching> caching;
private List<Restriction> restrictions;
private String flavorId;
private LogDelivery logDelivery;
Builder() {
}
Builder(CreateService source) {
@@ -100,6 +109,7 @@ public static final class Builder {
caching(source.getCaching());
restrictions(source.getRestrictions());
flavorId(source.getFlavorId());
logDelivery(source.getLogDelivery());
}

/**
@@ -164,6 +174,17 @@ public Builder flavorId(String flavorId) {
return this;
}

/**
* Required.
*
* @param logDelivery
* @return The CreateService builder.
*/
public Builder logDelivery(LogDelivery logDelivery) {
this.logDelivery = logDelivery;
return this;
}

public CreateService build() {
String missing = "";
if (name == null) {
@@ -178,6 +199,9 @@ public CreateService build() {
if (flavorId == null) {
missing += " flavorId";
}
if (logDelivery == null) {
missing += " logDelivery";
}
if (!missing.isEmpty()) {
throw new IllegalStateException("Missing required properties:" + missing);
}
@@ -187,7 +211,8 @@ public CreateService build() {
this.origins,
this.caching == null ? null : ImmutableList.copyOf(this.caching),
this.restrictions == null ? null : ImmutableList.copyOf(this.restrictions),
this.flavorId);
this.flavorId,
this.logDelivery);
return result;
}
}
@@ -0,0 +1,67 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.openstack.poppy.v1.domain;

import org.jclouds.json.SerializedNames;

import com.google.auto.value.AutoValue;

/**
* Representation of an OpenStack Poppy Service Logging.
*/
@AutoValue
public abstract class LogDelivery {

/**
* @return Specifies the delivery logging status
*/
public abstract boolean getEnabled();

@SerializedNames({ "enabled" })
private static LogDelivery create(boolean enabled) {
return builder().enabled(enabled).build();
}

public static Builder builder() {
return new AutoValue_LogDelivery.Builder();
}

public Builder toBuilder() {
return builder().enabled(getEnabled());
}

public static final class Builder {
private boolean enabled;

Builder() {
}

Builder(LogDelivery source) {
enabled(source.getEnabled());
}

public LogDelivery.Builder enabled(boolean enabled) {
this.enabled = enabled;
return this;
}

public LogDelivery build() {
LogDelivery result = new AutoValue_LogDelivery(this.enabled);
return result;
}
}
}
@@ -85,11 +85,16 @@ public abstract class Service {
*/
public abstract Set<Link> getLinks();

/**
* @return Specifies the delivery logging
*/
public abstract LogDelivery getLogDelivery();

@SerializedNames({ "id", "name", "domains", "origins", "caching", "restrictions", "flavor_id",
"status", "errors", "links" })
"status", "errors", "links", "log_delivery" })
private static Service create(String id, String name, List<Domain> domains,
List<Origin> origins, List<Caching> caching, List<Restriction> restrictions,
String flavorId, ServiceStatus status, List<Error> errors, Set<Link> links) {
String flavorId, ServiceStatus status, List<Error> errors, Set<Link> links, LogDelivery logDelivery) {
return new AutoValue_Service(
id,
name,
@@ -100,7 +105,8 @@ private static Service create(String id, String name, List<Domain> domains,
flavorId,
status,
errors != null ? ImmutableList.copyOf(errors) : null,
ImmutableSet.copyOf(links));
ImmutableSet.copyOf(links),
logDelivery);
}

public UpdateService.Builder toUpdatableService() {
@@ -27,6 +27,7 @@
import org.jclouds.openstack.poppy.v1.domain.Caching;
import org.jclouds.openstack.poppy.v1.domain.CreateService;
import org.jclouds.openstack.poppy.v1.domain.Domain;
import org.jclouds.openstack.poppy.v1.domain.LogDelivery;
import org.jclouds.openstack.poppy.v1.domain.Origin;
import org.jclouds.openstack.poppy.v1.domain.Restriction;
import org.jclouds.openstack.poppy.v1.domain.RestrictionRule;
@@ -74,6 +75,7 @@ public void testCreateUpdateAndDeleteService() {
.build())).build()))
.caching(ImmutableList.of(Caching.builder().name("default").ttl(3600).build()))
.flavorId(flavorApi.list().first().get().getId())
.logDelivery(LogDelivery.builder().enabled(false).build())
.build()
);

@@ -30,6 +30,7 @@
import org.jclouds.openstack.poppy.v1.domain.Caching;
import org.jclouds.openstack.poppy.v1.domain.CreateService;
import org.jclouds.openstack.poppy.v1.domain.Domain;
import org.jclouds.openstack.poppy.v1.domain.LogDelivery;
import org.jclouds.openstack.poppy.v1.domain.Origin;
import org.jclouds.openstack.poppy.v1.domain.Restriction;
import org.jclouds.openstack.poppy.v1.domain.RestrictionRule;
@@ -77,6 +78,7 @@ public void testCreateService() throws Exception {
.caching(ImmutableList.of(
Caching.builder().name("default").ttl(3600).build()))
.flavorId("cdn")
.logDelivery(LogDelivery.builder().enabled(false).build())
.build();

URI uri = api.create(options);
@@ -32,5 +32,9 @@
"ttl": 3600
}
],
"flavor_id": "cdn"
"flavor_id": "cdn",
"log_delivery":
{
"enabled": false
}
}
@@ -53,6 +53,10 @@
}
],
"flavor_id": "cdn",
"log_delivery":
{
"enabled": false
},
"status": "deployed",
"errors": [],
"links": [
@@ -63,6 +63,10 @@
}
],
"flavor_id": "asia",
"log_delivery":
{
"enabled": false
},
"status": "deployed",
"errors" : [],
"links": [
@@ -115,6 +119,10 @@
"restrictions": [
],
"flavor_id": "europe",
"log_delivery":
{
"enabled": false
},
"status": "deployed",
"links": [
{
@@ -59,6 +59,10 @@
}
],
"flavor_id": "asia",
"log_delivery":
{
"enabled": false
},
"status": "deployed",
"errors" : [],
"links": [
@@ -111,6 +115,10 @@
"restrictions": [
],
"flavor_id": "europe",
"log_delivery":
{
"enabled": false
},
"status": "deployed",
"links": [
{

0 comments on commit 18e50b6

Please sign in to comment.