Class: Kessel::Inventory::ClientBuilder
- Inherits:
-
Object
- Object
- Kessel::Inventory::ClientBuilder
- Includes:
- GRPC
- Defined in:
- lib/kessel/inventory.rb
Class Attribute Summary collapse
-
.stub_class ⇒ Object
readonly
Returns the value of attribute stub_class.
Instance Method Summary collapse
- #authenticated(call_credentials: nil, channel_credentials: nil) ⇒ Object
- #build ⇒ Object
-
#initialize(target) ⇒ ClientBuilder
constructor
A new instance of ClientBuilder.
- #insecure ⇒ Object
- #oauth2_client_authenticated(oauth2_client_credentials:, channel_credentials: nil) ⇒ Object
- #unauthenticated(channel_credentials: nil) ⇒ Object
Methods included from GRPC
Constructor Details
#initialize(target) ⇒ ClientBuilder
17 18 19 20 |
# File 'lib/kessel/inventory.rb', line 17 def initialize(target) @target = target raise 'Invalid target type' if @target.nil? || !@target.is_a?(String) end |
Class Attribute Details
.stub_class ⇒ Object (readonly)
Returns the value of attribute stub_class.
61 62 63 |
# File 'lib/kessel/inventory.rb', line 61 def stub_class @stub_class end |
Instance Method Details
#authenticated(call_credentials: nil, channel_credentials: nil) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/kessel/inventory.rb', line 29 def authenticated(call_credentials: nil, channel_credentials: nil) @call_credentials = call_credentials @channel_credentials = channel_credentials validate_credentials self end |
#build ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/kessel/inventory.rb', line 50 def build @channel_credentials = ::GRPC::Core::ChannelCredentials.new if @channel_credentials.nil? credentials = @channel_credentials credentials = credentials.compose(@call_credentials) unless @call_credentials.nil? self.class.stub_class.new(@target, credentials) end |
#insecure ⇒ Object
43 44 45 46 47 48 |
# File 'lib/kessel/inventory.rb', line 43 def insecure @call_credentials = nil @channel_credentials = :this_channel_is_insecure validate_credentials self end |
#oauth2_client_authenticated(oauth2_client_credentials:, channel_credentials: nil) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/kessel/inventory.rb', line 22 def oauth2_client_authenticated(oauth2_client_credentials:, channel_credentials: nil) @call_credentials = oauth2_call_credentials(oauth2_client_credentials) @channel_credentials = channel_credentials validate_credentials self end |
#unauthenticated(channel_credentials: nil) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/kessel/inventory.rb', line 36 def unauthenticated(channel_credentials: nil) @call_credentials = nil @channel_credentials = channel_credentials validate_credentials self end |