Skip to content

Bump Submodule/github/rest-api-description from a0508ce to b2ff88e #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
191 changes: 191 additions & 0 deletions Sources/billing/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,197 @@ public struct Client: APIProtocol {
private var converter: Converter {
client.converter
}
/// Get billing usage report for an organization
///
/// Gets a report of the total usage for an organization. To use this endpoint, you must be an administrator of an organization within an enterprise or an organization account.
///
/// **Note:** This endpoint is only available to organizations with access to the enhanced billing platform. For more information, see "[About the enhanced billing platform](https://docs.github.com/billing/using-the-new-billing-platform)."
///
/// - Remark: HTTP `GET /organizations/{org}/settings/billing/usage`.
/// - Remark: Generated from `#/paths//organizations/{org}/settings/billing/usage/get(billing/get-github-billing-usage-report-org)`.
public func billing_sol_get_hyphen_github_hyphen_billing_hyphen_usage_hyphen_report_hyphen_org(_ input: Operations.billing_sol_get_hyphen_github_hyphen_billing_hyphen_usage_hyphen_report_hyphen_org.Input) async throws -> Operations.billing_sol_get_hyphen_github_hyphen_billing_hyphen_usage_hyphen_report_hyphen_org.Output {
try await client.send(
input: input,
forOperation: Operations.billing_sol_get_hyphen_github_hyphen_billing_hyphen_usage_hyphen_report_hyphen_org.id,
serializer: { input in
let path = try converter.renderedPath(
template: "/organizations/{}/settings/billing/usage",
parameters: [
input.path.org
]
)
var request: HTTPTypes.HTTPRequest = .init(
soar_path: path,
method: .get
)
suppressMutabilityWarning(&request)
try converter.setQueryItemAsURI(
in: &request,
style: .form,
explode: true,
name: "year",
value: input.query.year
)
try converter.setQueryItemAsURI(
in: &request,
style: .form,
explode: true,
name: "month",
value: input.query.month
)
try converter.setQueryItemAsURI(
in: &request,
style: .form,
explode: true,
name: "day",
value: input.query.day
)
try converter.setQueryItemAsURI(
in: &request,
style: .form,
explode: true,
name: "hour",
value: input.query.hour
)
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: Components.Responses.billing_usage_report_org.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
"application/json"
]
)
switch chosenContentType {
case "application/json":
body = try await converter.getResponseBodyAsJSON(
Components.Schemas.billing_hyphen_usage_hyphen_report.self,
from: responseBody,
transforming: { value in
.json(value)
}
)
default:
preconditionFailure("bestContentType chose an invalid content type.")
}
return .ok(.init(body: body))
case 400:
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
let body: Components.Responses.bad_request.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
"application/json",
"application/scim+json"
]
)
switch chosenContentType {
case "application/json":
body = try await converter.getResponseBodyAsJSON(
Components.Schemas.basic_hyphen_error.self,
from: responseBody,
transforming: { value in
.json(value)
}
)
case "application/scim+json":
body = try await converter.getResponseBodyAsJSON(
Components.Schemas.scim_hyphen_error.self,
from: responseBody,
transforming: { value in
.application_scim_plus_json(value)
}
)
default:
preconditionFailure("bestContentType chose an invalid content type.")
}
return .badRequest(.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.basic_hyphen_error.self,
from: responseBody,
transforming: { value in
.json(value)
}
)
default:
preconditionFailure("bestContentType chose an invalid content type.")
}
return .forbidden(.init(body: body))
case 500:
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
let body: Components.Responses.internal_error.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
"application/json"
]
)
switch chosenContentType {
case "application/json":
body = try await converter.getResponseBodyAsJSON(
Components.Schemas.basic_hyphen_error.self,
from: responseBody,
transforming: { value in
.json(value)
}
)
default:
preconditionFailure("bestContentType chose an invalid content type.")
}
return .internalServerError(.init(body: body))
case 503:
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
let body: Components.Responses.service_unavailable.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
"application/json"
]
)
switch chosenContentType {
case "application/json":
body = try await converter.getResponseBodyAsJSON(
Components.Responses.service_unavailable.Body.jsonPayload.self,
from: responseBody,
transforming: { value in
.json(value)
}
)
default:
preconditionFailure("bestContentType chose an invalid content type.")
}
return .serviceUnavailable(.init(body: body))
default:
return .undocumented(
statusCode: response.status.code,
.init(
headerFields: response.headerFields,
body: responseBody
)
)
}
}
)
}
/// Get GitHub Actions billing for an organization
///
/// Gets the summary of the free and paid GitHub Actions minutes used.
Expand Down
Loading