Interface ChefApi
-
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Subinterfaces:
OrganizationApi
@Consumes("application/json") public interface ChefApi extends Closeable
Provides synchronous access to Chef.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ChefService
chefService()
Provides access to high level Chef features.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.com.google.common.base.Optional<OrganizationApi>
organizationApi()
Provides access to the organization, user and group management endpoints.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, Payload content)
Uploads the given content to the sandbox at the given URI.
-
-
-
Method Detail
-
chefService
@Provides ChefService chefService()
Provides access to high level Chef features.
-
organizationApi
com.google.common.base.Optional<OrganizationApi> organizationApi()
Provides access to the organization, user and group management endpoints.
-
listClients
@Named("client:list") @GET @Path("/clients") Set<String> listClients()
Lists the names of the existing clients.- Returns:
- The names of the existing clients.
-
getClient
@Named("client:get") @GET @Path("/clients/{clientname}") Client getClient(@PathParam("clientname") String clientName)
Gets the details of existing client.- Parameters:
clientName
- The name of the client to get.- Returns:
- The details of the given client.
-
createClient
@Named("client:create") @POST @Path("/clients") Client createClient(String clientName)
Creates a new client.- Parameters:
clientName
- The name of the new client- Returns:
- The client with the generated private key. This key should be stored so client can be properly authenticated .
-
createClient
@Named("client:create") @POST @Path("/clients") Client createClient(String clientName, CreateClientOptions options)
Creates a new client with custom options.- Parameters:
clientName
- The name of the new clientoptions
- 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 .
-
generateKeyForClient
@Named("client:generatekey") @PUT @Path("/clients/{clientname}") Client generateKeyForClient(@PathParam("clientname") String clientName)
Generates a new key-pair for this client, and return the new private key in the response body.- Parameters:
clientName
- The name of the client.- Returns:
- The details of the client with the new private key.
-
deleteClient
@Named("client:delete") @DELETE @Path("/clients/{clientname}") Client deleteClient(@PathParam("clientname") String clientName)
Deletes the given client.- Parameters:
clientName
- The name of the client to delete.- Returns:
- The deleted client.
-
listCookbooks
@Named("cookbook:list") @GET @Path("/cookbooks") Set<String> listCookbooks()
Lists the names of the existing cookbooks.- Returns:
- The names of the exsisting cookbooks.
-
listCookbooksInEnvironment
@Named("cookbook:list") @GET @Path("/environments/{environmentname}/cookbooks") Set<CookbookDefinition> listCookbooksInEnvironment(@PathParam("environmentname") String environmentName)
Lists the cookbooks that are available in the given environment.- Parameters:
environmentName
- The name of the environment to get the cookbooks from.- Returns:
- The definitions of the cookbooks (name, URL and versions) available in the given environment.
-
listCookbooksInEnvironment
@Named("cookbook:list") @GET @Path("/environments/{environmentname}/cookbooks?num_versions={numversions}") Set<CookbookDefinition> listCookbooksInEnvironment(@PathParam("environmentname") String environmentName, @PathParam("numversions") String numVersions)
Lists the cookbooks that are available in the given environment, limiting the number of versions returned for each cookbook.- Parameters:
environmentName
- The name of the environment to get the cookbooks from.numVersions
- The number of cookbook versions to include in the response, where n is the number of cookbook versions.- Returns:
- The definitions of the cookbooks (name, URL and versions) available in the given environment.
-
listVersionsOfCookbook
@Named("cookbook:versions") @GET @Path("/cookbooks/{cookbookname}") Set<String> listVersionsOfCookbook(@PathParam("cookbookname") String cookbookName)
Lists the available versions of the given cookbook.- Parameters:
cookbookName
- The name of the cookbook.- Returns:
- The available versions of the given cookbook.
-
getCookbook
@Named("cookbook:get") @GET @Path("/cookbooks/{cookbookname}/{version}") CookbookVersion getCookbook(@PathParam("cookbookname") String cookbookName, @PathParam("version") String version)
Gets the details of the given cookbook, with the links to each resource such as recipe files, attributes, etc.- Parameters:
cookbookName
- The name of the cookbook.version
- The version of the cookbook to get.- Returns:
- The details of the given cookbook.
-
getCookbookInEnvironment
@Named("environment:cookbook") @GET @Path("/environments/{environmentname}/cookbooks/{cookbookname}") CookbookDefinition getCookbookInEnvironment(@PathParam("environmentname") String environmentName, @PathParam("cookbookname") String cookbookName)
Gets the definition of the cookbook in the given environment.- Parameters:
environmentName
- The name of the environment.cookbookName
- The name of the cookbook.- Returns:
- The definition of the cookbook (URL and versions) of the cookbook in the given environment.
-
getCookbookInEnvironment
@Named("environment:cookbook") @GET @Path("/environments/{environmentname}/cookbooks/{cookbookname}?num_versions={numversions}") CookbookDefinition getCookbookInEnvironment(@PathParam("environmentname") String environmentName, @PathParam("cookbookname") String cookbookName, @PathParam("numversions") String numVersions)
Gets the definition of the cookbook in the given environment.- Parameters:
environmentName
- The name of the environment.cookbookName
- The name of the cookbook.numVersions
- The number of cookbook versions to include in the response, where n is the number of cookbook versions.- Returns:
- The definition of the cookbook (URL and versions) of the cookbook in the given environment.
-
listRecipesInEnvironment
@Named("environment:recipelist") @GET @Path("/environments/{environmentname}/recipes") Set<String> listRecipesInEnvironment(@PathParam("environmentname") String environmentName)
Lists the names of the recipes in the given environment.- Parameters:
environmentName
- The name of the environment.- Returns:
- The names of the recipes in the given environment.
-
updateCookbook
@Named("cookbook:update") @PUT @Path("/cookbooks/{cookbookname}/{version}") CookbookVersion updateCookbook(@PathParam("cookbookname") String cookbookName, @PathParam("version") String version, CookbookVersion cookbook)
Creates or updates the given cookbook.- 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.
-
deleteCookbook
@Named("cookbook:delete") @DELETE @Path("/cookbooks/{cookbookname}/{version}") CookbookVersion deleteCookbook(@PathParam("cookbookname") String cookbookName, @PathParam("version") String version)
Deletes the given cookbook.- Parameters:
cookbookName
- The name of the cookbook to delete.version
- The version of the cookbook to delete.- Returns:
- The details of the deleted cookbook.
-
listDatabags
@Named("databag:list") @GET @Path("/data") Set<String> listDatabags()
Lists the names of the existing data bags.- Returns:
- The names of the existing data bags.
-
createDatabag
@Named("databag:create") @POST @Path("/data") void createDatabag(String databagName)
Creates a new data bag.- Parameters:
databagName
- The name for the new data bag.
-
deleteDatabag
@Named("databag:delete") @DELETE @Path("/data/{name}") void deleteDatabag(@PathParam("name") String databagName)
Deletes a data bag, including its items.- Parameters:
databagName
- The name of the data bag to delete.
-
listDatabagItems
@Named("databag:listitems") @GET @Path("/data/{name}") Set<String> listDatabagItems(@PathParam("name") String databagName)
Lists the names of the items in a data bag.- Parameters:
databagName
- The name of the data bag.- Returns:
- The names of the items in the given data bag.
-
getDatabagItem
@Named("databag:getitem") @GET @Path("/data/{databagName}/{databagItemId}") DatabagItem getDatabagItem(@PathParam("databagName") String databagName, @PathParam("databagItemId") String databagItemId)
Gets an item in a data bag.- 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.
-
createDatabagItem
@Named("databag:createitem") @POST @Path("/data/{databagName}") DatabagItem createDatabagItem(@PathParam("databagName") String databagName, DatabagItem databagItem)
Adds an item in a data bag.- Parameters:
databagName
- The name of the data bag.databagItem
- item to add to the data bag.- Returns:
- The item just added to the data bag.
-
updateDatabagItem
@Named("databag:updateitem") @PUT @Path("/data/{databagName}/{databagItemId}") DatabagItem updateDatabagItem(@PathParam("databagName") String databagName, @PathParam("databagItemId") DatabagItem item)
Updates an item in a data bag.- 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.
-
deleteDatabagItem
@Named("databag:deleteitem") @DELETE @Path("/data/{databagName}/{databagItemId}") DatabagItem deleteDatabagItem(@PathParam("databagName") String databagName, @PathParam("databagItemId") String databagItemId)
Deletes an item from a data bag.- Parameters:
databagName
- The name of the data bag.databagItemId
- The identifier of the item to delete.- Returns:
- The item deleted from the data bag.
-
listEnvironments
@Named("environment:list") @GET @Path("/environments") Set<String> listEnvironments()
Lists the names of the existing environments.- Returns:
- The names of the existing environments.
-
getEnvironment
@Named("environment:get") @GET @Path("/environments/{environmentname}") Environment getEnvironment(@PathParam("environmentname") String environmentName)
Gets the details of an existing environment.- Parameters:
environmentName
- The name of the environment to get.- Returns:
- The details of the given environment.
-
createEnvironment
@Named("environment:create") @POST @Path("/environments") void createEnvironment(Environment environment)
Creates a new environment.- Parameters:
environment
- The environment to create.
-
updateEnvironment
@Named("environment:update") @PUT @Path("/environments/{environmentname}") Environment updateEnvironment(@PathParam("environmentname") Environment environment)
Updates the given environment.- Parameters:
environment
- The new details for the environment.- Returns:
- The details of the updated environment.
-
deleteEnvironment
@Named("environment:delete") @DELETE @Path("/environments/{environmentname}") Environment deleteEnvironment(@PathParam("environmentname") String environmentName)
Deletes the given environment.- Parameters:
environmentName
- The name of the environment to delete.- Returns:
- The details of the deleted environment.
-
listNodes
@Named("node:list") @GET @Path("/nodes") Set<String> listNodes()
Lists the names of the existing nodes.- Returns:
- The names of the existing nodes.
-
listNodesInEnvironment
@Named("environment:nodelist") @GET @Path("/environments/{environmentname}/nodes") Set<String> listNodesInEnvironment(@PathParam("environmentname") String environmentName)
Lists the names of the nodes in the given environment.- Parameters:
environmentName
- The name of the environment.- Returns:
- The names of the existing nodes in the given environment.
-
getNode
@Named("node:get") @GET @Path("/nodes/{nodename}") Node getNode(@PathParam("nodename") String nodeName)
Gets the details of the given node.- Parameters:
nodeName
- The name of the node to get.- Returns:
- The details of the given node.
-
createNode
@Named("node:create") @POST @Path("/nodes") void createNode(Node node)
Creates a new node.- Parameters:
node
- The details of the node to create.
-
updateNode
@Named("node:update") @PUT @Path("/nodes/{nodename}") Node updateNode(@PathParam("nodename") Node node)
Updates an existing node.- Parameters:
node
- The new details for the node.- Returns:
- The details of the updated node.
-
deleteNode
@Named("node:delete") @DELETE @Path("/nodes/{nodename}") Node deleteNode(@PathParam("nodename") String nodeName)
Deletes the given node.- Parameters:
nodeName
- The name of the node to delete.- Returns:
- The details of the deleted node.
-
listRoles
@Named("role:list") @GET @Path("/roles") Set<String> listRoles()
Lists the names of the existing roles.- Returns:
- The names of the existing roles.
-
getRole
@Named("role:get") @GET @Path("/roles/{rolename}") Role getRole(@PathParam("rolename") String roleName)
Gets the details of the given role.- Parameters:
roleName
- The name of the role to get.- Returns:
- The details of the given role.
-
createRole
@Named("role:create") @POST @Path("/roles") void createRole(Role role)
Creates a new role.- Parameters:
role
- The details for the new role.
-
updateRole
@Named("role:update") @PUT @Path("/roles/{rolename}") Role updateRole(@PathParam("rolename") Role role)
Updates the given role.- Parameters:
role
- The new details for the role.- Returns:
- The details of the updated role.
-
deleteRole
@Named("role:delete") @DELETE @Path("/roles/{rolename}") Role deleteRole(@PathParam("rolename") String roleName)
Deletes the given role.- Parameters:
roleName
- The name of the role to delete.- Returns:
- The details of the deleted role.
-
createUploadSandboxForChecksums
@Named("sandbox:upload") @POST @Path("/sandboxes") UploadSandbox createUploadSandboxForChecksums(Set<List<Byte>> md5s)
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.
- Parameters:
md5s
- The raw md5 sums. UsesBytes.asList()
andBytes.toByteArray()
as necessary- Returns:
- The upload sandbox with the URLs against which to PUT files that need to be uploaded.
-
uploadContent
@Named("content:upload") @PUT @Produces("application/x-binary") void uploadContent(URI location, Payload content)
Uploads the given content to the sandbox at the given URI.The URI must be obtained, after uploading a sandbox, from the
UploadSandbox.getUri()
.- Parameters:
location
- The URI where the upload must be performed.content
- The contents to upload.
-
getResourceContents
@Named("content:get") @GET InputStream getResourceContents(Resource resource)
Gets the contents of the given resource.- Parameters:
resource
- The resource to get.- Returns:
- An input stream for the content of the requested resource.
-
commitSandbox
@Named("sandbox:commit") @PUT @Path("/sandboxes/{id}") Sandbox commitSandbox(@PathParam("id") String id, boolean isCompleted)
Confirms if the sandbox is completed or not.This method should be used after uploading contents to the sandbox.
- 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.
-
listSearchIndexes
@Named("search:indexes") @GET @Path("/search") Set<String> listSearchIndexes()
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).
- Returns:
- The names of the available search indexes.
-
searchClients
@Named("search:clients") @GET @Path("/search/client") SearchResult<? extends Client> searchClients()
Searches all clients.Note that without any request parameters this will return all of the data within the index.
- 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
@Named("search:clients") @GET @Path("/search/client") SearchResult<? extends Client> searchClients(SearchOptions options)
Searches all clients that match the given options.- 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
@Named("search:databag") @GET @Path("/search/{databagName}") SearchResult<? extends DatabagItem> searchDatabagItems(@PathParam("databagName") String databagName)
Searches all items in a data bag.Note that without any request parameters this will return all of the data within the index.
- 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
@Named("search:databag") @GET @Path("/search/{databagName}") SearchResult<? extends DatabagItem> searchDatabagItems(@PathParam("databagName") String databagName, SearchOptions options)
Searches all items in a data bag that match the given options.- 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
@Named("search:environments") @GET @Path("/search/environment") SearchResult<? extends Environment> searchEnvironments()
Searches all environments.Note that without any request parameters this will return all of the data within the index.
- 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
@Named("search:environments") @GET @Path("/search/environment") SearchResult<? extends Environment> searchEnvironments(SearchOptions options)
Searches all environments that match the given options.- 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
@Named("search:nodes") @GET @Path("/search/node") SearchResult<? extends Node> searchNodes()
Searches all nodes.Note that without any request parameters this will return all of the data within the index.
- 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
@Named("search:nodes") @GET @Path("/search/node") SearchResult<? extends Node> searchNodes(SearchOptions options)
Searches all nodes that match the given options.- 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
@Named("search:roles") @GET @Path("/search/role") SearchResult<? extends Role> searchRoles()
Searches all roles.Note that without any request parameters this will return all of the data within the index.
- 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
@Named("search:roles") @GET @Path("/search/role") SearchResult<? extends Role> searchRoles(SearchOptions options)
Searches all roles that match the given options.- 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.
-
-