refactor(api): scope oauth operations by integration
This commit is contained in:
parent
fd19fa89c4
commit
a772767e9b
19 changed files with 404 additions and 303 deletions
|
|
@ -58,7 +58,7 @@ export const IntegrationGroup = HttpApiGroup.make("server.integration")
|
|||
),
|
||||
)
|
||||
.add(
|
||||
HttpApiEndpoint.post("integration.connect.oauth", "/api/integration/:integrationID/connect/oauth", {
|
||||
HttpApiEndpoint.post("integration.oauth.connect", "/api/integration/:integrationID/connect/oauth", {
|
||||
params: { integrationID: Integration.ID },
|
||||
query: LocationQuery,
|
||||
payload: Schema.Struct({
|
||||
|
|
@ -72,54 +72,58 @@ export const IntegrationGroup = HttpApiGroup.make("server.integration")
|
|||
.annotateMerge(locationQueryOpenApi)
|
||||
.annotateMerge(
|
||||
OpenApi.annotations({
|
||||
identifier: "v2.integration.connect.oauth",
|
||||
identifier: "v2.integration.oauth.connect",
|
||||
summary: "Begin OAuth connection",
|
||||
description: "Start an OAuth attempt and return the authorization details.",
|
||||
}),
|
||||
),
|
||||
)
|
||||
.add(
|
||||
HttpApiEndpoint.get("integration.attempt.status", "/api/integration/attempt/:attemptID", {
|
||||
params: { attemptID: Integration.AttemptID },
|
||||
HttpApiEndpoint.get("integration.oauth.status", "/api/integration/:integrationID/connect/oauth/:attemptID", {
|
||||
params: { integrationID: Integration.ID, attemptID: Integration.AttemptID },
|
||||
query: LocationQuery,
|
||||
success: Location.response(Integration.AttemptStatus),
|
||||
})
|
||||
.annotateMerge(locationQueryOpenApi)
|
||||
.annotateMerge(
|
||||
OpenApi.annotations({
|
||||
identifier: "v2.integration.attempt.status",
|
||||
identifier: "v2.integration.oauth.status",
|
||||
summary: "Get OAuth attempt status",
|
||||
description: "Poll the current status of an OAuth attempt.",
|
||||
}),
|
||||
),
|
||||
)
|
||||
.add(
|
||||
HttpApiEndpoint.post("integration.attempt.complete", "/api/integration/attempt/:attemptID/complete", {
|
||||
params: { attemptID: Integration.AttemptID },
|
||||
query: LocationQuery,
|
||||
payload: Schema.Struct({ code: Schema.optional(Schema.String) }),
|
||||
success: HttpApiSchema.NoContent,
|
||||
error: InvalidRequestError,
|
||||
})
|
||||
HttpApiEndpoint.post(
|
||||
"integration.oauth.complete",
|
||||
"/api/integration/:integrationID/connect/oauth/:attemptID/complete",
|
||||
{
|
||||
params: { integrationID: Integration.ID, attemptID: Integration.AttemptID },
|
||||
query: LocationQuery,
|
||||
payload: Schema.Struct({ code: Schema.optional(Schema.String) }),
|
||||
success: HttpApiSchema.NoContent,
|
||||
error: InvalidRequestError,
|
||||
},
|
||||
)
|
||||
.annotateMerge(locationQueryOpenApi)
|
||||
.annotateMerge(
|
||||
OpenApi.annotations({
|
||||
identifier: "v2.integration.attempt.complete",
|
||||
identifier: "v2.integration.oauth.complete",
|
||||
summary: "Complete OAuth connection",
|
||||
description: "Complete a code-based OAuth attempt and store the resulting credential.",
|
||||
}),
|
||||
),
|
||||
)
|
||||
.add(
|
||||
HttpApiEndpoint.delete("integration.attempt.cancel", "/api/integration/attempt/:attemptID", {
|
||||
params: { attemptID: Integration.AttemptID },
|
||||
HttpApiEndpoint.delete("integration.oauth.cancel", "/api/integration/:integrationID/connect/oauth/:attemptID", {
|
||||
params: { integrationID: Integration.ID, attemptID: Integration.AttemptID },
|
||||
query: LocationQuery,
|
||||
success: HttpApiSchema.NoContent,
|
||||
})
|
||||
.annotateMerge(locationQueryOpenApi)
|
||||
.annotateMerge(
|
||||
OpenApi.annotations({
|
||||
identifier: "v2.integration.attempt.cancel",
|
||||
identifier: "v2.integration.oauth.cancel",
|
||||
summary: "Cancel OAuth connection",
|
||||
description: "Cancel an OAuth attempt and release its resources.",
|
||||
}),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue