Skip to content
Permalink
Browse files
JCLOUDS-806: Support OpenStack Poppy Service API
  • Loading branch information
Jeremy Daggett authored and zack-shoylev committed Mar 11, 2015
1 parent eeceb98 commit 3b6094560318aaf940fadbc4255239d23369af23
Showing 38 changed files with 2,806 additions and 21 deletions.
@@ -90,8 +90,19 @@
<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.jclouds.driver</groupId>
<artifactId>jclouds-okhttp</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.github.fge</groupId>
<artifactId>json-patch</artifactId>
<version>1.9</version>
</dependency>
</dependencies>

<profiles>
@@ -25,9 +25,10 @@
import javax.ws.rs.core.MediaType;

import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
import org.jclouds.openstack.poppy.v1.PoppyFallbacks.FalseOn500or503;
import org.jclouds.openstack.poppy.v1.config.CDN;
import org.jclouds.openstack.poppy.v1.fallbacks.PoppyFallbacks.FalseOn500or503;
import org.jclouds.openstack.poppy.v1.features.FlavorApi;
import org.jclouds.openstack.poppy.v1.features.ServiceApi;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.Endpoint;
import org.jclouds.rest.annotations.Fallback;
@@ -62,4 +63,9 @@ public interface PoppyApi extends Closeable {
@Delegate
FlavorApi getFlavorApi();

/**
* Provides access to Service features.
*/
@Delegate
ServiceApi getServiceApi();
}
@@ -23,6 +23,7 @@
import java.util.Properties;

import org.jclouds.apis.ApiMetadata;
import org.jclouds.http.okhttp.config.OkHttpCommandExecutorServiceModule;
import org.jclouds.openstack.keystone.v2_0.config.AuthenticationApiModule;
import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule;
@@ -75,6 +76,7 @@ protected Builder() {
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
.add(AuthenticationApiModule.class)
.add(KeystoneAuthenticationModule.class)
.add(OkHttpCommandExecutorServiceModule.class)
.add(ProviderModule.class)
.add(PoppyHttpApiModule.class).build());
}
@@ -0,0 +1,124 @@
/*
* 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 java.util.List;

import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;

import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;

/**
* Representation of an OpenStack Poppy Caching Rule.
*/
@AutoValue
public abstract class Caching {
/**
* @see Builder#name(String)
*/
public abstract String getName();

/**
* @see Builder#ttl(int)
*/
public abstract int getTtl();

/**
* @see Builder#rules(List)
*/
@Nullable public abstract List<CachingRule> getRules();

@SerializedNames({ "name", "ttl", "rules" })
static Caching create(String name, int ttl, List<CachingRule> rules) {
return builder().name(name).ttl(ttl).rules(rules).build();
}

public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return builder()
.name(getName())
.ttl(getTtl())
.rules(getRules());
}

public static final class Builder {
private String name;
private Integer ttl;
private List<CachingRule> rules;
Builder() {
}
Builder(Caching source) {
name(source.getName());
ttl(source.getTtl());
rules(source.getRules());
}

/**
* Required.
* @param name Specifies the name of this caching rule. The minimum length for name is 1. The maximum length is
* 256. Note: default is a reserved name used for the default TTL setting.
* @return The Caching builder.
*/
public Builder name(String name) {
this.name = name;
return this;
}

/**
* Required.
* @param ttl Specifies the TTL to apply. The value of ttl must be greater than or equal to 0.
* @return The Caching builder.
*/
public Builder ttl(int ttl) {
this.ttl = ttl;
return this;
}

/**
* Optional.
* @param rules Specifies a collection of rules that determine if this TTL should be applied to an asset.
* Note: This is a required property if more than one entry is present for caching.
* @return The Caching builder.
*/
public Builder rules(List<CachingRule> rules) {
this.rules = rules;
return this;
}

public Caching build() {
String missing = "";
if (name == null) {
missing += " name";
}
if (ttl == null) {
missing += " ttl";
}
if (!missing.isEmpty()) {
throw new IllegalStateException("Missing required properties:" + missing);
}
Caching result = new AutoValue_Caching(
this.name,
this.ttl,
rules != null ? ImmutableList.copyOf(this.rules) : null);
return result;
}
}
}
@@ -0,0 +1,99 @@
/*
* 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;

@AutoValue
public abstract class CachingRule {
/**
* @see Builder#name(String)
*/
public abstract String getName();

/**
* @see Builder#requestURL(String)
*/
public abstract String getRequestURL();

@SerializedNames({ "name", "request_url" })
private static CachingRule create(String name, String requestUrl) {
return builder().name(name).requestURL(requestUrl).build();
}

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

public Builder toBuilder() {
return builder()
.name(getName())
.requestURL(getRequestURL());
}

public static final class Builder {
private String name;
private String requestURL;
Builder() {
}
Builder(CachingRule source) {
name(source.getName());
requestURL(source.getRequestURL());
}

/**
* Required.
* @param name Specifies the name of this rule. The minimum length for name is 1. The maximum length is 256.
* @return The CachingRule builder.
*/
public Builder name(String name) {
this.name = name;
return this;
}

/**
* Required.
* @param requestURL Specifies the request URL that this rule should match for this TTL to be used.
* The minimum length for request_url is 1. The maximum length is 1024. (Regex is supported.)
* @return The CachingRule builder.
*/
public Builder requestURL(String requestURL) {
this.requestURL = requestURL;
return this;
}

public CachingRule build() {
String missing = "";
if (name == null) {
missing += " name";
}
if (requestURL == null) {
missing += " requestURL";
}
if (!missing.isEmpty()) {
throw new IllegalStateException("Missing required properties:" + missing);
}
CachingRule result = new AutoValue_CachingRule(
this.name,
this.requestURL);
return result;
}
}
}

0 comments on commit 3b60945

Please sign in to comment.