Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
299 changes: 299 additions & 0 deletions Sources/interactions/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,305 @@ public struct Client: APIProtocol {
}
)
}
/// Get pull request creation cap for an org
///
/// Gets the pull request creation cap configuration for an organization.
/// The cap limits the total number of open pull requests a user can have across all public
/// repositories in the organization at one time.
///
/// Only users with admin access to the organization can view the cap configuration.
///
/// - Remark: HTTP `GET /orgs/{org}/interaction-limits/pulls/creation-cap`.
/// - Remark: Generated from `#/paths//orgs/{org}/interaction-limits/pulls/creation-cap/get(interactions/get-pull-request-creation-cap-for-org)`.
public func interactionsGetPullRequestCreationCapForOrg(_ input: Operations.InteractionsGetPullRequestCreationCapForOrg.Input) async throws -> Operations.InteractionsGetPullRequestCreationCapForOrg.Output {
try await client.send(
input: input,
forOperation: Operations.InteractionsGetPullRequestCreationCapForOrg.id,
serializer: { input in
let path = try converter.renderedPath(
template: "/orgs/{}/interaction-limits/pulls/creation-cap",
parameters: [
input.path.org
]
)
var request: HTTPTypes.HTTPRequest = .init(
soar_path: path,
method: .get
)
suppressMutabilityWarning(&request)
converter.setAcceptHeader(
in: &request.headerFields,
contentTypes: input.headers.accept
)
return (request, nil)
},
deserializer: { response, responseBody in
switch response.status.code {
case 200:
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
let body: Operations.InteractionsGetPullRequestCreationCapForOrg.Output.Ok.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
"application/json"
]
)
switch chosenContentType {
case "application/json":
body = try await converter.getResponseBodyAsJSON(
Operations.InteractionsGetPullRequestCreationCapForOrg.Output.Ok.Body.JsonPayload.self,
from: responseBody,
transforming: { value in
.json(value)
}
)
default:
preconditionFailure("bestContentType chose an invalid content type.")
}
return .ok(.init(body: body))
case 403:
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
let body: Components.Responses.Forbidden.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
"application/json"
]
)
switch chosenContentType {
case "application/json":
body = try await converter.getResponseBodyAsJSON(
Components.Schemas.BasicError.self,
from: responseBody,
transforming: { value in
.json(value)
}
)
default:
preconditionFailure("bestContentType chose an invalid content type.")
}
return .forbidden(.init(body: body))
case 404:
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
let body: Components.Responses.NotFound.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
"application/json"
]
)
switch chosenContentType {
case "application/json":
body = try await converter.getResponseBodyAsJSON(
Components.Schemas.BasicError.self,
from: responseBody,
transforming: { value in
.json(value)
}
)
default:
preconditionFailure("bestContentType chose an invalid content type.")
}
return .notFound(.init(body: body))
case 405:
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
let body: Operations.InteractionsGetPullRequestCreationCapForOrg.Output.MethodNotAllowed.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
"application/json"
]
)
switch chosenContentType {
case "application/json":
body = try await converter.getResponseBodyAsJSON(
Components.Schemas.BasicError.self,
from: responseBody,
transforming: { value in
.json(value)
}
)
default:
preconditionFailure("bestContentType chose an invalid content type.")
}
return .methodNotAllowed(.init(body: body))
default:
return .undocumented(
statusCode: response.status.code,
.init(
headerFields: response.headerFields,
body: responseBody
)
)
}
}
)
}
/// Update pull request creation cap for an org
///
/// Updates the pull request creation cap for an organization. The cap limits the total number
/// of open pull requests a user can have across all public repositories in the organization
/// at one time.
///
/// Only users with admin access to the organization can configure the cap.
///
/// - Remark: HTTP `PATCH /orgs/{org}/interaction-limits/pulls/creation-cap`.
/// - Remark: Generated from `#/paths//orgs/{org}/interaction-limits/pulls/creation-cap/patch(interactions/update-pull-request-creation-cap-for-org)`.
public func interactionsUpdatePullRequestCreationCapForOrg(_ input: Operations.InteractionsUpdatePullRequestCreationCapForOrg.Input) async throws -> Operations.InteractionsUpdatePullRequestCreationCapForOrg.Output {
try await client.send(
input: input,
forOperation: Operations.InteractionsUpdatePullRequestCreationCapForOrg.id,
serializer: { input in
let path = try converter.renderedPath(
template: "/orgs/{}/interaction-limits/pulls/creation-cap",
parameters: [
input.path.org
]
)
var request: HTTPTypes.HTTPRequest = .init(
soar_path: path,
method: .patch
)
suppressMutabilityWarning(&request)
converter.setAcceptHeader(
in: &request.headerFields,
contentTypes: input.headers.accept
)
let body: OpenAPIRuntime.HTTPBody?
switch input.body {
case let .json(value):
body = try converter.setRequiredRequestBodyAsJSON(
value,
headerFields: &request.headerFields,
contentType: "application/json; charset=utf-8"
)
}
return (request, body)
},
deserializer: { response, responseBody in
switch response.status.code {
case 200:
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
let body: Operations.InteractionsUpdatePullRequestCreationCapForOrg.Output.Ok.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
"application/json"
]
)
switch chosenContentType {
case "application/json":
body = try await converter.getResponseBodyAsJSON(
Operations.InteractionsUpdatePullRequestCreationCapForOrg.Output.Ok.Body.JsonPayload.self,
from: responseBody,
transforming: { value in
.json(value)
}
)
default:
preconditionFailure("bestContentType chose an invalid content type.")
}
return .ok(.init(body: body))
case 403:
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
let body: Components.Responses.Forbidden.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
"application/json"
]
)
switch chosenContentType {
case "application/json":
body = try await converter.getResponseBodyAsJSON(
Components.Schemas.BasicError.self,
from: responseBody,
transforming: { value in
.json(value)
}
)
default:
preconditionFailure("bestContentType chose an invalid content type.")
}
return .forbidden(.init(body: body))
case 404:
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
let body: Components.Responses.NotFound.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
"application/json"
]
)
switch chosenContentType {
case "application/json":
body = try await converter.getResponseBodyAsJSON(
Components.Schemas.BasicError.self,
from: responseBody,
transforming: { value in
.json(value)
}
)
default:
preconditionFailure("bestContentType chose an invalid content type.")
}
return .notFound(.init(body: body))
case 405:
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
let body: Operations.InteractionsUpdatePullRequestCreationCapForOrg.Output.MethodNotAllowed.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
"application/json"
]
)
switch chosenContentType {
case "application/json":
body = try await converter.getResponseBodyAsJSON(
Components.Schemas.BasicError.self,
from: responseBody,
transforming: { value in
.json(value)
}
)
default:
preconditionFailure("bestContentType chose an invalid content type.")
}
return .methodNotAllowed(.init(body: body))
case 422:
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
let body: Components.Responses.ValidationFailed.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
"application/json"
]
)
switch chosenContentType {
case "application/json":
body = try await converter.getResponseBodyAsJSON(
Components.Schemas.ValidationError.self,
from: responseBody,
transforming: { value in
.json(value)
}
)
default:
preconditionFailure("bestContentType chose an invalid content type.")
}
return .unprocessableContent(.init(body: body))
default:
return .undocumented(
statusCode: response.status.code,
.init(
headerFields: response.headerFields,
body: responseBody
)
)
}
}
)
}
/// Get interaction restrictions for a repository
///
/// Shows which type of GitHub user can interact with this repository and when the restriction expires. If there are no restrictions, you will see an empty response.
Expand Down
Loading