Class: SDM::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/models/porcelain.rb

Overview

A Token is an account providing tokenized access for automation or integration use. Tokens include admin tokens, API keys, and SCIM tokens.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(account_type: nil, deadline: nil, duration: nil, id: nil, name: nil, permissions: nil, rekeyed: nil, suspended: nil, tags: nil) ⇒ Token

Returns a new instance of Token.



12669
12670
12671
12672
12673
12674
12675
12676
12677
12678
12679
12680
12681
12682
12683
12684
12685
12686
12687
12688
12689
# File 'lib/models/porcelain.rb', line 12669

def initialize(
  account_type: nil,
  deadline: nil,
  duration: nil,
  id: nil,
  name: nil,
  permissions: nil,
  rekeyed: nil,
  suspended: nil,
  tags: nil
)
  @account_type =  == nil ? "" : 
  @deadline = deadline == nil ? nil : deadline
  @duration = duration == nil ? nil : duration
  @id = id == nil ? "" : id
  @name = name == nil ? "" : name
  @permissions = permissions == nil ? [] : permissions
  @rekeyed = rekeyed == nil ? nil : rekeyed
  @suspended = suspended == nil ? false : suspended
  @tags = tags == nil ? SDM::_porcelain_zero_value_tags() : tags
end

Instance Attribute Details

#account_typeObject

Corresponds to the type of token, e.g. api or admin-token.



12651
12652
12653
# File 'lib/models/porcelain.rb', line 12651

def 
  @account_type
end

#deadlineObject

The timestamp when the Token will expire.



12653
12654
12655
# File 'lib/models/porcelain.rb', line 12653

def deadline
  @deadline
end

#durationObject

Duration from token creation to expiration.



12655
12656
12657
# File 'lib/models/porcelain.rb', line 12655

def duration
  @duration
end

#idObject

Unique identifier of the Token.



12657
12658
12659
# File 'lib/models/porcelain.rb', line 12657

def id
  @id
end

#nameObject

Unique human-readable name of the Token.



12659
12660
12661
# File 'lib/models/porcelain.rb', line 12659

def name
  @name
end

#permissionsObject

Permissions assigned to the token, e.g. role:create.



12661
12662
12663
# File 'lib/models/porcelain.rb', line 12661

def permissions
  @permissions
end

#rekeyedObject

The timestamp when the Token was last rekeyed.



12663
12664
12665
# File 'lib/models/porcelain.rb', line 12663

def rekeyed
  @rekeyed
end

#suspendedObject

Reserved for future use. Always false for tokens.



12665
12666
12667
# File 'lib/models/porcelain.rb', line 12665

def suspended
  @suspended
end

#tagsObject

Tags is a map of key, value pairs.



12667
12668
12669
# File 'lib/models/porcelain.rb', line 12667

def tags
  @tags
end

Instance Method Details

#to_json(options = {}) ⇒ Object



12691
12692
12693
12694
12695
12696
12697
# File 'lib/models/porcelain.rb', line 12691

def to_json(options = {})
  hash = {}
  self.instance_variables.each do |var|
    hash[var.id2name.delete_prefix("@")] = self.instance_variable_get var
  end
  hash.to_json
end