hook0-client 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +235 -0
- data/assets/ruby-flow.svg +153 -0
- data/lib/hook0/client.rb +691 -0
- data/lib/hook0/errors.rb +78 -0
- data/lib/hook0/generated/all.rb +7 -0
- data/lib/hook0/generated/api.rb +1097 -0
- data/lib/hook0/generated/errors.rb +235 -0
- data/lib/hook0/generated/models.rb +3093 -0
- data/lib/hook0/runtime.rb +299 -0
- data/lib/hook0/signature.rb +294 -0
- data/lib/hook0/transport.rb +359 -0
- data/lib/hook0/version.rb +6 -0
- data/lib/hook0.rb +23 -0
- metadata +90 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
# Generated by hook0-sdkgen from the OpenAPI snapshot the API crate commits.
|
|
2
|
+
# Do not edit by hand: run `UPDATE_SDK=ruby cargo test -p hook0-sdkgen sdk_targets` and commit the result.
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
|
|
5
|
+
require_relative "../runtime"
|
|
6
|
+
require_relative "models"
|
|
7
|
+
|
|
8
|
+
module Hook0
|
|
9
|
+
# The failures the API reports, one exception per problem it can name.
|
|
10
|
+
module Generated
|
|
11
|
+
# A failure the API answered with, whether or not it could be read as a problem.
|
|
12
|
+
class ProblemError < StandardError
|
|
13
|
+
attr_reader :status, :problem
|
|
14
|
+
|
|
15
|
+
# @param status [Integer] what the API answered under
|
|
16
|
+
# @param problem [Problem, nil] the document it answered, when this client could read one
|
|
17
|
+
# @param detail [String] what to say about the failure
|
|
18
|
+
def initialize(status, problem, detail)
|
|
19
|
+
super(detail)
|
|
20
|
+
@status = status
|
|
21
|
+
@problem = problem
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# The API reported `ApplicationNameMissing`.
|
|
26
|
+
class ApplicationNameMissingError < ProblemError; end
|
|
27
|
+
|
|
28
|
+
# The API reported `AuthApplicationSecretLookupError`.
|
|
29
|
+
class AuthApplicationSecretLookupErrorError < ProblemError; end
|
|
30
|
+
|
|
31
|
+
# The API reported `AuthBiscuitLookupError`.
|
|
32
|
+
class AuthBiscuitLookupErrorError < ProblemError; end
|
|
33
|
+
|
|
34
|
+
# The API reported `AuthEmailAlreadyVerified`.
|
|
35
|
+
class AuthEmailAlreadyVerifiedError < ProblemError; end
|
|
36
|
+
|
|
37
|
+
# The API reported `AuthEmailExpired`.
|
|
38
|
+
class AuthEmailExpiredError < ProblemError; end
|
|
39
|
+
|
|
40
|
+
# The API reported `AuthEmailNotVerified`.
|
|
41
|
+
class AuthEmailNotVerifiedError < ProblemError; end
|
|
42
|
+
|
|
43
|
+
# The API reported `AuthFailedLogin`.
|
|
44
|
+
class AuthFailedLoginError < ProblemError; end
|
|
45
|
+
|
|
46
|
+
# The API reported `AuthFailedRefresh`.
|
|
47
|
+
class AuthFailedRefreshError < ProblemError; end
|
|
48
|
+
|
|
49
|
+
# The API reported `AuthInvalidApplicationSecret`.
|
|
50
|
+
class AuthInvalidApplicationSecretError < ProblemError; end
|
|
51
|
+
|
|
52
|
+
# The API reported `AuthInvalidAuthorizationHeader`.
|
|
53
|
+
class AuthInvalidAuthorizationHeaderError < ProblemError; end
|
|
54
|
+
|
|
55
|
+
# The API reported `AuthInvalidBiscuit`.
|
|
56
|
+
class AuthInvalidBiscuitError < ProblemError; end
|
|
57
|
+
|
|
58
|
+
# The API reported `AuthNoAuthorizationHeader`.
|
|
59
|
+
class AuthNoAuthorizationHeaderError < ProblemError; end
|
|
60
|
+
|
|
61
|
+
# The API reported `EventAlreadyIngested`.
|
|
62
|
+
class EventAlreadyIngestedError < ProblemError; end
|
|
63
|
+
|
|
64
|
+
# The API reported `EventInvalidBase64Payload`.
|
|
65
|
+
class EventInvalidBase64PayloadError < ProblemError; end
|
|
66
|
+
|
|
67
|
+
# The API reported `EventInvalidJsonPayload`.
|
|
68
|
+
class EventInvalidJsonPayloadError < ProblemError; end
|
|
69
|
+
|
|
70
|
+
# The API reported `EventInvalidPayloadContentType`.
|
|
71
|
+
class EventInvalidPayloadContentTypeError < ProblemError; end
|
|
72
|
+
|
|
73
|
+
# The API reported `EventTypeAlreadyExist`.
|
|
74
|
+
class EventTypeAlreadyExistError < ProblemError; end
|
|
75
|
+
|
|
76
|
+
# The API reported `EventTypeDoesNotExist`.
|
|
77
|
+
class EventTypeDoesNotExistError < ProblemError; end
|
|
78
|
+
|
|
79
|
+
# The API reported `Forbidden`.
|
|
80
|
+
class ForbiddenError < ProblemError; end
|
|
81
|
+
|
|
82
|
+
# The API reported `InternalServerError`.
|
|
83
|
+
class InternalServerErrorError < ProblemError; end
|
|
84
|
+
|
|
85
|
+
# The API reported `InvalidDateRange`.
|
|
86
|
+
class InvalidDateRangeError < ProblemError; end
|
|
87
|
+
|
|
88
|
+
# The API reported `InvalidRole`.
|
|
89
|
+
class InvalidRoleError < ProblemError; end
|
|
90
|
+
|
|
91
|
+
# The API reported `InvitedUserAlreadyInOrganization`.
|
|
92
|
+
class InvitedUserAlreadyInOrganizationError < ProblemError; end
|
|
93
|
+
|
|
94
|
+
# The API reported `InvitedUserDoesNotExist`.
|
|
95
|
+
class InvitedUserDoesNotExistError < ProblemError; end
|
|
96
|
+
|
|
97
|
+
# The API reported `JsonPayload`.
|
|
98
|
+
class JsonPayloadError < ProblemError; end
|
|
99
|
+
|
|
100
|
+
# The API reported `LabelsAmbiguity`.
|
|
101
|
+
class LabelsAmbiguityError < ProblemError; end
|
|
102
|
+
|
|
103
|
+
# The API reported `NotFound`.
|
|
104
|
+
class NotFoundError < ProblemError; end
|
|
105
|
+
|
|
106
|
+
# The API reported `OrganizationIsNotEmpty`.
|
|
107
|
+
class OrganizationIsNotEmptyError < ProblemError; end
|
|
108
|
+
|
|
109
|
+
# The API reported `OrganizationNameMissing`.
|
|
110
|
+
class OrganizationNameMissingError < ProblemError; end
|
|
111
|
+
|
|
112
|
+
# The API reported `PasswordNotDiverseEnough`.
|
|
113
|
+
class PasswordNotDiverseEnoughError < ProblemError; end
|
|
114
|
+
|
|
115
|
+
# The API reported `PasswordSimilarToEmail`.
|
|
116
|
+
class PasswordSimilarToEmailError < ProblemError; end
|
|
117
|
+
|
|
118
|
+
# The API reported `PasswordSimilarToName`.
|
|
119
|
+
class PasswordSimilarToNameError < ProblemError; end
|
|
120
|
+
|
|
121
|
+
# The API reported `PasswordTooCommon`.
|
|
122
|
+
class PasswordTooCommonError < ProblemError; end
|
|
123
|
+
|
|
124
|
+
# The API reported `PasswordTooLong`.
|
|
125
|
+
class PasswordTooLongError < ProblemError; end
|
|
126
|
+
|
|
127
|
+
# The API reported `PasswordTooShort`.
|
|
128
|
+
class PasswordTooShortError < ProblemError; end
|
|
129
|
+
|
|
130
|
+
# The API reported `RateLimited`.
|
|
131
|
+
class RateLimitedError < ProblemError; end
|
|
132
|
+
|
|
133
|
+
# The API reported `RegistrationDisabled`.
|
|
134
|
+
class RegistrationDisabledError < ProblemError; end
|
|
135
|
+
|
|
136
|
+
# The API reported `ServiceUnavailable`.
|
|
137
|
+
class ServiceUnavailableError < ProblemError; end
|
|
138
|
+
|
|
139
|
+
# The API reported `TooManyApplicationsPerOrganization`.
|
|
140
|
+
class TooManyApplicationsPerOrganizationError < ProblemError; end
|
|
141
|
+
|
|
142
|
+
# The API reported `TooManyEventTypesPerApplication`.
|
|
143
|
+
class TooManyEventTypesPerApplicationError < ProblemError; end
|
|
144
|
+
|
|
145
|
+
# The API reported `TooManyEventsToday`.
|
|
146
|
+
class TooManyEventsTodayError < ProblemError; end
|
|
147
|
+
|
|
148
|
+
# The API reported `TooManyMembersPerOrganization`.
|
|
149
|
+
class TooManyMembersPerOrganizationError < ProblemError; end
|
|
150
|
+
|
|
151
|
+
# The API reported `TooManySubscriptionsPerApplication`.
|
|
152
|
+
class TooManySubscriptionsPerApplicationError < ProblemError; end
|
|
153
|
+
|
|
154
|
+
# The API reported `UnauthorizedWorkers`.
|
|
155
|
+
class UnauthorizedWorkersError < ProblemError; end
|
|
156
|
+
|
|
157
|
+
# The API reported `UserAlreadyExist`.
|
|
158
|
+
class UserAlreadyExistError < ProblemError; end
|
|
159
|
+
|
|
160
|
+
# The API reported `Validation`.
|
|
161
|
+
class ValidationError < ProblemError; end
|
|
162
|
+
|
|
163
|
+
# The exception each problem the API names is raised as.
|
|
164
|
+
PROBLEMS = {
|
|
165
|
+
ProblemId::APPLICATION_NAME_MISSING => ApplicationNameMissingError,
|
|
166
|
+
ProblemId::AUTH_APPLICATION_SECRET_LOOKUP_ERROR => AuthApplicationSecretLookupErrorError,
|
|
167
|
+
ProblemId::AUTH_BISCUIT_LOOKUP_ERROR => AuthBiscuitLookupErrorError,
|
|
168
|
+
ProblemId::AUTH_EMAIL_ALREADY_VERIFIED => AuthEmailAlreadyVerifiedError,
|
|
169
|
+
ProblemId::AUTH_EMAIL_EXPIRED => AuthEmailExpiredError,
|
|
170
|
+
ProblemId::AUTH_EMAIL_NOT_VERIFIED => AuthEmailNotVerifiedError,
|
|
171
|
+
ProblemId::AUTH_FAILED_LOGIN => AuthFailedLoginError,
|
|
172
|
+
ProblemId::AUTH_FAILED_REFRESH => AuthFailedRefreshError,
|
|
173
|
+
ProblemId::AUTH_INVALID_APPLICATION_SECRET => AuthInvalidApplicationSecretError,
|
|
174
|
+
ProblemId::AUTH_INVALID_AUTHORIZATION_HEADER => AuthInvalidAuthorizationHeaderError,
|
|
175
|
+
ProblemId::AUTH_INVALID_BISCUIT => AuthInvalidBiscuitError,
|
|
176
|
+
ProblemId::AUTH_NO_AUTHORIZATION_HEADER => AuthNoAuthorizationHeaderError,
|
|
177
|
+
ProblemId::EVENT_ALREADY_INGESTED => EventAlreadyIngestedError,
|
|
178
|
+
ProblemId::EVENT_INVALID_BASE64_PAYLOAD => EventInvalidBase64PayloadError,
|
|
179
|
+
ProblemId::EVENT_INVALID_JSON_PAYLOAD => EventInvalidJsonPayloadError,
|
|
180
|
+
ProblemId::EVENT_INVALID_PAYLOAD_CONTENT_TYPE => EventInvalidPayloadContentTypeError,
|
|
181
|
+
ProblemId::EVENT_TYPE_ALREADY_EXIST => EventTypeAlreadyExistError,
|
|
182
|
+
ProblemId::EVENT_TYPE_DOES_NOT_EXIST => EventTypeDoesNotExistError,
|
|
183
|
+
ProblemId::FORBIDDEN => ForbiddenError,
|
|
184
|
+
ProblemId::INTERNAL_SERVER_ERROR => InternalServerErrorError,
|
|
185
|
+
ProblemId::INVALID_DATE_RANGE => InvalidDateRangeError,
|
|
186
|
+
ProblemId::INVALID_ROLE => InvalidRoleError,
|
|
187
|
+
ProblemId::INVITED_USER_ALREADY_IN_ORGANIZATION => InvitedUserAlreadyInOrganizationError,
|
|
188
|
+
ProblemId::INVITED_USER_DOES_NOT_EXIST => InvitedUserDoesNotExistError,
|
|
189
|
+
ProblemId::JSON_PAYLOAD => JsonPayloadError,
|
|
190
|
+
ProblemId::LABELS_AMBIGUITY => LabelsAmbiguityError,
|
|
191
|
+
ProblemId::NOT_FOUND => NotFoundError,
|
|
192
|
+
ProblemId::ORGANIZATION_IS_NOT_EMPTY => OrganizationIsNotEmptyError,
|
|
193
|
+
ProblemId::ORGANIZATION_NAME_MISSING => OrganizationNameMissingError,
|
|
194
|
+
ProblemId::PASSWORD_NOT_DIVERSE_ENOUGH => PasswordNotDiverseEnoughError,
|
|
195
|
+
ProblemId::PASSWORD_SIMILAR_TO_EMAIL => PasswordSimilarToEmailError,
|
|
196
|
+
ProblemId::PASSWORD_SIMILAR_TO_NAME => PasswordSimilarToNameError,
|
|
197
|
+
ProblemId::PASSWORD_TOO_COMMON => PasswordTooCommonError,
|
|
198
|
+
ProblemId::PASSWORD_TOO_LONG => PasswordTooLongError,
|
|
199
|
+
ProblemId::PASSWORD_TOO_SHORT => PasswordTooShortError,
|
|
200
|
+
ProblemId::RATE_LIMITED => RateLimitedError,
|
|
201
|
+
ProblemId::REGISTRATION_DISABLED => RegistrationDisabledError,
|
|
202
|
+
ProblemId::SERVICE_UNAVAILABLE => ServiceUnavailableError,
|
|
203
|
+
ProblemId::TOO_MANY_APPLICATIONS_PER_ORGANIZATION => TooManyApplicationsPerOrganizationError,
|
|
204
|
+
ProblemId::TOO_MANY_EVENT_TYPES_PER_APPLICATION => TooManyEventTypesPerApplicationError,
|
|
205
|
+
ProblemId::TOO_MANY_EVENTS_TODAY => TooManyEventsTodayError,
|
|
206
|
+
ProblemId::TOO_MANY_MEMBERS_PER_ORGANIZATION => TooManyMembersPerOrganizationError,
|
|
207
|
+
ProblemId::TOO_MANY_SUBSCRIPTIONS_PER_APPLICATION => TooManySubscriptionsPerApplicationError,
|
|
208
|
+
ProblemId::UNAUTHORIZED_WORKERS => UnauthorizedWorkersError,
|
|
209
|
+
ProblemId::USER_ALREADY_EXIST => UserAlreadyExistError,
|
|
210
|
+
ProblemId::VALIDATION => ValidationError
|
|
211
|
+
}.freeze
|
|
212
|
+
|
|
213
|
+
# Raise what the API reported, when what it answered was not a success.
|
|
214
|
+
#
|
|
215
|
+
# @param status [Integer] what the API answered under
|
|
216
|
+
# @param payload [String] the body it answered
|
|
217
|
+
# @return [void]
|
|
218
|
+
# @raise [ProblemError] whichever problem the body names, and the base one when it names none
|
|
219
|
+
def self.raise_for_status(status, payload)
|
|
220
|
+
return if status >= 200 && status < 300
|
|
221
|
+
|
|
222
|
+
begin
|
|
223
|
+
problem = Problem.from_json(Runtime.decode_payload(payload))
|
|
224
|
+
rescue Runtime::DecodeError
|
|
225
|
+
problem = nil
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
if problem.nil? || !PROBLEMS.key?(problem.id)
|
|
229
|
+
raise ProblemError.new(status, problem, Runtime.unreadable(status, payload))
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
raise PROBLEMS.fetch(problem.id).new(status, problem, Runtime.reported(status, problem))
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
end
|