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.

[View source]

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

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.


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

def 
  @account_type
end

#deadlineObject

The timestamp when the Token will expire.


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

def deadline
  @deadline
end

#durationObject

Duration from token creation to expiration.


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

def duration
  @duration
end

#idObject

Unique identifier of the Token.


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

def id
  @id
end

#nameObject

Unique human-readable name of the Token.


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

def name
  @name
end

#permissionsObject

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


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

def permissions
  @permissions
end

#rekeyedObject

The timestamp when the Token was last rekeyed.


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

def rekeyed
  @rekeyed
end

#suspendedObject

Reserved for future use. Always false for tokens.


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

def suspended
  @suspended
end

#tagsObject

Tags is a map of key, value pairs.


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

def tags
  @tags
end

Instance Method Details

#to_json(options = {}) ⇒ Object

[View source]

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

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