org.jclouds.chef.test
Class TransientChefApi

java.lang.Object
  extended by org.jclouds.chef.test.TransientChefApi
All Implemented Interfaces:
Closeable, ChefApi

public class TransientChefApi
extends Object
implements ChefApi

In-memory chef simulator.


Method Summary
 void close()
           
 Sandbox commitSandbox(String id, boolean isCompleted)
          Confirms if the sandbox is completed or not.
 Client createClient(String clientName)
          Creates a new client.
 Client createClient(String clientName, CreateClientOptions options)
          Creates a new client with custom options.
 void createDatabag(String databagName)
          Creates a new data bag.
 DatabagItem createDatabagItem(String databagName, DatabagItem databagItem)
          Adds an item in a data bag.
 void createEnvironment(Environment environment)
          Creates a new environment.
 void createNode(Node node)
          Creates a new node.
 void createRole(Role role)
          Creates a new role.
 UploadSandbox createUploadSandboxForChecksums(Set<List<Byte>> md5s)
          Creates a new sandbox.
 Client deleteClient(String clientName)
          Deletes the given client.
 CookbookVersion deleteCookbook(String cookbookName, String version)
          Deletes the given cookbook.
 void deleteDatabag(String databagName)
          Deletes a data bag, including its items.
 DatabagItem deleteDatabagItem(String databagName, String databagItemId)
          Deletes an item from a data bag.
 Environment deleteEnvironment(String environmentName)
          Deletes the given environment.
 Node deleteNode(String nodeName)
          Deletes the given node.
 Role deleteRole(String rolename)
          Deletes the given role.
 Client generateKeyForClient(String clientName)
          Generates a new key-pair for this client, and return the new private key in the response body.
 Client getClient(String clientName)
          Gets the details of existing client.
 CookbookVersion getCookbook(String cookbookName, String version)
          Gets the details of the given cookbook, with the links to each resource such as recipe files, attributes, etc.
 CookbookDefinition getCookbookInEnvironment(String environmentName, String cookbookName)
          Gets the definition of the cookbook in the given environment.
 CookbookDefinition getCookbookInEnvironment(String environmentName, String cookbookName, String numVersions)
          Gets the definition of the cookbook in the given environment.
 DatabagItem getDatabagItem(String databagName, String databagItemId)
          Gets an item in a data bag.
 Environment getEnvironment(String environmentName)
          Gets the details of an existing environment.
 Node getNode(String nodeName)
          Gets the details of the given node.
 InputStream getResourceContents(Resource resource)
          Gets the contents of the given resource.
 Role getRole(String roleName)
          Gets the details of the given role.
 Set<String> listClients()
          Lists the names of the existing clients.
 Set<String> listCookbooks()
          Lists the names of the existing cookbooks.
 Set<CookbookDefinition> listCookbooksInEnvironment(String environmentName)
          Lists the cookbooks that are available in the given environment.
 Set<CookbookDefinition> listCookbooksInEnvironment(String environmentName, String numVersions)
          Lists the cookbooks that are available in the given environment, limiting the number of versions returned for each cookbook.
 Set<String> listDatabagItems(String databagName)
          Lists the names of the items in a data bag.
 Set<String> listDatabags()
          Lists the names of the existing data bags.
 Set<String> listEnvironments()
          Lists the names of the existing environments.
 Set<String> listNodes()
          Lists the names of the existing nodes.
 Set<String> listNodesInEnvironment(String environmentName)
          Lists the names of the nodes in the given environment.
 Set<String> listRecipesInEnvironment(String environmentName)
          Lists the names of the recipes in the given environment.
 Set<String> listRoles()
          Lists the names of the existing roles.
 Set<String> listSearchIndexes()
          Lists the names of the available search indexes.
 Set<String> listVersionsOfCookbook(String cookbookName)
          Lists the available versions of the given cookbook.
 SearchResult<? extends Client> searchClients()
          Searches all clients.
 SearchResult<? extends Client> searchClients(SearchOptions options)
          Searches all clients that match the given options.
 SearchResult<? extends DatabagItem> searchDatabagItems(String databagName)
          Searches all items in a data bag.
 SearchResult<? extends DatabagItem> searchDatabagItems(String databagName, SearchOptions options)
          Searches all items in a data bag that match the given options.
 SearchResult<? extends Environment> searchEnvironments()
          Searches all environments.
 SearchResult<? extends Environment> searchEnvironments(SearchOptions options)
          Searches all environments that match the given options.
 SearchResult<? extends Node> searchNodes()
          Searches all nodes.
 SearchResult<? extends Node> searchNodes(SearchOptions options)
          Searches all nodes that match the given options.
 SearchResult<? extends Role> searchRoles()
          Searches all roles.
 SearchResult<? extends Role> searchRoles(SearchOptions options)
          Searches all roles that match the given options.
 CookbookVersion updateCookbook(String cookbookName, String version, CookbookVersion cookbook)
          Creates or updates the given cookbook.
 DatabagItem updateDatabagItem(String databagName, DatabagItem item)
          Updates an item in a data bag.
 Environment updateEnvironment(Environment environment)
          Updates the given environment.
 Node updateNode(Node node)
          Updates an existing node.
 Role updateRole(Role role)
          Updates the given role.
 void uploadContent(URI location, org.jclouds.io.Payload content)
          Uploads the given content to the sandbox at the given URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

