Skip to content

Commit 67439fb

Browse files
Merge pull request #124 from wei18/dependabot/submodules/Submodule/github/rest-api-description-bf4af7c
Bump Submodule/github/rest-api-description from `31cc3f6` to `bf4af7c`
2 parents be2c41d + 75a61f5 commit 67439fb

File tree

3 files changed

+346
-1
lines changed

3 files changed

+346
-1
lines changed

Sources/dependabot/Client.swift

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,105 @@ public struct Client: APIProtocol {
384384
}
385385
)
386386
}
387+
/// Updates repositories to the list of repositories that organization admins have allowed Dependabot to access when updating dependencies.
388+
///
389+
/// > [!NOTE]
390+
/// > This operation supports both server-to-server and user-to-server access.
391+
/// Unauthorized users will not see the existence of this endpoint.
392+
///
393+
/// - Remark: HTTP `PATCH /organizations/{org}/dependabot/repository-access`.
394+
/// - Remark: Generated from `#/paths//organizations/{org}/dependabot/repository-access/patch(dependabot/update-repository-access-for-org)`.
395+
public func dependabotUpdateRepositoryAccessForOrg(_ input: Operations.DependabotUpdateRepositoryAccessForOrg.Input) async throws -> Operations.DependabotUpdateRepositoryAccessForOrg.Output {
396+
try await client.send(
397+
input: input,
398+
forOperation: Operations.DependabotUpdateRepositoryAccessForOrg.id,
399+
serializer: { input in
400+
let path = try converter.renderedPath(
401+
template: "/organizations/{}/dependabot/repository-access",
402+
parameters: [
403+
input.path.org
404+
]
405+
)
406+
var request: HTTPTypes.HTTPRequest = .init(
407+
soar_path: path,
408+
method: .patch
409+
)
410+
suppressMutabilityWarning(&request)
411+
converter.setAcceptHeader(
412+
in: &request.headerFields,
413+
contentTypes: input.headers.accept
414+
)
415+
let body: OpenAPIRuntime.HTTPBody?
416+
switch input.body {
417+
case let .json(value):
418+
body = try converter.setRequiredRequestBodyAsJSON(
419+
value,
420+
headerFields: &request.headerFields,
421+
contentType: "application/json; charset=utf-8"
422+
)
423+
}
424+
return (request, body)
425+
},
426+
deserializer: { response, responseBody in
427+
switch response.status.code {
428+
case 204:
429+
return .noContent(.init())
430+
case 403:
431+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
432+
let body: Components.Responses.Forbidden.Body
433+
let chosenContentType = try converter.bestContentType(
434+
received: contentType,
435+
options: [
436+
"application/json"
437+
]
438+
)
439+
switch chosenContentType {
440+
case "application/json":
441+
body = try await converter.getResponseBodyAsJSON(
442+
Components.Schemas.BasicError.self,
443+
from: responseBody,
444+
transforming: { value in
445+
.json(value)
446+
}
447+
)
448+
default:
449+
preconditionFailure("bestContentType chose an invalid content type.")
450+
}
451+
return .forbidden(.init(body: body))
452+
case 404:
453+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
454+
let body: Components.Responses.NotFound.Body
455+
let chosenContentType = try converter.bestContentType(
456+
received: contentType,
457+
options: [
458+
"application/json"
459+
]
460+
)
461+
switch chosenContentType {
462+
case "application/json":
463+
body = try await converter.getResponseBodyAsJSON(
464+
Components.Schemas.BasicError.self,
465+
from: responseBody,
466+
transforming: { value in
467+
.json(value)
468+
}
469+
)
470+
default:
471+
preconditionFailure("bestContentType chose an invalid content type.")
472+
}
473+
return .notFound(.init(body: body))
474+
default:
475+
return .undocumented(
476+
statusCode: response.status.code,
477+
.init(
478+
headerFields: response.headerFields,
479+
body: responseBody
480+
)
481+
)
482+
}
483+
}
484+
)
485+
}
387486
/// Set the default repository access level for Dependabot
388487
///
389488
/// > [!NOTE]

