PastryClient¶
Supported Operations¶
Initialize Initialize the client with the chef server info Load Config Load server config from a yaml file Get Url Get the server and endpoint for the request Call Call a resource on the chef server
API Reference¶
-
class
pastry.pastry_client.
PastryClient
[source]¶ PastryClient is used by the resources to send requests to chef. You can use the PastryClient to initialize the config to use for the chef server.
-
classmethod
call
(endpoint, method='GET', data=None)[source]¶ Send an http request to the chef server api
Parameters: - endpoint (string) – The endpoint for the resource being called
- method (string) – The HTTP method
- data (hash) – The body of the request
Returns: The json response from the server
Return type: hash
-
classmethod
get_url
(endpoint)[source]¶ Fetches the server and updates the endpoint with the organization
Parameters: endpoint (string) – The endpoint being called on the chef server Returns: The server url and updated endpoint Return type: tuple
-
classmethod
initialize
(server, organization, client, keypath, verify)[source]¶ Initializes the server connection info
Parameters: - server (string) – The url for the chef server e.g. https://my.chef.server
- organization (string) – The name of the cheff org to use
- client (string) – The client/username to use
- keypath (string) – The path to the pem for the client/user
- verify (boolean) – Verify the ssl cert on requests
-
classmethod
load_config
(config_path=None)[source]¶ Load server config from a yaml file
If no config_path is specified it will try to load config from
$HOME/.chef/pastry.yaml
Note
This method is automatically called if an http requests is made and the client has not yet been initialised
Parameters: config_path (string) – The path to the config file on the local filesystem
-
classmethod