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, created_at: nil, deadline: nil, duration: nil, id: nil, name: nil, permissions: nil, rekeyed: nil, suspended: nil, tags: nil) ⇒ Token

Returns a new instance of Token.



18326
18327
18328
18329
18330
18331
18332
18333
18334
18335
18336
18337
18338
18339
18340
18341
18342
18343
18344
18345
18346
18347
18348
# File 'lib/models/porcelain.rb', line 18326

def initialize(
  account_type: nil,
  created_at: nil,
  deadline: nil,
  duration: nil,
  id: nil,
  name: nil,
  permissions: nil,
  rekeyed: nil,
  suspended: nil,
  tags: nil
)
  @account_type =  == nil ? "" : 
  @created_at = created_at == nil ? nil : created_at
  @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_type ⇒ Object

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



18306
18307
18308
# File 'lib/models/porcelain.rb', line 18306

def 
  @account_type
end

#created_at ⇒ Object

CreatedAt is the timestamp when the token was created



18308
18309
18310
# File 'lib/models/porcelain.rb', line 18308

def created_at
  @created_at
end

#deadline ⇒ Object

The timestamp when the Token will expire.



18310
18311
18312
# File 'lib/models/porcelain.rb', line 18310

def deadline
  @deadline
end

#duration ⇒ Object

Duration from token creation to expiration.



18312
18313
18314
# File 'lib/models/porcelain.rb', line 18312

def duration
  @duration
end

#id ⇒ Object

Unique identifier of the Token.



18314
18315
18316
# File 'lib/models/porcelain.rb', line 18314

def id
  @id
end

#name ⇒ Object

Unique human-readable name of the Token.



18316
18317
18318
# File 'lib/models/porcelain.rb', line 18316

def name
  @name
end

#permissions ⇒ Object

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



18318
18319
18320
# File 'lib/models/porcelain.rb', line 18318

def permissions
  @permissions
end

#rekeyed ⇒ Object

The timestamp when the Token was last rekeyed.



18320
18321
18322
# File 'lib/models/porcelain.rb', line 18320

def rekeyed
  @rekeyed
end

#suspended ⇒ Object

Reserved for future use. Always false for tokens.



18322
18323
18324
# File 'lib/models/porcelain.rb', line 18322

def suspended
  @suspended
end

#tags ⇒ Object

Tags is a map of key, value pairs.



18324
18325
18326
# File 'lib/models/porcelain.rb', line 18324

def tags
  @tags
end

Instance Method Details

#to_json(options = {}) ⇒ Object



18350
18351
18352
18353
18354
18355
18356
# File 'lib/models/porcelain.rb', line 18350

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