Sources/dependabot/Types.swift

Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ public protocol APIProtocol: Sendable {
3333
/// - Remark: HTTP `GET /organizations/{org}/dependabot/repository-access`.
3434
/// - Remark: Generated from `#/paths//organizations/{org}/dependabot/repository-access/get(dependabot/repository-access-for-org)`.
3535
func dependabotRepositoryAccessForOrg(_ input: Operations.DependabotRepositoryAccessForOrg.Input) async throws -> Operations.DependabotRepositoryAccessForOrg.Output
36+
/// Updates repositories to the list of repositories that organization admins have allowed Dependabot to access when updating dependencies.
37+
///
38+
/// > [!NOTE]
39+
/// > This operation supports both server-to-server and user-to-server access.
40+
/// Unauthorized users will not see the existence of this endpoint.
41+
///
42+
/// - Remark: HTTP `PATCH /organizations/{org}/dependabot/repository-access`.
43+
/// - Remark: Generated from `#/paths//organizations/{org}/dependabot/repository-access/patch(dependabot/update-repository-access-for-org)`.
44+
func dependabotUpdateRepositoryAccessForOrg(_ input: Operations.DependabotUpdateRepositoryAccessForOrg.Input) async throws -> Operations.DependabotUpdateRepositoryAccessForOrg.Output
3645
/// Set the default repository access level for Dependabot
3746
///
3847
/// > [!NOTE]
@@ -264,6 +273,25 @@ extension APIProtocol {
264273
headers: headers
265274
))
266275
}
276+
/// Updates repositories to the list of repositories that organization admins have allowed Dependabot to access when updating dependencies.
277+
///
278+
/// > [!NOTE]
279+
/// > This operation supports both server-to-server and user-to-server access.
280+
/// Unauthorized users will not see the existence of this endpoint.
281+
///
282+
/// - Remark: HTTP `PATCH /organizations/{org}/dependabot/repository-access`.
283+
/// - Remark: Generated from `#/paths//organizations/{org}/dependabot/repository-access/patch(dependabot/update-repository-access-for-org)`.
284+
public func dependabotUpdateRepositoryAccessForOrg(
285+
path: Operations.DependabotUpdateRepositoryAccessForOrg.Input.Path,
286+
headers: Operations.DependabotUpdateRepositoryAccessForOrg.Input.Headers = .init(),
287+
body: Operations.DependabotUpdateRepositoryAccessForOrg.Input.Body
288+
) async throws -> Operations.DependabotUpdateRepositoryAccessForOrg.Output {
289+
try await dependabotUpdateRepositoryAccessForOrg(Operations.DependabotUpdateRepositoryAccessForOrg.Input(
290+
path: path,
291+
headers: headers,
292+
body: body
293+
))
294+
}
267295
/// Set the default repository access level for Dependabot
268296
///
269297
/// > [!NOTE]
@@ -4642,6 +4670,224 @@ public enum Operations {
46424670
}
46434671
}
46444672
}
4673+
/// Updates repositories to the list of repositories that organization admins have allowed Dependabot to access when updating dependencies.
4674+
///
4675+
/// > [!NOTE]
4676+
/// > This operation supports both server-to-server and user-to-server access.
4677+
/// Unauthorized users will not see the existence of this endpoint.
4678+
///
4679+
/// - Remark: HTTP `PATCH /organizations/{org}/dependabot/repository-access`.
4680+
/// - Remark: Generated from `#/paths//organizations/{org}/dependabot/repository-access/patch(dependabot/update-repository-access-for-org)`.
4681+
public enum DependabotUpdateRepositoryAccessForOrg {
4682+
public static let id: Swift.String = "dependabot/update-repository-access-for-org"
4683+
public struct Input: Sendable, Hashable {
4684+
/// - Remark: Generated from `#/paths/organizations/{org}/dependabot/repository-access/PATCH/path`.
4685+
public struct Path: Sendable, Hashable {
4686+
/// The organization name. The name is not case sensitive.
4687+
///
4688+
/// - Remark: Generated from `#/paths/organizations/{org}/dependabot/repository-access/PATCH/path/org`.
4689+
public var org: Components.Parameters.Org
4690+
/// Creates a new `Path`.
4691+
///
4692+
/// - Parameters:
4693+
/// - org: The organization name. The name is not case sensitive.
4694+
public init(org: Components.Parameters.Org) {
4695+
self.org = org
4696+
}
4697+
}
4698+
public var path: Operations.DependabotUpdateRepositoryAccessForOrg.Input.Path
4699+
/// - Remark: Generated from `#/paths/organizations/{org}/dependabot/repository-access/PATCH/header`.
4700+
public struct Headers: Sendable, Hashable {
4701+
public var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.DependabotUpdateRepositoryAccessForOrg.AcceptableContentType>]
4702+
/// Creates a new `Headers`.
4703+
///
4704+
/// - Parameters:
4705+
/// - accept:
4706+
public init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.DependabotUpdateRepositoryAccessForOrg.AcceptableContentType>] = .defaultValues()) {
4707+
self.accept = accept
4708+
}
4709+
}
4710+
public var headers: Operations.DependabotUpdateRepositoryAccessForOrg.Input.Headers
4711+
/// - Remark: Generated from `#/paths/organizations/{org}/dependabot/repository-access/PATCH/requestBody`.
4712+
@frozen public enum Body: Sendable, Hashable {
4713+
/// - Remark: Generated from `#/paths/organizations/{org}/dependabot/repository-access/PATCH/requestBody/json`.
4714+
@frozen public enum JsonPayload: Codable, Hashable, Sendable {
4715+
/// - Remark: Generated from `#/paths/organizations/{org}/dependabot/repository-access/PATCH/requestBody/json/case1`.
4716+
public struct Case1Payload: Codable, Hashable, Sendable {
4717+
/// Creates a new `Case1Payload`.
4718+
public init() {}
4719+
}
4720+
/// - Remark: Generated from `#/paths/organizations/{org}/dependabot/repository-access/PATCH/requestBody/json/case1`.
4721+
case case1(Operations.DependabotUpdateRepositoryAccessForOrg.Input.Body.JsonPayload.Case1Payload)
4722+
/// - Remark: Generated from `#/paths/organizations/{org}/dependabot/repository-access/PATCH/requestBody/json/case2`.
4723+
public struct Case2Payload: Codable, Hashable, Sendable {
4724+
/// Creates a new `Case2Payload`.
4725+
public init() {}
4726+
}
4727+
/// - Remark: Generated from `#/paths/organizations/{org}/dependabot/repository-access/PATCH/requestBody/json/case2`.
4728+
case case2(Operations.DependabotUpdateRepositoryAccessForOrg.Input.Body.JsonPayload.Case2Payload)
4729+
public init(from decoder: any Decoder) throws {
4730+
var errors: [any Error] = []
4731+
do {
4732+
self = .case1(try .init(from: decoder))
4733+
return
4734+
} catch {
4735+
errors.append(error)
4736+
}
4737+
do {
4738+
self = .case2(try .init(from: decoder))
4739+
return
4740+
} catch {
4741+
errors.append(error)
4742+
}
4743+
throw Swift.DecodingError.failedToDecodeOneOfSchema(
4744+
type: Self.self,
4745+
codingPath: decoder.codingPath,
4746+
errors: errors
4747+
)
4748+
}
4749+
public func encode(to encoder: any Encoder) throws {
4750+
switch self {
4751+
case let .case1(value):
4752+
try value.encode(to: encoder)
4753+
case let .case2(value):
4754+
try value.encode(to: encoder)
4755+
}
4756+
}
4757+
}
4758+
/// - Remark: Generated from `#/paths/organizations/{org}/dependabot/repository-access/PATCH/requestBody/content/application\/json`.
4759+
case json(Operations.DependabotUpdateRepositoryAccessForOrg.Input.Body.JsonPayload)
4760+
}
4761+
public var body: Operations.DependabotUpdateRepositoryAccessForOrg.Input.Body
4762+
/// Creates a new `Input`.
4763+
///
4764+
/// - Parameters:
4765+
/// - path:
4766+
/// - headers:
4767+
/// - body:
4768+
public init(
4769+
path: Operations.DependabotUpdateRepositoryAccessForOrg.Input.Path,
4770+
headers: Operations.DependabotUpdateRepositoryAccessForOrg.Input.Headers = .init(),
4771+
body: Operations.DependabotUpdateRepositoryAccessForOrg.Input.Body
4772+
) {
4773+
self.path = path
4774+
self.headers = headers
4775+
self.body = body
4776+
}
4777+
}
4778+
@frozen public enum Output: Sendable, Hashable {
4779+
public struct NoContent: Sendable, Hashable {
4780+
/// Creates a new `NoContent`.
4781+
public init() {}
4782+
}
4783+
/// Response
4784+
///
4785+
/// - Remark: Generated from `#/paths//organizations/{org}/dependabot/repository-access/patch(dependabot/update-repository-access-for-org)/responses/204`.
4786+
///
4787+
/// HTTP response code: `204 noContent`.
4788+
case noContent(Operations.DependabotUpdateRepositoryAccessForOrg.Output.NoContent)
4789+
/// Response
4790+
///
4791+
/// - Remark: Generated from `#/paths//organizations/{org}/dependabot/repository-access/patch(dependabot/update-repository-access-for-org)/responses/204`.
4792+
///
4793+
/// HTTP response code: `204 noContent`.
4794+
public static var noContent: Self {
4795+
.noContent(.init())
4796+
}
4797+
/// The associated value of the enum case if `self` is `.noContent`.
4798+
///
4799+
/// - Throws: An error if `self` is not `.noContent`.
4800+
/// - SeeAlso: `.noContent`.
4801+
public var noContent: Operations.DependabotUpdateRepositoryAccessForOrg.Output.NoContent {
4802+
get throws {
4803+
switch self {
4804+
case let .noContent(response):
4805+
return response
4806+
default:
4807+
try throwUnexpectedResponseStatus(
4808+
expectedStatus: "noContent",
4809+
response: self
4810+
)
4811+
}
4812+
}
4813+
}
4814+
/// Forbidden
4815+
///
4816+
/// - Remark: Generated from `#/paths//organizations/{org}/dependabot/repository-access/patch(dependabot/update-repository-access-for-org)/responses/403`.
4817+
///
4818+
/// HTTP response code: `403 forbidden`.
4819+
case forbidden(Components.Responses.Forbidden)
4820+
/// The associated value of the enum case if `self` is `.forbidden`.
4821+
///
4822+
/// - Throws: An error if `self` is not `.forbidden`.
4823+
/// - SeeAlso: `.forbidden`.
4824+
public var forbidden: Components.Responses.Forbidden {
4825+
get throws {
4826+
switch self {
4827+
case let .forbidden(response):
4828+
return response
4829+
default:
4830+
try throwUnexpectedResponseStatus(
4831+
expectedStatus: "forbidden",
4832+
response: self
4833+
)
4834+
}
4835+
}
4836+
}
4837+
/// Resource not found
4838+
///
4839+
/// - Remark: Generated from `#/paths//organizations/{org}/dependabot/repository-access/patch(dependabot/update-repository-access-for-org)/responses/404`.
4840+
///
4841+
/// HTTP response code: `404 notFound`.
4842+
case notFound(Components.Responses.NotFound)
4843+
/// The associated value of the enum case if `self` is `.notFound`.
4844+
///
4845+
/// - Throws: An error if `self` is not `.notFound`.
4846+
/// - SeeAlso: `.notFound`.
4847+
public var notFound: Components.Responses.NotFound {
4848+
get throws {
4849+
switch self {
4850+
case let .notFound(response):
4851+
return response
4852+
default:
4853+
try throwUnexpectedResponseStatus(
4854+
expectedStatus: "notFound",
4855+
response: self
4856+
)
4857+
}
4858+
}
4859+
}
4860+
/// Undocumented response.
4861+
///
4862+
/// A response with a code that is not documented in the OpenAPI document.
4863+
case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload)
4864+
}
4865+
@frozen public enum AcceptableContentType: AcceptableProtocol {
4866+
case json
4867+
case other(Swift.String)
4868+
public init?(rawValue: Swift.String) {
4869+
switch rawValue.lowercased() {
4870+
case "application/json":
4871+
self = .json
4872+
default:
4873+
self = .other(rawValue)
4874+
}
4875+
}
4876+
public var rawValue: Swift.String {
4877+
switch self {
4878+
case let .other(string):
4879+
return string
4880+
case .json:
4881+
return "application/json"
4882+
}
4883+
}
4884+
public static var allCases: [Self] {
4885+
[
4886+
.json
4887+
]
4888+
}
4889+
}
4890+
}
46454891
/// Set the default repository access level for Dependabot
46464892
///
46474893
/// > [!NOTE]

0 commit comments

Comments
 (0)