Skip to content

Commit 98bed52

Browse files
Commit via running: make Sources/secret-scanning
1 parent 79f5de3 commit 98bed52

File tree

2 files changed

+1414
-0
lines changed

2 files changed

+1414
-0
lines changed

Sources/secret-scanning/Client.swift

Lines changed: 304 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,310 @@ public struct Client: APIProtocol {
455455
}
456456
)
457457
}
458+
/// List organization pattern configurations
459+
///
460+
/// Lists the secret scanning pattern configurations for an organization.
461+
///
462+
/// Personal access tokens (classic) need the `write:org` scope to use this endpoint.
463+
///
464+
/// - Remark: HTTP `GET /orgs/{org}/secret-scanning/pattern-configurations`.
465+
/// - Remark: Generated from `#/paths//orgs/{org}/secret-scanning/pattern-configurations/get(secret-scanning/list-org-pattern-configs)`.
466+
public func secretScanningListOrgPatternConfigs(_ input: Operations.SecretScanningListOrgPatternConfigs.Input) async throws -> Operations.SecretScanningListOrgPatternConfigs.Output {
467+
try await client.send(
468+
input: input,
469+
forOperation: Operations.SecretScanningListOrgPatternConfigs.id,
470+
serializer: { input in
471+
let path = try converter.renderedPath(
472+
template: "/orgs/{}/secret-scanning/pattern-configurations",
473+
parameters: [
474+
input.path.org
475+
]
476+
)
477+
var request: HTTPTypes.HTTPRequest = .init(
478+
soar_path: path,
479+
method: .get
480+
)
481+
suppressMutabilityWarning(&request)
482+
converter.setAcceptHeader(
483+
in: &request.headerFields,
484+
contentTypes: input.headers.accept
485+
)
486+
return (request, nil)
487+
},
488+
deserializer: { response, responseBody in
489+
switch response.status.code {
490+
case 200:
491+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
492+
let body: Operations.SecretScanningListOrgPatternConfigs.Output.Ok.Body
493+
let chosenContentType = try converter.bestContentType(
494+
received: contentType,
495+
options: [
496+
"application/json"
497+
]
498+
)
499+
switch chosenContentType {
500+
case "application/json":
501+
body = try await converter.getResponseBodyAsJSON(
502+
Components.Schemas.SecretScanningPatternConfiguration.self,
503+
from: responseBody,
504+
transforming: { value in
505+
.json(value)
506+
}
507+
)
508+
default:
509+
preconditionFailure("bestContentType chose an invalid content type.")
510+
}
511+
return .ok(.init(body: body))
512+
case 403:
513+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
514+
let body: Components.Responses.Forbidden.Body
515+
let chosenContentType = try converter.bestContentType(
516+
received: contentType,
517+
options: [
518+
"application/json"
519+
]
520+
)
521+
switch chosenContentType {
522+
case "application/json":
523+
body = try await converter.getResponseBodyAsJSON(
524+
Components.Schemas.BasicError.self,
525+
from: responseBody,
526+
transforming: { value in
527+
.json(value)
528+
}
529+
)
530+
default:
531+
preconditionFailure("bestContentType chose an invalid content type.")
532+
}
533+
return .forbidden(.init(body: body))
534+
case 404:
535+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
536+
let body: Components.Responses.NotFound.Body
537+
let chosenContentType = try converter.bestContentType(
538+
received: contentType,
539+
options: [
540+
"application/json"
541+
]
542+
)
543+
switch chosenContentType {
544+
case "application/json":
545+
body = try await converter.getResponseBodyAsJSON(
546+
Components.Schemas.BasicError.self,
547+
from: responseBody,
548+
transforming: { value in
549+
.json(value)
550+
}
551+
)
552+
default:
553+
preconditionFailure("bestContentType chose an invalid content type.")
554+
}
555+
return .notFound(.init(body: body))
556+
default:
557+
return .undocumented(
558+
statusCode: response.status.code,
559+
.init(
560+
headerFields: response.headerFields,
561+
body: responseBody
562+
)
563+
)
564+
}
565+
}
566+
)
567+
}
568+
/// Update organization pattern configurations
569+
///
570+
/// Updates the secret scanning pattern configurations for an organization.
571+
///
572+
/// Personal access tokens (classic) need the `write:org` scope to use this endpoint.
573+
///
574+
/// - Remark: HTTP `PATCH /orgs/{org}/secret-scanning/pattern-configurations`.
575+
/// - Remark: Generated from `#/paths//orgs/{org}/secret-scanning/pattern-configurations/patch(secret-scanning/update-org-pattern-configs)`.
576+
public func secretScanningUpdateOrgPatternConfigs(_ input: Operations.SecretScanningUpdateOrgPatternConfigs.Input) async throws -> Operations.SecretScanningUpdateOrgPatternConfigs.Output {
577+
try await client.send(
578+
input: input,
579+
forOperation: Operations.SecretScanningUpdateOrgPatternConfigs.id,
580+
serializer: { input in
581+
let path = try converter.renderedPath(
582+
template: "/orgs/{}/secret-scanning/pattern-configurations",
583+
parameters: [
584+
input.path.org
585+
]
586+
)
587+
var request: HTTPTypes.HTTPRequest = .init(
588+
soar_path: path,
589+
method: .patch
590+
)
591+
suppressMutabilityWarning(&request)
592+
converter.setAcceptHeader(
593+
in: &request.headerFields,
594+
contentTypes: input.headers.accept
595+
)
596+
let body: OpenAPIRuntime.HTTPBody?
597+
switch input.body {
598+
case let .json(value):
599+
body = try converter.setRequiredRequestBodyAsJSON(
600+
value,
601+
headerFields: &request.headerFields,
602+
contentType: "application/json; charset=utf-8"
603+
)
604+
}
605+
return (request, body)
606+
},
607+
deserializer: { response, responseBody in
608+
switch response.status.code {
609+
case 200:
610+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
611+
let body: Operations.SecretScanningUpdateOrgPatternConfigs.Output.Ok.Body
612+
let chosenContentType = try converter.bestContentType(
613+
received: contentType,
614+
options: [
615+
"application/json"
616+
]
617+
)
618+
switch chosenContentType {
619+
case "application/json":
620+
body = try await converter.getResponseBodyAsJSON(
621+
Operations.SecretScanningUpdateOrgPatternConfigs.Output.Ok.Body.JsonPayload.self,
622+
from: responseBody,
623+
transforming: { value in
624+
.json(value)
625+
}
626+
)
627+
default:
628+
preconditionFailure("bestContentType chose an invalid content type.")
629+
}
630+
return .ok(.init(body: body))
631+
case 400:
632+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
633+
let body: Components.Responses.BadRequest.Body
634+
let chosenContentType = try converter.bestContentType(
635+
received: contentType,
636+
options: [
637+
"application/json",
638+
"application/scim+json"
639+
]
640+
)
641+
switch chosenContentType {
642+
case "application/json":
643+
body = try await converter.getResponseBodyAsJSON(
644+
Components.Schemas.BasicError.self,
645+
from: responseBody,
646+
transforming: { value in
647+
.json(value)
648+
}
649+
)
650+
case "application/scim+json":
651+
body = try await converter.getResponseBodyAsJSON(
652+
Components.Schemas.ScimError.self,
653+
from: responseBody,
654+
transforming: { value in
655+
.applicationScimJson(value)
656+
}
657+
)
658+
default:
659+
preconditionFailure("bestContentType chose an invalid content type.")
660+
}
661+
return .badRequest(.init(body: body))
662+
case 403:
663+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
664+
let body: Components.Responses.Forbidden.Body
665+
let chosenContentType = try converter.bestContentType(
666+
received: contentType,
667+
options: [
668+
"application/json"
669+
]
670+
)
671+
switch chosenContentType {
672+
case "application/json":
673+
body = try await converter.getResponseBodyAsJSON(
674+
Components.Schemas.BasicError.self,
675+
from: responseBody,
676+
transforming: { value in
677+
.json(value)
678+
}
679+
)
680+
default:
681+
preconditionFailure("bestContentType chose an invalid content type.")
682+
}
683+
return .forbidden(.init(body: body))
684+
case 404:
685+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
686+
let body: Components.Responses.NotFound.Body
687+
let chosenContentType = try converter.bestContentType(
688+
received: contentType,
689+
options: [
690+
"application/json"
691+
]
692+
)
693+
switch chosenContentType {
694+
case "application/json":
695+
body = try await converter.getResponseBodyAsJSON(
696+
Components.Schemas.BasicError.self,
697+
from: responseBody,
698+
transforming: { value in
699+
.json(value)
700+
}
701+
)
702+
default:
703+
preconditionFailure("bestContentType chose an invalid content type.")
704+
}
705+
return .notFound(.init(body: body))
706+
case 409:
707+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
708+
let body: Components.Responses.Conflict.Body
709+
let chosenContentType = try converter.bestContentType(
710+
received: contentType,
711+
options: [
712+
"application/json"
713+
]
714+
)
715+
switch chosenContentType {
716+
case "application/json":
717+
body = try await converter.getResponseBodyAsJSON(
718+
Components.Schemas.BasicError.self,
719+
from: responseBody,
720+
transforming: { value in
721+
.json(value)
722+
}
723+
)
724+
default:
725+
preconditionFailure("bestContentType chose an invalid content type.")
726+
}
727+
return .conflict(.init(body: body))
728+
case 422:
729+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
730+
let body: Components.Responses.ValidationFailed.Body
731+
let chosenContentType = try converter.bestContentType(
732+
received: contentType,
733+
options: [
734+
"application/json"
735+
]
736+
)
737+
switch chosenContentType {
738+
case "application/json":
739+
body = try await converter.getResponseBodyAsJSON(
740+
Components.Schemas.ValidationError.self,
741+
from: responseBody,
742+
transforming: { value in
743+
.json(value)
744+
}
745+
)
746+
default:
747+
preconditionFailure("bestContentType chose an invalid content type.")
748+
}
749+
return .unprocessableContent(.init(body: body))
750+
default:
751+
return .undocumented(
752+
statusCode: response.status.code,
753+
.init(
754+
headerFields: response.headerFields,
755+
body: responseBody
756+
)
757+
)
758+
}
759+
}
760+
)
761+
}
458762
/// List secret scanning alerts for a repository
459763
///
460764
/// Lists secret scanning alerts for an eligible repository, from newest to oldest.

0 commit comments

Comments
 (0)