Sha256: f2c80b09c92ae2197da462aeaa8d038ecf4417de8364786d9922fea292d7dfe9

Contents?: true

Size: 647 Bytes

Versions: 2

Compression:

Stored size: 647 Bytes

Contents

require "ostruct"
require "json"

module Rancher
  module ManagementApi
    class RegistrationToken < OpenStruct
      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

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rancher-management_api-0.3.2 lib/rancher/management_api/registration_token.rb
rancher-management_api-0.3.0 lib/rancher/management_api/registration_token.rb