commitSandbox

public Sandbox commitSandbox(String id,
                             boolean isCompleted)
Description copied from interface: ChefApi
Confirms if the sandbox is completed or not.

This method should be used after uploading contents to the sandbox.

Specified by:
commitSandbox in interface ChefApi
Parameters:
id - The id of the sandbox to commit.
isCompleted - Flag to set if the sandbox is completed or not.
Returns:
The details of the sandbox.

createClient

public Client createClient(String clientName)
Description copied from interface: ChefApi
Creates a new client.

Specified by:
createClient in interface ChefApi
Returns:
The client with the generated private key. This key should be stored so client can be properly authenticated .

createClient

public Client createClient(String clientName,
                           CreateClientOptions options)
Description copied from interface: ChefApi
Creates a new client with custom options.

Specified by:
createClient in interface ChefApi
options - The options to customize the client creation.
Returns:
The client with the generated private key. This key should be stored so client can be properly authenticated .

createDatabag

public void createDatabag(String databagName)
Description copied from interface: ChefApi
Creates a new data bag.

Specified by:
createDatabag in interface ChefApi
Parameters:
databagName - The name for the new data bag.

createDatabagItem

public DatabagItem createDatabagItem(String databagName,
                                     DatabagItem databagItem)
Description copied from interface: ChefApi
Adds an item in a data bag.

Specified by:
createDatabagItem in interface ChefApi
Parameters:
databagName - The name of the data bag.

createNode

public void createNode(Node node)
Description copied from interface: ChefApi
Creates a new node.

Specified by:
createNode in interface ChefApi
Parameters:
node - The details of the node to create.

createRole

public void createRole(Role role)
Description copied from interface: ChefApi
Creates a new role.

Specified by:
createRole in interface ChefApi
Parameters:
role - The details for the new role.

deleteClient

public Client deleteClient(String clientName)
Description copied from interface: ChefApi
Deletes the given client.

Specified by:
deleteClient in interface ChefApi
Returns:
The deleted client.

deleteCookbook

public CookbookVersion deleteCookbook(String cookbookName,
                                      String version)
Description copied from interface: ChefApi
Deletes the given cookbook.

Specified by:
deleteCookbook in interface ChefApi
Parameters:
cookbookName - The name of the cookbook to delete.
version - The version of the cookbook to delete.
Returns:
The details of the deleted cookbook.

deleteDatabag

public void deleteDatabag(String databagName)
Description copied from interface: ChefApi
Deletes a data bag, including its items.

Specified by:
deleteDatabag in interface ChefApi
Parameters:
databagName - The name of the data bag to delete.

deleteDatabagItem

public DatabagItem deleteDatabagItem(String databagName,
                                     String databagItemId)
Description copied from interface: ChefApi
Deletes an item from a data bag.

Specified by:
deleteDatabagItem in interface ChefApi
Parameters:
databagName - The name of the data bag.
databagItemId - The identifier of the item to delete.
Returns:
The item deleted from the data bag.

deleteNode

public Node deleteNode(String nodeName)
Description copied from interface: ChefApi
Deletes the given node.

Specified by:
deleteNode in interface ChefApi
Returns:
The details of the deleted node.

deleteRole

public Role deleteRole(String rolename)
Description copied from interface: ChefApi
Deletes the given role.

