Class: Verizon::OauthScopeThingspaceOauth

Inherits:
Object
  • Object
show all
Defined in:
lib/verizon/models/oauth_scope_thingspace_oauth.rb

Overview

OAuth 2 scopes supported by the API

Constant Summary collapse

OAUTH_SCOPE_THINGSPACE_OAUTH =
[
  # Grant read-only access to discovery data
  DISCOVERYREAD = 'discovery:read'.freeze,

  # Grant read-only access to service profile data
  SERVICEPROFILEREAD = 'serviceprofile:read'.freeze,

  # Grant write access to service profile data
  SERVICEPROFILEWRITE = 'serviceprofile:write'.freeze,

  # Grant read-only access to Service registry data
  SERVICEREGISTRYREAD = 'serviceregistry:read'.freeze,

  # Grant write access to Service registry data
  SERVICEREGISTRYWRITE = 'serviceregistry:write'.freeze,

  # Full access for /serviceprofiles and /serviceendpoints.
  TS_MEC_FULLACCESS = 'ts.mec.fullaccess'.freeze,

  # Limited access. Will not allow use of /serviceprofiles and
  # /serviceendpoints but will allow discovery.
  TS_MEC_LIMITACCESS = 'ts.mec.limitaccess'.freeze,

  # TODO: Write general description for TS_APPLICATION_RO
  TS_APPLICATION_RO = 'ts.application.ro'.freeze,

  # Read access to the discovery service
  EDGEDISCOVERYREAD = 'edge:discovery:read'.freeze,

  # Read access to the service profile service
  EDGESERVICEPROFILEREAD = 'edge:serviceprofile:read'.freeze,

  # Write access to the service profile service
  EDGESERVICEPROFILEWRITE = 'edge:serviceprofile:write'.freeze,

  # Read access to the service registry service
  EDGESERVICEREGISTRYREAD = 'edge:serviceregistry:read'.freeze,

  # Write access to the service registry service
  EDGESERVICEREGISTRYWRITE = 'edge:serviceregistry:write'.freeze,

  # read access
  READ = 'read'.freeze,

  # read/write access
  WRITE = 'write'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = DISCOVERYREAD) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/verizon/models/oauth_scope_thingspace_oauth.rb', line 63

def self.from_value(value, default_value = DISCOVERYREAD)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'discoveryread' then DISCOVERYREAD
  when 'serviceprofileread' then SERVICEPROFILEREAD
  when 'serviceprofilewrite' then SERVICEPROFILEWRITE
  when 'serviceregistryread' then SERVICEREGISTRYREAD
  when 'serviceregistrywrite' then SERVICEREGISTRYWRITE
  when 'ts_mec_fullaccess' then TS_MEC_FULLACCESS
  when 'ts_mec_limitaccess' then TS_MEC_LIMITACCESS
  when 'ts_application_ro' then TS_APPLICATION_RO
  when 'edgediscoveryread' then EDGEDISCOVERYREAD
  when 'edgeserviceprofileread' then EDGESERVICEPROFILEREAD
  when 'edgeserviceprofilewrite' then EDGESERVICEPROFILEWRITE
  when 'edgeserviceregistryread' then EDGESERVICEREGISTRYREAD
  when 'edgeserviceregistrywrite' then EDGESERVICEREGISTRYWRITE
  when 'read' then READ
  when 'write' then WRITE
  else
    default_value
  end
end

.validate(value) ⇒ Object



57
58
59
60
61
# File 'lib/verizon/models/oauth_scope_thingspace_oauth.rb', line 57

def self.validate(value)
  return false if value.nil?

  OAUTH_SCOPE_THINGSPACE_OAUTH.include?(value)
end