Giter Club home page Giter Club logo

chef-cookbooks-client-java's Introduction

Chef Cookbooks Client (for Java)

This is a Java client that uses the REST API provided by the Chef cookbooks site described here:

http://docs.opscode.com/api_cookbooks_site.html

API

The API is defined as a set of interfaces. Agnostic of the implementation chosen, you can do the following:

Get a Cookbook's Information

The following examples show how to retrieve a cookbook's information. If the cookbook is found, then a Cookbook object is returned; otherwise, null is returned.

import com.github.jrh3k5.chef.client.CookbookClient;
import com.github.jrh3k5.chef.client.Cookbook;

[...]

final CookbookClient client = ...;
final Cookbook foundCookbook = client.getCookbook("name_of_cookbook");
assert foundCookbook != null;

final Cookbook missingCookbook = client.getCookbook("cookbook_not_found");
assert missingCookbook == null;

// When we're done, make sure we close the client to clean up any resources!
client.close();

Get Cookbook

Once you've retrieved a cookbook's information, you can actually download it through Cookbook.Version interface.

import com.github.jrh3k5.chef.client.Cookbook.Version;
import com.github.jrh3k5.chef.client.Cookbook;
import java.net.URL;

final Cookbook cookbook = ...;
// Get the latest version
final Cookbook.Version latestVersion = cookbook.getLatestVersion();
final URL latestTarballLocation = latestVersion.getFileLocation();

final Cookbook.Version v1Version = cookbook.getVersion("1.0.0");
assert v1Version != null;
final URL v1TarballLocation = v1Version.getFileLocation():

final Cookbook.Version notFoundVersion = cookbook.getVersion("not.found");
assert notFoundVersion == null;

// Do whatever you want now that you have the tarball location!

Jersey Implementation

The Jersey implementation uses Glassfish's Jersey 2.x implementation to interact with the REST API. The client can be created through the following means:

import com.github.jrh3k5.chef.client.jersey.JerseyCookbookClient;
import com.github.jrh3k5.chef.client.CookbookClient;

final CookbookClient defaultUrlClient = new JerseyCookbookClient();
final CookbookClient specifiedUrlClient = new JerseyCookbookClient("http://my.personal.chef.server/");

chef-cookbooks-client-java's People

Contributors

jrh3k5 avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.