Specified by:
deleteRole in interface ChefApi
Returns:
The details of the deleted role.

generateKeyForClient

public Client generateKeyForClient(String clientName)
Description copied from interface: ChefApi
Generates a new key-pair for this client, and return the new private key in the response body.

Specified by:
generateKeyForClient in interface ChefApi
Returns:
The details of the client with the new private key.

getClient

public Client getClient(String clientName)
Description copied from interface: ChefApi
Gets the details of existing client.

Specified by:
getClient in interface ChefApi
Returns:
The details of the given client.

getCookbook

public CookbookVersion getCookbook(String cookbookName,
                                   String version)
Description copied from interface: ChefApi
Gets the details of the given cookbook, with the links to each resource such as recipe files, attributes, etc.

Specified by:
getCookbook in interface ChefApi
Parameters:
cookbookName - The name of the cookbook.
version - The version of the cookbook to get.
Returns:
The details of the given cookbook.

getDatabagItem

public DatabagItem getDatabagItem(String databagName,
                                  String databagItemId)
Description copied from interface: ChefApi
Gets an item in a data bag.

Specified by:
getDatabagItem in interface ChefApi
Parameters:
databagName - The name of the data bag.
databagItemId - The identifier of the item to get.
Returns:
The details of the item in the given data bag.

getNode

public Node getNode(String nodeName)
Description copied from interface: ChefApi
Gets the details of the given node.

Specified by:
getNode in interface ChefApi
Returns:
The details of the given node.

getRole

public Role getRole(String roleName)
Description copied from interface: ChefApi
Gets the details of the given role.

Specified by:
getRole in interface ChefApi
Returns:
The details of the given role.

createUploadSandboxForChecksums

public UploadSandbox createUploadSandboxForChecksums(Set<List<Byte>> md5s)
Description copied from interface: ChefApi
Creates a new sandbox.

It accepts a list of checksums as input and returns the URLs against which to PUT files that need to be uploaded.

Specified by:
createUploadSandboxForChecksums in interface ChefApi
Parameters:
md5s - The raw md5 sums. Uses Bytes.asList() and Bytes.toByteArray() as necessary
Returns:
The upload sandbox with the URLs against which to PUT files that need to be uploaded.

listVersionsOfCookbook

public Set<String> listVersionsOfCookbook(String cookbookName)
Description copied from interface: ChefApi
Lists the available versions of the given cookbook.

Specified by:
listVersionsOfCookbook in interface ChefApi
Parameters:
cookbookName - The name of the cookbook.
Returns:
The available versions of the given cookbook.

listClients

public Set<String> listClients()
Description copied from interface: ChefApi
Lists the names of the existing clients.

Specified by:
listClients in interface ChefApi
Returns:
The names of the existing clients.

listCookbooks

public Set<String> listCookbooks()
Description copied from interface: ChefApi
Lists the names of the existing cookbooks.

Specified by:
listCookbooks in interface ChefApi
Returns:
The names of the exsisting cookbooks.

listDatabagItems

public Set<String> listDatabagItems(String databagName)
Description copied from interface: ChefApi
Lists the names of the items in a data bag.

Specified by:
listDatabagItems in interface ChefApi
Parameters:
databagName - The name of the data bag.
Returns:
The names of the items in the given data bag.

listDatabags

public Set<String> listDatabags()
Description copied from interface: ChefApi
Lists the names of the existing data bags.

Specified by:
listDatabags in interface ChefApi
Returns:
The names of the existing data bags.

listNodes

public Set<String> listNodes()
Description copied from interface: ChefApi
Lists the names of the existing nodes.

Specified by:
listNodes in interface ChefApi
Returns:
The names of the existing nodes.

listRoles

public Set<String> listRoles()
Description copied from interface: ChefApi
Lists the names of the existing roles.

Specified by:
listRoles in interface ChefApi
Returns:
The names of the existing roles.

listSearchIndexes

public Set<String> listSearchIndexes()
Description copied from interface: ChefApi
Lists the names of the available search indexes.

By default, the "role", "node" and "api" indexes will always be available.

Note that the search indexes may lag behind the most current data by at least 10 seconds at any given time - so if you need to write data and immediately query it, you likely need to produce an artificial delay (or simply retry until the data is available).

Specified by:
listSearchIndexes in interface ChefApi
Returns:
The names of the available search indexes.

searchClients

