Class: Azure::Directory::Config::Builder
- Inherits:
-
Object
- Object
- Azure::Directory::Config::Builder
- Defined in:
- lib/azure/directory/config.rb
Instance Method Summary collapse
- #build ⇒ Object
-
#client_id(client_id) ⇒ Object
OAuth: Application Client ID.
-
#client_secret(client_secret) ⇒ Object
OAuth: Application Client Secret.
-
#initialize(&block) ⇒ Builder
constructor
A new instance of Builder.
-
#resource_id(resource_id) ⇒ Object
Required Resource Access.
-
#scope(scope_name, &block) ⇒ Object
Set a new configuration for a specific scope, in order to support multiple connections to different applications.
-
#tenant_id(tenant_id) ⇒ Object
OAuth: Azure’s Tenant ID.
-
#use_yaml(yaml_file) ⇒ Object
Use a YAML file to store the requested access tokens.
Constructor Details
Instance Method Details
#build ⇒ Object
54 55 56 |
# File 'lib/azure/directory/config.rb', line 54 def build @config end |
#client_id(client_id) ⇒ Object
OAuth: Application Client ID
75 76 77 |
# File 'lib/azure/directory/config.rb', line 75 def client_id( client_id ) @current_config.instance_variable_set('@client_id', client_id) end |
#client_secret(client_secret) ⇒ Object
OAuth: Application Client Secret
82 83 84 |
# File 'lib/azure/directory/config.rb', line 82 def client_secret( client_secret ) @current_config.instance_variable_set('@client_secret', client_secret) end |
#resource_id(resource_id) ⇒ Object
Required Resource Access
100 101 102 |
# File 'lib/azure/directory/config.rb', line 100 def resource_id( resource_id ) @current_config.instance_variable_set('@resource_id', resource_id) end |
#scope(scope_name, &block) ⇒ Object
Set a new configuration for a specific scope, in order to support multiple connections to different applications. Provide a block with the configuration parameters.
110 111 112 113 114 115 116 117 118 |
# File 'lib/azure/directory/config.rb', line 110 def scope( scope_name, &block ) scopes = @config.instance_variable_get('@scopes') scopes[scope_name] = @current_config = Config.new(scope_name) @current_config.instance_variable_set('@token_store', @token_store) instance_eval(&block) @current_config = @config end |
#tenant_id(tenant_id) ⇒ Object
OAuth: Azure’s Tenant ID.
91 92 93 |
# File 'lib/azure/directory/config.rb', line 91 def tenant_id( tenant_id ) @current_config.instance_variable_set('@tenant_id', tenant_id) end |
#use_yaml(yaml_file) ⇒ Object
Use a YAML file to store the requested access tokens. When the token is refreshed, this file will be updated. You must declare this configuration attribute before any scope.
64 65 66 67 68 69 70 |
# File 'lib/azure/directory/config.rb', line 64 def use_yaml( yaml_file ) File.exist?(yaml_file) || FileUtils.touch(yaml_file) @token_store = YamlTokenStore.new( yaml_file ) @current_config.instance_variable_set('@token_store', @token_store) end |