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.



14877
14878
14879
14880
14881
14882
14883
14884
14885
14886
14887
14888
14889
14890
14891
14892
14893
14894
14895
14896
14897
# File 'lib/models/porcelain.rb', line 14877

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.



14859
14860
14861
# File 'lib/models/porcelain.rb', line 14859

def 
  @account_type
end

#deadlineObject

The timestamp when the Token will expire.



14861
14862
14863
# File 'lib/models/porcelain.rb', line 14861

def deadline
  @deadline
end

#durationObject

Duration from token creation to expiration.



14863
14864
14865
# File 'lib/models/porcelain.rb', line 14863

def duration
  @duration
end

#idObject

Unique identifier of the Token.



14865
14866
14867
# File 'lib/models/porcelain.rb', line 14865

def id
  @id
end

#nameObject

Unique human-readable name of the Token.



14867
14868
14869
# File 'lib/models/porcelain.rb', line 14867

def name
  @name
end

#permissionsObject

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



14869
14870
14871
# File 'lib/models/porcelain.rb', line 14869

def permissions
  @permissions
end

#rekeyedObject

The timestamp when the Token was last rekeyed.



14871
14872
14873
# File 'lib/models/porcelain.rb', line 14871

def rekeyed
  @rekeyed
end

#suspendedObject

Reserved for future use. Always false for tokens.



14873
14874
14875
# File 'lib/models/porcelain.rb', line 14873

def suspended
  @suspended
end

#tagsObject

Tags is a map of key, value pairs.



14875
14876
14877
# File 'lib/models/porcelain.rb', line 14875

def tags
  @tags
end

Instance Method Details

#to_json(options = {}) ⇒ Object



14899
14900
14901
14902
14903
14904
14905
# File 'lib/models/porcelain.rb', line 14899

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