Class: Verizon::Configuration
- Defined in:
- lib/verizon/configuration.rb,
lib/verizon/models/configuration.rb
Overview
List of the field names and values to set.
Constant Summary collapse
- ENVIRONMENTS =
All the environments the SDK can run in.
{ Environment::PRODUCTION => { Server::HYPER_PRECISE_CREDENTIALS => 'https://thingspace.verizon.com/api/auth/v1', Server::EDGE_DISCOVERY => 'https://5gedge.verizon.com/api/mec/eds', Server::IMP_SERVER => 'https://imp.thingspace.verizon.com', Server::THINGSPACE => 'https://thingspace.verizon.com/api', Server::OAUTH_SERVER => 'https://thingspace.verizon.com/api/ts/v1', Server::M2M => 'https://thingspace.verizon.com/api/m2m', Server::DEVICE_LOCATION => 'https://thingspace.verizon.com/api/loc/v1', Server::SUBSCRIPTION_SERVER => 'https://thingspace.verizon.com/api/subsc/v1', Server::SOFTWARE_MANAGEMENT_V1 => 'https://thingspace.verizon.com/api/fota/v1', Server::SOFTWARE_MANAGEMENT_V2 => 'https://thingspace.verizon.com/api/fota/v2', Server::SOFTWARE_MANAGEMENT_V3 => 'https://thingspace.verizon.com/api/fota/v3', Server::PERFORMANCE => 'https://5gedge.verizon.com/api/mec', Server::DEVICE_DIAGNOSTICS => 'https://thingspace.verizon.com/api/diagnostics/v1', Server::CLOUD_CONNECTOR => 'https://thingspace.verizon.com/api/cc/v1', Server::HYPER_PRECISE_LOCATION => 'https://thingspace.verizon.com/api/hyper-precise/v1', Server::SERVICES => 'https://5gedge.verizon.com/api/mec/services', Server::QUALITY_OF_SERVICE => 'https://thingspace.verizon.com/api/m2m/v1/devices' }, Environment::STAGING => { Server::HYPER_PRECISE_CREDENTIALS => 'https://staging.thingspace.verizon.com/api/auth/v1', Server::EDGE_DISCOVERY => 'https://staging.5gedge.verizon.com/api/mec/eds', Server::IMP_SERVER => 'https://imp-staging.thingspace.verizon.com', Server::THINGSPACE => 'https://staging.thingspace.verizon.com/api', Server::OAUTH_SERVER => 'https://staging.thingspace.verizon.com/api/ts/v1', Server::M2M => 'https://staging.thingspace.verizon.com/api/m2m', Server::DEVICE_LOCATION => 'https://staging.thingspace.verizon.com/api/loc/v1', Server::SUBSCRIPTION_SERVER => 'https://staging.thingspace.verizon.com/api/subsc/v1', Server::SOFTWARE_MANAGEMENT_V1 => 'https://staging.thingspace.verizon.com/api/fota/v1', Server::SOFTWARE_MANAGEMENT_V2 => 'https://staging.thingspace.verizon.com/api/fota/v2', Server::SOFTWARE_MANAGEMENT_V3 => 'https://staging.thingspace.verizon.com/api/fota/v3', Server::PERFORMANCE => 'https://staging.5gedge.verizon.com/api/mec', Server::DEVICE_DIAGNOSTICS => 'https://staging.thingspace.verizon.com/api/diagnostics/v1', Server::CLOUD_CONNECTOR => 'https://staging.thingspace.verizon.com/api/cc/v1', Server::HYPER_PRECISE_LOCATION => 'https://staging.thingspace.verizon.com/api/hyper-precise/v1', Server::SERVICES => 'https://staging.5gedge.verizon.com/api/mec/services', Server::QUALITY_OF_SERVICE => 'https://staging.thingspace.verizon.com/api/m2m/v1/devices' }, Environment::DEV => { Server::HYPER_PRECISE_CREDENTIALS => 'https://staging.thingspace.verizon.com/api/auth/v1', Server::EDGE_DISCOVERY => 'https://devmanagement-staging.5gedge.verizon.com:80/mec/eds', Server::IMP_SERVER => 'https://devmanagement-staging.imp.thingspace.verizon.com', Server::THINGSPACE => 'https://devmanagement-staging.thingspace.verizon.com/api', Server::OAUTH_SERVER => 'https://devmanagement-staging.thingspace.verizon.com:80/ts/v1', Server::M2M => 'https://devmanagement-staging.thingspace.verizon.com:80/m2m', Server::DEVICE_LOCATION => 'https://devmanagement-staging.thingspace.verizon.com:80/loc/v1', Server::SUBSCRIPTION_SERVER => 'https://devmanagement-staging.thingspace.verizon.com:80/subsc/v1', Server::SOFTWARE_MANAGEMENT_V1 => 'https://devmanagement-staging.thingspace.verizon.com:80/fota/v1', Server::SOFTWARE_MANAGEMENT_V2 => 'https://devmanagement-staging.thingspace.verizon.com:80/fota/v2', Server::SOFTWARE_MANAGEMENT_V3 => 'https://devmanagement-staging.thingspace.verizon.com:80/fota/v3', Server::PERFORMANCE => 'https://devmanagement-staging.5gedge.verizon.com:80/mec', Server::DEVICE_DIAGNOSTICS => 'https://devmanagement-staging.thingspace.verizon.com:80/diagnostics/v1', Server::CLOUD_CONNECTOR => 'https://devmanagement-staging.thingspace.verizon.com:80/cc/v1', Server::HYPER_PRECISE_LOCATION => 'https://devmanagement-staging.thingspace.verizon.com:80/hyper-precise/v1', Server::SERVICES => 'https://devmanagement-staging.5gedge.verizon.com:80/mec/services', Server::QUALITY_OF_SERVICE => 'https://devmanagement-staging.thingspace.verizon.com/api/m2m/v1/devices' }, Environment::QA => { Server::HYPER_PRECISE_CREDENTIALS => 'https://thingspace.verizon.com/api/auth/v1', Server::EDGE_DISCOVERY => 'https://tsd-nginx-qa-us-east-1.5gedge.verizon.com/api/mec/eds', Server::IMP_SERVER => 'https://tsd-nginx-qa-us-east-1.imp.thingspace.verizon.com', Server::THINGSPACE => 'https://tsd-nginx-qa-us-east-1.thingspace.verizon.com/api', Server::OAUTH_SERVER => 'https://tsd-nginx-qa-us-east-1.thingspace.verizon.com/api/ts/v1', Server::M2M => 'https://tsd-nginx-qa-us-east-1.thingspace.verizon.com/api/m2m', Server::DEVICE_LOCATION => 'https://tsd-nginx-qa-us-east-1.thingspace.verizon.com/api/loc/v1', Server::SUBSCRIPTION_SERVER => 'https://tsd-nginx-qa-us-east-1.thingspace.verizon.com/api/subsc/v1', Server::SOFTWARE_MANAGEMENT_V1 => 'https://tsd-nginx-qa-us-east-1.thingspace.verizon.com/api/fota/v1', Server::SOFTWARE_MANAGEMENT_V2 => 'https://tsd-nginx-qa-us-east-1.thingspace.verizon.com/api/fota/v2', Server::SOFTWARE_MANAGEMENT_V3 => 'https://tsd-nginx-qa-us-east-1.thingspace.verizon.com/api/fota/v3', Server::PERFORMANCE => 'https://tsd-nginx-qa-us-east-1.5gedge.verizon.com/api/mec', Server::DEVICE_DIAGNOSTICS => 'https://tsd-nginx-qa-us-east-1.thingspace.verizon.com/api/diagnostics/v1', Server::CLOUD_CONNECTOR => 'https://tsd-nginx-qa-us-east-1.thingspace.verizon.com/api/cc/v1', Server::HYPER_PRECISE_LOCATION => 'https://tsd-nginx-qa-us-east-1.thingspace.verizon.com/api/hyper-precise/v1', Server::SERVICES => 'https://tsd-nginx-qa-us-east-1.5gedge.verizon.com/api/mec/services', Server::QUALITY_OF_SERVICE => 'https://tsd-nginx-qa-us-east-1.thingspace.verizon.com/api/m2m/v1/devices' }, Environment::MOCK_SERVER_FOR_LIMITED_AVAILABILITY_SEE_QUICK_START => { Server::HYPER_PRECISE_CREDENTIALS => 'https://staging.thingspace.verizon.com/api/auth/v1', Server::EDGE_DISCOVERY => 'https://staging.5gedge.verizon.com/api/mec/eds', Server::IMP_SERVER => 'https://mock-staging.thingspace.verizon.com', Server::THINGSPACE => 'https://mock-staging.thingspace.verizon.com/api', Server::OAUTH_SERVER => 'https://mock-staging.thingspace.verizon.com/api/ts/v1', Server::M2M => 'https://mock-staging.thingspace.verizon.com/api/m2m', Server::DEVICE_LOCATION => 'https://mock-staging.thingspace.verizon.com/api/loc/v1', Server::SUBSCRIPTION_SERVER => 'https://mock-staging.thingspace.verizon.com/api/subsc/v1', Server::SOFTWARE_MANAGEMENT_V1 => 'https://mock-staging.thingspace.verizon.com/api/fota/v1', Server::SOFTWARE_MANAGEMENT_V2 => 'https://mock-staging.thingspace.verizon.com/api/fota/v2', Server::SOFTWARE_MANAGEMENT_V3 => 'https://mock-staging.thingspace.verizon.com/api/fota/v3', Server::PERFORMANCE => 'https://staging.5gedge.verizon.com/api/mec', Server::DEVICE_DIAGNOSTICS => 'https://mock-staging.thingspace.verizon.com/api/diagnostics/v1', Server::CLOUD_CONNECTOR => 'https://mock-staging.thingspace.verizon.com/api/cc/v1', Server::HYPER_PRECISE_LOCATION => 'https://mock-staging.thingspace.verizon.com/api/hyper-precise/v1', Server::SERVICES => 'https://mock-staging.thingspace.verizon.com/api/mec/services', Server::QUALITY_OF_SERVICE => 'https://mock-staging.thingspace.verizon.com/api/m2m/v1/devices' } }.freeze
Class Attribute Summary collapse
-
.environments ⇒ Object
readonly
Returns the value of attribute environments.
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
The attribute readers for properties.
-
#frequency ⇒ String
TODO: Write general description for this method.
-
#session_token_credentials ⇒ Object
readonly
The attribute readers for properties.
-
#thingspace_oauth_1_credentials ⇒ Object
readonly
The attribute readers for properties.
-
#thingspace_oauth_credentials ⇒ Object
readonly
The attribute readers for properties.
-
#vz_m2m_token_credentials ⇒ Object
readonly
The attribute readers for properties.
Class Method Summary collapse
-
.build_default_config_from_env ⇒ Object
Builds a Configuration instance using environment variables.
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
- #clone_with(connection: nil, adapter: nil, timeout: nil, max_retries: nil, retry_interval: nil, backoff_factor: nil, retry_statuses: nil, retry_methods: nil, http_callback: nil, proxy_settings: nil, logging_configuration: nil, environment: nil, thingspace_oauth_credentials: nil, vz_m2m_token_credentials: nil, session_token_credentials: nil, thingspace_oauth_1_credentials: nil) ⇒ Object
-
#get_base_uri(server = Server::EDGE_DISCOVERY) ⇒ String
Generates the appropriate base URI for the environment and the server.
-
#initialize(frequency: SKIP, additional_properties: nil) ⇒ Configuration
constructor
A new instance of Configuration.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(frequency: SKIP, additional_properties: nil) ⇒ Configuration
Returns a new instance of Configuration.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/verizon/configuration.rb', line 101 def initialize( connection: nil, adapter: :net_http_persistent, timeout: 30, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put], http_callback: nil, proxy_settings: nil, logging_configuration: nil, environment: Environment::PRODUCTION, thingspace_oauth_credentials: nil, vz_m2m_token_credentials: nil, session_token_credentials: nil, thingspace_oauth_1_credentials: nil ) super connection: connection, adapter: adapter, timeout: timeout, max_retries: max_retries, retry_interval: retry_interval, backoff_factor: backoff_factor, retry_statuses: retry_statuses, retry_methods: retry_methods, http_callback: http_callback, proxy_settings: proxy_settings, logging_configuration: logging_configuration # Current API environment @environment = String(environment) # The object holding OAuth 2 Client Credentials Grant credentials @thingspace_oauth_credentials = thingspace_oauth_credentials # The object holding Custom Header Signature credentials @vz_m2m_token_credentials = vz_m2m_token_credentials # The object holding Custom Header Signature credentials @session_token_credentials = session_token_credentials # The object holding OAuth 2 Client Credentials Grant credentials @thingspace_oauth_1_credentials = thingspace_oauth_1_credentials # The Http Client to use for making requests. set_http_client CoreLibrary::FaradayClient.new(self) end |
Class Attribute Details
.environments ⇒ Object (readonly)
Returns the value of attribute environments.
98 99 100 |
# File 'lib/verizon/configuration.rb', line 98 def environments @environments end |
Instance Attribute Details
#environment ⇒ Object (readonly)
The attribute readers for properties.
93 94 95 |
# File 'lib/verizon/configuration.rb', line 93 def environment @environment end |
#frequency ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/verizon/models/configuration.rb', line 14 def frequency @frequency end |
#session_token_credentials ⇒ Object (readonly)
The attribute readers for properties.
93 94 95 |
# File 'lib/verizon/configuration.rb', line 93 def session_token_credentials @session_token_credentials end |
#thingspace_oauth_1_credentials ⇒ Object (readonly)
The attribute readers for properties.
93 94 95 |
# File 'lib/verizon/configuration.rb', line 93 def thingspace_oauth_1_credentials @thingspace_oauth_1_credentials end |
#thingspace_oauth_credentials ⇒ Object (readonly)
The attribute readers for properties.
93 94 95 |
# File 'lib/verizon/configuration.rb', line 93 def thingspace_oauth_credentials @thingspace_oauth_credentials end |
#vz_m2m_token_credentials ⇒ Object (readonly)
The attribute readers for properties.
93 94 95 |
# File 'lib/verizon/configuration.rb', line 93 def vz_m2m_token_credentials @vz_m2m_token_credentials end |
Class Method Details
.build_default_config_from_env ⇒ Object
Builds a Configuration instance using environment variables.
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'lib/verizon/configuration.rb', line 284 def self.build_default_config_from_env # === Core environment === environment = Environment.from_value(ENV.fetch('ENVIRONMENT', 'production')) timeout = (ENV['TIMEOUT'] || 30).to_f max_retries = (ENV['MAX_RETRIES'] || 0).to_i retry_interval = (ENV['RETRY_INTERVAL'] || 1).to_f backoff_factor = (ENV['BACKOFF_FACTOR'] || 2).to_f retry_statuses = ENV.fetch('RETRY_STATUSES', '[408, 413, 429, 500, 502, 503, 504, 521, 522, 524]').gsub(/[\[\]]/, '') .split(',') .map(&:strip) .map do |item| item.match?(/\A\d+\z/) ? item.to_i : item.downcase end retry_methods = ENV.fetch('RETRY_METHODS', '%i[get put]').gsub(/[\[\]]/, '') .split(',') .map(&:strip) .map do |item| item.match?(/\A\d+\z/) ? item.to_i : item.downcase end # === Authentication credentials === thingspace_oauth_credentials = ThingspaceOauthCredentials.from_env vz_m2m_token_credentials = VzM2MTokenCredentials.from_env session_token_credentials = SessionTokenCredentials.from_env thingspace_oauth_1_credentials = ThingspaceOauth1Credentials.from_env # === Proxy settings === proxy_settings = ProxySettings.from_env # === Logging Configuration === logging_configuration = LoggingConfiguration.from_env if LoggingConfiguration.any_logging_configured? Configuration.new( environment: environment, timeout: timeout, max_retries: max_retries, retry_interval: retry_interval, backoff_factor: backoff_factor, retry_statuses: retry_statuses, retry_methods: retry_methods, thingspace_oauth_credentials: thingspace_oauth_credentials, vz_m2m_token_credentials: vz_m2m_token_credentials, session_token_credentials: session_token_credentials, thingspace_oauth_1_credentials: thingspace_oauth_1_credentials, proxy_settings: proxy_settings, logging_configuration: logging_configuration ) end |
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/verizon/models/configuration.rb', line 44 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. frequency = hash.key?('frequency') ? hash['frequency'] : SKIP # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. Configuration.new(frequency: frequency, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
17 18 19 20 21 |
# File 'lib/verizon/models/configuration.rb', line 17 def self.names @_hash = {} if @_hash.nil? @_hash['frequency'] = 'frequency' @_hash end |
.nullables ⇒ Object
An array for nullable fields
31 32 33 |
# File 'lib/verizon/models/configuration.rb', line 31 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
24 25 26 27 28 |
# File 'lib/verizon/models/configuration.rb', line 24 def self.optionals %w[ frequency ] end |
Instance Method Details
#clone_with(connection: nil, adapter: nil, timeout: nil, max_retries: nil, retry_interval: nil, backoff_factor: nil, retry_statuses: nil, retry_methods: nil, http_callback: nil, proxy_settings: nil, logging_configuration: nil, environment: nil, thingspace_oauth_credentials: nil, vz_m2m_token_credentials: nil, session_token_credentials: nil, thingspace_oauth_1_credentials: nil) ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/verizon/configuration.rb', line 136 def clone_with(connection: nil, adapter: nil, timeout: nil, max_retries: nil, retry_interval: nil, backoff_factor: nil, retry_statuses: nil, retry_methods: nil, http_callback: nil, proxy_settings: nil, logging_configuration: nil, environment: nil, thingspace_oauth_credentials: nil, vz_m2m_token_credentials: nil, session_token_credentials: nil, thingspace_oauth_1_credentials: nil) connection ||= self.connection adapter ||= self.adapter timeout ||= self.timeout max_retries ||= self.max_retries retry_interval ||= self.retry_interval backoff_factor ||= self.backoff_factor retry_statuses ||= self.retry_statuses retry_methods ||= self.retry_methods http_callback ||= self.http_callback proxy_settings ||= self.proxy_settings logging_configuration ||= self.logging_configuration environment ||= self.environment thingspace_oauth_credentials ||= self.thingspace_oauth_credentials vz_m2m_token_credentials ||= self.vz_m2m_token_credentials session_token_credentials ||= self.session_token_credentials thingspace_oauth_1_credentials ||= self.thingspace_oauth_1_credentials Configuration.new( connection: connection, adapter: adapter, timeout: timeout, max_retries: max_retries, retry_interval: retry_interval, backoff_factor: backoff_factor, retry_statuses: retry_statuses, retry_methods: retry_methods, http_callback: http_callback, proxy_settings: proxy_settings, logging_configuration: logging_configuration, environment: environment, thingspace_oauth_credentials: thingspace_oauth_credentials, vz_m2m_token_credentials: vz_m2m_token_credentials, session_token_credentials: session_token_credentials, thingspace_oauth_1_credentials: thingspace_oauth_1_credentials ) end |
#get_base_uri(server = Server::EDGE_DISCOVERY) ⇒ String
Generates the appropriate base URI for the environment and the server. required.
279 280 281 |
# File 'lib/verizon/configuration.rb', line 279 def get_base_uri(server = Server::EDGE_DISCOVERY) ENVIRONMENTS[environment][server].clone end |
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
70 71 72 73 74 |
# File 'lib/verizon/models/configuration.rb', line 70 def inspect class_name = self.class.name.split('::').last "<#{class_name} frequency: #{@frequency.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
63 64 65 66 67 |
# File 'lib/verizon/models/configuration.rb', line 63 def to_s class_name = self.class.name.split('::').last "<#{class_name} frequency: #{@frequency}, additional_properties:"\ " #{@additional_properties}>" end |