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
1 change: 1 addition & 0 deletions .spi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ builder:
- GitHubRestAPICodes_Of_Conduct
- GitHubRestAPICodespaces
- GitHubRestAPICopilot
- GitHubRestAPICredentials
- GitHubRestAPIDependabot
- GitHubRestAPIDependency_Graph
- GitHubRestAPIDesktop
Expand Down
9 changes: 9 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ let package = Package(
.library(name: "GitHubRestAPICodes_Of_Conduct", targets: ["GitHubRestAPICodes_Of_Conduct"]),
.library(name: "GitHubRestAPICodespaces", targets: ["GitHubRestAPICodespaces"]),
.library(name: "GitHubRestAPICopilot", targets: ["GitHubRestAPICopilot"]),
.library(name: "GitHubRestAPICredentials", targets: ["GitHubRestAPICredentials"]),
.library(name: "GitHubRestAPIDependabot", targets: ["GitHubRestAPIDependabot"]),
.library(name: "GitHubRestAPIDependency_Graph", targets: ["GitHubRestAPIDependency_Graph"]),
.library(name: "GitHubRestAPIDesktop", targets: ["GitHubRestAPIDesktop"]),
Expand Down Expand Up @@ -155,6 +156,14 @@ let package = Package(
],
path: "Sources/copilot"
),
.target(
name: "GitHubRestAPICredentials",
dependencies: [
.product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
.product(name: "OpenAPIURLSession", package: "swift-openapi-urlsession"),
],
path: "Sources/credentials"
),
.target(
name: "GitHubRestAPIDependabot",
dependencies: [
Expand Down
191 changes: 191 additions & 0 deletions Sources/billing/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -637,4 +637,195 @@ public struct Client: APIProtocol {
}
)
}
/// Get billing usage report for a user
///
/// Gets a report of the total usage for a user.
///
/// **Note:** This endpoint is only available to users with access to the enhanced billing platform.
///
/// - Remark: HTTP `GET /users/{username}/settings/billing/usage`.
/// - Remark: Generated from `#/paths//users/{username}/settings/billing/usage/get(billing/get-github-billing-usage-report-user)`.
public func billingGetGithubBillingUsageReportUser(_ input: Operations.BillingGetGithubBillingUsageReportUser.Input) async throws -> Operations.BillingGetGithubBillingUsageReportUser.Output {
try await client.send(
input: input,
forOperation: Operations.BillingGetGithubBillingUsageReportUser.id,
serializer: { input in
let path = try converter.renderedPath(
template: "/users/{}/settings/billing/usage",
parameters: [
input.path.username
]
)
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.BillingUsageReportUser.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
"application/json"
]
)
switch chosenContentType {
case "application/json":
body = try await converter.getResponseBodyAsJSON(
Components.Schemas.BillingUsageReportUser.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.BadRequest.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.BasicError.self,
from: responseBody,
transforming: { value in
.json(value)
}
)
case "application/scim+json":
body = try await converter.getResponseBodyAsJSON(
Components.Schemas.ScimError.self,
from: responseBody,
transforming: { value in
.applicationScimJson(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.BasicError.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.InternalError.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 .internalServerError(.init(body: body))
case 503:
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
let body: Components.Responses.ServiceUnavailable.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
"application/json"
]
)
switch chosenContentType {
case "application/json":
body = try await converter.getResponseBodyAsJSON(
Components.Responses.ServiceUnavailable.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
)
)
}
}
)
}
}
Loading