public SearchResult<? extends Client> searchClients()
Description copied from interface: ChefApi
Searches all clients.

Note that without any request parameters this will return all of the data within the index.

Specified by:
searchClients in interface ChefApi
Returns:
The response contains the total number of rows that matched the request, the position this result set returns (useful for paging) and the rows themselves.

searchClients

public SearchResult<? extends Client> searchClients(SearchOptions options)
Description copied from interface: ChefApi
Searches all clients that match the given options.

Specified by:
searchClients in interface ChefApi
Returns:
The response contains the total number of rows that matched the request, the position this result set returns (useful for paging) and the rows themselves.

searchDatabagItems

public SearchResult<? extends DatabagItem> searchDatabagItems(String databagName)
Description copied from interface: ChefApi
Searches all items in a data bag.

Note that without any request parameters this will return all of the data within the index.

Specified by:
searchDatabagItems in interface ChefApi
Returns:
The response contains the total number of rows that matched the request, the position this result set returns (useful for paging) and the rows themselves.

searchDatabagItems

public SearchResult<? extends DatabagItem> searchDatabagItems(String databagName,
                                                              SearchOptions options)
Description copied from interface: ChefApi
Searches all items in a data bag that match the given options.

Specified by:
searchDatabagItems in interface ChefApi
Returns:
The response contains the total number of rows that matched the request, the position this result set returns (useful for paging) and the rows themselves.

searchNodes

public SearchResult<? extends Node> searchNodes()
Description copied from interface: ChefApi
Searches all nodes.

Note that without any request parameters this will return all of the data within the index.

Specified by:
searchNodes in interface ChefApi
Returns:
The response contains the total number of rows that matched the request, the position this result set returns (useful for paging) and the rows themselves.

searchNodes

public SearchResult<? extends Node> searchNodes(SearchOptions options)
Description copied from interface: ChefApi
Searches all nodes that match the given options.

Specified by:
searchNodes in interface ChefApi
Returns:
The response contains the total number of rows that matched the request, the position this result set returns (useful for paging) and the rows themselves.

searchRoles

public SearchResult<? extends Role> searchRoles()
Description copied from interface: ChefApi
Searches all roles.

Note that without any request parameters this will return all of the data within the index.

Specified by:
searchRoles in interface ChefApi
Returns:
The response contains the total number of rows that matched the request, the position this result set returns (useful for paging) and the rows themselves.

searchRoles

public SearchResult<? extends Role> searchRoles(SearchOptions options)
Description copied from interface: ChefApi
Searches all roles that match the given options.

Specified by:
searchRoles in interface ChefApi
Returns:
The response contains the total number of rows that matched the request, the position this result set returns (useful for paging) and the rows themselves.

updateCookbook

public CookbookVersion updateCookbook(String cookbookName,
                                      String version,
                                      CookbookVersion cookbook)
Description copied from interface: ChefApi
Creates or updates the given cookbook.

Specified by:
updateCookbook in interface ChefApi
Parameters:
cookbookName - The name of the cookbook to create or update.
version - The version of the cookbook to create or update.
cookbook - The contents of the cookbook to create or update.
Returns:
The details of the created or updated cookbook.

updateDatabagItem

public DatabagItem updateDatabagItem(String databagName,
                                     DatabagItem item)
Description copied from interface: ChefApi
Updates an item in a data bag.

Specified by:
updateDatabagItem in interface ChefApi
Parameters:
databagName - The name of the data bag.
item - The new contents for the item in the data bag.
Returns:
The details for the updated item in the data bag.

updateNode

public Node updateNode(Node node)
Description copied from interface: ChefApi
Updates an existing node.

Specified by:
updateNode in interface ChefApi
Parameters:
node - The new details for the node.
Returns:
The details of the updated node.

updateRole

public Role updateRole(Role role)
Description copied from interface: ChefApi
Updates the given role.

Specified by:
updateRole in interface ChefApi
Parameters:
role - The new details for the role.
Returns:
The details of the updated role.

uploadContent

public void uploadContent(URI location,
                          org.jclouds.io.Payload content)
Description copied from interface: ChefApi
Uploads the given content to the sandbox at the given URI.

The URI must be obtained, after uploading a sandbox, from the UploadSandbox.getUri().

Specified by:
uploadContent in interface ChefApi
Parameters:
location - The URI where the upload must be performed.
content - The contents to upload.

