Class: OpenAI::Auth::WorkloadIdentity

Inherits:
Object
  • Object
show all
Defined in:
lib/openai/auth/workload_identity.rb,
sig/openai/auth.rbs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provider:, identity_provider_id: ENV["IDENTITY_PROVIDER_ID"], service_account_id: ENV["SERVICE_ACCOUNT_ID"], client_id: nil, refresh_buffer_seconds: 1200) ⇒ WorkloadIdentity

Returns a new instance of WorkloadIdentity.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/openai/auth/workload_identity.rb', line 8

def initialize(
  provider:,
  identity_provider_id: ENV["IDENTITY_PROVIDER_ID"],
  service_account_id: ENV["SERVICE_ACCOUNT_ID"],
  client_id: nil,
  refresh_buffer_seconds: 1200
)
  if identity_provider_id.to_s.strip.empty?
    raise(
      ArgumentError,
      "identity_provider_id must not be blank; pass identity_provider_id: or set IDENTITY_PROVIDER_ID"
    )
  end

  if .to_s.strip.empty?
    raise(
      ArgumentError,
      "service_account_id must not be blank; pass service_account_id: or set SERVICE_ACCOUNT_ID"
    )
  end

  @client_id = client_id&.to_s
  @identity_provider_id = identity_provider_id.to_s
  @service_account_id = .to_s
  @provider = provider
  @refresh_buffer_seconds = refresh_buffer_seconds.to_i
end

Instance Attribute Details

#client_idString? (readonly)

Returns the value of attribute client_id.

Returns:

  • (String, nil)


6
7
8
# File 'lib/openai/auth/workload_identity.rb', line 6

def client_id
  @client_id
end

#identity_provider_idString (readonly)

Returns the value of attribute identity_provider_id.

Returns:

  • (String)


6
7
8
# File 'lib/openai/auth/workload_identity.rb', line 6

def identity_provider_id
  @identity_provider_id
end

#providerOpenAI::Auth::SubjectTokenProvider (readonly)

Returns the value of attribute provider.



6
7
8
# File 'lib/openai/auth/workload_identity.rb', line 6

def provider
  @provider
end

#refresh_buffer_secondsInteger (readonly)

Returns the value of attribute refresh_buffer_seconds.

Returns:

  • (Integer)


6
7
8
# File 'lib/openai/auth/workload_identity.rb', line 6

def refresh_buffer_seconds
  @refresh_buffer_seconds
end

#service_account_idString (readonly)

Returns the value of attribute service_account_id.

Returns:

  • (String)


6
7
8
# File 'lib/openai/auth/workload_identity.rb', line 6

def 
  @service_account_id
end