Class: Cerca::Client
Constant Summary
collapse
- DEFAULT_MAX_RETRIES =
Default max number of retries to attempt after a failed retryable request.
2
- DEFAULT_TIMEOUT_IN_SECONDS =
Default per-request timeout.
60.0
- DEFAULT_INITIAL_RETRY_DELAY =
Default initial retry delay in seconds. Overall delay is calculated using exponential backoff + jitter.
0.5
- DEFAULT_MAX_RETRY_DELAY =
Default max retry delay in seconds.
8.0
Internal::Transport::BaseClient::MAX_REDIRECTS, Internal::Transport::BaseClient::PLATFORM_HEADERS
Instance Attribute Summary collapse
#base_url, #headers, #idempotency_header, #initial_retry_delay, #max_retries, #max_retry_delay, #requester, #timeout
Instance Method Summary
collapse
follow_redirect, #inspect, reap_connection!, #request, #send_request, should_retry?, validate!
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type
Constructor Details
#initialize(api_key: ENV["CERCA_API_KEY"], base_url: ENV["CERCA_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ Client
Creates and returns a new client for interacting with the API.
‘“api.example.com/v2/”`. Defaults to `ENV`
89
90
91
92
93
94
95
96
97
98
99
100
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
135
136
137
138
139
140
141
142
|
# File 'lib/cerca/client.rb', line 89
def initialize(
api_key: ENV["CERCA_API_KEY"],
base_url: ENV["CERCA_BASE_URL"],
max_retries: self.class::DEFAULT_MAX_RETRIES,
timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS,
initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY,
max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY
)
base_url ||= "https://api.cerca.dev"
if api_key.nil?
raise ArgumentError.new("api_key is required, and can be set via environ: \"CERCA_API_KEY\"")
end
= {}
= ENV["CERCA_CUSTOM_HEADERS"]
unless .nil?
parsed = {}
.split("\n").each do |line|
colon = line.index(":")
unless colon.nil?
parsed[line[0...colon].strip] = line[(colon + 1)..].strip
end
end
= parsed.merge()
end
@api_key = api_key.to_s
super(
base_url: base_url,
timeout: timeout,
max_retries: max_retries,
initial_retry_delay: initial_retry_delay,
max_retry_delay: max_retry_delay,
headers:
)
@auth = Cerca::Resources::Auth.new(client: self)
@oauth = Cerca::Resources::OAuth.new(client: self)
@connections = Cerca::Resources::Connections.new(client: self)
@fleets = Cerca::Resources::Fleets.new(client: self)
@tools = Cerca::Resources::Tools.new(client: self)
@webhooks = Cerca::Resources::Webhooks.new(client: self)
@events = Cerca::Resources::Events.new(client: self)
@agents = Cerca::Resources::Agents.new(client: self)
@threads = Cerca::Resources::Threads.new(client: self)
@context = Cerca::Resources::Context.new(client: self)
@schedules = Cerca::Resources::Schedules.new(client: self)
@approval_requests = Cerca::Resources::ApprovalRequests.new(client: self)
@approval_grants = Cerca::Resources::ApprovalGrants.new(client: self)
@sandbox = Cerca::Resources::Sandbox.new(client: self)
@models = Cerca::Resources::Models.new(client: self)
end
|
Instance Attribute Details
43
44
45
|
# File 'lib/cerca/client.rb', line 43
def agents
@agents
end
|
#api_key ⇒ String
19
20
21
|
# File 'lib/cerca/client.rb', line 19
def api_key
@api_key
end
|
58
59
60
|
# File 'lib/cerca/client.rb', line 58
def approval_grants
@approval_grants
end
|
55
56
57
|
# File 'lib/cerca/client.rb', line 55
def approval_requests
@approval_requests
end
|
22
23
24
|
# File 'lib/cerca/client.rb', line 22
def auth
@auth
end
|
28
29
30
|
# File 'lib/cerca/client.rb', line 28
def connections
@connections
end
|
49
50
51
|
# File 'lib/cerca/client.rb', line 49
def context
@context
end
|
40
41
42
|
# File 'lib/cerca/client.rb', line 40
def events
@events
end
|
31
32
33
|
# File 'lib/cerca/client.rb', line 31
def fleets
@fleets
end
|
64
65
66
|
# File 'lib/cerca/client.rb', line 64
def models
@models
end
|
25
26
27
|
# File 'lib/cerca/client.rb', line 25
def oauth
@oauth
end
|
61
62
63
|
# File 'lib/cerca/client.rb', line 61
def sandbox
@sandbox
end
|
52
53
54
|
# File 'lib/cerca/client.rb', line 52
def schedules
@schedules
end
|
46
47
48
|
# File 'lib/cerca/client.rb', line 46
def threads
@threads
end
|
34
35
36
|
# File 'lib/cerca/client.rb', line 34
def tools
@tools
end
|
37
38
39
|
# File 'lib/cerca/client.rb', line 37
def webhooks
@webhooks
end
|