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.



13133
13134
13135
13136
13137
13138
13139
13140
13141
13142
13143
13144
13145
13146
13147
13148
13149
13150
13151
13152
13153
# File 'lib/models/porcelain.rb', line 13133

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.



13115
13116
13117
# File 'lib/models/porcelain.rb', line 13115

def 
  @account_type
end

#deadlineObject

The timestamp when the Token will expire.



13117
13118
13119
# File 'lib/models/porcelain.rb', line 13117

def deadline
  @deadline
end

#durationObject

Duration from token creation to expiration.



13119
13120
13121
# File 'lib/models/porcelain.rb', line 13119

def duration
  @duration
end

#idObject

Unique identifier of the Token.



13121
13122
13123
# File 'lib/models/porcelain.rb', line 13121

def id
  @id
end

#nameObject

Unique human-readable name of the Token.



13123
13124
13125
# File 'lib/models/porcelain.rb', line 13123

def name
  @name
end

#permissionsObject

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



13125
13126
13127
# File 'lib/models/porcelain.rb', line 13125

def permissions
  @permissions
end

#rekeyedObject

The timestamp when the Token was last rekeyed.



13127
13128
13129
# File 'lib/models/porcelain.rb', line 13127

def rekeyed
  @rekeyed
end

#suspendedObject

Reserved for future use. Always false for tokens.



13129
13130
13131
# File 'lib/models/porcelain.rb', line 13129

def suspended
  @suspended
end

#tagsObject

Tags is a map of key, value pairs.



13131
13132
13133
# File 'lib/models/porcelain.rb', line 13131

def tags
  @tags
end

Instance Method Details

#to_json(options = {}) ⇒ Object



13155
13156
13157
13158
13159
13160
13161
# File 'lib/models/porcelain.rb', line 13155

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