Class: Rancher::ManagementApi::Project
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Rancher::ManagementApi::Project
- Defined in:
- lib/rancher/management_api/project.rb
Instance Attribute Summary collapse
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
Class Method Summary collapse
Instance Method Summary collapse
- #create_api_key(name) ⇒ Object
- #create_registration_token ⇒ Object
-
#initialize(conn, data) ⇒ Project
constructor
A new instance of Project.
Constructor Details
#initialize(conn, data) ⇒ Project
Returns a new instance of Project.
32 33 34 35 |
# File 'lib/rancher/management_api/project.rb', line 32 def initialize(conn, data) @conn = conn super(data) end |
Instance Attribute Details
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
30 31 32 |
# File 'lib/rancher/management_api/project.rb', line 30 def conn @conn end |
Class Method Details
.create(conn, name) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rancher/management_api/project.rb', line 6 def self.create(conn, name) env_response = conn.post do |req| req.url "/v1/project" req.body = { name: name, }.to_json end data = JSON.parse(env_response.body) # reload until the project is ready while data["state"] == "registering" sleep 0.5 url = data["links"]["self"] response = conn.get do |req| req.url url end data = JSON.parse(response.body) end new(conn, data) end |
Instance Method Details
#create_api_key(name) ⇒ Object
37 38 39 |
# File 'lib/rancher/management_api/project.rb', line 37 def create_api_key(name) ApiKey.create(self, name) end |
#create_registration_token ⇒ Object
41 42 43 |
# File 'lib/rancher/management_api/project.rb', line 41 def create_registration_token RegistrationToken.create(self) end |