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.



12736
12737
12738
12739
12740
12741
12742
12743
12744
12745
12746
12747
12748
12749
12750
12751
12752
12753
12754
12755
12756
# File 'lib/models/porcelain.rb', line 12736

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.



12718
12719
12720
# File 'lib/models/porcelain.rb', line 12718

def 
  @account_type
end

#deadlineObject

The timestamp when the Token will expire.



12720
12721
12722
# File 'lib/models/porcelain.rb', line 12720

def deadline
  @deadline
end

#durationObject

Duration from token creation to expiration.



12722
12723
12724
# File 'lib/models/porcelain.rb', line 12722

def duration
  @duration
end

#idObject

Unique identifier of the Token.



12724
12725
12726
# File 'lib/models/porcelain.rb', line 12724

def id
  @id
end

#nameObject

Unique human-readable name of the Token.



12726
12727
12728
# File 'lib/models/porcelain.rb', line 12726

def name
  @name
end

#permissionsObject

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



12728
12729
12730
# File 'lib/models/porcelain.rb', line 12728

def permissions
  @permissions
end

#rekeyedObject

The timestamp when the Token was last rekeyed.



12730
12731
12732
# File 'lib/models/porcelain.rb', line 12730

def rekeyed
  @rekeyed
end

#suspendedObject

Reserved for future use. Always false for tokens.



12732
12733
12734
# File 'lib/models/porcelain.rb', line 12732

def suspended
  @suspended
end

#tagsObject

Tags is a map of key, value pairs.



12734
12735
12736
# File 'lib/models/porcelain.rb', line 12734

def tags
  @tags
end

Instance Method Details

#to_json(options = {}) ⇒ Object



12758
12759
12760
12761
12762
12763
12764
# File 'lib/models/porcelain.rb', line 12758

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