Class: Rancher::ManagementApi::RegistrationToken

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/rancher/management_api/registration_token.rb

Class Method Summary collapse

Class Method Details

.create(project) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rancher/management_api/registration_token.rb', line 7

def self.create(project)
  response = project.conn.post do |req|
    req.url "/v1/registrationtokens?projectId=#{project.id}"
  end

  data = JSON.parse(response.body)

  # reload until the project is ready
  while data["state"] == "registering"
    sleep 0.5
    url = data["links"]["self"]
    response = project.conn.get do |req|
      req.url url
    end

    data = JSON.parse(response.body)
  end
  new(data)
end