From 89e0dd022b1cc0c5ae1e252cfbf54f55daad9c11 Mon Sep 17 00:00:00 2001 From: Wei <11254896+wei18@users.noreply.github.com> Date: Sun, 4 May 2025 22:09:50 +0800 Subject: [PATCH 1/7] Update Makefile - to fix typo commit message --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 00ec777e20..3f86781f42 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ MINT_BIN := $(HOME)/.mint/bin/mint .PHONY: commit commit: git add "$(file)" - git commit -m "Commit via running $make $(file)" >/dev/null \ + git commit -m "Commit via running: make $(file)" >/dev/null \ && echo "::notice:: git commit $(file)\n" \ || true; touch "$(file)"; From 00648aa54149a214151e7e8d2c7d2684e35ce2a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 May 2025 22:12:46 +0000 Subject: [PATCH 2/7] Bump Submodule/github/rest-api-description from `7291aeb` to `467f6a9` Bumps [Submodule/github/rest-api-description](https://github.com/github/rest-api-description) from `7291aeb` to `467f6a9`. - [Release notes](https://github.com/github/rest-api-description/releases) - [Commits](https://github.com/github/rest-api-description/compare/7291aebf74227b541192db318cb6d5ec7d9388e9...467f6a98a97a73630a1f1e75ddee01cb59f33dd5) --- updated-dependencies: - dependency-name: Submodule/github/rest-api-description dependency-version: 467f6a98a97a73630a1f1e75ddee01cb59f33dd5 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Submodule/github/rest-api-description | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Submodule/github/rest-api-description b/Submodule/github/rest-api-description index 7291aebf74..467f6a98a9 160000 --- a/Submodule/github/rest-api-description +++ b/Submodule/github/rest-api-description @@ -1 +1 @@ -Subproject commit 7291aebf74227b541192db318cb6d5ec7d9388e9 +Subproject commit 467f6a98a97a73630a1f1e75ddee01cb59f33dd5 From f6b1fb0ed821c0484f25f3fc50557d507708320f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 5 May 2025 22:37:39 +0000 Subject: [PATCH 3/7] Commit via running: make Sources/billing --- Sources/billing/Client.swift | 191 ++++++++++++++++ Sources/billing/Types.swift | 409 +++++++++++++++++++++++++++++++++++ 2 files changed, 600 insertions(+) diff --git a/Sources/billing/Client.swift b/Sources/billing/Client.swift index fdabab8fdf..3ee2570c21 100644 --- a/Sources/billing/Client.swift +++ b/Sources/billing/Client.swift @@ -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 + ) + ) + } + } + ) + } } diff --git a/Sources/billing/Types.swift b/Sources/billing/Types.swift index 549411ba67..732d2a61fa 100644 --- a/Sources/billing/Types.swift +++ b/Sources/billing/Types.swift @@ -86,6 +86,15 @@ public protocol APIProtocol: Sendable { /// - Remark: HTTP `GET /users/{username}/settings/billing/shared-storage`. /// - Remark: Generated from `#/paths//users/{username}/settings/billing/shared-storage/get(billing/get-shared-storage-billing-user)`. func billingGetSharedStorageBillingUser(_ input: Operations.BillingGetSharedStorageBillingUser.Input) async throws -> Operations.BillingGetSharedStorageBillingUser.Output + /// 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)`. + func billingGetGithubBillingUsageReportUser(_ input: Operations.BillingGetGithubBillingUsageReportUser.Input) async throws -> Operations.BillingGetGithubBillingUsageReportUser.Output } /// Convenience overloads for operation inputs. @@ -223,6 +232,25 @@ extension APIProtocol { headers: headers )) } + /// 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( + path: Operations.BillingGetGithubBillingUsageReportUser.Input.Path, + query: Operations.BillingGetGithubBillingUsageReportUser.Input.Query = .init(), + headers: Operations.BillingGetGithubBillingUsageReportUser.Input.Headers = .init() + ) async throws -> Operations.BillingGetGithubBillingUsageReportUser.Output { + try await billingGetGithubBillingUsageReportUser(Operations.BillingGetGithubBillingUsageReportUser.Input( + path: path, + query: query, + headers: headers + )) + } } /// Server URLs defined in the OpenAPI document. @@ -692,6 +720,114 @@ public enum Components { case estimatedStorageForMonth = "estimated_storage_for_month" } } + /// - Remark: Generated from `#/components/schemas/billing-usage-report-user`. + public struct BillingUsageReportUser: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/billing-usage-report-user/UsageItemsPayload`. + public struct UsageItemsPayloadPayload: Codable, Hashable, Sendable { + /// Date of the usage line item. + /// + /// - Remark: Generated from `#/components/schemas/billing-usage-report-user/UsageItemsPayload/date`. + public var date: Swift.String + /// Product name. + /// + /// - Remark: Generated from `#/components/schemas/billing-usage-report-user/UsageItemsPayload/product`. + public var product: Swift.String + /// SKU name. + /// + /// - Remark: Generated from `#/components/schemas/billing-usage-report-user/UsageItemsPayload/sku`. + public var sku: Swift.String + /// Quantity of the usage line item. + /// + /// - Remark: Generated from `#/components/schemas/billing-usage-report-user/UsageItemsPayload/quantity`. + public var quantity: Swift.Int + /// Unit type of the usage line item. + /// + /// - Remark: Generated from `#/components/schemas/billing-usage-report-user/UsageItemsPayload/unitType`. + public var unitType: Swift.String + /// Price per unit of the usage line item. + /// + /// - Remark: Generated from `#/components/schemas/billing-usage-report-user/UsageItemsPayload/pricePerUnit`. + public var pricePerUnit: Swift.Double + /// Gross amount of the usage line item. + /// + /// - Remark: Generated from `#/components/schemas/billing-usage-report-user/UsageItemsPayload/grossAmount`. + public var grossAmount: Swift.Double + /// Discount amount of the usage line item. + /// + /// - Remark: Generated from `#/components/schemas/billing-usage-report-user/UsageItemsPayload/discountAmount`. + public var discountAmount: Swift.Double + /// Net amount of the usage line item. + /// + /// - Remark: Generated from `#/components/schemas/billing-usage-report-user/UsageItemsPayload/netAmount`. + public var netAmount: Swift.Double + /// Name of the repository. + /// + /// - Remark: Generated from `#/components/schemas/billing-usage-report-user/UsageItemsPayload/repositoryName`. + public var repositoryName: Swift.String? + /// Creates a new `UsageItemsPayloadPayload`. + /// + /// - Parameters: + /// - date: Date of the usage line item. + /// - product: Product name. + /// - sku: SKU name. + /// - quantity: Quantity of the usage line item. + /// - unitType: Unit type of the usage line item. + /// - pricePerUnit: Price per unit of the usage line item. + /// - grossAmount: Gross amount of the usage line item. + /// - discountAmount: Discount amount of the usage line item. + /// - netAmount: Net amount of the usage line item. + /// - repositoryName: Name of the repository. + public init( + date: Swift.String, + product: Swift.String, + sku: Swift.String, + quantity: Swift.Int, + unitType: Swift.String, + pricePerUnit: Swift.Double, + grossAmount: Swift.Double, + discountAmount: Swift.Double, + netAmount: Swift.Double, + repositoryName: Swift.String? = nil + ) { + self.date = date + self.product = product + self.sku = sku + self.quantity = quantity + self.unitType = unitType + self.pricePerUnit = pricePerUnit + self.grossAmount = grossAmount + self.discountAmount = discountAmount + self.netAmount = netAmount + self.repositoryName = repositoryName + } + public enum CodingKeys: String, CodingKey { + case date + case product + case sku + case quantity + case unitType + case pricePerUnit + case grossAmount + case discountAmount + case netAmount + case repositoryName + } + } + /// - Remark: Generated from `#/components/schemas/billing-usage-report-user/usageItems`. + public typealias UsageItemsPayload = [Components.Schemas.BillingUsageReportUser.UsageItemsPayloadPayload] + /// - Remark: Generated from `#/components/schemas/billing-usage-report-user/usageItems`. + public var usageItems: Components.Schemas.BillingUsageReportUser.UsageItemsPayload? + /// Creates a new `BillingUsageReportUser`. + /// + /// - Parameters: + /// - usageItems: + public init(usageItems: Components.Schemas.BillingUsageReportUser.UsageItemsPayload? = nil) { + self.usageItems = usageItems + } + public enum CodingKeys: String, CodingKey { + case usageItems + } + } } /// Types generated from the `#/components/parameters` section of the OpenAPI document. public enum Parameters { @@ -917,6 +1053,34 @@ public enum Components { self.body = body } } + public struct BillingUsageReportUser: Sendable, Hashable { + /// - Remark: Generated from `#/components/responses/billing_usage_report_user/content`. + @frozen public enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/components/responses/billing_usage_report_user/content/application\/json`. + case json(Components.Schemas.BillingUsageReportUser) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + public var json: Components.Schemas.BillingUsageReportUser { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + public var body: Components.Responses.BillingUsageReportUser.Body + /// Creates a new `BillingUsageReportUser`. + /// + /// - Parameters: + /// - body: Received HTTP response body + public init(body: Components.Responses.BillingUsageReportUser.Body) { + self.body = body + } + } } /// Types generated from the `#/components/headers` section of the OpenAPI document. public enum Headers {} @@ -1985,4 +2149,249 @@ public enum Operations { } } } + /// 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 enum BillingGetGithubBillingUsageReportUser { + public static let id: Swift.String = "billing/get-github-billing-usage-report-user" + public struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/users/{username}/settings/billing/usage/GET/path`. + public struct Path: Sendable, Hashable { + /// The handle for the GitHub user account. + /// + /// - Remark: Generated from `#/paths/users/{username}/settings/billing/usage/GET/path/username`. + public var username: Components.Parameters.Username + /// Creates a new `Path`. + /// + /// - Parameters: + /// - username: The handle for the GitHub user account. + public init(username: Components.Parameters.Username) { + self.username = username + } + } + public var path: Operations.BillingGetGithubBillingUsageReportUser.Input.Path + /// - Remark: Generated from `#/paths/users/{username}/settings/billing/usage/GET/query`. + public struct Query: Sendable, Hashable { + /// If specified, only return results for a single year. The value of `year` is an integer with four digits representing a year. For example, `2025`. Default value is the current year. + /// + /// - Remark: Generated from `#/paths/users/{username}/settings/billing/usage/GET/query/year`. + public var year: Components.Parameters.BillingUsageReportYear? + /// If specified, only return results for a single month. The value of `month` is an integer between `1` and `12`. If no year is specified the default `year` is used. + /// + /// - Remark: Generated from `#/paths/users/{username}/settings/billing/usage/GET/query/month`. + public var month: Components.Parameters.BillingUsageReportMonth? + /// If specified, only return results for a single day. The value of `day` is an integer between `1` and `31`. If no `year` or `month` is specified, the default `year` and `month` are used. + /// + /// - Remark: Generated from `#/paths/users/{username}/settings/billing/usage/GET/query/day`. + public var day: Components.Parameters.BillingUsageReportDay? + /// If specified, only return results for a single hour. The value of `hour` is an integer between `0` and `23`. If no `year`, `month`, or `day` is specified, the default `year`, `month`, and `day` are used. + /// + /// - Remark: Generated from `#/paths/users/{username}/settings/billing/usage/GET/query/hour`. + public var hour: Components.Parameters.BillingUsageReportHour? + /// Creates a new `Query`. + /// + /// - Parameters: + /// - year: If specified, only return results for a single year. The value of `year` is an integer with four digits representing a year. For example, `2025`. Default value is the current year. + /// - month: If specified, only return results for a single month. The value of `month` is an integer between `1` and `12`. If no year is specified the default `year` is used. + /// - day: If specified, only return results for a single day. The value of `day` is an integer between `1` and `31`. If no `year` or `month` is specified, the default `year` and `month` are used. + /// - hour: If specified, only return results for a single hour. The value of `hour` is an integer between `0` and `23`. If no `year`, `month`, or `day` is specified, the default `year`, `month`, and `day` are used. + public init( + year: Components.Parameters.BillingUsageReportYear? = nil, + month: Components.Parameters.BillingUsageReportMonth? = nil, + day: Components.Parameters.BillingUsageReportDay? = nil, + hour: Components.Parameters.BillingUsageReportHour? = nil + ) { + self.year = year + self.month = month + self.day = day + self.hour = hour + } + } + public var query: Operations.BillingGetGithubBillingUsageReportUser.Input.Query + /// - Remark: Generated from `#/paths/users/{username}/settings/billing/usage/GET/header`. + public struct Headers: Sendable, Hashable { + public var accept: [OpenAPIRuntime.AcceptHeaderContentType] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + public init(accept: [OpenAPIRuntime.AcceptHeaderContentType] = .defaultValues()) { + self.accept = accept + } + } + public var headers: Operations.BillingGetGithubBillingUsageReportUser.Input.Headers + /// Creates a new `Input`. + /// + /// - Parameters: + /// - path: + /// - query: + /// - headers: + public init( + path: Operations.BillingGetGithubBillingUsageReportUser.Input.Path, + query: Operations.BillingGetGithubBillingUsageReportUser.Input.Query = .init(), + headers: Operations.BillingGetGithubBillingUsageReportUser.Input.Headers = .init() + ) { + self.path = path + self.query = query + self.headers = headers + } + } + @frozen public enum Output: Sendable, Hashable { + /// Response when getting a billing usage report + /// + /// - Remark: Generated from `#/paths//users/{username}/settings/billing/usage/get(billing/get-github-billing-usage-report-user)/responses/200`. + /// + /// HTTP response code: `200 ok`. + case ok(Components.Responses.BillingUsageReportUser) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + public var ok: Components.Responses.BillingUsageReportUser { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } + /// Bad Request + /// + /// - Remark: Generated from `#/paths//users/{username}/settings/billing/usage/get(billing/get-github-billing-usage-report-user)/responses/400`. + /// + /// HTTP response code: `400 badRequest`. + case badRequest(Components.Responses.BadRequest) + /// The associated value of the enum case if `self` is `.badRequest`. + /// + /// - Throws: An error if `self` is not `.badRequest`. + /// - SeeAlso: `.badRequest`. + public var badRequest: Components.Responses.BadRequest { + get throws { + switch self { + case let .badRequest(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "badRequest", + response: self + ) + } + } + } + /// Forbidden + /// + /// - Remark: Generated from `#/paths//users/{username}/settings/billing/usage/get(billing/get-github-billing-usage-report-user)/responses/403`. + /// + /// HTTP response code: `403 forbidden`. + case forbidden(Components.Responses.Forbidden) + /// The associated value of the enum case if `self` is `.forbidden`. + /// + /// - Throws: An error if `self` is not `.forbidden`. + /// - SeeAlso: `.forbidden`. + public var forbidden: Components.Responses.Forbidden { + get throws { + switch self { + case let .forbidden(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "forbidden", + response: self + ) + } + } + } + /// Internal Error + /// + /// - Remark: Generated from `#/paths//users/{username}/settings/billing/usage/get(billing/get-github-billing-usage-report-user)/responses/500`. + /// + /// HTTP response code: `500 internalServerError`. + case internalServerError(Components.Responses.InternalError) + /// The associated value of the enum case if `self` is `.internalServerError`. + /// + /// - Throws: An error if `self` is not `.internalServerError`. + /// - SeeAlso: `.internalServerError`. + public var internalServerError: Components.Responses.InternalError { + get throws { + switch self { + case let .internalServerError(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "internalServerError", + response: self + ) + } + } + } + /// Service unavailable + /// + /// - Remark: Generated from `#/paths//users/{username}/settings/billing/usage/get(billing/get-github-billing-usage-report-user)/responses/503`. + /// + /// HTTP response code: `503 serviceUnavailable`. + case serviceUnavailable(Components.Responses.ServiceUnavailable) + /// The associated value of the enum case if `self` is `.serviceUnavailable`. + /// + /// - Throws: An error if `self` is not `.serviceUnavailable`. + /// - SeeAlso: `.serviceUnavailable`. + public var serviceUnavailable: Components.Responses.ServiceUnavailable { + get throws { + switch self { + case let .serviceUnavailable(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "serviceUnavailable", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen public enum AcceptableContentType: AcceptableProtocol { + case json + case applicationScimJson + case other(Swift.String) + public init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + case "application/scim+json": + self = .applicationScimJson + default: + self = .other(rawValue) + } + } + public var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + case .applicationScimJson: + return "application/scim+json" + } + } + public static var allCases: [Self] { + [ + .json, + .applicationScimJson + ] + } + } + } } From a2b12b7f1b216fae289c6af3f817440526f7a770 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 5 May 2025 22:47:20 +0000 Subject: [PATCH 4/7] Commit via running: make Sources/secret-scanning --- Sources/secret-scanning/Types.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/secret-scanning/Types.swift b/Sources/secret-scanning/Types.swift index 61bbdaa0b9..c8ff4d6a54 100644 --- a/Sources/secret-scanning/Types.swift +++ b/Sources/secret-scanning/Types.swift @@ -1444,7 +1444,7 @@ public enum Components { case isBase64Encoded = "is_base64_encoded" } } - /// An optional comment when closing an alert. Cannot be updated or deleted. Must be `null` when changing `state` to `open`. + /// An optional comment when closing or reopening an alert. Cannot be updated or deleted. /// /// - Remark: Generated from `#/components/schemas/secret-scanning-alert-resolution-comment`. public typealias SecretScanningAlertResolutionComment = Swift.String From fcfb1887e6ad6c9ab7d5124525771aa43e4c96a8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 5 May 2025 22:52:21 +0000 Subject: [PATCH 5/7] Commit via running: make Sources/credentials --- Sources/credentials/Client.swift | 168 ++++++++++++ Sources/credentials/Types.swift | 425 +++++++++++++++++++++++++++++++ 2 files changed, 593 insertions(+) create mode 100644 Sources/credentials/Client.swift create mode 100644 Sources/credentials/Types.swift diff --git a/Sources/credentials/Client.swift b/Sources/credentials/Client.swift new file mode 100644 index 0000000000..5b24d4971c --- /dev/null +++ b/Sources/credentials/Client.swift @@ -0,0 +1,168 @@ +// Generated by swift-openapi-generator, do not modify. +@_spi(Generated) import OpenAPIRuntime +#if os(Linux) +@preconcurrency import struct Foundation.URL +@preconcurrency import struct Foundation.Data +@preconcurrency import struct Foundation.Date +#else +import struct Foundation.URL +import struct Foundation.Data +import struct Foundation.Date +#endif +import HTTPTypes +/// GitHub's v3 REST API. +public struct Client: APIProtocol { + /// The underlying HTTP client. + private let client: UniversalClient + /// Creates a new client. + /// - Parameters: + /// - serverURL: The server URL that the client connects to. Any server + /// URLs defined in the OpenAPI document are available as static methods + /// on the ``Servers`` type. + /// - configuration: A set of configuration values for the client. + /// - transport: A transport that performs HTTP operations. + /// - middlewares: A list of middlewares to call before the transport. + public init( + serverURL: Foundation.URL, + configuration: Configuration = .init(), + transport: any ClientTransport, + middlewares: [any ClientMiddleware] = [] + ) { + self.client = .init( + serverURL: serverURL, + configuration: configuration, + transport: transport, + middlewares: middlewares + ) + } + private var converter: Converter { + client.converter + } + /// Revoke a list of credentials + /// + /// Submit a list of credentials to be revoked. This endpoint is intended to revoke credentials the caller does not own and may have found exposed on GitHub.com or elsewhere. It can also be used for credentials associated with an old user account that you no longer have access to. Credential owners will be notified of the revocation. + /// + /// This endpoint currently accepts the following credential types: + /// - Personal access tokens (classic) + /// - Fine-grained personal access tokens + /// + /// Revoked credentials may impact users on GitHub Free, Pro, & Team and GitHub Enterprise Cloud, and GitHub Enterprise Cloud with Enterprise Managed Users. + /// GitHub cannot reactivate any credentials that have been revoked; new credentials will need to be generated. + /// + /// To prevent abuse, this API is limited to only 60 unauthenticated requests per hour and a max of 1000 tokens per API request. + /// + /// > [!NOTE] + /// > Any authenticated requests will return a 403. + /// + /// - Remark: HTTP `POST /credentials/revoke`. + /// - Remark: Generated from `#/paths//credentials/revoke/post(credentials/revoke)`. + public func credentialsRevoke(_ input: Operations.CredentialsRevoke.Input) async throws -> Operations.CredentialsRevoke.Output { + try await client.send( + input: input, + forOperation: Operations.CredentialsRevoke.id, + serializer: { input in + let path = try converter.renderedPath( + template: "/credentials/revoke", + parameters: [] + ) + var request: HTTPTypes.HTTPRequest = .init( + soar_path: path, + method: .post + ) + 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 202: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Components.Responses.Accepted.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + OpenAPIRuntime.OpenAPIObjectContainer.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .accepted(.init(body: body)) + case 422: + let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) + let body: Components.Responses.ValidationFailedSimple.Body + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getResponseBodyAsJSON( + Components.Schemas.ValidationErrorSimple.self, + from: responseBody, + transforming: { value in + .json(value) + } + ) + default: + preconditionFailure("bestContentType chose an invalid content type.") + } + return .unprocessableContent(.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)) + default: + return .undocumented( + statusCode: response.status.code, + .init( + headerFields: response.headerFields, + body: responseBody + ) + ) + } + } + ) + } +} diff --git a/Sources/credentials/Types.swift b/Sources/credentials/Types.swift new file mode 100644 index 0000000000..d4cad8dd0b --- /dev/null +++ b/Sources/credentials/Types.swift @@ -0,0 +1,425 @@ +// Generated by swift-openapi-generator, do not modify. +@_spi(Generated) import OpenAPIRuntime +#if os(Linux) +@preconcurrency import struct Foundation.URL +@preconcurrency import struct Foundation.Data +@preconcurrency import struct Foundation.Date +#else +import struct Foundation.URL +import struct Foundation.Data +import struct Foundation.Date +#endif +/// A type that performs HTTP operations defined by the OpenAPI document. +public protocol APIProtocol: Sendable { + /// Revoke a list of credentials + /// + /// Submit a list of credentials to be revoked. This endpoint is intended to revoke credentials the caller does not own and may have found exposed on GitHub.com or elsewhere. It can also be used for credentials associated with an old user account that you no longer have access to. Credential owners will be notified of the revocation. + /// + /// This endpoint currently accepts the following credential types: + /// - Personal access tokens (classic) + /// - Fine-grained personal access tokens + /// + /// Revoked credentials may impact users on GitHub Free, Pro, & Team and GitHub Enterprise Cloud, and GitHub Enterprise Cloud with Enterprise Managed Users. + /// GitHub cannot reactivate any credentials that have been revoked; new credentials will need to be generated. + /// + /// To prevent abuse, this API is limited to only 60 unauthenticated requests per hour and a max of 1000 tokens per API request. + /// + /// > [!NOTE] + /// > Any authenticated requests will return a 403. + /// + /// - Remark: HTTP `POST /credentials/revoke`. + /// - Remark: Generated from `#/paths//credentials/revoke/post(credentials/revoke)`. + func credentialsRevoke(_ input: Operations.CredentialsRevoke.Input) async throws -> Operations.CredentialsRevoke.Output +} + +/// Convenience overloads for operation inputs. +extension APIProtocol { + /// Revoke a list of credentials + /// + /// Submit a list of credentials to be revoked. This endpoint is intended to revoke credentials the caller does not own and may have found exposed on GitHub.com or elsewhere. It can also be used for credentials associated with an old user account that you no longer have access to. Credential owners will be notified of the revocation. + /// + /// This endpoint currently accepts the following credential types: + /// - Personal access tokens (classic) + /// - Fine-grained personal access tokens + /// + /// Revoked credentials may impact users on GitHub Free, Pro, & Team and GitHub Enterprise Cloud, and GitHub Enterprise Cloud with Enterprise Managed Users. + /// GitHub cannot reactivate any credentials that have been revoked; new credentials will need to be generated. + /// + /// To prevent abuse, this API is limited to only 60 unauthenticated requests per hour and a max of 1000 tokens per API request. + /// + /// > [!NOTE] + /// > Any authenticated requests will return a 403. + /// + /// - Remark: HTTP `POST /credentials/revoke`. + /// - Remark: Generated from `#/paths//credentials/revoke/post(credentials/revoke)`. + public func credentialsRevoke( + headers: Operations.CredentialsRevoke.Input.Headers = .init(), + body: Operations.CredentialsRevoke.Input.Body + ) async throws -> Operations.CredentialsRevoke.Output { + try await credentialsRevoke(Operations.CredentialsRevoke.Input( + headers: headers, + body: body + )) + } +} + +/// Server URLs defined in the OpenAPI document. +public enum Servers { + public enum Server1 { + public static func url() throws -> Foundation.URL { + try Foundation.URL( + validatingOpenAPIServerURL: "https://api.github.com", + variables: [] + ) + } + } + @available(*, deprecated, renamed: "Servers.Server1.url") + public static func server1() throws -> Foundation.URL { + try Foundation.URL( + validatingOpenAPIServerURL: "https://api.github.com", + variables: [] + ) + } +} + +/// Types generated from the components section of the OpenAPI document. +public enum Components { + /// Types generated from the `#/components/schemas` section of the OpenAPI document. + public enum Schemas { + /// Basic Error + /// + /// - Remark: Generated from `#/components/schemas/basic-error`. + public struct BasicError: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/basic-error/message`. + public var message: Swift.String? + /// - Remark: Generated from `#/components/schemas/basic-error/documentation_url`. + public var documentationUrl: Swift.String? + /// - Remark: Generated from `#/components/schemas/basic-error/url`. + public var url: Swift.String? + /// - Remark: Generated from `#/components/schemas/basic-error/status`. + public var status: Swift.String? + /// Creates a new `BasicError`. + /// + /// - Parameters: + /// - message: + /// - documentationUrl: + /// - url: + /// - status: + public init( + message: Swift.String? = nil, + documentationUrl: Swift.String? = nil, + url: Swift.String? = nil, + status: Swift.String? = nil + ) { + self.message = message + self.documentationUrl = documentationUrl + self.url = url + self.status = status + } + public enum CodingKeys: String, CodingKey { + case message + case documentationUrl = "documentation_url" + case url + case status + } + } + /// Validation Error Simple + /// + /// - Remark: Generated from `#/components/schemas/validation-error-simple`. + public struct ValidationErrorSimple: Codable, Hashable, Sendable { + /// - Remark: Generated from `#/components/schemas/validation-error-simple/message`. + public var message: Swift.String + /// - Remark: Generated from `#/components/schemas/validation-error-simple/documentation_url`. + public var documentationUrl: Swift.String + /// - Remark: Generated from `#/components/schemas/validation-error-simple/errors`. + public var errors: [Swift.String]? + /// Creates a new `ValidationErrorSimple`. + /// + /// - Parameters: + /// - message: + /// - documentationUrl: + /// - errors: + public init( + message: Swift.String, + documentationUrl: Swift.String, + errors: [Swift.String]? = nil + ) { + self.message = message + self.documentationUrl = documentationUrl + self.errors = errors + } + public enum CodingKeys: String, CodingKey { + case message + case documentationUrl = "documentation_url" + case errors + } + } + } + /// Types generated from the `#/components/parameters` section of the OpenAPI document. + public enum Parameters {} + /// Types generated from the `#/components/requestBodies` section of the OpenAPI document. + public enum RequestBodies {} + /// Types generated from the `#/components/responses` section of the OpenAPI document. + public enum Responses { + public struct ValidationFailedSimple: Sendable, Hashable { + /// - Remark: Generated from `#/components/responses/validation_failed_simple/content`. + @frozen public enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/components/responses/validation_failed_simple/content/application\/json`. + case json(Components.Schemas.ValidationErrorSimple) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + public var json: Components.Schemas.ValidationErrorSimple { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + public var body: Components.Responses.ValidationFailedSimple.Body + /// Creates a new `ValidationFailedSimple`. + /// + /// - Parameters: + /// - body: Received HTTP response body + public init(body: Components.Responses.ValidationFailedSimple.Body) { + self.body = body + } + } + public struct Accepted: Sendable, Hashable { + /// - Remark: Generated from `#/components/responses/accepted/content`. + @frozen public enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/components/responses/accepted/content/application\/json`. + case json(OpenAPIRuntime.OpenAPIObjectContainer) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + public var json: OpenAPIRuntime.OpenAPIObjectContainer { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + public var body: Components.Responses.Accepted.Body + /// Creates a new `Accepted`. + /// + /// - Parameters: + /// - body: Received HTTP response body + public init(body: Components.Responses.Accepted.Body) { + self.body = body + } + } + public struct InternalError: Sendable, Hashable { + /// - Remark: Generated from `#/components/responses/internal_error/content`. + @frozen public enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/components/responses/internal_error/content/application\/json`. + case json(Components.Schemas.BasicError) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + public var json: Components.Schemas.BasicError { + get throws { + switch self { + case let .json(body): + return body + } + } + } + } + /// Received HTTP response body + public var body: Components.Responses.InternalError.Body + /// Creates a new `InternalError`. + /// + /// - Parameters: + /// - body: Received HTTP response body + public init(body: Components.Responses.InternalError.Body) { + self.body = body + } + } + } + /// Types generated from the `#/components/headers` section of the OpenAPI document. + public enum Headers {} +} + +/// API operations, with input and output types, generated from `#/paths` in the OpenAPI document. +public enum Operations { + /// Revoke a list of credentials + /// + /// Submit a list of credentials to be revoked. This endpoint is intended to revoke credentials the caller does not own and may have found exposed on GitHub.com or elsewhere. It can also be used for credentials associated with an old user account that you no longer have access to. Credential owners will be notified of the revocation. + /// + /// This endpoint currently accepts the following credential types: + /// - Personal access tokens (classic) + /// - Fine-grained personal access tokens + /// + /// Revoked credentials may impact users on GitHub Free, Pro, & Team and GitHub Enterprise Cloud, and GitHub Enterprise Cloud with Enterprise Managed Users. + /// GitHub cannot reactivate any credentials that have been revoked; new credentials will need to be generated. + /// + /// To prevent abuse, this API is limited to only 60 unauthenticated requests per hour and a max of 1000 tokens per API request. + /// + /// > [!NOTE] + /// > Any authenticated requests will return a 403. + /// + /// - Remark: HTTP `POST /credentials/revoke`. + /// - Remark: Generated from `#/paths//credentials/revoke/post(credentials/revoke)`. + public enum CredentialsRevoke { + public static let id: Swift.String = "credentials/revoke" + public struct Input: Sendable, Hashable { + /// - Remark: Generated from `#/paths/credentials/revoke/POST/header`. + public struct Headers: Sendable, Hashable { + public var accept: [OpenAPIRuntime.AcceptHeaderContentType] + /// Creates a new `Headers`. + /// + /// - Parameters: + /// - accept: + public init(accept: [OpenAPIRuntime.AcceptHeaderContentType] = .defaultValues()) { + self.accept = accept + } + } + public var headers: Operations.CredentialsRevoke.Input.Headers + /// - Remark: Generated from `#/paths/credentials/revoke/POST/requestBody`. + @frozen public enum Body: Sendable, Hashable { + /// - Remark: Generated from `#/paths/credentials/revoke/POST/requestBody/json`. + public struct JsonPayload: Codable, Hashable, Sendable { + /// A list of credentials to be revoked, up to 1000 per request. + /// + /// - Remark: Generated from `#/paths/credentials/revoke/POST/requestBody/json/credentials`. + public var credentials: [Swift.String] + /// Creates a new `JsonPayload`. + /// + /// - Parameters: + /// - credentials: A list of credentials to be revoked, up to 1000 per request. + public init(credentials: [Swift.String]) { + self.credentials = credentials + } + public enum CodingKeys: String, CodingKey { + case credentials + } + } + /// - Remark: Generated from `#/paths/credentials/revoke/POST/requestBody/content/application\/json`. + case json(Operations.CredentialsRevoke.Input.Body.JsonPayload) + } + public var body: Operations.CredentialsRevoke.Input.Body + /// Creates a new `Input`. + /// + /// - Parameters: + /// - headers: + /// - body: + public init( + headers: Operations.CredentialsRevoke.Input.Headers = .init(), + body: Operations.CredentialsRevoke.Input.Body + ) { + self.headers = headers + self.body = body + } + } + @frozen public enum Output: Sendable, Hashable { + /// Accepted + /// + /// - Remark: Generated from `#/paths//credentials/revoke/post(credentials/revoke)/responses/202`. + /// + /// HTTP response code: `202 accepted`. + case accepted(Components.Responses.Accepted) + /// The associated value of the enum case if `self` is `.accepted`. + /// + /// - Throws: An error if `self` is not `.accepted`. + /// - SeeAlso: `.accepted`. + public var accepted: Components.Responses.Accepted { + get throws { + switch self { + case let .accepted(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "accepted", + response: self + ) + } + } + } + /// Validation failed, or the endpoint has been spammed. + /// + /// - Remark: Generated from `#/paths//credentials/revoke/post(credentials/revoke)/responses/422`. + /// + /// HTTP response code: `422 unprocessableContent`. + case unprocessableContent(Components.Responses.ValidationFailedSimple) + /// The associated value of the enum case if `self` is `.unprocessableContent`. + /// + /// - Throws: An error if `self` is not `.unprocessableContent`. + /// - SeeAlso: `.unprocessableContent`. + public var unprocessableContent: Components.Responses.ValidationFailedSimple { + get throws { + switch self { + case let .unprocessableContent(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "unprocessableContent", + response: self + ) + } + } + } + /// Internal Error + /// + /// - Remark: Generated from `#/paths//credentials/revoke/post(credentials/revoke)/responses/500`. + /// + /// HTTP response code: `500 internalServerError`. + case internalServerError(Components.Responses.InternalError) + /// The associated value of the enum case if `self` is `.internalServerError`. + /// + /// - Throws: An error if `self` is not `.internalServerError`. + /// - SeeAlso: `.internalServerError`. + public var internalServerError: Components.Responses.InternalError { + get throws { + switch self { + case let .internalServerError(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "internalServerError", + response: self + ) + } + } + } + /// Undocumented response. + /// + /// A response with a code that is not documented in the OpenAPI document. + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) + } + @frozen public enum AcceptableContentType: AcceptableProtocol { + case json + case other(Swift.String) + public init?(rawValue: Swift.String) { + switch rawValue.lowercased() { + case "application/json": + self = .json + default: + self = .other(rawValue) + } + } + public var rawValue: Swift.String { + switch self { + case let .other(string): + return string + case .json: + return "application/json" + } + } + public static var allCases: [Self] { + [ + .json + ] + } + } + } +} From 023d92b9d2a2ef5ded56d567565f144d4eab05e4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 5 May 2025 22:52:45 +0000 Subject: [PATCH 6/7] Commit via running: make Package.swift --- Package.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Package.swift b/Package.swift index 6306bada50..36b9524d02 100644 --- a/Package.swift +++ b/Package.swift @@ -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"]), @@ -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: [ From 4505848b34a2b9ebf79e985dbdacf08c120ebfb8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 5 May 2025 22:52:46 +0000 Subject: [PATCH 7/7] Commit via running: make .spi.yml --- .spi.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.spi.yml b/.spi.yml index 7ce45f7db1..44c3facca8 100644 --- a/.spi.yml +++ b/.spi.yml @@ -14,6 +14,7 @@ builder: - GitHubRestAPICodes_Of_Conduct - GitHubRestAPICodespaces - GitHubRestAPICopilot + - GitHubRestAPICredentials - GitHubRestAPIDependabot - GitHubRestAPIDependency_Graph - GitHubRestAPIDesktop