cheflib.entities package¶
Submodules¶
cheflib.entities.base module¶
Chef base entity.
- class cheflib.entities.base.Entity(_chef: 'Chef', _name: str, _url: str, _data: Dict | None = None)[source]¶
Bases:
object- property data¶
Return cached data or retrieve it from server.
- classmethod from_data(chef_instance, data: Dict)[source]¶
Function to intantiate entity from given data.
- property name¶
Return name of entity.
cheflib.entities.client module¶
Chef client entity.
Source: https://docs.chef.io/server/api_chef_server/
GET: /organizations/NAME/clients This method has no request body. Response: {
“org1-validator” : “https://chef.example/orgaizations/org1/clients/org1-validator”, “client1” : “https://chef.example/orgaizations/org1/clients/client1”
}
POST: /organizations/NAME/clients Body: {
“name”: “name_of_API_client”, “clientname”: “name_of_API_client”, “validator”: true, “create_key”: true
}
DELETE: /organizations/NAME/clients/NAME This method has no request body. The response has no body.
GET: /organizations/NAME/clients/NAME This method has no request body. Response: {
“name”: “user1”, “clientname”: “user1”, “orgname”: “test”, “json_class”: “Chef::ApiClient”, “chef_type”: “client”, “validator”: “false”
}
PUT: /organizations/NAME/clients/NAME with a request body similar to: {
“name”: “monkeypants”, “validator”: false
} The response is similar to: {
“name”: “monkeypants”, “clientname”: “monkeypants”, “validator”: true, “json_class”:”Chef::ApiClient”, “chef_type”:”client”
}
cheflib.entities.client_key module¶
Chef client key entity.
Source: https://docs.chef.io/server/api_chef_server/
GET: /organizations/NAME/clients/NAME/keys This method has no request body. Response: {
“org1-validator” : “https://chef.example/orgaizations/org1/clients/org1-validator”, “client1” : “https://chef.example/orgaizations/org1/clients/client1”
}
POST: /organizations/NAME/clients Body: {
“name”: “name_of_API_client”, “clientname”: “name_of_API_client”, “validator”: true, “create_key”: true
}
DELETE: /organizations/NAME/clients/NAME This method has no request body. The response has no body.
GET: /organizations/NAME/clients/NAME This method has no request body. Response: {
“name”: “user1”, “clientname”: “user1”, “orgname”: “test”, “json_class”: “Chef::ApiClient”, “chef_type”: “client”, “validator”: “false”
}
PUT: /organizations/NAME/clients/NAME with a request body similar to: {
“name”: “monkeypants”, “validator”: false
} The response is similar to: {
“name”: “monkeypants”, “clientname”: “monkeypants”, “validator”: true, “json_class”:”Chef::ApiClient”, “chef_type”:”client”
}
- class cheflib.entities.client_key.ClientKey(_chef: Chef, _name: str, _url: str, _data: Dict | None = None)[source]¶
Bases:
EntityClient key entity.
- property expiration_date¶
Return the expiration date of the key or None.
- property expired¶
Returns true if key is expired.
- property public_key¶
Return public key or None.
cheflib.entities.cookbook module¶
Chef cookbook entity.
Source: https://docs.chef.io/server/api_chef_server/
GET /organizations/NAME/cookbooks
- {
- “apache2”: {
“url”: “https://localhost/cookbooks/apache2”, “versions”: [
- {“url”: “https://localhost/cookbooks/apache2/5.1.0”,
“version”: “5.1.0”},
- {“url”: “https://localhost/cookbooks/apache2/4.2.0”,
“version”: “4.2.0”}
]
}, “nginx”: {
“url”: “https://localhost/cookbooks/nginx”, “versions”: [
- {“url”: “https://localhost/cookbooks/nginx/1.0.0”,
“version”: “1.0.0”},
- {“url”: “https://localhost/cookbooks/nginx/0.3.0”,
“version”: “0.3.0”}
]
}
}
cheflib.entities.databag module¶
Chef data bag entity.
Source: https://docs.chef.io/server/api_chef_server/
GET: /organizations/NAME/data {
“users”: “https://chef.example/organizations/NAME/data/users”, “applications”: “https://chef.example/organizations/NAME/data/applications”
}
POST: /organizations/NAME/data {
“name”: “users”
}
GET: /organizations/NAME/data/NAME/ITEM {
“real_name”: “Adam Jacob”, “id”: “adam”
}
- class cheflib.entities.databag.DataBag(_chef: Chef, _name: str, _url: str, _data: Dict | None = None)[source]¶
Bases:
EntityData bag entity.
- create_item(name, data, secret=None) DataBagItem | None[source]¶
Create item in data bag, encrypt if secret is given.
- get_item_by_name(name: str, secret: bytes | None = None) [<class 'cheflib.entities.databagitem.DataBagItem'>, None][source]¶
Get data bag item by name.
- property get_item_names¶
cheflib.entities.databagitem module¶
Chef data bag entity.
Source: https://docs.chef.io/server/api_chef_server/
GET: /organizations/NAME/data {
“users”: “https://chef.example/organizations/NAME/data/users”, “applications”: “https://chef.example/organizations/NAME/data/applications”
}
POST: /organizations/NAME/data {
“name”: “users”
}
GET: /organizations/NAME/data/NAME/ITEM {
“real_name”: “Adam Jacob”, “id”: “adam”
}
cheflib.entities.environment module¶
Chef environment entity.
Source: https://docs.chef.io/server/api_chef_server/
Request:
GET /organizations/NAME/environments Response
The response is similar to:
- {
“_default”: “https://api.chef.io/organizations/org_name/environments/_default”, “webserver”: “https://api.chef.io/organizations/org_name/environments/webserver”
}
POST /organizations/NAME/environments with a request body similar to:
- {
“name”: “dev”, “default_attributes”: {}, “json_class”: “Chef::Environment”, “description”: “”, “cookbook_versions”: {}, “chef_type”: “environment”
}
Response
The response is similar to:
{ “uri”: “https://localhost/environments/dev” }
cheflib.entities.node module¶
Chef node entity.
Source: https://docs.chef.io/server/api_chef_server/
Request
GET /organizations/NAME/nodes Response
The response is similar to:
- {
“latte”: “https://localhost/nodes/latte”
}
Request
POST /organizations/NAME/nodes with a request body similar to:
- {
“name”: “latte”, “chef_type”: “node”, “json_class”: “Chef::Node”, “attributes”: {
“hardware_type”: “laptop”
}, “overrides”: {}, “defaults”: {}, “run_list”: [ “recipe[unicorn]” ]
}
Response
The response is similar to:
{ “uri”: “https://localhost/nodes/latte” }
cheflib.entities.role module¶
Chef role entity.
Source: https://docs.chef.io/server/api_chef_server/
Request
GET /organizations/NAME/roles
Response
The response is similar to:
- {
“webserver”: “https://chef.example/organizations/org1/roles/webserver”
}
Request
POST /organizations/NAME/roles with a request body similar to:
- {
“name”: “webserver”, “default_attributes”: {}, “description”: “A webserver”, “env_run_lists”: {
- “testenv”: {
“recipe[pegasus]”
}
}, “run_list”: [
“recipe[unicorn]”, “recipe[apache2]”
], “override_attributes”: {}
} Response
The response is similar to:
{ “uri”: “https://chef.example/organizations/org1/roles/webserver” }
Module contents¶
cheflib package.
Import all parts from cheflib.entities here