Skip to content
Permalink
Browse files
Promoted jclouds-chef/enterprise to providers/chef
  • Loading branch information
nacx committed Oct 10, 2014
2 parents aa17a4f + 3123f8d commit 8a2de9a5c7c0a63d51b473cbdaec997f92bc397d
Show file tree
Hide file tree
Showing 19 changed files with 1,502 additions and 0 deletions.
@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.jclouds.chef</groupId>
<artifactId>chef-project</artifactId>
<version>2.0.0-SNAPSHOT</version>
<relativePath>../project/pom.xml</relativePath>
</parent>
<groupId>org.apache.jclouds.provider</groupId>
<artifactId>enterprisechef</artifactId>
<name>Apache jclouds Chef :: Enterprise</name>
<description>jclouds components to access Enterprise Chef</description>

<properties>
<test.enterprisechef.org>YOUR_ORG</test.enterprisechef.org>
<test.enterprisechef.endpoint>https://api.opscode.com/organizations/${test.enterprisechef.org}</test.enterprisechef.endpoint>
<test.enterprisechef.api-version />
<test.enterprisechef.build-version />
<test.enterprisechef.identity>YOUR_USER</test.enterprisechef.identity>
<test.enterprisechef.credential>${user.home}/.chef/${test.enterprisechef.org}/${test.enterprisechef.identity}.pem</test.enterprisechef.credential>
<jclouds.osgi.export>org.jclouds.enterprisechef*;version="${project.version}"</jclouds.osgi.export>
<jclouds.osgi.import>org.jclouds*;version="${jclouds.version}",*</jclouds.osgi.import>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>chef</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>chef</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jclouds</groupId>
<artifactId>jclouds-core</artifactId>
<version>${jclouds.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jclouds.driver</groupId>
<artifactId>jclouds-slf4j</artifactId>
<version>${jclouds.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.9</version>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
<profile>
<id>live</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>integration</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<systemPropertyVariables>
<test.enterprisechef.org>${test.enterprisechef.org}</test.enterprisechef.org>
<test.enterprisechef.endpoint>${test.enterprisechef.endpoint}</test.enterprisechef.endpoint>
<test.enterprisechef.api-version>${test.enterprisechef.api-version}</test.enterprisechef.api-version>
<test.enterprisechef.build-version>${test.enterprisechef.build-version}</test.enterprisechef.build-version>
<test.enterprisechef.identity>${test.enterprisechef.identity}</test.enterprisechef.identity>
<test.enterprisechef.credential>${test.enterprisechef.credential}</test.enterprisechef.credential>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
@@ -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.enterprisechef;

import java.util.Set;

import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;

import org.jclouds.Constants;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.chef.ChefApi;
import org.jclouds.chef.filters.SignedHeaderAuth;
import org.jclouds.chef.functions.ParseKeySetFromJson;
import org.jclouds.enterprisechef.binders.BindGroupToUpdateRequestJsonPayload;
import org.jclouds.enterprisechef.binders.GroupName;
import org.jclouds.enterprisechef.domain.Group;
import org.jclouds.enterprisechef.domain.User;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.Headers;
import org.jclouds.rest.annotations.ParamParser;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.WrapWith;

/**
* Provides synchronous access to the Enterprise Chef Api.
*/
@RequestFilters(SignedHeaderAuth.class)
@Consumes(MediaType.APPLICATION_JSON)
@Headers(keys = "X-Chef-Version", values = "{" + Constants.PROPERTY_API_VERSION + "}")
public interface EnterpriseChefApi extends ChefApi
{
/**
* Retrieves an existing user.
*
* @param name The name of the user to get.
* @return The details of the user or <code>null</code> if not found.
*/
@Named("user:get")
@GET
@Path("/users/{name}")
@Fallback(NullOnNotFoundOr404.class)
User getUser(@PathParam("name") String name);

/**
* List all existing groups.
*
* @return The list of groups.
*/
@Named("group:list")
@GET
@Path("/groups")
@ResponseParser(ParseKeySetFromJson.class)
Set<String> listGroups();

/**
* Retrieves an existing group.
*
* @param name The name of the group to get.
* @return The details of the group or <code>null</code> if not found.
*/
@Named("group:get")
@GET
@Path("/groups/{name}")
@Fallback(NullOnNotFoundOr404.class)
Group getGroup(@PathParam("name") String name);

/**
* Creates a new group.
*
* @param name The name of the group to create.
*/
@Named("group:create")
@POST
@Path("/groups")
void createGroup(@WrapWith("groupname") String name);

/**
* Updates a group.
* <p>
* This method can be used to add actors (clients, groups) to the group.
*
* @param group The group with the updated information.
*/
@Named("group:update")
@PUT
@Path("/groups/{name}")
void updateGroup(
@PathParam("name") @ParamParser(GroupName.class) @BinderParam(BindGroupToUpdateRequestJsonPayload.class) Group group);

/**
* Deletes a group.
*
* @param name The name of the group to delete.
*/
@Named("group:delete")
@DELETE
@Path("/groups/{name}")
void deleteGroup(@PathParam("name") String name);

}
@@ -0,0 +1,82 @@
/*
* 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.enterprisechef;

import java.net.URI;
import java.util.Properties;

import org.jclouds.chef.ChefApiMetadata;
import org.jclouds.chef.ChefContext;
import org.jclouds.chef.config.ChefBootstrapModule;
import org.jclouds.chef.config.ChefParserModule;
import org.jclouds.enterprisechef.config.EnterpriseChefHttpApiModule;
import org.jclouds.ohai.config.JMXOhaiModule;
import org.jclouds.rest.internal.BaseHttpApiMetadata;

import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;

/**
* Implementation of {@link ApiMetadata} for the Enterprise Chef api.
*/
public class EnterpriseChefApiMetadata extends BaseHttpApiMetadata<EnterpriseChefApi> {

@Override
public Builder toBuilder() {
return new Builder().fromApiMetadata(this);
}

public EnterpriseChefApiMetadata() {
this(new Builder());
}

protected EnterpriseChefApiMetadata(Builder builder) {
super(builder);
}

public static Properties defaultProperties() {
return ChefApiMetadata.defaultProperties();
}

public static class Builder extends BaseHttpApiMetadata.Builder<EnterpriseChefApi, Builder> {

protected Builder() {
id("enterprisechef")
.name("Enterprise Chef Api")
.identityName("User")
.credentialName("Certificate")
.version(ChefApiMetadata.DEFAULT_API_VERSION)
.documentation(URI.create("http://www.opscode.com/support"))
.defaultEndpoint("https://api.opscode.com")
.view(ChefContext.class)
.defaultProperties(EnterpriseChefApiMetadata.defaultProperties())
.defaultModules(
ImmutableSet.<Class<? extends Module>> of(EnterpriseChefHttpApiModule.class,
ChefParserModule.class, ChefBootstrapModule.class, JMXOhaiModule.class));
}

@Override
public EnterpriseChefApiMetadata build() {
return new EnterpriseChefApiMetadata(this);
}

@Override
protected Builder self() {
return this;
}
}
}

0 comments on commit 8a2de9a

Please sign in to comment.