getResourceContents

public InputStream getResourceContents(Resource resource)
Description copied from interface: ChefApi
Gets the contents of the given resource.

Specified by:
getResourceContents in interface ChefApi
Parameters:
resource - The resource to get.
Returns:
An input stream for the content of the requested resource.

listEnvironments

public Set<String> listEnvironments()
Description copied from interface: ChefApi
Lists the names of the existing environments.

Specified by:
listEnvironments in interface ChefApi
Returns:
The names of the existing environments.

createEnvironment

public void createEnvironment(Environment environment)
Description copied from interface: ChefApi
Creates a new environment.

Specified by:
createEnvironment in interface ChefApi
Parameters:
environment - The environment to create.

deleteEnvironment

public Environment deleteEnvironment(String environmentName)
Description copied from interface: ChefApi
Deletes the given environment.

Specified by:
deleteEnvironment in interface ChefApi
Returns:
The details of the deleted environment.

getEnvironment

public Environment getEnvironment(String environmentName)
Description copied from interface: ChefApi
Gets the details of an existing environment.

Specified by:
getEnvironment in interface ChefApi
Returns:
The details of the given environment.

updateEnvironment

public Environment updateEnvironment(Environment environment)
Description copied from interface: ChefApi
Updates the given environment.

Specified by:
updateEnvironment in interface ChefApi
Parameters:
environment - The new details for the environment.
Returns:
The details of the updated environment.

listCookbooksInEnvironment

public Set<CookbookDefinition> listCookbooksInEnvironment(String environmentName)
Description copied from interface: ChefApi
Lists the cookbooks that are available in the given environment.

Specified by:
listCookbooksInEnvironment in interface ChefApi
Returns:
The definitions of the cookbooks (name, URL and versions) available in the given environment.

listCookbooksInEnvironment

public Set<CookbookDefinition> listCookbooksInEnvironment(String environmentName,
                                                          String numVersions)
Description copied from interface: ChefApi
Lists the cookbooks that are available in the given environment, limiting the number of versions returned for each cookbook.

Specified by:
listCookbooksInEnvironment in interface ChefApi
Returns:
The definitions of the cookbooks (name, URL and versions) available in the given environment.

getCookbookInEnvironment

public CookbookDefinition getCookbookInEnvironment(String environmentName,
                                                   String cookbookName)
Description copied from interface: ChefApi
Gets the definition of the cookbook in the given environment.

Specified by:
getCookbookInEnvironment in interface ChefApi
Returns:
The definition of the cookbook (URL and versions) of the cookbook in the given environment.

getCookbookInEnvironment

public CookbookDefinition getCookbookInEnvironment(String environmentName,
                                                   String cookbookName,
                                                   String numVersions)
Description copied from interface: ChefApi
Gets the definition of the cookbook in the given environment.

Specified by:
getCookbookInEnvironment in interface ChefApi
Returns:
The definition of the cookbook (URL and versions) of the cookbook in the given environment.

searchEnvironments

public SearchResult<? extends Environment> searchEnvironments()
Description copied from interface: ChefApi
Searches all environments.

Note that without any request parameters this will return all of the data within the index.

Specified by:
searchEnvironments in interface ChefApi
Returns:
The response contains the total number of rows that matched the request, the position this result set returns (useful for paging) and the rows themselves.

searchEnvironments

public SearchResult<? extends Environment> searchEnvironments(SearchOptions options)
Description copied from interface: ChefApi
Searches all environments that match the given options.

Specified by:
searchEnvironments in interface ChefApi
Returns:
The response contains the total number of rows that matched the request, the position this result set returns (useful for paging) and the rows themselves.

listRecipesInEnvironment

public Set<String> listRecipesInEnvironment(String environmentName)
Description copied from interface: ChefApi
Lists the names of the recipes in the given environment.

Specified by:
listRecipesInEnvironment in interface ChefApi
Returns:
The names of the recipes in the given environment.

listNodesInEnvironment

public Set<String> listNodesInEnvironment(String environmentName)
Description copied from interface: ChefApi
Lists the names of the nodes in the given environment.

Specified by:
listNodesInEnvironment in interface ChefApi
Returns:
The names of the existing nodes in the given environment.

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Throws:
IOException


Copyright © 2009-2014 The Apache Software Foundation. All Rights Reserved.