From 9995a11786296c0ab97cb00bcecf0d2a96cc1380 Mon Sep 17 00:00:00 2001 From: Daniel Lamando Date: Fri, 19 Sep 2025 23:46:58 +0200 Subject: [PATCH 1/4] v0.5.6: Regen with Kubernetes v1.34 --- generation/generate-all.sh | 10 +- generation/sources/external-dns.sh | 4 +- lib/argo-cd/argoproj.io@v1alpha1/structs.ts | 261 ++++++ .../mod.ts | 199 ++-- .../structs.ts | 261 +++--- lib/builtin/apps@v1/structs.ts | 8 +- .../authentication.k8s.io@v1beta1/mod.ts | 31 - .../authentication.k8s.io@v1beta1/structs.ts | 46 - lib/builtin/autoscaling@v2/structs.ts | 9 +- .../certificates.k8s.io@v1alpha1/mod.ts | 209 +++++ .../certificates.k8s.io@v1alpha1/structs.ts | 98 ++ .../certificates.k8s.io@v1beta1/mod.ts | 133 +++ .../certificates.k8s.io@v1beta1/structs.ts | 63 ++ .../coordination.k8s.io@v1beta1/mod.ts | 178 ++++ .../coordination.k8s.io@v1beta1/structs.ts | 69 ++ lib/builtin/core@v1/structs.ts | 172 +++- lib/builtin/discovery.k8s.io@v1/structs.ts | 19 +- lib/builtin/networking.k8s.io@v1/mod.ts | 281 ++++++ lib/builtin/networking.k8s.io@v1/structs.ts | 141 ++- lib/builtin/resource.k8s.io@v1/mod.ts | 603 ++++++++++++ lib/builtin/resource.k8s.io@v1/structs.ts | 887 ++++++++++++++++++ lib/builtin/resource.k8s.io@v1alpha3/mod.ts | 546 +---------- .../resource.k8s.io@v1alpha3/structs.ts | 596 ++---------- .../resource.k8s.io@v1beta1/structs.ts | 262 +++++- lib/builtin/resource.k8s.io@v1beta2/mod.ts | 603 ++++++++++++ .../resource.k8s.io@v1beta2/structs.ts | 887 ++++++++++++++++++ lib/builtin/storage.k8s.io@v1/mod.ts | 117 +++ lib/builtin/storage.k8s.io@v1/structs.ts | 40 + .../acme.cert-manager.io@v1/structs.ts | 2 + .../cert-manager.io@v1/structs.ts | 20 +- lib/deno.json | 2 +- .../externaldns.k8s.io@v1alpha1/structs.ts | 2 + lib/vpa/autoscaling.k8s.io@v1/structs.ts | 11 +- 33 files changed, 5333 insertions(+), 1437 deletions(-) delete mode 100644 lib/builtin/authentication.k8s.io@v1beta1/mod.ts delete mode 100644 lib/builtin/authentication.k8s.io@v1beta1/structs.ts create mode 100644 lib/builtin/certificates.k8s.io@v1beta1/mod.ts create mode 100644 lib/builtin/certificates.k8s.io@v1beta1/structs.ts create mode 100644 lib/builtin/coordination.k8s.io@v1beta1/mod.ts create mode 100644 lib/builtin/coordination.k8s.io@v1beta1/structs.ts create mode 100644 lib/builtin/resource.k8s.io@v1/mod.ts create mode 100644 lib/builtin/resource.k8s.io@v1/structs.ts create mode 100644 lib/builtin/resource.k8s.io@v1beta2/mod.ts create mode 100644 lib/builtin/resource.k8s.io@v1beta2/structs.ts diff --git a/generation/generate-all.sh b/generation/generate-all.sh index 5d249a2..cbf0cfb 100755 --- a/generation/generate-all.sh +++ b/generation/generate-all.sh @@ -1,16 +1,16 @@ #!/bin/sh -eux # https://github.com/kubernetes/kubernetes/releases -./generation/sources/builtin.sh v1.32.0 +./generation/sources/builtin.sh v1.34.1 # https://github.com/argoproj/argo-cd/releases -./generation/sources/argo-cd.sh v2.13.3 +./generation/sources/argo-cd.sh v3.1.6 # https://github.com/cert-manager/cert-manager/releases -./generation/sources/cert-manager.sh v1.16.2 +./generation/sources/cert-manager.sh v1.18.2 # https://github.com/kubernetes-sigs/external-dns/releases -./generation/sources/external-dns.sh v0.15.1 +./generation/sources/external-dns.sh v0.19.0 # https://github.com/kubernetes/autoscaler/releases?q=vertical -./generation/sources/vpa.sh 1.2.1 +./generation/sources/vpa.sh 1.4.1 diff --git a/generation/sources/external-dns.sh b/generation/sources/external-dns.sh index 633b23c..53955a5 100755 --- a/generation/sources/external-dns.sh +++ b/generation/sources/external-dns.sh @@ -2,7 +2,7 @@ gitapi="https://api.github.com" upstream="kubernetes-sigs/external-dns" -crdpath="docs/contributing/crd-source" +crdpath="config/crd/standard" projectname="external-dns" specdir="generation/api-specs/$projectname-$1" @@ -11,7 +11,7 @@ then { echo 'mkdir '"$specdir" echo 'cd '"$specdir" wget -O - "$gitapi/repos/$upstream/contents/$crdpath?ref=$1" \ - | jq -r '.[] | select(.name | startswith("crd-")) | "wget \(.download_url)"' + | jq -r '.[] | select(.name | endswith(".yaml")) | "wget \(.download_url)"' } | sh -eux fi diff --git a/lib/argo-cd/argoproj.io@v1alpha1/structs.ts b/lib/argo-cd/argoproj.io@v1alpha1/structs.ts index 2e07cd0..978fd8f 100644 --- a/lib/argo-cd/argoproj.io@v1alpha1/structs.ts +++ b/lib/argo-cd/argoproj.io@v1alpha1/structs.ts @@ -46,6 +46,8 @@ export interface ApplicationSource { passCredentials?: boolean | null; releaseName?: string | null; skipCrds?: boolean | null; + skipSchemaValidation?: boolean | null; + skipTests?: boolean | null; valueFiles?: Array | null; values?: string | null; valuesObject?: c.JSONValue | null; @@ -59,8 +61,10 @@ export interface ApplicationSource { components?: Array | null; forceCommonAnnotations?: boolean | null; forceCommonLabels?: boolean | null; + ignoreMissingComponents?: boolean | null; images?: Array | null; kubeVersion?: string | null; + labelIncludeTemplates?: boolean | null; labelWithoutSelector?: boolean | null; namePrefix?: string | null; nameSuffix?: string | null; @@ -85,6 +89,7 @@ export interface ApplicationSource { }> | null; version?: string | null; } | null; + name?: string | null; path?: string | null; plugin?: { env?: Array<{ @@ -110,6 +115,7 @@ export function toApplicationSource(input: c.JSONValue): ApplicationSource { directory: c.readOpt(obj["directory"], toApplicationSource_directory), helm: c.readOpt(obj["helm"], toApplicationSource_helm), kustomize: c.readOpt(obj["kustomize"], toApplicationSource_kustomize), + name: c.readOpt(obj["name"], c.checkStr), path: c.readOpt(obj["path"], c.checkStr), plugin: c.readOpt(obj["plugin"], toApplicationSource_plugin), ref: c.readOpt(obj["ref"], c.checkStr), @@ -140,6 +146,8 @@ function toApplicationSource_helm(input: c.JSONValue) { passCredentials: c.readOpt(obj["passCredentials"], c.checkBool), releaseName: c.readOpt(obj["releaseName"], c.checkStr), skipCrds: c.readOpt(obj["skipCrds"], c.checkBool), + skipSchemaValidation: c.readOpt(obj["skipSchemaValidation"], c.checkBool), + skipTests: c.readOpt(obj["skipTests"], c.checkBool), valueFiles: c.readOpt(obj["valueFiles"], x => c.readList(x, c.checkStr)), values: c.readOpt(obj["values"], c.checkStr), valuesObject: c.readOpt(obj["valuesObject"], c.identity), @@ -155,8 +163,10 @@ function toApplicationSource_kustomize(input: c.JSONValue) { components: c.readOpt(obj["components"], x => c.readList(x, c.checkStr)), forceCommonAnnotations: c.readOpt(obj["forceCommonAnnotations"], c.checkBool), forceCommonLabels: c.readOpt(obj["forceCommonLabels"], c.checkBool), + ignoreMissingComponents: c.readOpt(obj["ignoreMissingComponents"], c.checkBool), images: c.readOpt(obj["images"], x => c.readList(x, c.checkStr)), kubeVersion: c.readOpt(obj["kubeVersion"], c.checkStr), + labelIncludeTemplates: c.readOpt(obj["labelIncludeTemplates"], c.checkBool), labelWithoutSelector: c.readOpt(obj["labelWithoutSelector"], c.checkBool), namePrefix: c.readOpt(obj["namePrefix"], c.checkStr), nameSuffix: c.readOpt(obj["nameSuffix"], c.checkStr), @@ -316,10 +326,25 @@ export interface Application { project: string; revisionHistoryLimit?: number | null; source?: ApplicationSource | null; + sourceHydrator?: { + drySource: { + path: string; + repoURL: string; + targetRevision: string; + }; + hydrateTo?: { + targetBranch: string; + } | null; + syncSource: { + path: string; + targetBranch: string; + }; + } | null; sources?: Array | null; syncPolicy?: { automated?: { allowEmpty?: boolean | null; + enabled?: boolean | null; prune?: boolean | null; selfHeal?: boolean | null; } | null; @@ -346,6 +371,7 @@ export interface Application { }> | null; controllerNamespace?: string | null; health?: { + lastTransitionTime?: c.Time | null; message?: string | null; status?: string | null; } | null; @@ -421,6 +447,7 @@ export interface Application { group: string; hookPhase?: string | null; hookType?: string | null; + images?: Array | null; kind: string; message?: string | null; name: string; @@ -440,6 +467,7 @@ export interface Application { resources?: Array<{ group?: string | null; health?: { + lastTransitionTime?: c.Time | null; message?: string | null; status?: string | null; } | null; @@ -447,11 +475,54 @@ export interface Application { kind?: string | null; name?: string | null; namespace?: string | null; + requiresDeletionConfirmation?: boolean | null; requiresPruning?: boolean | null; status?: string | null; syncWave?: number | null; version?: string | null; }> | null; + sourceHydrator?: { + currentOperation?: { + drySHA?: string | null; + finishedAt?: c.Time | null; + hydratedSHA?: string | null; + message: string; + phase: "Hydrating" | "Failed" | "Hydrated" | c.UnexpectedEnumValue; + sourceHydrator?: { + drySource: { + path: string; + repoURL: string; + targetRevision: string; + }; + hydrateTo?: { + targetBranch: string; + } | null; + syncSource: { + path: string; + targetBranch: string; + }; + } | null; + startedAt?: c.Time | null; + } | null; + lastSuccessfulOperation?: { + drySHA?: string | null; + hydratedSHA?: string | null; + sourceHydrator?: { + drySource: { + path: string; + repoURL: string; + targetRevision: string; + }; + hydrateTo?: { + targetBranch: string; + } | null; + syncSource: { + path: string; + targetBranch: string; + }; + } | null; + } | null; + } | null; sourceType?: string | null; sourceTypes?: Array | null; summary?: { @@ -516,6 +587,10 @@ export function fromApplication(input: Application): c.JSONValue { ...x, lastTransitionTime: x.lastTransitionTime != null ? c.fromTime(x.lastTransitionTime) : undefined, })), + health: input.status.health != null ? { + ...input.status.health, + lastTransitionTime: input.status.health.lastTransitionTime != null ? c.fromTime(input.status.health.lastTransitionTime) : undefined, + } : undefined, history: input.status.history?.map(x => ({ ...x, deployStartedAt: x.deployStartedAt != null ? c.fromTime(x.deployStartedAt) : undefined, @@ -543,6 +618,21 @@ export function fromApplication(input: Application): c.JSONValue { } : undefined, } : undefined, reconciledAt: input.status.reconciledAt != null ? c.fromTime(input.status.reconciledAt) : undefined, + resources: input.status.resources?.map(x => ({ + ...x, + health: x.health != null ? { + ...x.health, + lastTransitionTime: x.health.lastTransitionTime != null ? c.fromTime(x.health.lastTransitionTime) : undefined, + } : undefined, + })), + sourceHydrator: input.status.sourceHydrator != null ? { + ...input.status.sourceHydrator, + currentOperation: input.status.sourceHydrator.currentOperation != null ? { + ...input.status.sourceHydrator.currentOperation, + finishedAt: input.status.sourceHydrator.currentOperation.finishedAt != null ? c.fromTime(input.status.sourceHydrator.currentOperation.finishedAt) : undefined, + startedAt: input.status.sourceHydrator.currentOperation.startedAt != null ? c.fromTime(input.status.sourceHydrator.currentOperation.startedAt) : undefined, + } : undefined, + } : undefined, sync: input.status.sync != null ? { ...input.status.sync, comparedTo: input.status.sync.comparedTo != null ? { @@ -570,6 +660,7 @@ function toApplication_spec(input: c.JSONValue) { project: c.checkStr(obj["project"]), revisionHistoryLimit: c.readOpt(obj["revisionHistoryLimit"], c.checkNum), source: c.readOpt(obj["source"], toApplicationSource), + sourceHydrator: c.readOpt(obj["sourceHydrator"], toApplication_spec_sourceHydrator), sources: c.readOpt(obj["sources"], x => c.readList(x, toApplicationSource)), syncPolicy: c.readOpt(obj["syncPolicy"], toApplication_spec_syncPolicy), }} @@ -585,6 +676,7 @@ function toApplication_status(input: c.JSONValue) { reconciledAt: c.readOpt(obj["reconciledAt"], c.toTime), resourceHealthSource: c.readOpt(obj["resourceHealthSource"], c.checkStr), resources: c.readOpt(obj["resources"], x => c.readList(x, toApplication_status_resources)), + sourceHydrator: c.readOpt(obj["sourceHydrator"], toApplication_status_sourceHydrator), sourceType: c.readOpt(obj["sourceType"], c.checkStr), sourceTypes: c.readOpt(obj["sourceTypes"], x => c.readList(x, c.checkStr)), summary: c.readOpt(obj["summary"], toApplication_status_summary), @@ -647,6 +739,13 @@ function toApplication_spec_info(input: c.JSONValue) { name: c.checkStr(obj["name"]), value: c.checkStr(obj["value"]), }} +function toApplication_spec_sourceHydrator(input: c.JSONValue) { + const obj = c.checkObj(input); + return { + drySource: toApplication_spec_sourceHydrator_drySource(obj["drySource"]), + hydrateTo: c.readOpt(obj["hydrateTo"], toApplication_spec_sourceHydrator_hydrateTo), + syncSource: toApplication_spec_sourceHydrator_syncSource(obj["syncSource"]), + }} function toApplication_spec_syncPolicy(input: c.JSONValue) { const obj = c.checkObj(input); return { @@ -665,6 +764,7 @@ function toApplication_status_conditions(input: c.JSONValue) { function toApplication_status_health(input: c.JSONValue) { const obj = c.checkObj(input); return { + lastTransitionTime: c.readOpt(obj["lastTransitionTime"], c.toTime), message: c.readOpt(obj["message"], c.checkStr), status: c.readOpt(obj["status"], c.checkStr), }} @@ -700,11 +800,18 @@ function toApplication_status_resources(input: c.JSONValue) { kind: c.readOpt(obj["kind"], c.checkStr), name: c.readOpt(obj["name"], c.checkStr), namespace: c.readOpt(obj["namespace"], c.checkStr), + requiresDeletionConfirmation: c.readOpt(obj["requiresDeletionConfirmation"], c.checkBool), requiresPruning: c.readOpt(obj["requiresPruning"], c.checkBool), status: c.readOpt(obj["status"], c.checkStr), syncWave: c.readOpt(obj["syncWave"], c.checkNum), version: c.readOpt(obj["version"], c.checkStr), }} +function toApplication_status_sourceHydrator(input: c.JSONValue) { + const obj = c.checkObj(input); + return { + currentOperation: c.readOpt(obj["currentOperation"], toApplication_status_sourceHydrator_currentOperation), + lastSuccessfulOperation: c.readOpt(obj["lastSuccessfulOperation"], toApplication_status_sourceHydrator_lastSuccessfulOperation), + }} function toApplication_status_summary(input: c.JSONValue) { const obj = c.checkObj(input); return { @@ -740,10 +847,29 @@ function toApplication_operation_sync_syncStrategy(input: c.JSONValue) { apply: c.readOpt(obj["apply"], toApplication_operation_sync_syncStrategy_apply), hook: c.readOpt(obj["hook"], toApplication_operation_sync_syncStrategy_hook), }} +function toApplication_spec_sourceHydrator_drySource(input: c.JSONValue) { + const obj = c.checkObj(input); + return { + path: c.checkStr(obj["path"]), + repoURL: c.checkStr(obj["repoURL"]), + targetRevision: c.checkStr(obj["targetRevision"]), + }} +function toApplication_spec_sourceHydrator_hydrateTo(input: c.JSONValue) { + const obj = c.checkObj(input); + return { + targetBranch: c.checkStr(obj["targetBranch"]), + }} +function toApplication_spec_sourceHydrator_syncSource(input: c.JSONValue) { + const obj = c.checkObj(input); + return { + path: c.checkStr(obj["path"]), + targetBranch: c.checkStr(obj["targetBranch"]), + }} function toApplication_spec_syncPolicy_automated(input: c.JSONValue) { const obj = c.checkObj(input); return { allowEmpty: c.readOpt(obj["allowEmpty"], c.checkBool), + enabled: c.readOpt(obj["enabled"], c.checkBool), prune: c.readOpt(obj["prune"], c.checkBool), selfHeal: c.readOpt(obj["selfHeal"], c.checkBool), }} @@ -786,9 +912,28 @@ function toApplication_status_operationState_syncResult(input: c.JSONValue) { function toApplication_status_resources_health(input: c.JSONValue) { const obj = c.checkObj(input); return { + lastTransitionTime: c.readOpt(obj["lastTransitionTime"], c.toTime), message: c.readOpt(obj["message"], c.checkStr), status: c.readOpt(obj["status"], c.checkStr), }} +function toApplication_status_sourceHydrator_currentOperation(input: c.JSONValue) { + const obj = c.checkObj(input); + return { + drySHA: c.readOpt(obj["drySHA"], c.checkStr), + finishedAt: c.readOpt(obj["finishedAt"], c.toTime), + hydratedSHA: c.readOpt(obj["hydratedSHA"], c.checkStr), + message: c.checkStr(obj["message"]), + phase: (x => c.readEnum<"Hydrating" | "Failed" | "Hydrated" | c.UnexpectedEnumValue>(x))(obj["phase"]), + sourceHydrator: c.readOpt(obj["sourceHydrator"], toApplication_status_sourceHydrator_currentOperation_sourceHydrator), + startedAt: c.readOpt(obj["startedAt"], c.toTime), + }} +function toApplication_status_sourceHydrator_lastSuccessfulOperation(input: c.JSONValue) { + const obj = c.checkObj(input); + return { + drySHA: c.readOpt(obj["drySHA"], c.checkStr), + hydratedSHA: c.readOpt(obj["hydratedSHA"], c.checkStr), + sourceHydrator: c.readOpt(obj["sourceHydrator"], toApplication_status_sourceHydrator_lastSuccessfulOperation_sourceHydrator), + }} function toApplication_status_sync_comparedTo(input: c.JSONValue) { const obj = c.checkObj(input); return { @@ -859,6 +1004,7 @@ function toApplication_status_operationState_syncResult_resources(input: c.JSONV group: c.checkStr(obj["group"]), hookPhase: c.readOpt(obj["hookPhase"], c.checkStr), hookType: c.readOpt(obj["hookType"], c.checkStr), + images: c.readOpt(obj["images"], x => c.readList(x, c.checkStr)), kind: c.checkStr(obj["kind"]), message: c.readOpt(obj["message"], c.checkStr), name: c.checkStr(obj["name"]), @@ -867,6 +1013,20 @@ function toApplication_status_operationState_syncResult_resources(input: c.JSONV syncPhase: c.readOpt(obj["syncPhase"], c.checkStr), version: c.checkStr(obj["version"]), }} +function toApplication_status_sourceHydrator_currentOperation_sourceHydrator(input: c.JSONValue) { + const obj = c.checkObj(input); + return { + drySource: toApplication_status_sourceHydrator_currentOperation_sourceHydrator_drySource(obj["drySource"]), + hydrateTo: c.readOpt(obj["hydrateTo"], toApplication_status_sourceHydrator_currentOperation_sourceHydrator_hydrateTo), + syncSource: toApplication_status_sourceHydrator_currentOperation_sourceHydrator_syncSource(obj["syncSource"]), + }} +function toApplication_status_sourceHydrator_lastSuccessfulOperation_sourceHydrator(input: c.JSONValue) { + const obj = c.checkObj(input); + return { + drySource: toApplication_status_sourceHydrator_lastSuccessfulOperation_sourceHydrator_drySource(obj["drySource"]), + hydrateTo: c.readOpt(obj["hydrateTo"], toApplication_status_sourceHydrator_lastSuccessfulOperation_sourceHydrator_hydrateTo), + syncSource: toApplication_status_sourceHydrator_lastSuccessfulOperation_sourceHydrator_syncSource(obj["syncSource"]), + }} function toApplication_status_sync_comparedTo_destination(input: c.JSONValue) { const obj = c.checkObj(input); return { @@ -906,6 +1066,42 @@ function toApplication_status_operationState_operation_sync_syncStrategy(input: apply: c.readOpt(obj["apply"], toApplication_status_operationState_operation_sync_syncStrategy_apply), hook: c.readOpt(obj["hook"], toApplication_status_operationState_operation_sync_syncStrategy_hook), }} +function toApplication_status_sourceHydrator_currentOperation_sourceHydrator_drySource(input: c.JSONValue) { + const obj = c.checkObj(input); + return { + path: c.checkStr(obj["path"]), + repoURL: c.checkStr(obj["repoURL"]), + targetRevision: c.checkStr(obj["targetRevision"]), + }} +function toApplication_status_sourceHydrator_currentOperation_sourceHydrator_hydrateTo(input: c.JSONValue) { + const obj = c.checkObj(input); + return { + targetBranch: c.checkStr(obj["targetBranch"]), + }} +function toApplication_status_sourceHydrator_currentOperation_sourceHydrator_syncSource(input: c.JSONValue) { + const obj = c.checkObj(input); + return { + path: c.checkStr(obj["path"]), + targetBranch: c.checkStr(obj["targetBranch"]), + }} +function toApplication_status_sourceHydrator_lastSuccessfulOperation_sourceHydrator_drySource(input: c.JSONValue) { + const obj = c.checkObj(input); + return { + path: c.checkStr(obj["path"]), + repoURL: c.checkStr(obj["repoURL"]), + targetRevision: c.checkStr(obj["targetRevision"]), + }} +function toApplication_status_sourceHydrator_lastSuccessfulOperation_sourceHydrator_hydrateTo(input: c.JSONValue) { + const obj = c.checkObj(input); + return { + targetBranch: c.checkStr(obj["targetBranch"]), + }} +function toApplication_status_sourceHydrator_lastSuccessfulOperation_sourceHydrator_syncSource(input: c.JSONValue) { + const obj = c.checkObj(input); + return { + path: c.checkStr(obj["path"]), + targetBranch: c.checkStr(obj["targetBranch"]), + }} function toApplication_status_operationState_operation_sync_syncStrategy_apply(input: c.JSONValue) { const obj = c.checkObj(input); return { @@ -939,6 +1135,7 @@ export interface ApplicationSetGenerator { values?: Record | null; } | null; clusters?: { + flatList?: boolean | null; selector?: MetaV1.LabelSelector | null; template?: ApplicationTemplate | null; values?: Record | null; @@ -949,6 +1146,7 @@ export interface ApplicationSetGenerator { path: string; }> | null; files?: Array<{ + exclude?: boolean | null; path: string; }> | null; pathParamPrefix?: string | null; @@ -1043,6 +1241,7 @@ export interface ApplicationSetGenerator { gitea?: { api: string; insecure?: boolean | null; + labels?: Array | null; owner: string; repo: string; tokenRef?: { @@ -1078,6 +1277,7 @@ export interface ApplicationSetGenerator { } | null; requeueAfterSeconds?: number | null; template?: ApplicationTemplate | null; + values?: Record | null; } | null; scmProvider?: { awsCodeCommit?: { @@ -1254,6 +1454,7 @@ function toApplicationSetGenerator_clusterDecisionResource(input: c.JSONValue) { function toApplicationSetGenerator_clusters(input: c.JSONValue) { const obj = c.checkObj(input); return { + flatList: c.readOpt(obj["flatList"], c.checkBool), selector: c.readOpt(obj["selector"], MetaV1.toLabelSelector), template: c.readOpt(obj["template"], toApplicationTemplate), values: c.readOpt(obj["values"], x => c.readMap(x, c.checkStr)), @@ -1311,6 +1512,7 @@ function toApplicationSetGenerator_pullRequest(input: c.JSONValue) { gitlab: c.readOpt(obj["gitlab"], toApplicationSetGenerator_pullRequest_gitlab), requeueAfterSeconds: c.readOpt(obj["requeueAfterSeconds"], c.checkNum), template: c.readOpt(obj["template"], toApplicationTemplate), + values: c.readOpt(obj["values"], x => c.readMap(x, c.checkStr)), }} function toApplicationSetGenerator_scmProvider(input: c.JSONValue) { const obj = c.checkObj(input); @@ -1337,6 +1539,7 @@ function toApplicationSetGenerator_git_directories(input: c.JSONValue) { function toApplicationSetGenerator_git_files(input: c.JSONValue) { const obj = c.checkObj(input); return { + exclude: c.readOpt(obj["exclude"], c.checkBool), path: c.checkStr(obj["path"]), }} function toApplicationSetGenerator_plugin_configMapRef(input: c.JSONValue) { @@ -1390,6 +1593,7 @@ function toApplicationSetGenerator_pullRequest_gitea(input: c.JSONValue) { return { api: c.checkStr(obj["api"]), insecure: c.readOpt(obj["insecure"], c.checkBool), + labels: c.readOpt(obj["labels"], x => c.readList(x, c.checkStr)), owner: c.checkStr(obj["owner"]), repo: c.checkStr(obj["repo"]), tokenRef: c.readOpt(obj["tokenRef"], toApplicationSetGenerator_pullRequest_gitea_tokenRef), @@ -1675,10 +1879,25 @@ export interface ApplicationTemplate { project: string; revisionHistoryLimit?: number | null; source?: ApplicationSource | null; + sourceHydrator?: { + drySource: { + path: string; + repoURL: string; + targetRevision: string; + }; + hydrateTo?: { + targetBranch: string; + } | null; + syncSource: { + path: string; + targetBranch: string; + }; + } | null; sources?: Array | null; syncPolicy?: { automated?: { allowEmpty?: boolean | null; + enabled?: boolean | null; prune?: boolean | null; selfHeal?: boolean | null; } | null; @@ -1731,6 +1950,7 @@ function toApplicationTemplate_spec(input: c.JSONValue) { project: c.checkStr(obj["project"]), revisionHistoryLimit: c.readOpt(obj["revisionHistoryLimit"], c.checkNum), source: c.readOpt(obj["source"], toApplicationSource), + sourceHydrator: c.readOpt(obj["sourceHydrator"], toApplicationTemplate_spec_sourceHydrator), sources: c.readOpt(obj["sources"], x => c.readList(x, toApplicationSource)), syncPolicy: c.readOpt(obj["syncPolicy"], toApplicationTemplate_spec_syncPolicy), }} @@ -1758,6 +1978,13 @@ function toApplicationTemplate_spec_info(input: c.JSONValue) { name: c.checkStr(obj["name"]), value: c.checkStr(obj["value"]), }} +function toApplicationTemplate_spec_sourceHydrator(input: c.JSONValue) { + const obj = c.checkObj(input); + return { + drySource: toApplicationTemplate_spec_sourceHydrator_drySource(obj["drySource"]), + hydrateTo: c.readOpt(obj["hydrateTo"], toApplicationTemplate_spec_sourceHydrator_hydrateTo), + syncSource: toApplicationTemplate_spec_sourceHydrator_syncSource(obj["syncSource"]), + }} function toApplicationTemplate_spec_syncPolicy(input: c.JSONValue) { const obj = c.checkObj(input); return { @@ -1766,10 +1993,29 @@ function toApplicationTemplate_spec_syncPolicy(input: c.JSONValue) { retry: c.readOpt(obj["retry"], toApplicationTemplate_spec_syncPolicy_retry), syncOptions: c.readOpt(obj["syncOptions"], x => c.readList(x, c.checkStr)), }} +function toApplicationTemplate_spec_sourceHydrator_drySource(input: c.JSONValue) { + const obj = c.checkObj(input); + return { + path: c.checkStr(obj["path"]), + repoURL: c.checkStr(obj["repoURL"]), + targetRevision: c.checkStr(obj["targetRevision"]), + }} +function toApplicationTemplate_spec_sourceHydrator_hydrateTo(input: c.JSONValue) { + const obj = c.checkObj(input); + return { + targetBranch: c.checkStr(obj["targetBranch"]), + }} +function toApplicationTemplate_spec_sourceHydrator_syncSource(input: c.JSONValue) { + const obj = c.checkObj(input); + return { + path: c.checkStr(obj["path"]), + targetBranch: c.checkStr(obj["targetBranch"]), + }} function toApplicationTemplate_spec_syncPolicy_automated(input: c.JSONValue) { const obj = c.checkObj(input); return { allowEmpty: c.readOpt(obj["allowEmpty"], c.checkBool), + enabled: c.readOpt(obj["enabled"], c.checkBool), prune: c.readOpt(obj["prune"], c.checkBool), selfHeal: c.readOpt(obj["selfHeal"], c.checkBool), }} @@ -1850,6 +2096,7 @@ export interface ApplicationSet { resources?: Array<{ group?: string | null; health?: { + lastTransitionTime?: c.Time | null; message?: string | null; status?: string | null; } | null; @@ -1857,6 +2104,7 @@ export interface ApplicationSet { kind?: string | null; name?: string | null; namespace?: string | null; + requiresDeletionConfirmation?: boolean | null; requiresPruning?: boolean | null; status?: string | null; syncWave?: number | null; @@ -1892,6 +2140,13 @@ export function fromApplicationSet(input: ApplicationSet): c.JSONValue { ...x, lastTransitionTime: x.lastTransitionTime != null ? c.fromTime(x.lastTransitionTime) : undefined, })), + resources: input.status.resources?.map(x => ({ + ...x, + health: x.health != null ? { + ...x.health, + lastTransitionTime: x.health.lastTransitionTime != null ? c.fromTime(x.health.lastTransitionTime) : undefined, + } : undefined, + })), } : undefined, }} function toApplicationSet_spec(input: c.JSONValue) { @@ -1968,6 +2223,7 @@ function toApplicationSet_status_resources(input: c.JSONValue) { kind: c.readOpt(obj["kind"], c.checkStr), name: c.readOpt(obj["name"], c.checkStr), namespace: c.readOpt(obj["namespace"], c.checkStr), + requiresDeletionConfirmation: c.readOpt(obj["requiresDeletionConfirmation"], c.checkBool), requiresPruning: c.readOpt(obj["requiresPruning"], c.checkBool), status: c.readOpt(obj["status"], c.checkStr), syncWave: c.readOpt(obj["syncWave"], c.checkNum), @@ -1981,6 +2237,7 @@ function toApplicationSet_spec_strategy_rollingSync(input: c.JSONValue) { function toApplicationSet_status_resources_health(input: c.JSONValue) { const obj = c.checkObj(input); return { + lastTransitionTime: c.readOpt(obj["lastTransitionTime"], c.toTime), message: c.readOpt(obj["message"], c.checkStr), status: c.readOpt(obj["status"], c.checkStr), }} @@ -2074,8 +2331,10 @@ export interface AppProject { sourceNamespaces?: Array | null; sourceRepos?: Array | null; syncWindows?: Array<{ + andOperator?: boolean | null; applications?: Array | null; clusters?: Array | null; + description?: string | null; duration?: string | null; kind?: string | null; manualSync?: boolean | null; @@ -2192,8 +2451,10 @@ function toAppProject_spec_signatureKeys(input: c.JSONValue) { function toAppProject_spec_syncWindows(input: c.JSONValue) { const obj = c.checkObj(input); return { + andOperator: c.readOpt(obj["andOperator"], c.checkBool), applications: c.readOpt(obj["applications"], x => c.readList(x, c.checkStr)), clusters: c.readOpt(obj["clusters"], x => c.readList(x, c.checkStr)), + description: c.readOpt(obj["description"], c.checkStr), duration: c.readOpt(obj["duration"], c.checkStr), kind: c.readOpt(obj["kind"], c.checkStr), manualSync: c.readOpt(obj["manualSync"], c.checkBool), diff --git a/lib/builtin/admissionregistration.k8s.io@v1beta1/mod.ts b/lib/builtin/admissionregistration.k8s.io@v1beta1/mod.ts index 50fd2b9..fa33041 100644 --- a/lib/builtin/admissionregistration.k8s.io@v1beta1/mod.ts +++ b/lib/builtin/admissionregistration.k8s.io@v1beta1/mod.ts @@ -13,285 +13,238 @@ export class AdmissionregistrationV1beta1Api { this.#client = client; } - async getValidatingAdmissionPolicyList( + async getMutatingAdmissionPolicyList( opts: operations.GetListOpts = {}, - ): Promise { + ): Promise { const resp = await this.#client.performRequest({ method: "GET", - path: `${this.#root}validatingadmissionpolicies`, + path: `${this.#root}mutatingadmissionpolicies`, expectJson: true, querystring: operations.formatGetListOpts(opts), abortSignal: opts.abortSignal, }); - return AdmissionregistrationV1beta1.toValidatingAdmissionPolicyList(resp); + return AdmissionregistrationV1beta1.toMutatingAdmissionPolicyList(resp); } - async watchValidatingAdmissionPolicyList( + async watchMutatingAdmissionPolicyList( opts: operations.WatchListOpts = {}, - ): Promise> { + ): Promise> { const resp = await this.#client.performRequest({ method: "GET", - path: `${this.#root}validatingadmissionpolicies`, + path: `${this.#root}mutatingadmissionpolicies`, expectJson: true, expectStream: true, querystring: operations.formatWatchListOpts(opts), abortSignal: opts.abortSignal, }); - return resp.pipeThrough(new c.WatchEventTransformer(AdmissionregistrationV1beta1.toValidatingAdmissionPolicy, MetaV1.toStatus)); + return resp.pipeThrough(new c.WatchEventTransformer(AdmissionregistrationV1beta1.toMutatingAdmissionPolicy, MetaV1.toStatus)); } - async createValidatingAdmissionPolicy( - body: AdmissionregistrationV1beta1.ValidatingAdmissionPolicy, + async createMutatingAdmissionPolicy( + body: AdmissionregistrationV1beta1.MutatingAdmissionPolicy, opts: operations.PutOpts = {}, - ): Promise { + ): Promise { const resp = await this.#client.performRequest({ method: "POST", - path: `${this.#root}validatingadmissionpolicies`, + path: `${this.#root}mutatingadmissionpolicies`, expectJson: true, querystring: operations.formatPutOpts(opts), - bodyJson: AdmissionregistrationV1beta1.fromValidatingAdmissionPolicy(body), + bodyJson: AdmissionregistrationV1beta1.fromMutatingAdmissionPolicy(body), abortSignal: opts.abortSignal, }); - return AdmissionregistrationV1beta1.toValidatingAdmissionPolicy(resp); + return AdmissionregistrationV1beta1.toMutatingAdmissionPolicy(resp); } - async deleteValidatingAdmissionPolicyList( + async deleteMutatingAdmissionPolicyList( opts: operations.DeleteListOpts = {}, - ): Promise { + ): Promise { const resp = await this.#client.performRequest({ method: "DELETE", - path: `${this.#root}validatingadmissionpolicies`, + path: `${this.#root}mutatingadmissionpolicies`, expectJson: true, querystring: operations.formatDeleteListOpts(opts), abortSignal: opts.abortSignal, }); - return AdmissionregistrationV1beta1.toValidatingAdmissionPolicyList(resp); + return AdmissionregistrationV1beta1.toMutatingAdmissionPolicyList(resp); } - async getValidatingAdmissionPolicy( + async getMutatingAdmissionPolicy( name: string, opts: operations.NoOpts = {}, - ): Promise { + ): Promise { const resp = await this.#client.performRequest({ method: "GET", - path: `${this.#root}validatingadmissionpolicies/${name}`, + path: `${this.#root}mutatingadmissionpolicies/${name}`, expectJson: true, abortSignal: opts.abortSignal, }); - return AdmissionregistrationV1beta1.toValidatingAdmissionPolicy(resp); + return AdmissionregistrationV1beta1.toMutatingAdmissionPolicy(resp); } - async deleteValidatingAdmissionPolicy( + async deleteMutatingAdmissionPolicy( name: string, opts: operations.DeleteOpts = {}, - ): Promise { + ): Promise { const resp = await this.#client.performRequest({ method: "DELETE", - path: `${this.#root}validatingadmissionpolicies/${name}`, + path: `${this.#root}mutatingadmissionpolicies/${name}`, expectJson: true, querystring: operations.formatDeleteOpts(opts), abortSignal: opts.abortSignal, }); if (c.isStatusKind(resp)) return MetaV1.toStatus(resp); - return AdmissionregistrationV1beta1.toValidatingAdmissionPolicy(resp); + return AdmissionregistrationV1beta1.toMutatingAdmissionPolicy(resp); } - async replaceValidatingAdmissionPolicy( + async replaceMutatingAdmissionPolicy( name: string, - body: AdmissionregistrationV1beta1.ValidatingAdmissionPolicy, + body: AdmissionregistrationV1beta1.MutatingAdmissionPolicy, opts: operations.PutOpts = {}, - ): Promise { + ): Promise { const resp = await this.#client.performRequest({ method: "PUT", - path: `${this.#root}validatingadmissionpolicies/${name}`, + path: `${this.#root}mutatingadmissionpolicies/${name}`, expectJson: true, querystring: operations.formatPutOpts(opts), - bodyJson: AdmissionregistrationV1beta1.fromValidatingAdmissionPolicy(body), + bodyJson: AdmissionregistrationV1beta1.fromMutatingAdmissionPolicy(body), abortSignal: opts.abortSignal, }); - return AdmissionregistrationV1beta1.toValidatingAdmissionPolicy(resp); + return AdmissionregistrationV1beta1.toMutatingAdmissionPolicy(resp); } - async patchValidatingAdmissionPolicy( + async patchMutatingAdmissionPolicy( name: string, type: c.PatchType, - body: AdmissionregistrationV1beta1.ValidatingAdmissionPolicy | c.JsonPatch, + body: AdmissionregistrationV1beta1.MutatingAdmissionPolicy | c.JsonPatch, opts: operations.PatchOpts = {}, - ): Promise { + ): Promise { const resp = await this.#client.performRequest({ method: "PATCH", - path: `${this.#root}validatingadmissionpolicies/${name}`, + path: `${this.#root}mutatingadmissionpolicies/${name}`, expectJson: true, querystring: operations.formatPatchOpts(opts), contentType: c.getPatchContentType(type), - bodyJson: Array.isArray(body) ? body : AdmissionregistrationV1beta1.fromValidatingAdmissionPolicy(body), + bodyJson: Array.isArray(body) ? body : AdmissionregistrationV1beta1.fromMutatingAdmissionPolicy(body), abortSignal: opts.abortSignal, }); - return AdmissionregistrationV1beta1.toValidatingAdmissionPolicy(resp); + return AdmissionregistrationV1beta1.toMutatingAdmissionPolicy(resp); } - async getValidatingAdmissionPolicyStatus( - name: string, - opts: operations.NoOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "GET", - path: `${this.#root}validatingadmissionpolicies/${name}/status`, - expectJson: true, - abortSignal: opts.abortSignal, - }); - return AdmissionregistrationV1beta1.toValidatingAdmissionPolicy(resp); - } - - async replaceValidatingAdmissionPolicyStatus( - name: string, - body: AdmissionregistrationV1beta1.ValidatingAdmissionPolicy, - opts: operations.PutOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "PUT", - path: `${this.#root}validatingadmissionpolicies/${name}/status`, - expectJson: true, - querystring: operations.formatPutOpts(opts), - bodyJson: AdmissionregistrationV1beta1.fromValidatingAdmissionPolicy(body), - abortSignal: opts.abortSignal, - }); - return AdmissionregistrationV1beta1.toValidatingAdmissionPolicy(resp); - } - - async patchValidatingAdmissionPolicyStatus( - name: string, - type: c.PatchType, - body: AdmissionregistrationV1beta1.ValidatingAdmissionPolicy | c.JsonPatch, - opts: operations.PatchOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "PATCH", - path: `${this.#root}validatingadmissionpolicies/${name}/status`, - expectJson: true, - querystring: operations.formatPatchOpts(opts), - contentType: c.getPatchContentType(type), - bodyJson: Array.isArray(body) ? body : AdmissionregistrationV1beta1.fromValidatingAdmissionPolicy(body), - abortSignal: opts.abortSignal, - }); - return AdmissionregistrationV1beta1.toValidatingAdmissionPolicy(resp); - } - - async getValidatingAdmissionPolicyBindingList( + async getMutatingAdmissionPolicyBindingList( opts: operations.GetListOpts = {}, - ): Promise { + ): Promise { const resp = await this.#client.performRequest({ method: "GET", - path: `${this.#root}validatingadmissionpolicybindings`, + path: `${this.#root}mutatingadmissionpolicybindings`, expectJson: true, querystring: operations.formatGetListOpts(opts), abortSignal: opts.abortSignal, }); - return AdmissionregistrationV1beta1.toValidatingAdmissionPolicyBindingList(resp); + return AdmissionregistrationV1beta1.toMutatingAdmissionPolicyBindingList(resp); } - async watchValidatingAdmissionPolicyBindingList( + async watchMutatingAdmissionPolicyBindingList( opts: operations.WatchListOpts = {}, - ): Promise> { + ): Promise> { const resp = await this.#client.performRequest({ method: "GET", - path: `${this.#root}validatingadmissionpolicybindings`, + path: `${this.#root}mutatingadmissionpolicybindings`, expectJson: true, expectStream: true, querystring: operations.formatWatchListOpts(opts), abortSignal: opts.abortSignal, }); - return resp.pipeThrough(new c.WatchEventTransformer(AdmissionregistrationV1beta1.toValidatingAdmissionPolicyBinding, MetaV1.toStatus)); + return resp.pipeThrough(new c.WatchEventTransformer(AdmissionregistrationV1beta1.toMutatingAdmissionPolicyBinding, MetaV1.toStatus)); } - async createValidatingAdmissionPolicyBinding( - body: AdmissionregistrationV1beta1.ValidatingAdmissionPolicyBinding, + async createMutatingAdmissionPolicyBinding( + body: AdmissionregistrationV1beta1.MutatingAdmissionPolicyBinding, opts: operations.PutOpts = {}, - ): Promise { + ): Promise { const resp = await this.#client.performRequest({ method: "POST", - path: `${this.#root}validatingadmissionpolicybindings`, + path: `${this.#root}mutatingadmissionpolicybindings`, expectJson: true, querystring: operations.formatPutOpts(opts), - bodyJson: AdmissionregistrationV1beta1.fromValidatingAdmissionPolicyBinding(body), + bodyJson: AdmissionregistrationV1beta1.fromMutatingAdmissionPolicyBinding(body), abortSignal: opts.abortSignal, }); - return AdmissionregistrationV1beta1.toValidatingAdmissionPolicyBinding(resp); + return AdmissionregistrationV1beta1.toMutatingAdmissionPolicyBinding(resp); } - async deleteValidatingAdmissionPolicyBindingList( + async deleteMutatingAdmissionPolicyBindingList( opts: operations.DeleteListOpts = {}, - ): Promise { + ): Promise { const resp = await this.#client.performRequest({ method: "DELETE", - path: `${this.#root}validatingadmissionpolicybindings`, + path: `${this.#root}mutatingadmissionpolicybindings`, expectJson: true, querystring: operations.formatDeleteListOpts(opts), abortSignal: opts.abortSignal, }); - return AdmissionregistrationV1beta1.toValidatingAdmissionPolicyBindingList(resp); + return AdmissionregistrationV1beta1.toMutatingAdmissionPolicyBindingList(resp); } - async getValidatingAdmissionPolicyBinding( + async getMutatingAdmissionPolicyBinding( name: string, opts: operations.NoOpts = {}, - ): Promise { + ): Promise { const resp = await this.#client.performRequest({ method: "GET", - path: `${this.#root}validatingadmissionpolicybindings/${name}`, + path: `${this.#root}mutatingadmissionpolicybindings/${name}`, expectJson: true, abortSignal: opts.abortSignal, }); - return AdmissionregistrationV1beta1.toValidatingAdmissionPolicyBinding(resp); + return AdmissionregistrationV1beta1.toMutatingAdmissionPolicyBinding(resp); } - async deleteValidatingAdmissionPolicyBinding( + async deleteMutatingAdmissionPolicyBinding( name: string, opts: operations.DeleteOpts = {}, - ): Promise { + ): Promise { const resp = await this.#client.performRequest({ method: "DELETE", - path: `${this.#root}validatingadmissionpolicybindings/${name}`, + path: `${this.#root}mutatingadmissionpolicybindings/${name}`, expectJson: true, querystring: operations.formatDeleteOpts(opts), abortSignal: opts.abortSignal, }); if (c.isStatusKind(resp)) return MetaV1.toStatus(resp); - return AdmissionregistrationV1beta1.toValidatingAdmissionPolicyBinding(resp); + return AdmissionregistrationV1beta1.toMutatingAdmissionPolicyBinding(resp); } - async replaceValidatingAdmissionPolicyBinding( + async replaceMutatingAdmissionPolicyBinding( name: string, - body: AdmissionregistrationV1beta1.ValidatingAdmissionPolicyBinding, + body: AdmissionregistrationV1beta1.MutatingAdmissionPolicyBinding, opts: operations.PutOpts = {}, - ): Promise { + ): Promise { const resp = await this.#client.performRequest({ method: "PUT", - path: `${this.#root}validatingadmissionpolicybindings/${name}`, + path: `${this.#root}mutatingadmissionpolicybindings/${name}`, expectJson: true, querystring: operations.formatPutOpts(opts), - bodyJson: AdmissionregistrationV1beta1.fromValidatingAdmissionPolicyBinding(body), + bodyJson: AdmissionregistrationV1beta1.fromMutatingAdmissionPolicyBinding(body), abortSignal: opts.abortSignal, }); - return AdmissionregistrationV1beta1.toValidatingAdmissionPolicyBinding(resp); + return AdmissionregistrationV1beta1.toMutatingAdmissionPolicyBinding(resp); } - async patchValidatingAdmissionPolicyBinding( + async patchMutatingAdmissionPolicyBinding( name: string, type: c.PatchType, - body: AdmissionregistrationV1beta1.ValidatingAdmissionPolicyBinding | c.JsonPatch, + body: AdmissionregistrationV1beta1.MutatingAdmissionPolicyBinding | c.JsonPatch, opts: operations.PatchOpts = {}, - ): Promise { + ): Promise { const resp = await this.#client.performRequest({ method: "PATCH", - path: `${this.#root}validatingadmissionpolicybindings/${name}`, + path: `${this.#root}mutatingadmissionpolicybindings/${name}`, expectJson: true, querystring: operations.formatPatchOpts(opts), contentType: c.getPatchContentType(type), - bodyJson: Array.isArray(body) ? body : AdmissionregistrationV1beta1.fromValidatingAdmissionPolicyBinding(body), + bodyJson: Array.isArray(body) ? body : AdmissionregistrationV1beta1.fromMutatingAdmissionPolicyBinding(body), abortSignal: opts.abortSignal, }); - return AdmissionregistrationV1beta1.toValidatingAdmissionPolicyBinding(resp); + return AdmissionregistrationV1beta1.toMutatingAdmissionPolicyBinding(resp); } } diff --git a/lib/builtin/admissionregistration.k8s.io@v1beta1/structs.ts b/lib/builtin/admissionregistration.k8s.io@v1beta1/structs.ts index 499b4e0..d41b0b5 100644 --- a/lib/builtin/admissionregistration.k8s.io@v1beta1/structs.ts +++ b/lib/builtin/admissionregistration.k8s.io@v1beta1/structs.ts @@ -7,34 +7,30 @@ type ListOf = { items: Array; }; -/** AuditAnnotation describes how to produce an audit annotation for an API request. */ -export interface AuditAnnotation { - key: string; - valueExpression: string; +/** ApplyConfiguration defines the desired configuration values of an object. */ +export interface ApplyConfiguration { + expression?: string | null; } -export function toAuditAnnotation(input: c.JSONValue): AuditAnnotation { +export function toApplyConfiguration(input: c.JSONValue): ApplyConfiguration { const obj = c.checkObj(input); return { - key: c.checkStr(obj["key"]), - valueExpression: c.checkStr(obj["valueExpression"]), + expression: c.readOpt(obj["expression"], c.checkStr), }} -export function fromAuditAnnotation(input: AuditAnnotation): c.JSONValue { +export function fromApplyConfiguration(input: ApplyConfiguration): c.JSONValue { return { ...input, }} -/** ExpressionWarning is a warning information that targets a specific expression. */ -export interface ExpressionWarning { - fieldRef: string; - warning: string; +/** JSONPatch defines a JSON Patch. */ +export interface JSONPatch { + expression?: string | null; } -export function toExpressionWarning(input: c.JSONValue): ExpressionWarning { +export function toJSONPatch(input: c.JSONValue): JSONPatch { const obj = c.checkObj(input); return { - fieldRef: c.checkStr(obj["fieldRef"]), - warning: c.checkStr(obj["warning"]), + expression: c.readOpt(obj["expression"], c.checkStr), }} -export function fromExpressionWarning(input: ExpressionWarning): c.JSONValue { +export function fromJSONPatch(input: JSONPatch): c.JSONValue { return { ...input, }} @@ -105,241 +101,200 @@ export function fromNamedRuleWithOperations(input: NamedRuleWithOperations): c.J ...input, }} -/** ParamKind is a tuple of Group Kind and Version. */ -export interface ParamKind { - apiVersion?: string | null; - kind?: string | null; -} -export function toParamKind(input: c.JSONValue): ParamKind { - const obj = c.checkObj(input); - return { - apiVersion: c.readOpt(obj["apiVersion"], c.checkStr), - kind: c.readOpt(obj["kind"], c.checkStr), - }} -export function fromParamKind(input: ParamKind): c.JSONValue { - return { - ...input, - }} - -/** ParamRef describes how to locate the params to be used as input to expressions of rules applied by a policy binding. */ -export interface ParamRef { - name?: string | null; - namespace?: string | null; - parameterNotFoundAction?: string | null; - selector?: MetaV1.LabelSelector | null; -} -export function toParamRef(input: c.JSONValue): ParamRef { - const obj = c.checkObj(input); - return { - name: c.readOpt(obj["name"], c.checkStr), - namespace: c.readOpt(obj["namespace"], c.checkStr), - parameterNotFoundAction: c.readOpt(obj["parameterNotFoundAction"], c.checkStr), - selector: c.readOpt(obj["selector"], MetaV1.toLabelSelector), - }} -export function fromParamRef(input: ParamRef): c.JSONValue { - return { - ...input, - selector: input.selector != null ? MetaV1.fromLabelSelector(input.selector) : undefined, - }} - -/** TypeChecking contains results of type checking the expressions in the ValidatingAdmissionPolicy */ -export interface TypeChecking { - expressionWarnings?: Array | null; -} -export function toTypeChecking(input: c.JSONValue): TypeChecking { - const obj = c.checkObj(input); - return { - expressionWarnings: c.readOpt(obj["expressionWarnings"], x => c.readList(x, toExpressionWarning)), - }} -export function fromTypeChecking(input: TypeChecking): c.JSONValue { - return { - ...input, - expressionWarnings: input.expressionWarnings?.map(fromExpressionWarning), - }} - -/** ValidatingAdmissionPolicy describes the definition of an admission validation policy that accepts or rejects an object without changing it. */ -export interface ValidatingAdmissionPolicy { +/** MutatingAdmissionPolicy describes the definition of an admission mutation policy that mutates the object coming into admission chain. */ +export interface MutatingAdmissionPolicy { apiVersion?: "admissionregistration.k8s.io/v1beta1"; - kind?: "ValidatingAdmissionPolicy"; + kind?: "MutatingAdmissionPolicy"; metadata?: MetaV1.ObjectMeta | null; - spec?: ValidatingAdmissionPolicySpec | null; - status?: ValidatingAdmissionPolicyStatus | null; + spec?: MutatingAdmissionPolicySpec | null; } -export function toValidatingAdmissionPolicy(input: c.JSONValue): ValidatingAdmissionPolicy & c.ApiKind { +export function toMutatingAdmissionPolicy(input: c.JSONValue): MutatingAdmissionPolicy & c.ApiKind { const obj = c.checkObj(input); return { - ...c.assertOrAddApiVersionAndKind(obj, "admissionregistration.k8s.io/v1beta1", "ValidatingAdmissionPolicy"), + ...c.assertOrAddApiVersionAndKind(obj, "admissionregistration.k8s.io/v1beta1", "MutatingAdmissionPolicy"), metadata: c.readOpt(obj["metadata"], MetaV1.toObjectMeta), - spec: c.readOpt(obj["spec"], toValidatingAdmissionPolicySpec), - status: c.readOpt(obj["status"], toValidatingAdmissionPolicyStatus), + spec: c.readOpt(obj["spec"], toMutatingAdmissionPolicySpec), }} -export function fromValidatingAdmissionPolicy(input: ValidatingAdmissionPolicy): c.JSONValue { +export function fromMutatingAdmissionPolicy(input: MutatingAdmissionPolicy): c.JSONValue { return { - ...c.assertOrAddApiVersionAndKind(input, "admissionregistration.k8s.io/v1beta1", "ValidatingAdmissionPolicy"), + ...c.assertOrAddApiVersionAndKind(input, "admissionregistration.k8s.io/v1beta1", "MutatingAdmissionPolicy"), ...input, metadata: input.metadata != null ? MetaV1.fromObjectMeta(input.metadata) : undefined, - spec: input.spec != null ? fromValidatingAdmissionPolicySpec(input.spec) : undefined, - status: input.status != null ? fromValidatingAdmissionPolicyStatus(input.status) : undefined, + spec: input.spec != null ? fromMutatingAdmissionPolicySpec(input.spec) : undefined, }} -/** ValidatingAdmissionPolicySpec is the specification of the desired behavior of the AdmissionPolicy. */ -export interface ValidatingAdmissionPolicySpec { - auditAnnotations?: Array | null; +/** MutatingAdmissionPolicySpec is the specification of the desired behavior of the admission policy. */ +export interface MutatingAdmissionPolicySpec { failurePolicy?: string | null; matchConditions?: Array | null; matchConstraints?: MatchResources | null; + mutations?: Array | null; paramKind?: ParamKind | null; - validations?: Array | null; + reinvocationPolicy?: string | null; variables?: Array | null; } -export function toValidatingAdmissionPolicySpec(input: c.JSONValue): ValidatingAdmissionPolicySpec { +export function toMutatingAdmissionPolicySpec(input: c.JSONValue): MutatingAdmissionPolicySpec { const obj = c.checkObj(input); return { - auditAnnotations: c.readOpt(obj["auditAnnotations"], x => c.readList(x, toAuditAnnotation)), failurePolicy: c.readOpt(obj["failurePolicy"], c.checkStr), matchConditions: c.readOpt(obj["matchConditions"], x => c.readList(x, toMatchCondition)), matchConstraints: c.readOpt(obj["matchConstraints"], toMatchResources), + mutations: c.readOpt(obj["mutations"], x => c.readList(x, toMutation)), paramKind: c.readOpt(obj["paramKind"], toParamKind), - validations: c.readOpt(obj["validations"], x => c.readList(x, toValidation)), + reinvocationPolicy: c.readOpt(obj["reinvocationPolicy"], c.checkStr), variables: c.readOpt(obj["variables"], x => c.readList(x, toVariable)), }} -export function fromValidatingAdmissionPolicySpec(input: ValidatingAdmissionPolicySpec): c.JSONValue { +export function fromMutatingAdmissionPolicySpec(input: MutatingAdmissionPolicySpec): c.JSONValue { return { ...input, - auditAnnotations: input.auditAnnotations?.map(fromAuditAnnotation), matchConditions: input.matchConditions?.map(fromMatchCondition), matchConstraints: input.matchConstraints != null ? fromMatchResources(input.matchConstraints) : undefined, + mutations: input.mutations?.map(fromMutation), paramKind: input.paramKind != null ? fromParamKind(input.paramKind) : undefined, - validations: input.validations?.map(fromValidation), variables: input.variables?.map(fromVariable), }} -/** Validation specifies the CEL expression which is used to apply the validation. */ -export interface Validation { - expression: string; - message?: string | null; - messageExpression?: string | null; - reason?: string | null; +/** Mutation specifies the CEL expression which is used to apply the Mutation. */ +export interface Mutation { + applyConfiguration?: ApplyConfiguration | null; + jsonPatch?: JSONPatch | null; + patchType: string; } -export function toValidation(input: c.JSONValue): Validation { +export function toMutation(input: c.JSONValue): Mutation { const obj = c.checkObj(input); return { - expression: c.checkStr(obj["expression"]), - message: c.readOpt(obj["message"], c.checkStr), - messageExpression: c.readOpt(obj["messageExpression"], c.checkStr), - reason: c.readOpt(obj["reason"], c.checkStr), + applyConfiguration: c.readOpt(obj["applyConfiguration"], toApplyConfiguration), + jsonPatch: c.readOpt(obj["jsonPatch"], toJSONPatch), + patchType: c.checkStr(obj["patchType"]), }} -export function fromValidation(input: Validation): c.JSONValue { +export function fromMutation(input: Mutation): c.JSONValue { return { ...input, + applyConfiguration: input.applyConfiguration != null ? fromApplyConfiguration(input.applyConfiguration) : undefined, + jsonPatch: input.jsonPatch != null ? fromJSONPatch(input.jsonPatch) : undefined, }} -/** Variable is the definition of a variable that is used for composition. A variable is defined as a named expression. */ -export interface Variable { - expression: string; - name: string; +/** ParamKind is a tuple of Group Kind and Version. */ +export interface ParamKind { + apiVersion?: string | null; + kind?: string | null; } -export function toVariable(input: c.JSONValue): Variable { +export function toParamKind(input: c.JSONValue): ParamKind { const obj = c.checkObj(input); return { - expression: c.checkStr(obj["expression"]), - name: c.checkStr(obj["name"]), + apiVersion: c.readOpt(obj["apiVersion"], c.checkStr), + kind: c.readOpt(obj["kind"], c.checkStr), }} -export function fromVariable(input: Variable): c.JSONValue { +export function fromParamKind(input: ParamKind): c.JSONValue { return { ...input, }} -/** ValidatingAdmissionPolicyStatus represents the status of an admission validation policy. */ -export interface ValidatingAdmissionPolicyStatus { - conditions?: Array | null; - observedGeneration?: number | null; - typeChecking?: TypeChecking | null; +/** Variable is the definition of a variable that is used for composition. A variable is defined as a named expression. */ +export interface Variable { + expression: string; + name: string; } -export function toValidatingAdmissionPolicyStatus(input: c.JSONValue): ValidatingAdmissionPolicyStatus { +export function toVariable(input: c.JSONValue): Variable { const obj = c.checkObj(input); return { - conditions: c.readOpt(obj["conditions"], x => c.readList(x, MetaV1.toCondition)), - observedGeneration: c.readOpt(obj["observedGeneration"], c.checkNum), - typeChecking: c.readOpt(obj["typeChecking"], toTypeChecking), + expression: c.checkStr(obj["expression"]), + name: c.checkStr(obj["name"]), }} -export function fromValidatingAdmissionPolicyStatus(input: ValidatingAdmissionPolicyStatus): c.JSONValue { +export function fromVariable(input: Variable): c.JSONValue { return { ...input, - conditions: input.conditions?.map(MetaV1.fromCondition), - typeChecking: input.typeChecking != null ? fromTypeChecking(input.typeChecking) : undefined, }} -/** ValidatingAdmissionPolicyBinding binds the ValidatingAdmissionPolicy with paramerized resources. ValidatingAdmissionPolicyBinding and parameter CRDs together define how cluster administrators configure policies for clusters. +/** MutatingAdmissionPolicyBinding binds the MutatingAdmissionPolicy with parametrized resources. MutatingAdmissionPolicyBinding and the optional parameter resource together define how cluster administrators configure policies for clusters. -For a given admission request, each binding will cause its policy to be evaluated N times, where N is 1 for policies/bindings that don't use params, otherwise N is the number of parameters selected by the binding. +For a given admission request, each binding will cause its policy to be evaluated N times, where N is 1 for policies/bindings that don't use params, otherwise N is the number of parameters selected by the binding. Each evaluation is constrained by a [runtime cost budget](https://kubernetes.io/docs/reference/using-api/cel/#runtime-cost-budget). -The CEL expressions of a policy must have a computed CEL cost below the maximum CEL budget. Each evaluation of the policy is given an independent CEL cost budget. Adding/removing policies, bindings, or params can not affect whether a given (policy, binding, param) combination is within its own CEL budget. */ -export interface ValidatingAdmissionPolicyBinding { +Adding/removing policies, bindings, or params can not affect whether a given (policy, binding, param) combination is within its own CEL budget. */ +export interface MutatingAdmissionPolicyBinding { apiVersion?: "admissionregistration.k8s.io/v1beta1"; - kind?: "ValidatingAdmissionPolicyBinding"; + kind?: "MutatingAdmissionPolicyBinding"; metadata?: MetaV1.ObjectMeta | null; - spec?: ValidatingAdmissionPolicyBindingSpec | null; + spec?: MutatingAdmissionPolicyBindingSpec | null; } -export function toValidatingAdmissionPolicyBinding(input: c.JSONValue): ValidatingAdmissionPolicyBinding & c.ApiKind { +export function toMutatingAdmissionPolicyBinding(input: c.JSONValue): MutatingAdmissionPolicyBinding & c.ApiKind { const obj = c.checkObj(input); return { - ...c.assertOrAddApiVersionAndKind(obj, "admissionregistration.k8s.io/v1beta1", "ValidatingAdmissionPolicyBinding"), + ...c.assertOrAddApiVersionAndKind(obj, "admissionregistration.k8s.io/v1beta1", "MutatingAdmissionPolicyBinding"), metadata: c.readOpt(obj["metadata"], MetaV1.toObjectMeta), - spec: c.readOpt(obj["spec"], toValidatingAdmissionPolicyBindingSpec), + spec: c.readOpt(obj["spec"], toMutatingAdmissionPolicyBindingSpec), }} -export function fromValidatingAdmissionPolicyBinding(input: ValidatingAdmissionPolicyBinding): c.JSONValue { +export function fromMutatingAdmissionPolicyBinding(input: MutatingAdmissionPolicyBinding): c.JSONValue { return { - ...c.assertOrAddApiVersionAndKind(input, "admissionregistration.k8s.io/v1beta1", "ValidatingAdmissionPolicyBinding"), + ...c.assertOrAddApiVersionAndKind(input, "admissionregistration.k8s.io/v1beta1", "MutatingAdmissionPolicyBinding"), ...input, metadata: input.metadata != null ? MetaV1.fromObjectMeta(input.metadata) : undefined, - spec: input.spec != null ? fromValidatingAdmissionPolicyBindingSpec(input.spec) : undefined, + spec: input.spec != null ? fromMutatingAdmissionPolicyBindingSpec(input.spec) : undefined, }} -/** ValidatingAdmissionPolicyBindingSpec is the specification of the ValidatingAdmissionPolicyBinding. */ -export interface ValidatingAdmissionPolicyBindingSpec { +/** MutatingAdmissionPolicyBindingSpec is the specification of the MutatingAdmissionPolicyBinding. */ +export interface MutatingAdmissionPolicyBindingSpec { matchResources?: MatchResources | null; paramRef?: ParamRef | null; policyName?: string | null; - validationActions?: Array | null; } -export function toValidatingAdmissionPolicyBindingSpec(input: c.JSONValue): ValidatingAdmissionPolicyBindingSpec { +export function toMutatingAdmissionPolicyBindingSpec(input: c.JSONValue): MutatingAdmissionPolicyBindingSpec { const obj = c.checkObj(input); return { matchResources: c.readOpt(obj["matchResources"], toMatchResources), paramRef: c.readOpt(obj["paramRef"], toParamRef), policyName: c.readOpt(obj["policyName"], c.checkStr), - validationActions: c.readOpt(obj["validationActions"], x => c.readList(x, c.checkStr)), }} -export function fromValidatingAdmissionPolicyBindingSpec(input: ValidatingAdmissionPolicyBindingSpec): c.JSONValue { +export function fromMutatingAdmissionPolicyBindingSpec(input: MutatingAdmissionPolicyBindingSpec): c.JSONValue { return { ...input, matchResources: input.matchResources != null ? fromMatchResources(input.matchResources) : undefined, paramRef: input.paramRef != null ? fromParamRef(input.paramRef) : undefined, }} -/** ValidatingAdmissionPolicyBindingList is a list of ValidatingAdmissionPolicyBinding. */ -export interface ValidatingAdmissionPolicyBindingList extends ListOf { +/** ParamRef describes how to locate the params to be used as input to expressions of rules applied by a policy binding. */ +export interface ParamRef { + name?: string | null; + namespace?: string | null; + parameterNotFoundAction?: string | null; + selector?: MetaV1.LabelSelector | null; +} +export function toParamRef(input: c.JSONValue): ParamRef { + const obj = c.checkObj(input); + return { + name: c.readOpt(obj["name"], c.checkStr), + namespace: c.readOpt(obj["namespace"], c.checkStr), + parameterNotFoundAction: c.readOpt(obj["parameterNotFoundAction"], c.checkStr), + selector: c.readOpt(obj["selector"], MetaV1.toLabelSelector), + }} +export function fromParamRef(input: ParamRef): c.JSONValue { + return { + ...input, + selector: input.selector != null ? MetaV1.fromLabelSelector(input.selector) : undefined, + }} + +/** MutatingAdmissionPolicyBindingList is a list of MutatingAdmissionPolicyBinding. */ +export interface MutatingAdmissionPolicyBindingList extends ListOf { apiVersion?: "admissionregistration.k8s.io/v1beta1"; - kind?: "ValidatingAdmissionPolicyBindingList"; + kind?: "MutatingAdmissionPolicyBindingList"; }; -export function toValidatingAdmissionPolicyBindingList(input: c.JSONValue): ValidatingAdmissionPolicyBindingList & c.ApiKind { +export function toMutatingAdmissionPolicyBindingList(input: c.JSONValue): MutatingAdmissionPolicyBindingList & c.ApiKind { const obj = c.checkObj(input); return { - ...c.assertOrAddApiVersionAndKind(obj, "admissionregistration.k8s.io/v1beta1", "ValidatingAdmissionPolicyBindingList"), + ...c.assertOrAddApiVersionAndKind(obj, "admissionregistration.k8s.io/v1beta1", "MutatingAdmissionPolicyBindingList"), metadata: MetaV1.toListMeta(obj.metadata), - items: c.readList(obj.items, toValidatingAdmissionPolicyBinding), + items: c.readList(obj.items, toMutatingAdmissionPolicyBinding), }} -/** ValidatingAdmissionPolicyList is a list of ValidatingAdmissionPolicy. */ -export interface ValidatingAdmissionPolicyList extends ListOf { +/** MutatingAdmissionPolicyList is a list of MutatingAdmissionPolicy. */ +export interface MutatingAdmissionPolicyList extends ListOf { apiVersion?: "admissionregistration.k8s.io/v1beta1"; - kind?: "ValidatingAdmissionPolicyList"; + kind?: "MutatingAdmissionPolicyList"; }; -export function toValidatingAdmissionPolicyList(input: c.JSONValue): ValidatingAdmissionPolicyList & c.ApiKind { +export function toMutatingAdmissionPolicyList(input: c.JSONValue): MutatingAdmissionPolicyList & c.ApiKind { const obj = c.checkObj(input); return { - ...c.assertOrAddApiVersionAndKind(obj, "admissionregistration.k8s.io/v1beta1", "ValidatingAdmissionPolicyList"), + ...c.assertOrAddApiVersionAndKind(obj, "admissionregistration.k8s.io/v1beta1", "MutatingAdmissionPolicyList"), metadata: MetaV1.toListMeta(obj.metadata), - items: c.readList(obj.items, toValidatingAdmissionPolicy), + items: c.readList(obj.items, toMutatingAdmissionPolicy), }} diff --git a/lib/builtin/apps@v1/structs.ts b/lib/builtin/apps@v1/structs.ts index ce7f231..91fad5f 100644 --- a/lib/builtin/apps@v1/structs.ts +++ b/lib/builtin/apps@v1/structs.ts @@ -293,6 +293,7 @@ export interface DeploymentStatus { observedGeneration?: number | null; readyReplicas?: number | null; replicas?: number | null; + terminatingReplicas?: number | null; unavailableReplicas?: number | null; updatedReplicas?: number | null; } @@ -305,6 +306,7 @@ export function toDeploymentStatus(input: c.JSONValue): DeploymentStatus { observedGeneration: c.readOpt(obj["observedGeneration"], c.checkNum), readyReplicas: c.readOpt(obj["readyReplicas"], c.checkNum), replicas: c.readOpt(obj["replicas"], c.checkNum), + terminatingReplicas: c.readOpt(obj["terminatingReplicas"], c.checkNum), unavailableReplicas: c.readOpt(obj["unavailableReplicas"], c.checkNum), updatedReplicas: c.readOpt(obj["updatedReplicas"], c.checkNum), }} @@ -408,6 +410,7 @@ export interface ReplicaSetStatus { observedGeneration?: number | null; readyReplicas?: number | null; replicas: number; + terminatingReplicas?: number | null; } export function toReplicaSetStatus(input: c.JSONValue): ReplicaSetStatus { const obj = c.checkObj(input); @@ -418,6 +421,7 @@ export function toReplicaSetStatus(input: c.JSONValue): ReplicaSetStatus { observedGeneration: c.readOpt(obj["observedGeneration"], c.checkNum), readyReplicas: c.readOpt(obj["readyReplicas"], c.checkNum), replicas: c.checkNum(obj["replicas"]), + terminatingReplicas: c.readOpt(obj["terminatingReplicas"], c.checkNum), }} export function fromReplicaSetStatus(input: ReplicaSetStatus): c.JSONValue { return { @@ -515,7 +519,7 @@ export interface StatefulSetSpec { replicas?: number | null; revisionHistoryLimit?: number | null; selector: MetaV1.LabelSelector; - serviceName: string; + serviceName?: string | null; template: CoreV1.PodTemplateSpec; updateStrategy?: StatefulSetUpdateStrategy | null; volumeClaimTemplates?: Array | null; @@ -530,7 +534,7 @@ export function toStatefulSetSpec(input: c.JSONValue): StatefulSetSpec { replicas: c.readOpt(obj["replicas"], c.checkNum), revisionHistoryLimit: c.readOpt(obj["revisionHistoryLimit"], c.checkNum), selector: MetaV1.toLabelSelector(obj["selector"]), - serviceName: c.checkStr(obj["serviceName"]), + serviceName: c.readOpt(obj["serviceName"], c.checkStr), template: CoreV1.toPodTemplateSpec(obj["template"]), updateStrategy: c.readOpt(obj["updateStrategy"], toStatefulSetUpdateStrategy), volumeClaimTemplates: c.readOpt(obj["volumeClaimTemplates"], x => c.readList(x, CoreV1.toPersistentVolumeClaim)), diff --git a/lib/builtin/authentication.k8s.io@v1beta1/mod.ts b/lib/builtin/authentication.k8s.io@v1beta1/mod.ts deleted file mode 100644 index 75231a6..0000000 --- a/lib/builtin/authentication.k8s.io@v1beta1/mod.ts +++ /dev/null @@ -1,31 +0,0 @@ -export * from "./structs.ts"; - -// Autogenerated API file for AuthenticationV1beta1 -import * as c from "../../common.ts"; -import * as operations from "../../operations.ts"; -import * as MetaV1 from "../meta@v1/structs.ts"; -import * as AuthenticationV1beta1 from "./structs.ts"; - -export class AuthenticationV1beta1Api { - #client: c.RestClient; - #root = "/apis/authentication.k8s.io/v1beta1/"; - constructor(client: c.RestClient) { - this.#client = client; - } - - async createSelfSubjectReview( - body: AuthenticationV1beta1.SelfSubjectReview, - opts: operations.PutOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "POST", - path: `${this.#root}selfsubjectreviews`, - expectJson: true, - querystring: operations.formatPutOpts(opts), - bodyJson: AuthenticationV1beta1.fromSelfSubjectReview(body), - abortSignal: opts.abortSignal, - }); - return AuthenticationV1beta1.toSelfSubjectReview(resp); - } - -} diff --git a/lib/builtin/authentication.k8s.io@v1beta1/structs.ts b/lib/builtin/authentication.k8s.io@v1beta1/structs.ts deleted file mode 100644 index 40d6244..0000000 --- a/lib/builtin/authentication.k8s.io@v1beta1/structs.ts +++ /dev/null @@ -1,46 +0,0 @@ -// Autogenerated Schema file for AuthenticationV1beta1 -import * as c from "../../common.ts"; - -import * as AuthenticationV1 from "../authentication.k8s.io@v1/structs.ts"; -import * as MetaV1 from "../meta@v1/structs.ts"; -type ListOf = { - metadata: MetaV1.ListMeta; - items: Array; -}; - -/** SelfSubjectReview contains the user information that the kube-apiserver has about the user making this request. When using impersonation, users will receive the user info of the user being impersonated. If impersonation or request header authentication is used, any extra keys will have their case ignored and returned as lowercase. */ -export interface SelfSubjectReview { - apiVersion?: "authentication.k8s.io/v1beta1"; - kind?: "SelfSubjectReview"; - metadata?: MetaV1.ObjectMeta | null; - status?: SelfSubjectReviewStatus | null; -} -export function toSelfSubjectReview(input: c.JSONValue): SelfSubjectReview & c.ApiKind { - const obj = c.checkObj(input); - return { - ...c.assertOrAddApiVersionAndKind(obj, "authentication.k8s.io/v1beta1", "SelfSubjectReview"), - metadata: c.readOpt(obj["metadata"], MetaV1.toObjectMeta), - status: c.readOpt(obj["status"], toSelfSubjectReviewStatus), - }} -export function fromSelfSubjectReview(input: SelfSubjectReview): c.JSONValue { - return { - ...c.assertOrAddApiVersionAndKind(input, "authentication.k8s.io/v1beta1", "SelfSubjectReview"), - ...input, - metadata: input.metadata != null ? MetaV1.fromObjectMeta(input.metadata) : undefined, - status: input.status != null ? fromSelfSubjectReviewStatus(input.status) : undefined, - }} - -/** SelfSubjectReviewStatus is filled by the kube-apiserver and sent back to a user. */ -export interface SelfSubjectReviewStatus { - userInfo?: AuthenticationV1.UserInfo | null; -} -export function toSelfSubjectReviewStatus(input: c.JSONValue): SelfSubjectReviewStatus { - const obj = c.checkObj(input); - return { - userInfo: c.readOpt(obj["userInfo"], AuthenticationV1.toUserInfo), - }} -export function fromSelfSubjectReviewStatus(input: SelfSubjectReviewStatus): c.JSONValue { - return { - ...input, - userInfo: input.userInfo != null ? AuthenticationV1.fromUserInfo(input.userInfo) : undefined, - }} diff --git a/lib/builtin/autoscaling@v2/structs.ts b/lib/builtin/autoscaling@v2/structs.ts index 5236f21..8d29dcd 100644 --- a/lib/builtin/autoscaling@v2/structs.ts +++ b/lib/builtin/autoscaling@v2/structs.ts @@ -176,11 +176,16 @@ export function fromHPAScalingPolicy(input: HPAScalingPolicy): c.JSONValue { ...input, }} -/** HPAScalingRules configures the scaling behavior for one direction. These Rules are applied after calculating DesiredReplicas from metrics for the HPA. They can limit the scaling velocity by specifying scaling policies. They can prevent flapping by specifying the stabilization window, so that the number of replicas is not set instantly, instead, the safest value from the stabilization window is chosen. */ +/** HPAScalingRules configures the scaling behavior for one direction via scaling Policy Rules and a configurable metric tolerance. + +Scaling Policy Rules are applied after calculating DesiredReplicas from metrics for the HPA. They can limit the scaling velocity by specifying scaling policies. They can prevent flapping by specifying the stabilization window, so that the number of replicas is not set instantly, instead, the safest value from the stabilization window is chosen. + +The tolerance is applied to the metric values and prevents scaling too eagerly for small metric variations. (Note that setting a tolerance requires enabling the alpha HPAConfigurableTolerance feature gate.) */ export interface HPAScalingRules { policies?: Array | null; selectPolicy?: string | null; stabilizationWindowSeconds?: number | null; + tolerance?: c.Quantity | null; } export function toHPAScalingRules(input: c.JSONValue): HPAScalingRules { const obj = c.checkObj(input); @@ -188,11 +193,13 @@ export function toHPAScalingRules(input: c.JSONValue): HPAScalingRules { policies: c.readOpt(obj["policies"], x => c.readList(x, toHPAScalingPolicy)), selectPolicy: c.readOpt(obj["selectPolicy"], c.checkStr), stabilizationWindowSeconds: c.readOpt(obj["stabilizationWindowSeconds"], c.checkNum), + tolerance: c.readOpt(obj["tolerance"], c.toQuantity), }} export function fromHPAScalingRules(input: HPAScalingRules): c.JSONValue { return { ...input, policies: input.policies?.map(fromHPAScalingPolicy), + tolerance: input.tolerance != null ? c.fromQuantity(input.tolerance) : undefined, }} /** HorizontalPodAutoscaler is the configuration for a horizontal pod autoscaler, which automatically manages the replica count of any resource implementing the scale subresource based on the metrics specified. */ diff --git a/lib/builtin/certificates.k8s.io@v1alpha1/mod.ts b/lib/builtin/certificates.k8s.io@v1alpha1/mod.ts index c56746c..a3fd6c2 100644 --- a/lib/builtin/certificates.k8s.io@v1alpha1/mod.ts +++ b/lib/builtin/certificates.k8s.io@v1alpha1/mod.ts @@ -13,6 +13,14 @@ export class CertificatesV1alpha1Api { this.#client = client; } + namespace(name: string): CertificatesV1alpha1NamespacedApi { + return new CertificatesV1alpha1NamespacedApi(this.#client, name); + } + myNamespace(): CertificatesV1alpha1NamespacedApi { + if (!this.#client.defaultNamespace) throw new Error("No current namespace is set"); + return new CertificatesV1alpha1NamespacedApi(this.#client, this.#client.defaultNamespace); + } + async getClusterTrustBundleList( opts: operations.GetListOpts = {}, ): Promise { @@ -130,4 +138,205 @@ export class CertificatesV1alpha1Api { return CertificatesV1alpha1.toClusterTrustBundle(resp); } + async getPodCertificateRequestListForAllNamespaces( + opts: operations.GetListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}podcertificaterequests`, + expectJson: true, + querystring: operations.formatGetListOpts(opts), + abortSignal: opts.abortSignal, + }); + return CertificatesV1alpha1.toPodCertificateRequestList(resp); + } + + async watchPodCertificateRequestListForAllNamespaces( + opts: operations.WatchListOpts = {}, + ): Promise> { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}podcertificaterequests`, + expectJson: true, + expectStream: true, + querystring: operations.formatWatchListOpts(opts), + abortSignal: opts.abortSignal, + }); + return resp.pipeThrough(new c.WatchEventTransformer(CertificatesV1alpha1.toPodCertificateRequest, MetaV1.toStatus)); + } + +} + +export class CertificatesV1alpha1NamespacedApi { + #client: c.RestClient + #root: string + constructor(client: c.RestClient, namespace: string) { + this.#client = client; + this.#root = `/apis/certificates.k8s.io/v1alpha1/namespaces/${namespace}/`; + } + + async getPodCertificateRequestList( + opts: operations.GetListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}podcertificaterequests`, + expectJson: true, + querystring: operations.formatGetListOpts(opts), + abortSignal: opts.abortSignal, + }); + return CertificatesV1alpha1.toPodCertificateRequestList(resp); + } + + async watchPodCertificateRequestList( + opts: operations.WatchListOpts = {}, + ): Promise> { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}podcertificaterequests`, + expectJson: true, + expectStream: true, + querystring: operations.formatWatchListOpts(opts), + abortSignal: opts.abortSignal, + }); + return resp.pipeThrough(new c.WatchEventTransformer(CertificatesV1alpha1.toPodCertificateRequest, MetaV1.toStatus)); + } + + async createPodCertificateRequest( + body: CertificatesV1alpha1.PodCertificateRequest, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "POST", + path: `${this.#root}podcertificaterequests`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: CertificatesV1alpha1.fromPodCertificateRequest(body), + abortSignal: opts.abortSignal, + }); + return CertificatesV1alpha1.toPodCertificateRequest(resp); + } + + async deletePodCertificateRequestList( + opts: operations.DeleteListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}podcertificaterequests`, + expectJson: true, + querystring: operations.formatDeleteListOpts(opts), + abortSignal: opts.abortSignal, + }); + return CertificatesV1alpha1.toPodCertificateRequestList(resp); + } + + async getPodCertificateRequest( + name: string, + opts: operations.NoOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}podcertificaterequests/${name}`, + expectJson: true, + abortSignal: opts.abortSignal, + }); + return CertificatesV1alpha1.toPodCertificateRequest(resp); + } + + async deletePodCertificateRequest( + name: string, + opts: operations.DeleteOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}podcertificaterequests/${name}`, + expectJson: true, + querystring: operations.formatDeleteOpts(opts), + abortSignal: opts.abortSignal, + }); + if (c.isStatusKind(resp)) return MetaV1.toStatus(resp); + return CertificatesV1alpha1.toPodCertificateRequest(resp); + } + + async replacePodCertificateRequest( + name: string, + body: CertificatesV1alpha1.PodCertificateRequest, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PUT", + path: `${this.#root}podcertificaterequests/${name}`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: CertificatesV1alpha1.fromPodCertificateRequest(body), + abortSignal: opts.abortSignal, + }); + return CertificatesV1alpha1.toPodCertificateRequest(resp); + } + + async patchPodCertificateRequest( + name: string, + type: c.PatchType, + body: CertificatesV1alpha1.PodCertificateRequest | c.JsonPatch, + opts: operations.PatchOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PATCH", + path: `${this.#root}podcertificaterequests/${name}`, + expectJson: true, + querystring: operations.formatPatchOpts(opts), + contentType: c.getPatchContentType(type), + bodyJson: Array.isArray(body) ? body : CertificatesV1alpha1.fromPodCertificateRequest(body), + abortSignal: opts.abortSignal, + }); + return CertificatesV1alpha1.toPodCertificateRequest(resp); + } + + async getPodCertificateRequestStatus( + name: string, + opts: operations.NoOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}podcertificaterequests/${name}/status`, + expectJson: true, + abortSignal: opts.abortSignal, + }); + return CertificatesV1alpha1.toPodCertificateRequest(resp); + } + + async replacePodCertificateRequestStatus( + name: string, + body: CertificatesV1alpha1.PodCertificateRequest, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PUT", + path: `${this.#root}podcertificaterequests/${name}/status`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: CertificatesV1alpha1.fromPodCertificateRequest(body), + abortSignal: opts.abortSignal, + }); + return CertificatesV1alpha1.toPodCertificateRequest(resp); + } + + async patchPodCertificateRequestStatus( + name: string, + type: c.PatchType, + body: CertificatesV1alpha1.PodCertificateRequest | c.JsonPatch, + opts: operations.PatchOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PATCH", + path: `${this.#root}podcertificaterequests/${name}/status`, + expectJson: true, + querystring: operations.formatPatchOpts(opts), + contentType: c.getPatchContentType(type), + bodyJson: Array.isArray(body) ? body : CertificatesV1alpha1.fromPodCertificateRequest(body), + abortSignal: opts.abortSignal, + }); + return CertificatesV1alpha1.toPodCertificateRequest(resp); + } + } diff --git a/lib/builtin/certificates.k8s.io@v1alpha1/structs.ts b/lib/builtin/certificates.k8s.io@v1alpha1/structs.ts index 8e6792d..f0c7f6f 100644 --- a/lib/builtin/certificates.k8s.io@v1alpha1/structs.ts +++ b/lib/builtin/certificates.k8s.io@v1alpha1/structs.ts @@ -61,3 +61,101 @@ export function toClusterTrustBundleList(input: c.JSONValue): ClusterTrustBundle metadata: MetaV1.toListMeta(obj.metadata), items: c.readList(obj.items, toClusterTrustBundle), }} + +/** PodCertificateRequest encodes a pod requesting a certificate from a given signer. + +Kubelets use this API to implement podCertificate projected volumes */ +export interface PodCertificateRequest { + apiVersion?: "certificates.k8s.io/v1alpha1"; + kind?: "PodCertificateRequest"; + metadata?: MetaV1.ObjectMeta | null; + spec: PodCertificateRequestSpec; + status?: PodCertificateRequestStatus | null; +} +export function toPodCertificateRequest(input: c.JSONValue): PodCertificateRequest & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "certificates.k8s.io/v1alpha1", "PodCertificateRequest"), + metadata: c.readOpt(obj["metadata"], MetaV1.toObjectMeta), + spec: toPodCertificateRequestSpec(obj["spec"]), + status: c.readOpt(obj["status"], toPodCertificateRequestStatus), + }} +export function fromPodCertificateRequest(input: PodCertificateRequest): c.JSONValue { + return { + ...c.assertOrAddApiVersionAndKind(input, "certificates.k8s.io/v1alpha1", "PodCertificateRequest"), + ...input, + metadata: input.metadata != null ? MetaV1.fromObjectMeta(input.metadata) : undefined, + spec: input.spec != null ? fromPodCertificateRequestSpec(input.spec) : undefined, + status: input.status != null ? fromPodCertificateRequestStatus(input.status) : undefined, + }} + +/** PodCertificateRequestSpec describes the certificate request. All fields are immutable after creation. */ +export interface PodCertificateRequestSpec { + maxExpirationSeconds?: number | null; + nodeName: string; + nodeUID: string; + pkixPublicKey: string; + podName: string; + podUID: string; + proofOfPossession: string; + serviceAccountName: string; + serviceAccountUID: string; + signerName: string; +} +export function toPodCertificateRequestSpec(input: c.JSONValue): PodCertificateRequestSpec { + const obj = c.checkObj(input); + return { + maxExpirationSeconds: c.readOpt(obj["maxExpirationSeconds"], c.checkNum), + nodeName: c.checkStr(obj["nodeName"]), + nodeUID: c.checkStr(obj["nodeUID"]), + pkixPublicKey: c.checkStr(obj["pkixPublicKey"]), + podName: c.checkStr(obj["podName"]), + podUID: c.checkStr(obj["podUID"]), + proofOfPossession: c.checkStr(obj["proofOfPossession"]), + serviceAccountName: c.checkStr(obj["serviceAccountName"]), + serviceAccountUID: c.checkStr(obj["serviceAccountUID"]), + signerName: c.checkStr(obj["signerName"]), + }} +export function fromPodCertificateRequestSpec(input: PodCertificateRequestSpec): c.JSONValue { + return { + ...input, + }} + +/** PodCertificateRequestStatus describes the status of the request, and holds the certificate data if the request is issued. */ +export interface PodCertificateRequestStatus { + beginRefreshAt?: c.Time | null; + certificateChain?: string | null; + conditions?: Array | null; + notAfter?: c.Time | null; + notBefore?: c.Time | null; +} +export function toPodCertificateRequestStatus(input: c.JSONValue): PodCertificateRequestStatus { + const obj = c.checkObj(input); + return { + beginRefreshAt: c.readOpt(obj["beginRefreshAt"], c.toTime), + certificateChain: c.readOpt(obj["certificateChain"], c.checkStr), + conditions: c.readOpt(obj["conditions"], x => c.readList(x, MetaV1.toCondition)), + notAfter: c.readOpt(obj["notAfter"], c.toTime), + notBefore: c.readOpt(obj["notBefore"], c.toTime), + }} +export function fromPodCertificateRequestStatus(input: PodCertificateRequestStatus): c.JSONValue { + return { + ...input, + beginRefreshAt: input.beginRefreshAt != null ? c.fromTime(input.beginRefreshAt) : undefined, + conditions: input.conditions?.map(MetaV1.fromCondition), + notAfter: input.notAfter != null ? c.fromTime(input.notAfter) : undefined, + notBefore: input.notBefore != null ? c.fromTime(input.notBefore) : undefined, + }} + +/** PodCertificateRequestList is a collection of PodCertificateRequest objects */ +export interface PodCertificateRequestList extends ListOf { + apiVersion?: "certificates.k8s.io/v1alpha1"; + kind?: "PodCertificateRequestList"; +}; +export function toPodCertificateRequestList(input: c.JSONValue): PodCertificateRequestList & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "certificates.k8s.io/v1alpha1", "PodCertificateRequestList"), + metadata: MetaV1.toListMeta(obj.metadata), + items: c.readList(obj.items, toPodCertificateRequest), + }} diff --git a/lib/builtin/certificates.k8s.io@v1beta1/mod.ts b/lib/builtin/certificates.k8s.io@v1beta1/mod.ts new file mode 100644 index 0000000..ec39ddb --- /dev/null +++ b/lib/builtin/certificates.k8s.io@v1beta1/mod.ts @@ -0,0 +1,133 @@ +export * from "./structs.ts"; + +// Autogenerated API file for CertificatesV1beta1 +import * as c from "../../common.ts"; +import * as operations from "../../operations.ts"; +import * as MetaV1 from "../meta@v1/structs.ts"; +import * as CertificatesV1beta1 from "./structs.ts"; + +export class CertificatesV1beta1Api { + #client: c.RestClient; + #root = "/apis/certificates.k8s.io/v1beta1/"; + constructor(client: c.RestClient) { + this.#client = client; + } + + async getClusterTrustBundleList( + opts: operations.GetListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}clustertrustbundles`, + expectJson: true, + querystring: operations.formatGetListOpts(opts), + abortSignal: opts.abortSignal, + }); + return CertificatesV1beta1.toClusterTrustBundleList(resp); + } + + async watchClusterTrustBundleList( + opts: operations.WatchListOpts = {}, + ): Promise> { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}clustertrustbundles`, + expectJson: true, + expectStream: true, + querystring: operations.formatWatchListOpts(opts), + abortSignal: opts.abortSignal, + }); + return resp.pipeThrough(new c.WatchEventTransformer(CertificatesV1beta1.toClusterTrustBundle, MetaV1.toStatus)); + } + + async createClusterTrustBundle( + body: CertificatesV1beta1.ClusterTrustBundle, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "POST", + path: `${this.#root}clustertrustbundles`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: CertificatesV1beta1.fromClusterTrustBundle(body), + abortSignal: opts.abortSignal, + }); + return CertificatesV1beta1.toClusterTrustBundle(resp); + } + + async deleteClusterTrustBundleList( + opts: operations.DeleteListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}clustertrustbundles`, + expectJson: true, + querystring: operations.formatDeleteListOpts(opts), + abortSignal: opts.abortSignal, + }); + return CertificatesV1beta1.toClusterTrustBundleList(resp); + } + + async getClusterTrustBundle( + name: string, + opts: operations.NoOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}clustertrustbundles/${name}`, + expectJson: true, + abortSignal: opts.abortSignal, + }); + return CertificatesV1beta1.toClusterTrustBundle(resp); + } + + async deleteClusterTrustBundle( + name: string, + opts: operations.DeleteOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}clustertrustbundles/${name}`, + expectJson: true, + querystring: operations.formatDeleteOpts(opts), + abortSignal: opts.abortSignal, + }); + if (c.isStatusKind(resp)) return MetaV1.toStatus(resp); + return CertificatesV1beta1.toClusterTrustBundle(resp); + } + + async replaceClusterTrustBundle( + name: string, + body: CertificatesV1beta1.ClusterTrustBundle, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PUT", + path: `${this.#root}clustertrustbundles/${name}`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: CertificatesV1beta1.fromClusterTrustBundle(body), + abortSignal: opts.abortSignal, + }); + return CertificatesV1beta1.toClusterTrustBundle(resp); + } + + async patchClusterTrustBundle( + name: string, + type: c.PatchType, + body: CertificatesV1beta1.ClusterTrustBundle | c.JsonPatch, + opts: operations.PatchOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PATCH", + path: `${this.#root}clustertrustbundles/${name}`, + expectJson: true, + querystring: operations.formatPatchOpts(opts), + contentType: c.getPatchContentType(type), + bodyJson: Array.isArray(body) ? body : CertificatesV1beta1.fromClusterTrustBundle(body), + abortSignal: opts.abortSignal, + }); + return CertificatesV1beta1.toClusterTrustBundle(resp); + } + +} diff --git a/lib/builtin/certificates.k8s.io@v1beta1/structs.ts b/lib/builtin/certificates.k8s.io@v1beta1/structs.ts new file mode 100644 index 0000000..ddf0f89 --- /dev/null +++ b/lib/builtin/certificates.k8s.io@v1beta1/structs.ts @@ -0,0 +1,63 @@ +// Autogenerated Schema file for CertificatesV1beta1 +import * as c from "../../common.ts"; + +import * as MetaV1 from "../meta@v1/structs.ts"; +type ListOf = { + metadata: MetaV1.ListMeta; + items: Array; +}; + +/** ClusterTrustBundle is a cluster-scoped container for X.509 trust anchors (root certificates). + +ClusterTrustBundle objects are considered to be readable by any authenticated user in the cluster, because they can be mounted by pods using the `clusterTrustBundle` projection. All service accounts have read access to ClusterTrustBundles by default. Users who only have namespace-level access to a cluster can read ClusterTrustBundles by impersonating a serviceaccount that they have access to. + +It can be optionally associated with a particular assigner, in which case it contains one valid set of trust anchors for that signer. Signers may have multiple associated ClusterTrustBundles; each is an independent set of trust anchors for that signer. Admission control is used to enforce that only users with permissions on the signer can create or modify the corresponding bundle. */ +export interface ClusterTrustBundle { + apiVersion?: "certificates.k8s.io/v1beta1"; + kind?: "ClusterTrustBundle"; + metadata?: MetaV1.ObjectMeta | null; + spec: ClusterTrustBundleSpec; +} +export function toClusterTrustBundle(input: c.JSONValue): ClusterTrustBundle & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "certificates.k8s.io/v1beta1", "ClusterTrustBundle"), + metadata: c.readOpt(obj["metadata"], MetaV1.toObjectMeta), + spec: toClusterTrustBundleSpec(obj["spec"]), + }} +export function fromClusterTrustBundle(input: ClusterTrustBundle): c.JSONValue { + return { + ...c.assertOrAddApiVersionAndKind(input, "certificates.k8s.io/v1beta1", "ClusterTrustBundle"), + ...input, + metadata: input.metadata != null ? MetaV1.fromObjectMeta(input.metadata) : undefined, + spec: input.spec != null ? fromClusterTrustBundleSpec(input.spec) : undefined, + }} + +/** ClusterTrustBundleSpec contains the signer and trust anchors. */ +export interface ClusterTrustBundleSpec { + signerName?: string | null; + trustBundle: string; +} +export function toClusterTrustBundleSpec(input: c.JSONValue): ClusterTrustBundleSpec { + const obj = c.checkObj(input); + return { + signerName: c.readOpt(obj["signerName"], c.checkStr), + trustBundle: c.checkStr(obj["trustBundle"]), + }} +export function fromClusterTrustBundleSpec(input: ClusterTrustBundleSpec): c.JSONValue { + return { + ...input, + }} + +/** ClusterTrustBundleList is a collection of ClusterTrustBundle objects */ +export interface ClusterTrustBundleList extends ListOf { + apiVersion?: "certificates.k8s.io/v1beta1"; + kind?: "ClusterTrustBundleList"; +}; +export function toClusterTrustBundleList(input: c.JSONValue): ClusterTrustBundleList & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "certificates.k8s.io/v1beta1", "ClusterTrustBundleList"), + metadata: MetaV1.toListMeta(obj.metadata), + items: c.readList(obj.items, toClusterTrustBundle), + }} diff --git a/lib/builtin/coordination.k8s.io@v1beta1/mod.ts b/lib/builtin/coordination.k8s.io@v1beta1/mod.ts new file mode 100644 index 0000000..6df3ca4 --- /dev/null +++ b/lib/builtin/coordination.k8s.io@v1beta1/mod.ts @@ -0,0 +1,178 @@ +export * from "./structs.ts"; + +// Autogenerated API file for CoordinationV1beta1 +import * as c from "../../common.ts"; +import * as operations from "../../operations.ts"; +import * as MetaV1 from "../meta@v1/structs.ts"; +import * as CoordinationV1beta1 from "./structs.ts"; + +export class CoordinationV1beta1Api { + #client: c.RestClient; + #root = "/apis/coordination.k8s.io/v1beta1/"; + constructor(client: c.RestClient) { + this.#client = client; + } + + namespace(name: string): CoordinationV1beta1NamespacedApi { + return new CoordinationV1beta1NamespacedApi(this.#client, name); + } + myNamespace(): CoordinationV1beta1NamespacedApi { + if (!this.#client.defaultNamespace) throw new Error("No current namespace is set"); + return new CoordinationV1beta1NamespacedApi(this.#client, this.#client.defaultNamespace); + } + + async getLeaseCandidateListForAllNamespaces( + opts: operations.GetListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}leasecandidates`, + expectJson: true, + querystring: operations.formatGetListOpts(opts), + abortSignal: opts.abortSignal, + }); + return CoordinationV1beta1.toLeaseCandidateList(resp); + } + + async watchLeaseCandidateListForAllNamespaces( + opts: operations.WatchListOpts = {}, + ): Promise> { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}leasecandidates`, + expectJson: true, + expectStream: true, + querystring: operations.formatWatchListOpts(opts), + abortSignal: opts.abortSignal, + }); + return resp.pipeThrough(new c.WatchEventTransformer(CoordinationV1beta1.toLeaseCandidate, MetaV1.toStatus)); + } + +} + +export class CoordinationV1beta1NamespacedApi { + #client: c.RestClient + #root: string + constructor(client: c.RestClient, namespace: string) { + this.#client = client; + this.#root = `/apis/coordination.k8s.io/v1beta1/namespaces/${namespace}/`; + } + + async getLeaseCandidateList( + opts: operations.GetListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}leasecandidates`, + expectJson: true, + querystring: operations.formatGetListOpts(opts), + abortSignal: opts.abortSignal, + }); + return CoordinationV1beta1.toLeaseCandidateList(resp); + } + + async watchLeaseCandidateList( + opts: operations.WatchListOpts = {}, + ): Promise> { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}leasecandidates`, + expectJson: true, + expectStream: true, + querystring: operations.formatWatchListOpts(opts), + abortSignal: opts.abortSignal, + }); + return resp.pipeThrough(new c.WatchEventTransformer(CoordinationV1beta1.toLeaseCandidate, MetaV1.toStatus)); + } + + async createLeaseCandidate( + body: CoordinationV1beta1.LeaseCandidate, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "POST", + path: `${this.#root}leasecandidates`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: CoordinationV1beta1.fromLeaseCandidate(body), + abortSignal: opts.abortSignal, + }); + return CoordinationV1beta1.toLeaseCandidate(resp); + } + + async deleteLeaseCandidateList( + opts: operations.DeleteListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}leasecandidates`, + expectJson: true, + querystring: operations.formatDeleteListOpts(opts), + abortSignal: opts.abortSignal, + }); + return CoordinationV1beta1.toLeaseCandidateList(resp); + } + + async getLeaseCandidate( + name: string, + opts: operations.NoOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}leasecandidates/${name}`, + expectJson: true, + abortSignal: opts.abortSignal, + }); + return CoordinationV1beta1.toLeaseCandidate(resp); + } + + async deleteLeaseCandidate( + name: string, + opts: operations.DeleteOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}leasecandidates/${name}`, + expectJson: true, + querystring: operations.formatDeleteOpts(opts), + abortSignal: opts.abortSignal, + }); + if (c.isStatusKind(resp)) return MetaV1.toStatus(resp); + return CoordinationV1beta1.toLeaseCandidate(resp); + } + + async replaceLeaseCandidate( + name: string, + body: CoordinationV1beta1.LeaseCandidate, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PUT", + path: `${this.#root}leasecandidates/${name}`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: CoordinationV1beta1.fromLeaseCandidate(body), + abortSignal: opts.abortSignal, + }); + return CoordinationV1beta1.toLeaseCandidate(resp); + } + + async patchLeaseCandidate( + name: string, + type: c.PatchType, + body: CoordinationV1beta1.LeaseCandidate | c.JsonPatch, + opts: operations.PatchOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PATCH", + path: `${this.#root}leasecandidates/${name}`, + expectJson: true, + querystring: operations.formatPatchOpts(opts), + contentType: c.getPatchContentType(type), + bodyJson: Array.isArray(body) ? body : CoordinationV1beta1.fromLeaseCandidate(body), + abortSignal: opts.abortSignal, + }); + return CoordinationV1beta1.toLeaseCandidate(resp); + } + +} diff --git a/lib/builtin/coordination.k8s.io@v1beta1/structs.ts b/lib/builtin/coordination.k8s.io@v1beta1/structs.ts new file mode 100644 index 0000000..329c9f2 --- /dev/null +++ b/lib/builtin/coordination.k8s.io@v1beta1/structs.ts @@ -0,0 +1,69 @@ +// Autogenerated Schema file for CoordinationV1beta1 +import * as c from "../../common.ts"; + +import * as MetaV1 from "../meta@v1/structs.ts"; +type ListOf = { + metadata: MetaV1.ListMeta; + items: Array; +}; + +/** LeaseCandidate defines a candidate for a Lease object. Candidates are created such that coordinated leader election will pick the best leader from the list of candidates. */ +export interface LeaseCandidate { + apiVersion?: "coordination.k8s.io/v1beta1"; + kind?: "LeaseCandidate"; + metadata?: MetaV1.ObjectMeta | null; + spec?: LeaseCandidateSpec | null; +} +export function toLeaseCandidate(input: c.JSONValue): LeaseCandidate & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "coordination.k8s.io/v1beta1", "LeaseCandidate"), + metadata: c.readOpt(obj["metadata"], MetaV1.toObjectMeta), + spec: c.readOpt(obj["spec"], toLeaseCandidateSpec), + }} +export function fromLeaseCandidate(input: LeaseCandidate): c.JSONValue { + return { + ...c.assertOrAddApiVersionAndKind(input, "coordination.k8s.io/v1beta1", "LeaseCandidate"), + ...input, + metadata: input.metadata != null ? MetaV1.fromObjectMeta(input.metadata) : undefined, + spec: input.spec != null ? fromLeaseCandidateSpec(input.spec) : undefined, + }} + +/** LeaseCandidateSpec is a specification of a Lease. */ +export interface LeaseCandidateSpec { + binaryVersion: string; + emulationVersion?: string | null; + leaseName: string; + pingTime?: c.MicroTime | null; + renewTime?: c.MicroTime | null; + strategy: string; +} +export function toLeaseCandidateSpec(input: c.JSONValue): LeaseCandidateSpec { + const obj = c.checkObj(input); + return { + binaryVersion: c.checkStr(obj["binaryVersion"]), + emulationVersion: c.readOpt(obj["emulationVersion"], c.checkStr), + leaseName: c.checkStr(obj["leaseName"]), + pingTime: c.readOpt(obj["pingTime"], c.toMicroTime), + renewTime: c.readOpt(obj["renewTime"], c.toMicroTime), + strategy: c.checkStr(obj["strategy"]), + }} +export function fromLeaseCandidateSpec(input: LeaseCandidateSpec): c.JSONValue { + return { + ...input, + pingTime: input.pingTime != null ? c.fromMicroTime(input.pingTime) : undefined, + renewTime: input.renewTime != null ? c.fromMicroTime(input.renewTime) : undefined, + }} + +/** LeaseCandidateList is a list of Lease objects. */ +export interface LeaseCandidateList extends ListOf { + apiVersion?: "coordination.k8s.io/v1beta1"; + kind?: "LeaseCandidateList"; +}; +export function toLeaseCandidateList(input: c.JSONValue): LeaseCandidateList & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "coordination.k8s.io/v1beta1", "LeaseCandidateList"), + metadata: MetaV1.toListMeta(obj.metadata), + items: c.readList(obj.items, toLeaseCandidate), + }} diff --git a/lib/builtin/core@v1/structs.ts b/lib/builtin/core@v1/structs.ts index 3f3b8d2..30d20a8 100644 --- a/lib/builtin/core@v1/structs.ts +++ b/lib/builtin/core@v1/structs.ts @@ -821,6 +821,7 @@ export interface Container { resizePolicy?: Array | null; resources?: ResourceRequirements | null; restartPolicy?: string | null; + restartPolicyRules?: Array | null; securityContext?: SecurityContext | null; startupProbe?: Probe | null; stdin?: boolean | null; @@ -849,6 +850,7 @@ export function toContainer(input: c.JSONValue): Container { resizePolicy: c.readOpt(obj["resizePolicy"], x => c.readList(x, toContainerResizePolicy)), resources: c.readOpt(obj["resources"], toResourceRequirements), restartPolicy: c.readOpt(obj["restartPolicy"], c.checkStr), + restartPolicyRules: c.readOpt(obj["restartPolicyRules"], x => c.readList(x, toContainerRestartRule)), securityContext: c.readOpt(obj["securityContext"], toSecurityContext), startupProbe: c.readOpt(obj["startupProbe"], toProbe), stdin: c.readOpt(obj["stdin"], c.checkBool), @@ -871,6 +873,7 @@ export function fromContainer(input: Container): c.JSONValue { readinessProbe: input.readinessProbe != null ? fromProbe(input.readinessProbe) : undefined, resizePolicy: input.resizePolicy?.map(fromContainerResizePolicy), resources: input.resources != null ? fromResourceRequirements(input.resources) : undefined, + restartPolicyRules: input.restartPolicyRules?.map(fromContainerRestartRule), securityContext: input.securityContext != null ? fromSecurityContext(input.securityContext) : undefined, startupProbe: input.startupProbe != null ? fromProbe(input.startupProbe) : undefined, volumeDevices: input.volumeDevices?.map(fromVolumeDevice), @@ -900,6 +903,7 @@ export function fromEnvVar(input: EnvVar): c.JSONValue { export interface EnvVarSource { configMapKeyRef?: ConfigMapKeySelector | null; fieldRef?: ObjectFieldSelector | null; + fileKeyRef?: FileKeySelector | null; resourceFieldRef?: ResourceFieldSelector | null; secretKeyRef?: SecretKeySelector | null; } @@ -908,6 +912,7 @@ export function toEnvVarSource(input: c.JSONValue): EnvVarSource { return { configMapKeyRef: c.readOpt(obj["configMapKeyRef"], toConfigMapKeySelector), fieldRef: c.readOpt(obj["fieldRef"], toObjectFieldSelector), + fileKeyRef: c.readOpt(obj["fileKeyRef"], toFileKeySelector), resourceFieldRef: c.readOpt(obj["resourceFieldRef"], toResourceFieldSelector), secretKeyRef: c.readOpt(obj["secretKeyRef"], toSecretKeySelector), }} @@ -916,6 +921,7 @@ export function fromEnvVarSource(input: EnvVarSource): c.JSONValue { ...input, configMapKeyRef: input.configMapKeyRef != null ? fromConfigMapKeySelector(input.configMapKeyRef) : undefined, fieldRef: input.fieldRef != null ? fromObjectFieldSelector(input.fieldRef) : undefined, + fileKeyRef: input.fileKeyRef != null ? fromFileKeySelector(input.fileKeyRef) : undefined, resourceFieldRef: input.resourceFieldRef != null ? fromResourceFieldSelector(input.resourceFieldRef) : undefined, secretKeyRef: input.secretKeyRef != null ? fromSecretKeySelector(input.secretKeyRef) : undefined, }} @@ -936,6 +942,26 @@ export function fromObjectFieldSelector(input: ObjectFieldSelector): c.JSONValue ...input, }} +/** FileKeySelector selects a key of the env file. */ +export interface FileKeySelector { + key: string; + optional?: boolean | null; + path: string; + volumeName: string; +} +export function toFileKeySelector(input: c.JSONValue): FileKeySelector { + const obj = c.checkObj(input); + return { + key: c.checkStr(obj["key"]), + optional: c.readOpt(obj["optional"], c.checkBool), + path: c.checkStr(obj["path"]), + volumeName: c.checkStr(obj["volumeName"]), + }} +export function fromFileKeySelector(input: FileKeySelector): c.JSONValue { + return { + ...input, + }} + /** ResourceFieldSelector represents container resources (cpu, memory) and their output format */ export interface ResourceFieldSelector { containerName?: string | null; @@ -973,7 +999,7 @@ export function fromSecretKeySelector(input: SecretKeySelector): c.JSONValue { ...input, }} -/** EnvFromSource represents the source of a set of ConfigMaps */ +/** EnvFromSource represents the source of a set of ConfigMaps or Secrets */ export interface EnvFromSource { configMapRef?: ConfigMapEnvSource | null; prefix?: string | null; @@ -1015,12 +1041,14 @@ export function fromSecretEnvSource(input: SecretEnvSource): c.JSONValue { export interface Lifecycle { postStart?: LifecycleHandler | null; preStop?: LifecycleHandler | null; + stopSignal?: string | null; } export function toLifecycle(input: c.JSONValue): Lifecycle { const obj = c.checkObj(input); return { postStart: c.readOpt(obj["postStart"], toLifecycleHandler), preStop: c.readOpt(obj["preStop"], toLifecycleHandler), + stopSignal: c.readOpt(obj["stopSignal"], c.checkStr), }} export function fromLifecycle(input: Lifecycle): c.JSONValue { return { @@ -1263,6 +1291,39 @@ export function fromResourceClaim(input: ResourceClaim): c.JSONValue { ...input, }} +/** ContainerRestartRule describes how a container exit is handled. */ +export interface ContainerRestartRule { + action: string; + exitCodes?: ContainerRestartRuleOnExitCodes | null; +} +export function toContainerRestartRule(input: c.JSONValue): ContainerRestartRule { + const obj = c.checkObj(input); + return { + action: c.checkStr(obj["action"]), + exitCodes: c.readOpt(obj["exitCodes"], toContainerRestartRuleOnExitCodes), + }} +export function fromContainerRestartRule(input: ContainerRestartRule): c.JSONValue { + return { + ...input, + exitCodes: input.exitCodes != null ? fromContainerRestartRuleOnExitCodes(input.exitCodes) : undefined, + }} + +/** ContainerRestartRuleOnExitCodes describes the condition for handling an exited container based on its exit codes. */ +export interface ContainerRestartRuleOnExitCodes { + operator: string; + values?: Array | null; +} +export function toContainerRestartRuleOnExitCodes(input: c.JSONValue): ContainerRestartRuleOnExitCodes { + const obj = c.checkObj(input); + return { + operator: c.checkStr(obj["operator"]), + values: c.readOpt(obj["values"], x => c.readList(x, c.checkNum)), + }} +export function fromContainerRestartRuleOnExitCodes(input: ContainerRestartRuleOnExitCodes): c.JSONValue { + return { + ...input, + }} + /** SecurityContext holds security configuration that will be applied to a container. Some fields are present in both SecurityContext and PodSecurityContext. When both are set, the values in SecurityContext take precedence. */ export interface SecurityContext { allowPrivilegeEscalation?: boolean | null; @@ -1402,6 +1463,24 @@ export function fromVolumeMount(input: VolumeMount): c.JSONValue { ...input, }} +/** ContainerExtendedResourceRequest has the mapping of container name, extended resource name to the device request name. */ +export interface ContainerExtendedResourceRequest { + containerName: string; + requestName: string; + resourceName: string; +} +export function toContainerExtendedResourceRequest(input: c.JSONValue): ContainerExtendedResourceRequest { + const obj = c.checkObj(input); + return { + containerName: c.checkStr(obj["containerName"]), + requestName: c.checkStr(obj["requestName"]), + resourceName: c.checkStr(obj["resourceName"]), + }} +export function fromContainerExtendedResourceRequest(input: ContainerExtendedResourceRequest): c.JSONValue { + return { + ...input, + }} + /** Describe a container image */ export interface ContainerImage { names?: Array | null; @@ -1512,6 +1591,7 @@ export interface ContainerStatus { restartCount: number; started?: boolean | null; state?: ContainerState | null; + stopSignal?: string | null; user?: ContainerUser | null; volumeMounts?: Array | null; } @@ -1530,6 +1610,7 @@ export function toContainerStatus(input: c.JSONValue): ContainerStatus { restartCount: c.checkNum(obj["restartCount"]), started: c.readOpt(obj["started"], c.checkBool), state: c.readOpt(obj["state"], toContainerState), + stopSignal: c.readOpt(obj["stopSignal"], c.checkStr), user: c.readOpt(obj["user"], toContainerUser), volumeMounts: c.readOpt(obj["volumeMounts"], x => c.readList(x, toVolumeMountStatus)), }} @@ -1716,7 +1797,7 @@ export function fromEmptyDirVolumeSource(input: EmptyDirVolumeSource): c.JSONVal sizeLimit: input.sizeLimit != null ? c.fromQuantity(input.sizeLimit) : undefined, }} -/** EndpointAddress is a tuple that describes single IP address. */ +/** EndpointAddress is a tuple that describes single IP address. Deprecated: This API is deprecated in v1.33+. */ export interface EndpointAddress { hostname?: string | null; ip: string; @@ -1737,7 +1818,7 @@ export function fromEndpointAddress(input: EndpointAddress): c.JSONValue { targetRef: input.targetRef != null ? fromObjectReference(input.targetRef) : undefined, }} -/** EndpointPort is a tuple that describes a single port. */ +/** EndpointPort is a tuple that describes a single port. Deprecated: This API is deprecated in v1.33+. */ export interface EndpointPort { appProtocol?: string | null; name?: string | null; @@ -1767,7 +1848,9 @@ export function fromEndpointPort(input: EndpointPort): c.JSONValue { The resulting set of endpoints can be viewed as: a: [ 10.10.1.1:8675, 10.10.2.2:8675 ], - b: [ 10.10.1.1:309, 10.10.2.2:309 ] */ + b: [ 10.10.1.1:309, 10.10.2.2:309 ] + +Deprecated: This API is deprecated in v1.33+. */ export interface EndpointSubset { addresses?: Array | null; notReadyAddresses?: Array | null; @@ -1800,7 +1883,11 @@ export function fromEndpointSubset(input: EndpointSubset): c.JSONValue { Addresses: [{"ip": "10.10.3.3"}], Ports: [{"name": "a", "port": 93}, {"name": "b", "port": 76}] }, - ] */ + ] + +Endpoints is a legacy API and does not contain information about all Service features. Use discoveryv1.EndpointSlice for complete information about Service endpoints. + +Deprecated: This API is deprecated in v1.33+. Use discoveryv1.EndpointSlice. */ export interface Endpoints { apiVersion?: "v1"; kind?: "Endpoints"; @@ -1822,7 +1909,7 @@ export function fromEndpoints(input: Endpoints): c.JSONValue { subsets: input.subsets?.map(fromEndpointSubset), }} -/** EndpointsList is a list of endpoints. */ +/** EndpointsList is a list of endpoints. Deprecated: This API is deprecated in v1.33+. */ export interface EndpointsList extends ListOf { apiVersion?: "v1"; kind?: "EndpointsList"; @@ -1853,6 +1940,7 @@ export interface EphemeralContainer { resizePolicy?: Array | null; resources?: ResourceRequirements | null; restartPolicy?: string | null; + restartPolicyRules?: Array | null; securityContext?: SecurityContext | null; startupProbe?: Probe | null; stdin?: boolean | null; @@ -1882,6 +1970,7 @@ export function toEphemeralContainer(input: c.JSONValue): EphemeralContainer { resizePolicy: c.readOpt(obj["resizePolicy"], x => c.readList(x, toContainerResizePolicy)), resources: c.readOpt(obj["resources"], toResourceRequirements), restartPolicy: c.readOpt(obj["restartPolicy"], c.checkStr), + restartPolicyRules: c.readOpt(obj["restartPolicyRules"], x => c.readList(x, toContainerRestartRule)), securityContext: c.readOpt(obj["securityContext"], toSecurityContext), startupProbe: c.readOpt(obj["startupProbe"], toProbe), stdin: c.readOpt(obj["stdin"], c.checkBool), @@ -1905,6 +1994,7 @@ export function fromEphemeralContainer(input: EphemeralContainer): c.JSONValue { readinessProbe: input.readinessProbe != null ? fromProbe(input.readinessProbe) : undefined, resizePolicy: input.resizePolicy?.map(fromContainerResizePolicy), resources: input.resources != null ? fromResourceRequirements(input.resources) : undefined, + restartPolicyRules: input.restartPolicyRules?.map(fromContainerRestartRule), securityContext: input.securityContext != null ? fromSecurityContext(input.securityContext) : undefined, startupProbe: input.startupProbe != null ? fromProbe(input.startupProbe) : undefined, volumeDevices: input.volumeDevices?.map(fromVolumeDevice), @@ -2948,6 +3038,7 @@ export interface NodeSystemInfo { machineID: string; operatingSystem: string; osImage: string; + swap?: NodeSwapStatus | null; systemUUID: string; } export function toNodeSystemInfo(input: c.JSONValue): NodeSystemInfo { @@ -2962,9 +3053,25 @@ export function toNodeSystemInfo(input: c.JSONValue): NodeSystemInfo { machineID: c.checkStr(obj["machineID"]), operatingSystem: c.checkStr(obj["operatingSystem"]), osImage: c.checkStr(obj["osImage"]), + swap: c.readOpt(obj["swap"], toNodeSwapStatus), systemUUID: c.checkStr(obj["systemUUID"]), }} export function fromNodeSystemInfo(input: NodeSystemInfo): c.JSONValue { + return { + ...input, + swap: input.swap != null ? fromNodeSwapStatus(input.swap) : undefined, + }} + +/** NodeSwapStatus represents swap memory information. */ +export interface NodeSwapStatus { + capacity?: number | null; +} +export function toNodeSwapStatus(input: c.JSONValue): NodeSwapStatus { + const obj = c.checkObj(input); + return { + capacity: c.readOpt(obj["capacity"], c.checkNum), + }} +export function fromNodeSwapStatus(input: NodeSwapStatus): c.JSONValue { return { ...input, }} @@ -3504,6 +3611,7 @@ export interface PodSpec { hostPID?: boolean | null; hostUsers?: boolean | null; hostname?: string | null; + hostnameOverride?: string | null; imagePullSecrets?: Array | null; initContainers?: Array | null; nodeName?: string | null; @@ -3548,6 +3656,7 @@ export function toPodSpec(input: c.JSONValue): PodSpec { hostPID: c.readOpt(obj["hostPID"], c.checkBool), hostUsers: c.readOpt(obj["hostUsers"], c.checkBool), hostname: c.readOpt(obj["hostname"], c.checkStr), + hostnameOverride: c.readOpt(obj["hostnameOverride"], c.checkStr), imagePullSecrets: c.readOpt(obj["imagePullSecrets"], x => c.readList(x, toLocalObjectReference)), initContainers: c.readOpt(obj["initContainers"], x => c.readList(x, toContainer)), nodeName: c.readOpt(obj["nodeName"], c.checkStr), @@ -3930,6 +4039,7 @@ export interface VolumeProjection { clusterTrustBundle?: ClusterTrustBundleProjection | null; configMap?: ConfigMapProjection | null; downwardAPI?: DownwardAPIProjection | null; + podCertificate?: PodCertificateProjection | null; secret?: SecretProjection | null; serviceAccountToken?: ServiceAccountTokenProjection | null; } @@ -3939,6 +4049,7 @@ export function toVolumeProjection(input: c.JSONValue): VolumeProjection { clusterTrustBundle: c.readOpt(obj["clusterTrustBundle"], toClusterTrustBundleProjection), configMap: c.readOpt(obj["configMap"], toConfigMapProjection), downwardAPI: c.readOpt(obj["downwardAPI"], toDownwardAPIProjection), + podCertificate: c.readOpt(obj["podCertificate"], toPodCertificateProjection), secret: c.readOpt(obj["secret"], toSecretProjection), serviceAccountToken: c.readOpt(obj["serviceAccountToken"], toServiceAccountTokenProjection), }} @@ -3948,10 +4059,35 @@ export function fromVolumeProjection(input: VolumeProjection): c.JSONValue { clusterTrustBundle: input.clusterTrustBundle != null ? fromClusterTrustBundleProjection(input.clusterTrustBundle) : undefined, configMap: input.configMap != null ? fromConfigMapProjection(input.configMap) : undefined, downwardAPI: input.downwardAPI != null ? fromDownwardAPIProjection(input.downwardAPI) : undefined, + podCertificate: input.podCertificate != null ? fromPodCertificateProjection(input.podCertificate) : undefined, secret: input.secret != null ? fromSecretProjection(input.secret) : undefined, serviceAccountToken: input.serviceAccountToken != null ? fromServiceAccountTokenProjection(input.serviceAccountToken) : undefined, }} +/** PodCertificateProjection provides a private key and X.509 certificate in the pod filesystem. */ +export interface PodCertificateProjection { + certificateChainPath?: string | null; + credentialBundlePath?: string | null; + keyPath?: string | null; + keyType: string; + maxExpirationSeconds?: number | null; + signerName: string; +} +export function toPodCertificateProjection(input: c.JSONValue): PodCertificateProjection { + const obj = c.checkObj(input); + return { + certificateChainPath: c.readOpt(obj["certificateChainPath"], c.checkStr), + credentialBundlePath: c.readOpt(obj["credentialBundlePath"], c.checkStr), + keyPath: c.readOpt(obj["keyPath"], c.checkStr), + keyType: c.checkStr(obj["keyType"]), + maxExpirationSeconds: c.readOpt(obj["maxExpirationSeconds"], c.checkNum), + signerName: c.checkStr(obj["signerName"]), + }} +export function fromPodCertificateProjection(input: PodCertificateProjection): c.JSONValue { + return { + ...input, + }} + /** Adapts a secret into a projected volume. The contents of the target Secret's Data field will be presented in a projected volume as files using the keys in the Data field as the file names. Note that this is identical to a secret volume source without the default mode. */ @@ -4104,11 +4240,13 @@ export interface PodStatus { conditions?: Array | null; containerStatuses?: Array | null; ephemeralContainerStatuses?: Array | null; + extendedResourceClaimStatus?: PodExtendedResourceClaimStatus | null; hostIP?: string | null; hostIPs?: Array | null; initContainerStatuses?: Array | null; message?: string | null; nominatedNodeName?: string | null; + observedGeneration?: number | null; phase?: string | null; podIP?: string | null; podIPs?: Array | null; @@ -4124,11 +4262,13 @@ export function toPodStatus(input: c.JSONValue): PodStatus { conditions: c.readOpt(obj["conditions"], x => c.readList(x, toPodCondition)), containerStatuses: c.readOpt(obj["containerStatuses"], x => c.readList(x, toContainerStatus)), ephemeralContainerStatuses: c.readOpt(obj["ephemeralContainerStatuses"], x => c.readList(x, toContainerStatus)), + extendedResourceClaimStatus: c.readOpt(obj["extendedResourceClaimStatus"], toPodExtendedResourceClaimStatus), hostIP: c.readOpt(obj["hostIP"], c.checkStr), hostIPs: c.readOpt(obj["hostIPs"], x => c.readList(x, toHostIP)), initContainerStatuses: c.readOpt(obj["initContainerStatuses"], x => c.readList(x, toContainerStatus)), message: c.readOpt(obj["message"], c.checkStr), nominatedNodeName: c.readOpt(obj["nominatedNodeName"], c.checkStr), + observedGeneration: c.readOpt(obj["observedGeneration"], c.checkNum), phase: c.readOpt(obj["phase"], c.checkStr), podIP: c.readOpt(obj["podIP"], c.checkStr), podIPs: c.readOpt(obj["podIPs"], x => c.readList(x, toPodIP)), @@ -4144,6 +4284,7 @@ export function fromPodStatus(input: PodStatus): c.JSONValue { conditions: input.conditions?.map(fromPodCondition), containerStatuses: input.containerStatuses?.map(fromContainerStatus), ephemeralContainerStatuses: input.ephemeralContainerStatuses?.map(fromContainerStatus), + extendedResourceClaimStatus: input.extendedResourceClaimStatus != null ? fromPodExtendedResourceClaimStatus(input.extendedResourceClaimStatus) : undefined, hostIPs: input.hostIPs?.map(fromHostIP), initContainerStatuses: input.initContainerStatuses?.map(fromContainerStatus), podIPs: input.podIPs?.map(fromPodIP), @@ -4156,6 +4297,7 @@ export interface PodCondition { lastProbeTime?: c.Time | null; lastTransitionTime?: c.Time | null; message?: string | null; + observedGeneration?: number | null; reason?: string | null; status: string; type: string; @@ -4166,6 +4308,7 @@ export function toPodCondition(input: c.JSONValue): PodCondition { lastProbeTime: c.readOpt(obj["lastProbeTime"], c.toTime), lastTransitionTime: c.readOpt(obj["lastTransitionTime"], c.toTime), message: c.readOpt(obj["message"], c.checkStr), + observedGeneration: c.readOpt(obj["observedGeneration"], c.checkNum), reason: c.readOpt(obj["reason"], c.checkStr), status: c.checkStr(obj["status"]), type: c.checkStr(obj["type"]), @@ -4177,6 +4320,23 @@ export function fromPodCondition(input: PodCondition): c.JSONValue { lastTransitionTime: input.lastTransitionTime != null ? c.fromTime(input.lastTransitionTime) : undefined, }} +/** PodExtendedResourceClaimStatus is stored in the PodStatus for the extended resource requests backed by DRA. It stores the generated name for the corresponding special ResourceClaim created by the scheduler. */ +export interface PodExtendedResourceClaimStatus { + requestMappings: Array; + resourceClaimName: string; +} +export function toPodExtendedResourceClaimStatus(input: c.JSONValue): PodExtendedResourceClaimStatus { + const obj = c.checkObj(input); + return { + requestMappings: c.readList(obj["requestMappings"], toContainerExtendedResourceRequest), + resourceClaimName: c.checkStr(obj["resourceClaimName"]), + }} +export function fromPodExtendedResourceClaimStatus(input: PodExtendedResourceClaimStatus): c.JSONValue { + return { + ...input, + requestMappings: input.requestMappings?.map(fromContainerExtendedResourceRequest), + }} + /** PodIP represents a single IP address allocated to the pod. */ export interface PodIP { ip: string; diff --git a/lib/builtin/discovery.k8s.io@v1/structs.ts b/lib/builtin/discovery.k8s.io@v1/structs.ts index 43d8c6c..12cddd7 100644 --- a/lib/builtin/discovery.k8s.io@v1/structs.ts +++ b/lib/builtin/discovery.k8s.io@v1/structs.ts @@ -59,19 +59,36 @@ export function fromEndpointConditions(input: EndpointConditions): c.JSONValue { /** EndpointHints provides hints describing how an endpoint should be consumed. */ export interface EndpointHints { + forNodes?: Array | null; forZones?: Array | null; } export function toEndpointHints(input: c.JSONValue): EndpointHints { const obj = c.checkObj(input); return { + forNodes: c.readOpt(obj["forNodes"], x => c.readList(x, toForNode)), forZones: c.readOpt(obj["forZones"], x => c.readList(x, toForZone)), }} export function fromEndpointHints(input: EndpointHints): c.JSONValue { return { ...input, + forNodes: input.forNodes?.map(fromForNode), forZones: input.forZones?.map(fromForZone), }} +/** ForNode provides information about which nodes should consume this endpoint. */ +export interface ForNode { + name: string; +} +export function toForNode(input: c.JSONValue): ForNode { + const obj = c.checkObj(input); + return { + name: c.checkStr(obj["name"]), + }} +export function fromForNode(input: ForNode): c.JSONValue { + return { + ...input, + }} + /** ForZone provides information about which zones should consume this endpoint. */ export interface ForZone { name: string; @@ -106,7 +123,7 @@ export function fromEndpointPort(input: EndpointPort): c.JSONValue { ...input, }} -/** EndpointSlice represents a subset of the endpoints that implement a service. For a given service there may be multiple EndpointSlice objects, selected by labels, which must be joined to produce the full set of endpoints. */ +/** EndpointSlice represents a set of service endpoints. Most EndpointSlices are created by the EndpointSlice controller to represent the Pods selected by Service objects. For a given service there may be multiple EndpointSlice objects which must be joined to produce the full set of endpoints; you can find all of the slices for a given service by listing EndpointSlices in the service's namespace whose `kubernetes.io/service-name` label contains the service's name. */ export interface EndpointSlice { apiVersion?: "discovery.k8s.io/v1"; kind?: "EndpointSlice"; diff --git a/lib/builtin/networking.k8s.io@v1/mod.ts b/lib/builtin/networking.k8s.io@v1/mod.ts index 1940bbf..c6703ba 100644 --- a/lib/builtin/networking.k8s.io@v1/mod.ts +++ b/lib/builtin/networking.k8s.io@v1/mod.ts @@ -165,6 +165,123 @@ export class NetworkingV1Api { return resp.pipeThrough(new c.WatchEventTransformer(NetworkingV1.toIngress, MetaV1.toStatus)); } + async getIPAddressList( + opts: operations.GetListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}ipaddresses`, + expectJson: true, + querystring: operations.formatGetListOpts(opts), + abortSignal: opts.abortSignal, + }); + return NetworkingV1.toIPAddressList(resp); + } + + async watchIPAddressList( + opts: operations.WatchListOpts = {}, + ): Promise> { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}ipaddresses`, + expectJson: true, + expectStream: true, + querystring: operations.formatWatchListOpts(opts), + abortSignal: opts.abortSignal, + }); + return resp.pipeThrough(new c.WatchEventTransformer(NetworkingV1.toIPAddress, MetaV1.toStatus)); + } + + async createIPAddress( + body: NetworkingV1.IPAddress, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "POST", + path: `${this.#root}ipaddresses`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: NetworkingV1.fromIPAddress(body), + abortSignal: opts.abortSignal, + }); + return NetworkingV1.toIPAddress(resp); + } + + async deleteIPAddressList( + opts: operations.DeleteListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}ipaddresses`, + expectJson: true, + querystring: operations.formatDeleteListOpts(opts), + abortSignal: opts.abortSignal, + }); + return NetworkingV1.toIPAddressList(resp); + } + + async getIPAddress( + name: string, + opts: operations.NoOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}ipaddresses/${name}`, + expectJson: true, + abortSignal: opts.abortSignal, + }); + return NetworkingV1.toIPAddress(resp); + } + + async deleteIPAddress( + name: string, + opts: operations.DeleteOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}ipaddresses/${name}`, + expectJson: true, + querystring: operations.formatDeleteOpts(opts), + abortSignal: opts.abortSignal, + }); + if (c.isStatusKind(resp)) return MetaV1.toStatus(resp); + return NetworkingV1.toIPAddress(resp); + } + + async replaceIPAddress( + name: string, + body: NetworkingV1.IPAddress, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PUT", + path: `${this.#root}ipaddresses/${name}`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: NetworkingV1.fromIPAddress(body), + abortSignal: opts.abortSignal, + }); + return NetworkingV1.toIPAddress(resp); + } + + async patchIPAddress( + name: string, + type: c.PatchType, + body: NetworkingV1.IPAddress | c.JsonPatch, + opts: operations.PatchOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PATCH", + path: `${this.#root}ipaddresses/${name}`, + expectJson: true, + querystring: operations.formatPatchOpts(opts), + contentType: c.getPatchContentType(type), + bodyJson: Array.isArray(body) ? body : NetworkingV1.fromIPAddress(body), + abortSignal: opts.abortSignal, + }); + return NetworkingV1.toIPAddress(resp); + } + async getNetworkPolicyListForAllNamespaces( opts: operations.GetListOpts = {}, ): Promise { @@ -192,6 +309,170 @@ export class NetworkingV1Api { return resp.pipeThrough(new c.WatchEventTransformer(NetworkingV1.toNetworkPolicy, MetaV1.toStatus)); } + async getServiceCIDRList( + opts: operations.GetListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}servicecidrs`, + expectJson: true, + querystring: operations.formatGetListOpts(opts), + abortSignal: opts.abortSignal, + }); + return NetworkingV1.toServiceCIDRList(resp); + } + + async watchServiceCIDRList( + opts: operations.WatchListOpts = {}, + ): Promise> { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}servicecidrs`, + expectJson: true, + expectStream: true, + querystring: operations.formatWatchListOpts(opts), + abortSignal: opts.abortSignal, + }); + return resp.pipeThrough(new c.WatchEventTransformer(NetworkingV1.toServiceCIDR, MetaV1.toStatus)); + } + + async createServiceCIDR( + body: NetworkingV1.ServiceCIDR, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "POST", + path: `${this.#root}servicecidrs`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: NetworkingV1.fromServiceCIDR(body), + abortSignal: opts.abortSignal, + }); + return NetworkingV1.toServiceCIDR(resp); + } + + async deleteServiceCIDRList( + opts: operations.DeleteListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}servicecidrs`, + expectJson: true, + querystring: operations.formatDeleteListOpts(opts), + abortSignal: opts.abortSignal, + }); + return NetworkingV1.toServiceCIDRList(resp); + } + + async getServiceCIDR( + name: string, + opts: operations.NoOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}servicecidrs/${name}`, + expectJson: true, + abortSignal: opts.abortSignal, + }); + return NetworkingV1.toServiceCIDR(resp); + } + + async deleteServiceCIDR( + name: string, + opts: operations.DeleteOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}servicecidrs/${name}`, + expectJson: true, + querystring: operations.formatDeleteOpts(opts), + abortSignal: opts.abortSignal, + }); + if (c.isStatusKind(resp)) return MetaV1.toStatus(resp); + return NetworkingV1.toServiceCIDR(resp); + } + + async replaceServiceCIDR( + name: string, + body: NetworkingV1.ServiceCIDR, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PUT", + path: `${this.#root}servicecidrs/${name}`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: NetworkingV1.fromServiceCIDR(body), + abortSignal: opts.abortSignal, + }); + return NetworkingV1.toServiceCIDR(resp); + } + + async patchServiceCIDR( + name: string, + type: c.PatchType, + body: NetworkingV1.ServiceCIDR | c.JsonPatch, + opts: operations.PatchOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PATCH", + path: `${this.#root}servicecidrs/${name}`, + expectJson: true, + querystring: operations.formatPatchOpts(opts), + contentType: c.getPatchContentType(type), + bodyJson: Array.isArray(body) ? body : NetworkingV1.fromServiceCIDR(body), + abortSignal: opts.abortSignal, + }); + return NetworkingV1.toServiceCIDR(resp); + } + + async getServiceCIDRStatus( + name: string, + opts: operations.NoOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}servicecidrs/${name}/status`, + expectJson: true, + abortSignal: opts.abortSignal, + }); + return NetworkingV1.toServiceCIDR(resp); + } + + async replaceServiceCIDRStatus( + name: string, + body: NetworkingV1.ServiceCIDR, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PUT", + path: `${this.#root}servicecidrs/${name}/status`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: NetworkingV1.fromServiceCIDR(body), + abortSignal: opts.abortSignal, + }); + return NetworkingV1.toServiceCIDR(resp); + } + + async patchServiceCIDRStatus( + name: string, + type: c.PatchType, + body: NetworkingV1.ServiceCIDR | c.JsonPatch, + opts: operations.PatchOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PATCH", + path: `${this.#root}servicecidrs/${name}/status`, + expectJson: true, + querystring: operations.formatPatchOpts(opts), + contentType: c.getPatchContentType(type), + bodyJson: Array.isArray(body) ? body : NetworkingV1.fromServiceCIDR(body), + abortSignal: opts.abortSignal, + }); + return NetworkingV1.toServiceCIDR(resp); + } + } export class NetworkingV1NamespacedApi { diff --git a/lib/builtin/networking.k8s.io@v1/structs.ts b/lib/builtin/networking.k8s.io@v1/structs.ts index 3337894..32440f2 100644 --- a/lib/builtin/networking.k8s.io@v1/structs.ts +++ b/lib/builtin/networking.k8s.io@v1/structs.ts @@ -93,6 +93,76 @@ export function fromHTTPIngressRuleValue(input: HTTPIngressRuleValue): c.JSONVal paths: input.paths?.map(fromHTTPIngressPath), }} +/** IPAddress represents a single IP of a single IP Family. The object is designed to be used by APIs that operate on IP addresses. The object is used by the Service core API for allocation of IP addresses. An IP address can be represented in different formats, to guarantee the uniqueness of the IP, the name of the object is the IP address in canonical format, four decimal digits separated by dots suppressing leading zeros for IPv4 and the representation defined by RFC 5952 for IPv6. Valid: 192.168.1.5 or 2001:db8::1 or 2001:db8:aaaa:bbbb:cccc:dddd:eeee:1 Invalid: 10.01.2.3 or 2001:db8:0:0:0::1 */ +export interface IPAddress { + apiVersion?: "networking.k8s.io/v1"; + kind?: "IPAddress"; + metadata?: MetaV1.ObjectMeta | null; + spec?: IPAddressSpec | null; +} +export function toIPAddress(input: c.JSONValue): IPAddress & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "networking.k8s.io/v1", "IPAddress"), + metadata: c.readOpt(obj["metadata"], MetaV1.toObjectMeta), + spec: c.readOpt(obj["spec"], toIPAddressSpec), + }} +export function fromIPAddress(input: IPAddress): c.JSONValue { + return { + ...c.assertOrAddApiVersionAndKind(input, "networking.k8s.io/v1", "IPAddress"), + ...input, + metadata: input.metadata != null ? MetaV1.fromObjectMeta(input.metadata) : undefined, + spec: input.spec != null ? fromIPAddressSpec(input.spec) : undefined, + }} + +/** IPAddressSpec describe the attributes in an IP Address. */ +export interface IPAddressSpec { + parentRef: ParentReference; +} +export function toIPAddressSpec(input: c.JSONValue): IPAddressSpec { + const obj = c.checkObj(input); + return { + parentRef: toParentReference(obj["parentRef"]), + }} +export function fromIPAddressSpec(input: IPAddressSpec): c.JSONValue { + return { + ...input, + parentRef: input.parentRef != null ? fromParentReference(input.parentRef) : undefined, + }} + +/** ParentReference describes a reference to a parent object. */ +export interface ParentReference { + group?: string | null; + name: string; + namespace?: string | null; + resource: string; +} +export function toParentReference(input: c.JSONValue): ParentReference { + const obj = c.checkObj(input); + return { + group: c.readOpt(obj["group"], c.checkStr), + name: c.checkStr(obj["name"]), + namespace: c.readOpt(obj["namespace"], c.checkStr), + resource: c.checkStr(obj["resource"]), + }} +export function fromParentReference(input: ParentReference): c.JSONValue { + return { + ...input, + }} + +/** IPAddressList contains a list of IPAddress. */ +export interface IPAddressList extends ListOf { + apiVersion?: "networking.k8s.io/v1"; + kind?: "IPAddressList"; +}; +export function toIPAddressList(input: c.JSONValue): IPAddressList & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "networking.k8s.io/v1", "IPAddressList"), + metadata: MetaV1.toListMeta(obj.metadata), + items: c.readList(obj.items, toIPAddress), + }} + /** IPBlock describes a particular CIDR (Ex. "192.168.1.0/24","2001:db8::/64") that is allowed to the pods matched by a NetworkPolicySpec's podSelector. The except entry describes CIDRs that should not be included within this rule. */ export interface IPBlock { cidr: string; @@ -370,7 +440,7 @@ export function fromNetworkPolicy(input: NetworkPolicy): c.JSONValue { export interface NetworkPolicySpec { egress?: Array | null; ingress?: Array | null; - podSelector: MetaV1.LabelSelector; + podSelector?: MetaV1.LabelSelector | null; policyTypes?: Array | null; } export function toNetworkPolicySpec(input: c.JSONValue): NetworkPolicySpec { @@ -378,7 +448,7 @@ export function toNetworkPolicySpec(input: c.JSONValue): NetworkPolicySpec { return { egress: c.readOpt(obj["egress"], x => c.readList(x, toNetworkPolicyEgressRule)), ingress: c.readOpt(obj["ingress"], x => c.readList(x, toNetworkPolicyIngressRule)), - podSelector: MetaV1.toLabelSelector(obj["podSelector"]), + podSelector: c.readOpt(obj["podSelector"], MetaV1.toLabelSelector), policyTypes: c.readOpt(obj["policyTypes"], x => c.readList(x, c.checkStr)), }} export function fromNetworkPolicySpec(input: NetworkPolicySpec): c.JSONValue { @@ -476,3 +546,70 @@ export function toNetworkPolicyList(input: c.JSONValue): NetworkPolicyList & c.A metadata: MetaV1.toListMeta(obj.metadata), items: c.readList(obj.items, toNetworkPolicy), }} + +/** ServiceCIDR defines a range of IP addresses using CIDR format (e.g. 192.168.0.0/24 or 2001:db2::/64). This range is used to allocate ClusterIPs to Service objects. */ +export interface ServiceCIDR { + apiVersion?: "networking.k8s.io/v1"; + kind?: "ServiceCIDR"; + metadata?: MetaV1.ObjectMeta | null; + spec?: ServiceCIDRSpec | null; + status?: ServiceCIDRStatus | null; +} +export function toServiceCIDR(input: c.JSONValue): ServiceCIDR & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "networking.k8s.io/v1", "ServiceCIDR"), + metadata: c.readOpt(obj["metadata"], MetaV1.toObjectMeta), + spec: c.readOpt(obj["spec"], toServiceCIDRSpec), + status: c.readOpt(obj["status"], toServiceCIDRStatus), + }} +export function fromServiceCIDR(input: ServiceCIDR): c.JSONValue { + return { + ...c.assertOrAddApiVersionAndKind(input, "networking.k8s.io/v1", "ServiceCIDR"), + ...input, + metadata: input.metadata != null ? MetaV1.fromObjectMeta(input.metadata) : undefined, + spec: input.spec != null ? fromServiceCIDRSpec(input.spec) : undefined, + status: input.status != null ? fromServiceCIDRStatus(input.status) : undefined, + }} + +/** ServiceCIDRSpec define the CIDRs the user wants to use for allocating ClusterIPs for Services. */ +export interface ServiceCIDRSpec { + cidrs?: Array | null; +} +export function toServiceCIDRSpec(input: c.JSONValue): ServiceCIDRSpec { + const obj = c.checkObj(input); + return { + cidrs: c.readOpt(obj["cidrs"], x => c.readList(x, c.checkStr)), + }} +export function fromServiceCIDRSpec(input: ServiceCIDRSpec): c.JSONValue { + return { + ...input, + }} + +/** ServiceCIDRStatus describes the current state of the ServiceCIDR. */ +export interface ServiceCIDRStatus { + conditions?: Array | null; +} +export function toServiceCIDRStatus(input: c.JSONValue): ServiceCIDRStatus { + const obj = c.checkObj(input); + return { + conditions: c.readOpt(obj["conditions"], x => c.readList(x, MetaV1.toCondition)), + }} +export function fromServiceCIDRStatus(input: ServiceCIDRStatus): c.JSONValue { + return { + ...input, + conditions: input.conditions?.map(MetaV1.fromCondition), + }} + +/** ServiceCIDRList contains a list of ServiceCIDR objects. */ +export interface ServiceCIDRList extends ListOf { + apiVersion?: "networking.k8s.io/v1"; + kind?: "ServiceCIDRList"; +}; +export function toServiceCIDRList(input: c.JSONValue): ServiceCIDRList & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "networking.k8s.io/v1", "ServiceCIDRList"), + metadata: MetaV1.toListMeta(obj.metadata), + items: c.readList(obj.items, toServiceCIDR), + }} diff --git a/lib/builtin/resource.k8s.io@v1/mod.ts b/lib/builtin/resource.k8s.io@v1/mod.ts new file mode 100644 index 0000000..eb8b706 --- /dev/null +++ b/lib/builtin/resource.k8s.io@v1/mod.ts @@ -0,0 +1,603 @@ +export * from "./structs.ts"; + +// Autogenerated API file for ResourceV1 +import * as c from "../../common.ts"; +import * as operations from "../../operations.ts"; +import * as MetaV1 from "../meta@v1/structs.ts"; +import * as ResourceV1 from "./structs.ts"; + +export class ResourceV1Api { + #client: c.RestClient; + #root = "/apis/resource.k8s.io/v1/"; + constructor(client: c.RestClient) { + this.#client = client; + } + + namespace(name: string): ResourceV1NamespacedApi { + return new ResourceV1NamespacedApi(this.#client, name); + } + myNamespace(): ResourceV1NamespacedApi { + if (!this.#client.defaultNamespace) throw new Error("No current namespace is set"); + return new ResourceV1NamespacedApi(this.#client, this.#client.defaultNamespace); + } + + async getDeviceClassList( + opts: operations.GetListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}deviceclasses`, + expectJson: true, + querystring: operations.formatGetListOpts(opts), + abortSignal: opts.abortSignal, + }); + return ResourceV1.toDeviceClassList(resp); + } + + async watchDeviceClassList( + opts: operations.WatchListOpts = {}, + ): Promise> { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}deviceclasses`, + expectJson: true, + expectStream: true, + querystring: operations.formatWatchListOpts(opts), + abortSignal: opts.abortSignal, + }); + return resp.pipeThrough(new c.WatchEventTransformer(ResourceV1.toDeviceClass, MetaV1.toStatus)); + } + + async createDeviceClass( + body: ResourceV1.DeviceClass, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "POST", + path: `${this.#root}deviceclasses`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: ResourceV1.fromDeviceClass(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1.toDeviceClass(resp); + } + + async deleteDeviceClassList( + opts: operations.DeleteListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}deviceclasses`, + expectJson: true, + querystring: operations.formatDeleteListOpts(opts), + abortSignal: opts.abortSignal, + }); + return ResourceV1.toDeviceClassList(resp); + } + + async getDeviceClass( + name: string, + opts: operations.NoOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}deviceclasses/${name}`, + expectJson: true, + abortSignal: opts.abortSignal, + }); + return ResourceV1.toDeviceClass(resp); + } + + async deleteDeviceClass( + name: string, + opts: operations.DeleteOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}deviceclasses/${name}`, + expectJson: true, + querystring: operations.formatDeleteOpts(opts), + abortSignal: opts.abortSignal, + }); + if (c.isStatusKind(resp)) return MetaV1.toStatus(resp); + return ResourceV1.toDeviceClass(resp); + } + + async replaceDeviceClass( + name: string, + body: ResourceV1.DeviceClass, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PUT", + path: `${this.#root}deviceclasses/${name}`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: ResourceV1.fromDeviceClass(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1.toDeviceClass(resp); + } + + async patchDeviceClass( + name: string, + type: c.PatchType, + body: ResourceV1.DeviceClass | c.JsonPatch, + opts: operations.PatchOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PATCH", + path: `${this.#root}deviceclasses/${name}`, + expectJson: true, + querystring: operations.formatPatchOpts(opts), + contentType: c.getPatchContentType(type), + bodyJson: Array.isArray(body) ? body : ResourceV1.fromDeviceClass(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1.toDeviceClass(resp); + } + + async getResourceClaimListForAllNamespaces( + opts: operations.GetListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceclaims`, + expectJson: true, + querystring: operations.formatGetListOpts(opts), + abortSignal: opts.abortSignal, + }); + return ResourceV1.toResourceClaimList(resp); + } + + async watchResourceClaimListForAllNamespaces( + opts: operations.WatchListOpts = {}, + ): Promise> { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceclaims`, + expectJson: true, + expectStream: true, + querystring: operations.formatWatchListOpts(opts), + abortSignal: opts.abortSignal, + }); + return resp.pipeThrough(new c.WatchEventTransformer(ResourceV1.toResourceClaim, MetaV1.toStatus)); + } + + async getResourceClaimTemplateListForAllNamespaces( + opts: operations.GetListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceclaimtemplates`, + expectJson: true, + querystring: operations.formatGetListOpts(opts), + abortSignal: opts.abortSignal, + }); + return ResourceV1.toResourceClaimTemplateList(resp); + } + + async watchResourceClaimTemplateListForAllNamespaces( + opts: operations.WatchListOpts = {}, + ): Promise> { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceclaimtemplates`, + expectJson: true, + expectStream: true, + querystring: operations.formatWatchListOpts(opts), + abortSignal: opts.abortSignal, + }); + return resp.pipeThrough(new c.WatchEventTransformer(ResourceV1.toResourceClaimTemplate, MetaV1.toStatus)); + } + + async getResourceSliceList( + opts: operations.GetListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceslices`, + expectJson: true, + querystring: operations.formatGetListOpts(opts), + abortSignal: opts.abortSignal, + }); + return ResourceV1.toResourceSliceList(resp); + } + + async watchResourceSliceList( + opts: operations.WatchListOpts = {}, + ): Promise> { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceslices`, + expectJson: true, + expectStream: true, + querystring: operations.formatWatchListOpts(opts), + abortSignal: opts.abortSignal, + }); + return resp.pipeThrough(new c.WatchEventTransformer(ResourceV1.toResourceSlice, MetaV1.toStatus)); + } + + async createResourceSlice( + body: ResourceV1.ResourceSlice, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "POST", + path: `${this.#root}resourceslices`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: ResourceV1.fromResourceSlice(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1.toResourceSlice(resp); + } + + async deleteResourceSliceList( + opts: operations.DeleteListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}resourceslices`, + expectJson: true, + querystring: operations.formatDeleteListOpts(opts), + abortSignal: opts.abortSignal, + }); + return ResourceV1.toResourceSliceList(resp); + } + + async getResourceSlice( + name: string, + opts: operations.NoOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceslices/${name}`, + expectJson: true, + abortSignal: opts.abortSignal, + }); + return ResourceV1.toResourceSlice(resp); + } + + async deleteResourceSlice( + name: string, + opts: operations.DeleteOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}resourceslices/${name}`, + expectJson: true, + querystring: operations.formatDeleteOpts(opts), + abortSignal: opts.abortSignal, + }); + if (c.isStatusKind(resp)) return MetaV1.toStatus(resp); + return ResourceV1.toResourceSlice(resp); + } + + async replaceResourceSlice( + name: string, + body: ResourceV1.ResourceSlice, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PUT", + path: `${this.#root}resourceslices/${name}`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: ResourceV1.fromResourceSlice(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1.toResourceSlice(resp); + } + + async patchResourceSlice( + name: string, + type: c.PatchType, + body: ResourceV1.ResourceSlice | c.JsonPatch, + opts: operations.PatchOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PATCH", + path: `${this.#root}resourceslices/${name}`, + expectJson: true, + querystring: operations.formatPatchOpts(opts), + contentType: c.getPatchContentType(type), + bodyJson: Array.isArray(body) ? body : ResourceV1.fromResourceSlice(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1.toResourceSlice(resp); + } + +} + +export class ResourceV1NamespacedApi { + #client: c.RestClient + #root: string + constructor(client: c.RestClient, namespace: string) { + this.#client = client; + this.#root = `/apis/resource.k8s.io/v1/namespaces/${namespace}/`; + } + + async getResourceClaimList( + opts: operations.GetListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceclaims`, + expectJson: true, + querystring: operations.formatGetListOpts(opts), + abortSignal: opts.abortSignal, + }); + return ResourceV1.toResourceClaimList(resp); + } + + async watchResourceClaimList( + opts: operations.WatchListOpts = {}, + ): Promise> { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceclaims`, + expectJson: true, + expectStream: true, + querystring: operations.formatWatchListOpts(opts), + abortSignal: opts.abortSignal, + }); + return resp.pipeThrough(new c.WatchEventTransformer(ResourceV1.toResourceClaim, MetaV1.toStatus)); + } + + async createResourceClaim( + body: ResourceV1.ResourceClaim, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "POST", + path: `${this.#root}resourceclaims`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: ResourceV1.fromResourceClaim(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1.toResourceClaim(resp); + } + + async deleteResourceClaimList( + opts: operations.DeleteListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}resourceclaims`, + expectJson: true, + querystring: operations.formatDeleteListOpts(opts), + abortSignal: opts.abortSignal, + }); + return ResourceV1.toResourceClaimList(resp); + } + + async getResourceClaim( + name: string, + opts: operations.NoOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceclaims/${name}`, + expectJson: true, + abortSignal: opts.abortSignal, + }); + return ResourceV1.toResourceClaim(resp); + } + + async deleteResourceClaim( + name: string, + opts: operations.DeleteOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}resourceclaims/${name}`, + expectJson: true, + querystring: operations.formatDeleteOpts(opts), + abortSignal: opts.abortSignal, + }); + if (c.isStatusKind(resp)) return MetaV1.toStatus(resp); + return ResourceV1.toResourceClaim(resp); + } + + async replaceResourceClaim( + name: string, + body: ResourceV1.ResourceClaim, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PUT", + path: `${this.#root}resourceclaims/${name}`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: ResourceV1.fromResourceClaim(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1.toResourceClaim(resp); + } + + async patchResourceClaim( + name: string, + type: c.PatchType, + body: ResourceV1.ResourceClaim | c.JsonPatch, + opts: operations.PatchOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PATCH", + path: `${this.#root}resourceclaims/${name}`, + expectJson: true, + querystring: operations.formatPatchOpts(opts), + contentType: c.getPatchContentType(type), + bodyJson: Array.isArray(body) ? body : ResourceV1.fromResourceClaim(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1.toResourceClaim(resp); + } + + async getResourceClaimStatus( + name: string, + opts: operations.NoOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceclaims/${name}/status`, + expectJson: true, + abortSignal: opts.abortSignal, + }); + return ResourceV1.toResourceClaim(resp); + } + + async replaceResourceClaimStatus( + name: string, + body: ResourceV1.ResourceClaim, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PUT", + path: `${this.#root}resourceclaims/${name}/status`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: ResourceV1.fromResourceClaim(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1.toResourceClaim(resp); + } + + async patchResourceClaimStatus( + name: string, + type: c.PatchType, + body: ResourceV1.ResourceClaim | c.JsonPatch, + opts: operations.PatchOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PATCH", + path: `${this.#root}resourceclaims/${name}/status`, + expectJson: true, + querystring: operations.formatPatchOpts(opts), + contentType: c.getPatchContentType(type), + bodyJson: Array.isArray(body) ? body : ResourceV1.fromResourceClaim(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1.toResourceClaim(resp); + } + + async getResourceClaimTemplateList( + opts: operations.GetListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceclaimtemplates`, + expectJson: true, + querystring: operations.formatGetListOpts(opts), + abortSignal: opts.abortSignal, + }); + return ResourceV1.toResourceClaimTemplateList(resp); + } + + async watchResourceClaimTemplateList( + opts: operations.WatchListOpts = {}, + ): Promise> { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceclaimtemplates`, + expectJson: true, + expectStream: true, + querystring: operations.formatWatchListOpts(opts), + abortSignal: opts.abortSignal, + }); + return resp.pipeThrough(new c.WatchEventTransformer(ResourceV1.toResourceClaimTemplate, MetaV1.toStatus)); + } + + async createResourceClaimTemplate( + body: ResourceV1.ResourceClaimTemplate, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "POST", + path: `${this.#root}resourceclaimtemplates`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: ResourceV1.fromResourceClaimTemplate(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1.toResourceClaimTemplate(resp); + } + + async deleteResourceClaimTemplateList( + opts: operations.DeleteListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}resourceclaimtemplates`, + expectJson: true, + querystring: operations.formatDeleteListOpts(opts), + abortSignal: opts.abortSignal, + }); + return ResourceV1.toResourceClaimTemplateList(resp); + } + + async getResourceClaimTemplate( + name: string, + opts: operations.NoOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceclaimtemplates/${name}`, + expectJson: true, + abortSignal: opts.abortSignal, + }); + return ResourceV1.toResourceClaimTemplate(resp); + } + + async deleteResourceClaimTemplate( + name: string, + opts: operations.DeleteOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}resourceclaimtemplates/${name}`, + expectJson: true, + querystring: operations.formatDeleteOpts(opts), + abortSignal: opts.abortSignal, + }); + if (c.isStatusKind(resp)) return MetaV1.toStatus(resp); + return ResourceV1.toResourceClaimTemplate(resp); + } + + async replaceResourceClaimTemplate( + name: string, + body: ResourceV1.ResourceClaimTemplate, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PUT", + path: `${this.#root}resourceclaimtemplates/${name}`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: ResourceV1.fromResourceClaimTemplate(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1.toResourceClaimTemplate(resp); + } + + async patchResourceClaimTemplate( + name: string, + type: c.PatchType, + body: ResourceV1.ResourceClaimTemplate | c.JsonPatch, + opts: operations.PatchOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PATCH", + path: `${this.#root}resourceclaimtemplates/${name}`, + expectJson: true, + querystring: operations.formatPatchOpts(opts), + contentType: c.getPatchContentType(type), + bodyJson: Array.isArray(body) ? body : ResourceV1.fromResourceClaimTemplate(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1.toResourceClaimTemplate(resp); + } + +} diff --git a/lib/builtin/resource.k8s.io@v1/structs.ts b/lib/builtin/resource.k8s.io@v1/structs.ts new file mode 100644 index 0000000..7dd88ab --- /dev/null +++ b/lib/builtin/resource.k8s.io@v1/structs.ts @@ -0,0 +1,887 @@ +// Autogenerated Schema file for ResourceV1 +import * as c from "../../common.ts"; + +import * as CoreV1 from "../core@v1/structs.ts"; +import * as MetaV1 from "../meta@v1/structs.ts"; +type ListOf = { + metadata: MetaV1.ListMeta; + items: Array; +}; + +/** AllocatedDeviceStatus contains the status of an allocated device, if the driver chooses to report it. This may include driver-specific information. + +The combination of Driver, Pool, Device, and ShareID must match the corresponding key in Status.Allocation.Devices. */ +export interface AllocatedDeviceStatus { + conditions?: Array | null; + data?: c.JSONValue | null; + device: string; + driver: string; + networkData?: NetworkDeviceData | null; + pool: string; + shareID?: string | null; +} +export function toAllocatedDeviceStatus(input: c.JSONValue): AllocatedDeviceStatus { + const obj = c.checkObj(input); + return { + conditions: c.readOpt(obj["conditions"], x => c.readList(x, MetaV1.toCondition)), + data: c.readOpt(obj["data"], c.identity), + device: c.checkStr(obj["device"]), + driver: c.checkStr(obj["driver"]), + networkData: c.readOpt(obj["networkData"], toNetworkDeviceData), + pool: c.checkStr(obj["pool"]), + shareID: c.readOpt(obj["shareID"], c.checkStr), + }} +export function fromAllocatedDeviceStatus(input: AllocatedDeviceStatus): c.JSONValue { + return { + ...input, + conditions: input.conditions?.map(MetaV1.fromCondition), + networkData: input.networkData != null ? fromNetworkDeviceData(input.networkData) : undefined, + }} + +/** NetworkDeviceData provides network-related details for the allocated device. This information may be filled by drivers or other components to configure or identify the device within a network context. */ +export interface NetworkDeviceData { + hardwareAddress?: string | null; + interfaceName?: string | null; + ips?: Array | null; +} +export function toNetworkDeviceData(input: c.JSONValue): NetworkDeviceData { + const obj = c.checkObj(input); + return { + hardwareAddress: c.readOpt(obj["hardwareAddress"], c.checkStr), + interfaceName: c.readOpt(obj["interfaceName"], c.checkStr), + ips: c.readOpt(obj["ips"], x => c.readList(x, c.checkStr)), + }} +export function fromNetworkDeviceData(input: NetworkDeviceData): c.JSONValue { + return { + ...input, + }} + +/** AllocationResult contains attributes of an allocated resource. */ +export interface AllocationResult { + allocationTimestamp?: c.Time | null; + devices?: DeviceAllocationResult | null; + nodeSelector?: CoreV1.NodeSelector | null; +} +export function toAllocationResult(input: c.JSONValue): AllocationResult { + const obj = c.checkObj(input); + return { + allocationTimestamp: c.readOpt(obj["allocationTimestamp"], c.toTime), + devices: c.readOpt(obj["devices"], toDeviceAllocationResult), + nodeSelector: c.readOpt(obj["nodeSelector"], CoreV1.toNodeSelector), + }} +export function fromAllocationResult(input: AllocationResult): c.JSONValue { + return { + ...input, + allocationTimestamp: input.allocationTimestamp != null ? c.fromTime(input.allocationTimestamp) : undefined, + devices: input.devices != null ? fromDeviceAllocationResult(input.devices) : undefined, + nodeSelector: input.nodeSelector != null ? CoreV1.fromNodeSelector(input.nodeSelector) : undefined, + }} + +/** DeviceAllocationResult is the result of allocating devices. */ +export interface DeviceAllocationResult { + config?: Array | null; + results?: Array | null; +} +export function toDeviceAllocationResult(input: c.JSONValue): DeviceAllocationResult { + const obj = c.checkObj(input); + return { + config: c.readOpt(obj["config"], x => c.readList(x, toDeviceAllocationConfiguration)), + results: c.readOpt(obj["results"], x => c.readList(x, toDeviceRequestAllocationResult)), + }} +export function fromDeviceAllocationResult(input: DeviceAllocationResult): c.JSONValue { + return { + ...input, + config: input.config?.map(fromDeviceAllocationConfiguration), + results: input.results?.map(fromDeviceRequestAllocationResult), + }} + +/** DeviceAllocationConfiguration gets embedded in an AllocationResult. */ +export interface DeviceAllocationConfiguration { + opaque?: OpaqueDeviceConfiguration | null; + requests?: Array | null; + source: string; +} +export function toDeviceAllocationConfiguration(input: c.JSONValue): DeviceAllocationConfiguration { + const obj = c.checkObj(input); + return { + opaque: c.readOpt(obj["opaque"], toOpaqueDeviceConfiguration), + requests: c.readOpt(obj["requests"], x => c.readList(x, c.checkStr)), + source: c.checkStr(obj["source"]), + }} +export function fromDeviceAllocationConfiguration(input: DeviceAllocationConfiguration): c.JSONValue { + return { + ...input, + opaque: input.opaque != null ? fromOpaqueDeviceConfiguration(input.opaque) : undefined, + }} + +/** OpaqueDeviceConfiguration contains configuration parameters for a driver in a format defined by the driver vendor. */ +export interface OpaqueDeviceConfiguration { + driver: string; + parameters: c.JSONValue; +} +export function toOpaqueDeviceConfiguration(input: c.JSONValue): OpaqueDeviceConfiguration { + const obj = c.checkObj(input); + return { + driver: c.checkStr(obj["driver"]), + parameters: c.identity(obj["parameters"]), + }} +export function fromOpaqueDeviceConfiguration(input: OpaqueDeviceConfiguration): c.JSONValue { + return { + ...input, + }} + +/** DeviceRequestAllocationResult contains the allocation result for one request. */ +export interface DeviceRequestAllocationResult { + adminAccess?: boolean | null; + bindingConditions?: Array | null; + bindingFailureConditions?: Array | null; + consumedCapacity?: Record | null; + device: string; + driver: string; + pool: string; + request: string; + shareID?: string | null; + tolerations?: Array | null; +} +export function toDeviceRequestAllocationResult(input: c.JSONValue): DeviceRequestAllocationResult { + const obj = c.checkObj(input); + return { + adminAccess: c.readOpt(obj["adminAccess"], c.checkBool), + bindingConditions: c.readOpt(obj["bindingConditions"], x => c.readList(x, c.checkStr)), + bindingFailureConditions: c.readOpt(obj["bindingFailureConditions"], x => c.readList(x, c.checkStr)), + consumedCapacity: c.readOpt(obj["consumedCapacity"], x => c.readMap(x, c.toQuantity)), + device: c.checkStr(obj["device"]), + driver: c.checkStr(obj["driver"]), + pool: c.checkStr(obj["pool"]), + request: c.checkStr(obj["request"]), + shareID: c.readOpt(obj["shareID"], c.checkStr), + tolerations: c.readOpt(obj["tolerations"], x => c.readList(x, toDeviceToleration)), + }} +export function fromDeviceRequestAllocationResult(input: DeviceRequestAllocationResult): c.JSONValue { + return { + ...input, + consumedCapacity: c.writeMap(input.consumedCapacity, c.fromQuantity), + tolerations: input.tolerations?.map(fromDeviceToleration), + }} + +/** The ResourceClaim this DeviceToleration is attached to tolerates any taint that matches the triple using the matching operator . */ +export interface DeviceToleration { + effect?: string | null; + key?: string | null; + operator?: string | null; + tolerationSeconds?: number | null; + value?: string | null; +} +export function toDeviceToleration(input: c.JSONValue): DeviceToleration { + const obj = c.checkObj(input); + return { + effect: c.readOpt(obj["effect"], c.checkStr), + key: c.readOpt(obj["key"], c.checkStr), + operator: c.readOpt(obj["operator"], c.checkStr), + tolerationSeconds: c.readOpt(obj["tolerationSeconds"], c.checkNum), + value: c.readOpt(obj["value"], c.checkStr), + }} +export function fromDeviceToleration(input: DeviceToleration): c.JSONValue { + return { + ...input, + }} + +/** CELDeviceSelector contains a CEL expression for selecting a device. */ +export interface CELDeviceSelector { + expression: string; +} +export function toCELDeviceSelector(input: c.JSONValue): CELDeviceSelector { + const obj = c.checkObj(input); + return { + expression: c.checkStr(obj["expression"]), + }} +export function fromCELDeviceSelector(input: CELDeviceSelector): c.JSONValue { + return { + ...input, + }} + +/** CapacityRequestPolicy defines how requests consume device capacity. + +Must not set more than one ValidRequestValues. */ +export interface CapacityRequestPolicy { + default?: c.Quantity | null; + validRange?: CapacityRequestPolicyRange | null; + validValues?: Array | null; +} +export function toCapacityRequestPolicy(input: c.JSONValue): CapacityRequestPolicy { + const obj = c.checkObj(input); + return { + default: c.readOpt(obj["default"], c.toQuantity), + validRange: c.readOpt(obj["validRange"], toCapacityRequestPolicyRange), + validValues: c.readOpt(obj["validValues"], x => c.readList(x, c.toQuantity)), + }} +export function fromCapacityRequestPolicy(input: CapacityRequestPolicy): c.JSONValue { + return { + ...input, + default: input.default != null ? c.fromQuantity(input.default) : undefined, + validRange: input.validRange != null ? fromCapacityRequestPolicyRange(input.validRange) : undefined, + validValues: input.validValues?.map(c.fromQuantity), + }} + +/** CapacityRequestPolicyRange defines a valid range for consumable capacity values. + + - If the requested amount is less than Min, it is rounded up to the Min value. + - If Step is set and the requested amount is between Min and Max but not aligned with Step, + it will be rounded up to the next value equal to Min + (n * Step). + - If Step is not set, the requested amount is used as-is if it falls within the range Min to Max (if set). + - If the requested or rounded amount exceeds Max (if set), the request does not satisfy the policy, + and the device cannot be allocated. */ +export interface CapacityRequestPolicyRange { + max?: c.Quantity | null; + min: c.Quantity; + step?: c.Quantity | null; +} +export function toCapacityRequestPolicyRange(input: c.JSONValue): CapacityRequestPolicyRange { + const obj = c.checkObj(input); + return { + max: c.readOpt(obj["max"], c.toQuantity), + min: c.toQuantity(obj["min"]), + step: c.readOpt(obj["step"], c.toQuantity), + }} +export function fromCapacityRequestPolicyRange(input: CapacityRequestPolicyRange): c.JSONValue { + return { + ...input, + max: input.max != null ? c.fromQuantity(input.max) : undefined, + min: input.min != null ? c.fromQuantity(input.min) : undefined, + step: input.step != null ? c.fromQuantity(input.step) : undefined, + }} + +/** CapacityRequirements defines the capacity requirements for a specific device request. */ +export interface CapacityRequirements { + requests?: Record | null; +} +export function toCapacityRequirements(input: c.JSONValue): CapacityRequirements { + const obj = c.checkObj(input); + return { + requests: c.readOpt(obj["requests"], x => c.readMap(x, c.toQuantity)), + }} +export function fromCapacityRequirements(input: CapacityRequirements): c.JSONValue { + return { + ...input, + requests: c.writeMap(input.requests, c.fromQuantity), + }} + +/** Counter describes a quantity associated with a device. */ +export interface Counter { + value: c.Quantity; +} +export function toCounter(input: c.JSONValue): Counter { + const obj = c.checkObj(input); + return { + value: c.toQuantity(obj["value"]), + }} +export function fromCounter(input: Counter): c.JSONValue { + return { + ...input, + value: input.value != null ? c.fromQuantity(input.value) : undefined, + }} + +/** CounterSet defines a named set of counters that are available to be used by devices defined in the ResourceSlice. + +The counters are not allocatable by themselves, but can be referenced by devices. When a device is allocated, the portion of counters it uses will no longer be available for use by other devices. */ +export interface CounterSet { + counters: Record; + name: string; +} +export function toCounterSet(input: c.JSONValue): CounterSet { + const obj = c.checkObj(input); + return { + counters: c.readMap(obj["counters"], toCounter), + name: c.checkStr(obj["name"]), + }} +export function fromCounterSet(input: CounterSet): c.JSONValue { + return { + ...input, + counters: c.writeMap(input.counters, fromCounter), + }} + +/** Device represents one individual hardware instance that can be selected based on its attributes. Besides the name, exactly one field must be set. */ +export interface Device { + allNodes?: boolean | null; + allowMultipleAllocations?: boolean | null; + attributes?: Record | null; + bindingConditions?: Array | null; + bindingFailureConditions?: Array | null; + bindsToNode?: boolean | null; + capacity?: Record | null; + consumesCounters?: Array | null; + name: string; + nodeName?: string | null; + nodeSelector?: CoreV1.NodeSelector | null; + taints?: Array | null; +} +export function toDevice(input: c.JSONValue): Device { + const obj = c.checkObj(input); + return { + allNodes: c.readOpt(obj["allNodes"], c.checkBool), + allowMultipleAllocations: c.readOpt(obj["allowMultipleAllocations"], c.checkBool), + attributes: c.readOpt(obj["attributes"], x => c.readMap(x, toDeviceAttribute)), + bindingConditions: c.readOpt(obj["bindingConditions"], x => c.readList(x, c.checkStr)), + bindingFailureConditions: c.readOpt(obj["bindingFailureConditions"], x => c.readList(x, c.checkStr)), + bindsToNode: c.readOpt(obj["bindsToNode"], c.checkBool), + capacity: c.readOpt(obj["capacity"], x => c.readMap(x, toDeviceCapacity)), + consumesCounters: c.readOpt(obj["consumesCounters"], x => c.readList(x, toDeviceCounterConsumption)), + name: c.checkStr(obj["name"]), + nodeName: c.readOpt(obj["nodeName"], c.checkStr), + nodeSelector: c.readOpt(obj["nodeSelector"], CoreV1.toNodeSelector), + taints: c.readOpt(obj["taints"], x => c.readList(x, toDeviceTaint)), + }} +export function fromDevice(input: Device): c.JSONValue { + return { + ...input, + attributes: c.writeMap(input.attributes, fromDeviceAttribute), + capacity: c.writeMap(input.capacity, fromDeviceCapacity), + consumesCounters: input.consumesCounters?.map(fromDeviceCounterConsumption), + nodeSelector: input.nodeSelector != null ? CoreV1.fromNodeSelector(input.nodeSelector) : undefined, + taints: input.taints?.map(fromDeviceTaint), + }} + +/** DeviceAttribute must have exactly one field set. */ +export interface DeviceAttribute { + bool?: boolean | null; + int?: number | null; + string?: string | null; + version?: string | null; +} +export function toDeviceAttribute(input: c.JSONValue): DeviceAttribute { + const obj = c.checkObj(input); + return { + bool: c.readOpt(obj["bool"], c.checkBool), + int: c.readOpt(obj["int"], c.checkNum), + string: c.readOpt(obj["string"], c.checkStr), + version: c.readOpt(obj["version"], c.checkStr), + }} +export function fromDeviceAttribute(input: DeviceAttribute): c.JSONValue { + return { + ...input, + }} + +/** DeviceCapacity describes a quantity associated with a device. */ +export interface DeviceCapacity { + requestPolicy?: CapacityRequestPolicy | null; + value: c.Quantity; +} +export function toDeviceCapacity(input: c.JSONValue): DeviceCapacity { + const obj = c.checkObj(input); + return { + requestPolicy: c.readOpt(obj["requestPolicy"], toCapacityRequestPolicy), + value: c.toQuantity(obj["value"]), + }} +export function fromDeviceCapacity(input: DeviceCapacity): c.JSONValue { + return { + ...input, + requestPolicy: input.requestPolicy != null ? fromCapacityRequestPolicy(input.requestPolicy) : undefined, + value: input.value != null ? c.fromQuantity(input.value) : undefined, + }} + +/** DeviceCounterConsumption defines a set of counters that a device will consume from a CounterSet. */ +export interface DeviceCounterConsumption { + counterSet: string; + counters: Record; +} +export function toDeviceCounterConsumption(input: c.JSONValue): DeviceCounterConsumption { + const obj = c.checkObj(input); + return { + counterSet: c.checkStr(obj["counterSet"]), + counters: c.readMap(obj["counters"], toCounter), + }} +export function fromDeviceCounterConsumption(input: DeviceCounterConsumption): c.JSONValue { + return { + ...input, + counters: c.writeMap(input.counters, fromCounter), + }} + +/** The device this taint is attached to has the "effect" on any claim which does not tolerate the taint and, through the claim, to pods using the claim. */ +export interface DeviceTaint { + effect: string; + key: string; + timeAdded?: c.Time | null; + value?: string | null; +} +export function toDeviceTaint(input: c.JSONValue): DeviceTaint { + const obj = c.checkObj(input); + return { + effect: c.checkStr(obj["effect"]), + key: c.checkStr(obj["key"]), + timeAdded: c.readOpt(obj["timeAdded"], c.toTime), + value: c.readOpt(obj["value"], c.checkStr), + }} +export function fromDeviceTaint(input: DeviceTaint): c.JSONValue { + return { + ...input, + timeAdded: input.timeAdded != null ? c.fromTime(input.timeAdded) : undefined, + }} + +/** DeviceClaim defines how to request devices with a ResourceClaim. */ +export interface DeviceClaim { + config?: Array | null; + constraints?: Array | null; + requests?: Array | null; +} +export function toDeviceClaim(input: c.JSONValue): DeviceClaim { + const obj = c.checkObj(input); + return { + config: c.readOpt(obj["config"], x => c.readList(x, toDeviceClaimConfiguration)), + constraints: c.readOpt(obj["constraints"], x => c.readList(x, toDeviceConstraint)), + requests: c.readOpt(obj["requests"], x => c.readList(x, toDeviceRequest)), + }} +export function fromDeviceClaim(input: DeviceClaim): c.JSONValue { + return { + ...input, + config: input.config?.map(fromDeviceClaimConfiguration), + constraints: input.constraints?.map(fromDeviceConstraint), + requests: input.requests?.map(fromDeviceRequest), + }} + +/** DeviceClaimConfiguration is used for configuration parameters in DeviceClaim. */ +export interface DeviceClaimConfiguration { + opaque?: OpaqueDeviceConfiguration | null; + requests?: Array | null; +} +export function toDeviceClaimConfiguration(input: c.JSONValue): DeviceClaimConfiguration { + const obj = c.checkObj(input); + return { + opaque: c.readOpt(obj["opaque"], toOpaqueDeviceConfiguration), + requests: c.readOpt(obj["requests"], x => c.readList(x, c.checkStr)), + }} +export function fromDeviceClaimConfiguration(input: DeviceClaimConfiguration): c.JSONValue { + return { + ...input, + opaque: input.opaque != null ? fromOpaqueDeviceConfiguration(input.opaque) : undefined, + }} + +/** DeviceConstraint must have exactly one field set besides Requests. */ +export interface DeviceConstraint { + distinctAttribute?: string | null; + matchAttribute?: string | null; + requests?: Array | null; +} +export function toDeviceConstraint(input: c.JSONValue): DeviceConstraint { + const obj = c.checkObj(input); + return { + distinctAttribute: c.readOpt(obj["distinctAttribute"], c.checkStr), + matchAttribute: c.readOpt(obj["matchAttribute"], c.checkStr), + requests: c.readOpt(obj["requests"], x => c.readList(x, c.checkStr)), + }} +export function fromDeviceConstraint(input: DeviceConstraint): c.JSONValue { + return { + ...input, + }} + +/** DeviceRequest is a request for devices required for a claim. This is typically a request for a single resource like a device, but can also ask for several identical devices. With FirstAvailable it is also possible to provide a prioritized list of requests. */ +export interface DeviceRequest { + exactly?: ExactDeviceRequest | null; + firstAvailable?: Array | null; + name: string; +} +export function toDeviceRequest(input: c.JSONValue): DeviceRequest { + const obj = c.checkObj(input); + return { + exactly: c.readOpt(obj["exactly"], toExactDeviceRequest), + firstAvailable: c.readOpt(obj["firstAvailable"], x => c.readList(x, toDeviceSubRequest)), + name: c.checkStr(obj["name"]), + }} +export function fromDeviceRequest(input: DeviceRequest): c.JSONValue { + return { + ...input, + exactly: input.exactly != null ? fromExactDeviceRequest(input.exactly) : undefined, + firstAvailable: input.firstAvailable?.map(fromDeviceSubRequest), + }} + +/** ExactDeviceRequest is a request for one or more identical devices. */ +export interface ExactDeviceRequest { + adminAccess?: boolean | null; + allocationMode?: string | null; + capacity?: CapacityRequirements | null; + count?: number | null; + deviceClassName: string; + selectors?: Array | null; + tolerations?: Array | null; +} +export function toExactDeviceRequest(input: c.JSONValue): ExactDeviceRequest { + const obj = c.checkObj(input); + return { + adminAccess: c.readOpt(obj["adminAccess"], c.checkBool), + allocationMode: c.readOpt(obj["allocationMode"], c.checkStr), + capacity: c.readOpt(obj["capacity"], toCapacityRequirements), + count: c.readOpt(obj["count"], c.checkNum), + deviceClassName: c.checkStr(obj["deviceClassName"]), + selectors: c.readOpt(obj["selectors"], x => c.readList(x, toDeviceSelector)), + tolerations: c.readOpt(obj["tolerations"], x => c.readList(x, toDeviceToleration)), + }} +export function fromExactDeviceRequest(input: ExactDeviceRequest): c.JSONValue { + return { + ...input, + capacity: input.capacity != null ? fromCapacityRequirements(input.capacity) : undefined, + selectors: input.selectors?.map(fromDeviceSelector), + tolerations: input.tolerations?.map(fromDeviceToleration), + }} + +/** DeviceSelector must have exactly one field set. */ +export interface DeviceSelector { + cel?: CELDeviceSelector | null; +} +export function toDeviceSelector(input: c.JSONValue): DeviceSelector { + const obj = c.checkObj(input); + return { + cel: c.readOpt(obj["cel"], toCELDeviceSelector), + }} +export function fromDeviceSelector(input: DeviceSelector): c.JSONValue { + return { + ...input, + cel: input.cel != null ? fromCELDeviceSelector(input.cel) : undefined, + }} + +/** DeviceSubRequest describes a request for device provided in the claim.spec.devices.requests[].firstAvailable array. Each is typically a request for a single resource like a device, but can also ask for several identical devices. + +DeviceSubRequest is similar to ExactDeviceRequest, but doesn't expose the AdminAccess field as that one is only supported when requesting a specific device. */ +export interface DeviceSubRequest { + allocationMode?: string | null; + capacity?: CapacityRequirements | null; + count?: number | null; + deviceClassName: string; + name: string; + selectors?: Array | null; + tolerations?: Array | null; +} +export function toDeviceSubRequest(input: c.JSONValue): DeviceSubRequest { + const obj = c.checkObj(input); + return { + allocationMode: c.readOpt(obj["allocationMode"], c.checkStr), + capacity: c.readOpt(obj["capacity"], toCapacityRequirements), + count: c.readOpt(obj["count"], c.checkNum), + deviceClassName: c.checkStr(obj["deviceClassName"]), + name: c.checkStr(obj["name"]), + selectors: c.readOpt(obj["selectors"], x => c.readList(x, toDeviceSelector)), + tolerations: c.readOpt(obj["tolerations"], x => c.readList(x, toDeviceToleration)), + }} +export function fromDeviceSubRequest(input: DeviceSubRequest): c.JSONValue { + return { + ...input, + capacity: input.capacity != null ? fromCapacityRequirements(input.capacity) : undefined, + selectors: input.selectors?.map(fromDeviceSelector), + tolerations: input.tolerations?.map(fromDeviceToleration), + }} + +/** DeviceClass is a vendor- or admin-provided resource that contains device configuration and selectors. It can be referenced in the device requests of a claim to apply these presets. Cluster scoped. + +This is an alpha type and requires enabling the DynamicResourceAllocation feature gate. */ +export interface DeviceClass { + apiVersion?: "resource.k8s.io/v1"; + kind?: "DeviceClass"; + metadata?: MetaV1.ObjectMeta | null; + spec: DeviceClassSpec; +} +export function toDeviceClass(input: c.JSONValue): DeviceClass & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1", "DeviceClass"), + metadata: c.readOpt(obj["metadata"], MetaV1.toObjectMeta), + spec: toDeviceClassSpec(obj["spec"]), + }} +export function fromDeviceClass(input: DeviceClass): c.JSONValue { + return { + ...c.assertOrAddApiVersionAndKind(input, "resource.k8s.io/v1", "DeviceClass"), + ...input, + metadata: input.metadata != null ? MetaV1.fromObjectMeta(input.metadata) : undefined, + spec: input.spec != null ? fromDeviceClassSpec(input.spec) : undefined, + }} + +/** DeviceClassSpec is used in a [DeviceClass] to define what can be allocated and how to configure it. */ +export interface DeviceClassSpec { + config?: Array | null; + extendedResourceName?: string | null; + selectors?: Array | null; +} +export function toDeviceClassSpec(input: c.JSONValue): DeviceClassSpec { + const obj = c.checkObj(input); + return { + config: c.readOpt(obj["config"], x => c.readList(x, toDeviceClassConfiguration)), + extendedResourceName: c.readOpt(obj["extendedResourceName"], c.checkStr), + selectors: c.readOpt(obj["selectors"], x => c.readList(x, toDeviceSelector)), + }} +export function fromDeviceClassSpec(input: DeviceClassSpec): c.JSONValue { + return { + ...input, + config: input.config?.map(fromDeviceClassConfiguration), + selectors: input.selectors?.map(fromDeviceSelector), + }} + +/** DeviceClassConfiguration is used in DeviceClass. */ +export interface DeviceClassConfiguration { + opaque?: OpaqueDeviceConfiguration | null; +} +export function toDeviceClassConfiguration(input: c.JSONValue): DeviceClassConfiguration { + const obj = c.checkObj(input); + return { + opaque: c.readOpt(obj["opaque"], toOpaqueDeviceConfiguration), + }} +export function fromDeviceClassConfiguration(input: DeviceClassConfiguration): c.JSONValue { + return { + ...input, + opaque: input.opaque != null ? fromOpaqueDeviceConfiguration(input.opaque) : undefined, + }} + +/** DeviceClassList is a collection of classes. */ +export interface DeviceClassList extends ListOf { + apiVersion?: "resource.k8s.io/v1"; + kind?: "DeviceClassList"; +}; +export function toDeviceClassList(input: c.JSONValue): DeviceClassList & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1", "DeviceClassList"), + metadata: MetaV1.toListMeta(obj.metadata), + items: c.readList(obj.items, toDeviceClass), + }} + +/** ResourceClaim describes a request for access to resources in the cluster, for use by workloads. For example, if a workload needs an accelerator device with specific properties, this is how that request is expressed. The status stanza tracks whether this claim has been satisfied and what specific resources have been allocated. + +This is an alpha type and requires enabling the DynamicResourceAllocation feature gate. */ +export interface ResourceClaim { + apiVersion?: "resource.k8s.io/v1"; + kind?: "ResourceClaim"; + metadata?: MetaV1.ObjectMeta | null; + spec: ResourceClaimSpec; + status?: ResourceClaimStatus | null; +} +export function toResourceClaim(input: c.JSONValue): ResourceClaim & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1", "ResourceClaim"), + metadata: c.readOpt(obj["metadata"], MetaV1.toObjectMeta), + spec: toResourceClaimSpec(obj["spec"]), + status: c.readOpt(obj["status"], toResourceClaimStatus), + }} +export function fromResourceClaim(input: ResourceClaim): c.JSONValue { + return { + ...c.assertOrAddApiVersionAndKind(input, "resource.k8s.io/v1", "ResourceClaim"), + ...input, + metadata: input.metadata != null ? MetaV1.fromObjectMeta(input.metadata) : undefined, + spec: input.spec != null ? fromResourceClaimSpec(input.spec) : undefined, + status: input.status != null ? fromResourceClaimStatus(input.status) : undefined, + }} + +/** ResourceClaimSpec defines what is being requested in a ResourceClaim and how to configure it. */ +export interface ResourceClaimSpec { + devices?: DeviceClaim | null; +} +export function toResourceClaimSpec(input: c.JSONValue): ResourceClaimSpec { + const obj = c.checkObj(input); + return { + devices: c.readOpt(obj["devices"], toDeviceClaim), + }} +export function fromResourceClaimSpec(input: ResourceClaimSpec): c.JSONValue { + return { + ...input, + devices: input.devices != null ? fromDeviceClaim(input.devices) : undefined, + }} + +/** ResourceClaimStatus tracks whether the resource has been allocated and what the result of that was. */ +export interface ResourceClaimStatus { + allocation?: AllocationResult | null; + devices?: Array | null; + reservedFor?: Array | null; +} +export function toResourceClaimStatus(input: c.JSONValue): ResourceClaimStatus { + const obj = c.checkObj(input); + return { + allocation: c.readOpt(obj["allocation"], toAllocationResult), + devices: c.readOpt(obj["devices"], x => c.readList(x, toAllocatedDeviceStatus)), + reservedFor: c.readOpt(obj["reservedFor"], x => c.readList(x, toResourceClaimConsumerReference)), + }} +export function fromResourceClaimStatus(input: ResourceClaimStatus): c.JSONValue { + return { + ...input, + allocation: input.allocation != null ? fromAllocationResult(input.allocation) : undefined, + devices: input.devices?.map(fromAllocatedDeviceStatus), + reservedFor: input.reservedFor?.map(fromResourceClaimConsumerReference), + }} + +/** ResourceClaimConsumerReference contains enough information to let you locate the consumer of a ResourceClaim. The user must be a resource in the same namespace as the ResourceClaim. */ +export interface ResourceClaimConsumerReference { + apiGroup?: string | null; + name: string; + resource: string; + uid: string; +} +export function toResourceClaimConsumerReference(input: c.JSONValue): ResourceClaimConsumerReference { + const obj = c.checkObj(input); + return { + apiGroup: c.readOpt(obj["apiGroup"], c.checkStr), + name: c.checkStr(obj["name"]), + resource: c.checkStr(obj["resource"]), + uid: c.checkStr(obj["uid"]), + }} +export function fromResourceClaimConsumerReference(input: ResourceClaimConsumerReference): c.JSONValue { + return { + ...input, + }} + +/** ResourceClaimList is a collection of claims. */ +export interface ResourceClaimList extends ListOf { + apiVersion?: "resource.k8s.io/v1"; + kind?: "ResourceClaimList"; +}; +export function toResourceClaimList(input: c.JSONValue): ResourceClaimList & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1", "ResourceClaimList"), + metadata: MetaV1.toListMeta(obj.metadata), + items: c.readList(obj.items, toResourceClaim), + }} + +/** ResourceClaimTemplate is used to produce ResourceClaim objects. + +This is an alpha type and requires enabling the DynamicResourceAllocation feature gate. */ +export interface ResourceClaimTemplate { + apiVersion?: "resource.k8s.io/v1"; + kind?: "ResourceClaimTemplate"; + metadata?: MetaV1.ObjectMeta | null; + spec: ResourceClaimTemplateSpec; +} +export function toResourceClaimTemplate(input: c.JSONValue): ResourceClaimTemplate & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1", "ResourceClaimTemplate"), + metadata: c.readOpt(obj["metadata"], MetaV1.toObjectMeta), + spec: toResourceClaimTemplateSpec(obj["spec"]), + }} +export function fromResourceClaimTemplate(input: ResourceClaimTemplate): c.JSONValue { + return { + ...c.assertOrAddApiVersionAndKind(input, "resource.k8s.io/v1", "ResourceClaimTemplate"), + ...input, + metadata: input.metadata != null ? MetaV1.fromObjectMeta(input.metadata) : undefined, + spec: input.spec != null ? fromResourceClaimTemplateSpec(input.spec) : undefined, + }} + +/** ResourceClaimTemplateSpec contains the metadata and fields for a ResourceClaim. */ +export interface ResourceClaimTemplateSpec { + metadata?: MetaV1.ObjectMeta | null; + spec: ResourceClaimSpec; +} +export function toResourceClaimTemplateSpec(input: c.JSONValue): ResourceClaimTemplateSpec { + const obj = c.checkObj(input); + return { + metadata: c.readOpt(obj["metadata"], MetaV1.toObjectMeta), + spec: toResourceClaimSpec(obj["spec"]), + }} +export function fromResourceClaimTemplateSpec(input: ResourceClaimTemplateSpec): c.JSONValue { + return { + ...input, + metadata: input.metadata != null ? MetaV1.fromObjectMeta(input.metadata) : undefined, + spec: input.spec != null ? fromResourceClaimSpec(input.spec) : undefined, + }} + +/** ResourceClaimTemplateList is a collection of claim templates. */ +export interface ResourceClaimTemplateList extends ListOf { + apiVersion?: "resource.k8s.io/v1"; + kind?: "ResourceClaimTemplateList"; +}; +export function toResourceClaimTemplateList(input: c.JSONValue): ResourceClaimTemplateList & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1", "ResourceClaimTemplateList"), + metadata: MetaV1.toListMeta(obj.metadata), + items: c.readList(obj.items, toResourceClaimTemplate), + }} + +/** ResourcePool describes the pool that ResourceSlices belong to. */ +export interface ResourcePool { + generation: number; + name: string; + resourceSliceCount: number; +} +export function toResourcePool(input: c.JSONValue): ResourcePool { + const obj = c.checkObj(input); + return { + generation: c.checkNum(obj["generation"]), + name: c.checkStr(obj["name"]), + resourceSliceCount: c.checkNum(obj["resourceSliceCount"]), + }} +export function fromResourcePool(input: ResourcePool): c.JSONValue { + return { + ...input, + }} + +/** ResourceSlice represents one or more resources in a pool of similar resources, managed by a common driver. A pool may span more than one ResourceSlice, and exactly how many ResourceSlices comprise a pool is determined by the driver. + +At the moment, the only supported resources are devices with attributes and capacities. Each device in a given pool, regardless of how many ResourceSlices, must have a unique name. The ResourceSlice in which a device gets published may change over time. The unique identifier for a device is the tuple , , . + +Whenever a driver needs to update a pool, it increments the pool.Spec.Pool.Generation number and updates all ResourceSlices with that new number and new resource definitions. A consumer must only use ResourceSlices with the highest generation number and ignore all others. + +When allocating all resources in a pool matching certain criteria or when looking for the best solution among several different alternatives, a consumer should check the number of ResourceSlices in a pool (included in each ResourceSlice) to determine whether its view of a pool is complete and if not, should wait until the driver has completed updating the pool. + +For resources that are not local to a node, the node name is not set. Instead, the driver may use a node selector to specify where the devices are available. + +This is an alpha type and requires enabling the DynamicResourceAllocation feature gate. */ +export interface ResourceSlice { + apiVersion?: "resource.k8s.io/v1"; + kind?: "ResourceSlice"; + metadata?: MetaV1.ObjectMeta | null; + spec: ResourceSliceSpec; +} +export function toResourceSlice(input: c.JSONValue): ResourceSlice & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1", "ResourceSlice"), + metadata: c.readOpt(obj["metadata"], MetaV1.toObjectMeta), + spec: toResourceSliceSpec(obj["spec"]), + }} +export function fromResourceSlice(input: ResourceSlice): c.JSONValue { + return { + ...c.assertOrAddApiVersionAndKind(input, "resource.k8s.io/v1", "ResourceSlice"), + ...input, + metadata: input.metadata != null ? MetaV1.fromObjectMeta(input.metadata) : undefined, + spec: input.spec != null ? fromResourceSliceSpec(input.spec) : undefined, + }} + +/** ResourceSliceSpec contains the information published by the driver in one ResourceSlice. */ +export interface ResourceSliceSpec { + allNodes?: boolean | null; + devices?: Array | null; + driver: string; + nodeName?: string | null; + nodeSelector?: CoreV1.NodeSelector | null; + perDeviceNodeSelection?: boolean | null; + pool: ResourcePool; + sharedCounters?: Array | null; +} +export function toResourceSliceSpec(input: c.JSONValue): ResourceSliceSpec { + const obj = c.checkObj(input); + return { + allNodes: c.readOpt(obj["allNodes"], c.checkBool), + devices: c.readOpt(obj["devices"], x => c.readList(x, toDevice)), + driver: c.checkStr(obj["driver"]), + nodeName: c.readOpt(obj["nodeName"], c.checkStr), + nodeSelector: c.readOpt(obj["nodeSelector"], CoreV1.toNodeSelector), + perDeviceNodeSelection: c.readOpt(obj["perDeviceNodeSelection"], c.checkBool), + pool: toResourcePool(obj["pool"]), + sharedCounters: c.readOpt(obj["sharedCounters"], x => c.readList(x, toCounterSet)), + }} +export function fromResourceSliceSpec(input: ResourceSliceSpec): c.JSONValue { + return { + ...input, + devices: input.devices?.map(fromDevice), + nodeSelector: input.nodeSelector != null ? CoreV1.fromNodeSelector(input.nodeSelector) : undefined, + pool: input.pool != null ? fromResourcePool(input.pool) : undefined, + sharedCounters: input.sharedCounters?.map(fromCounterSet), + }} + +/** ResourceSliceList is a collection of ResourceSlices. */ +export interface ResourceSliceList extends ListOf { + apiVersion?: "resource.k8s.io/v1"; + kind?: "ResourceSliceList"; +}; +export function toResourceSliceList(input: c.JSONValue): ResourceSliceList & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1", "ResourceSliceList"), + metadata: MetaV1.toListMeta(obj.metadata), + items: c.readList(obj.items, toResourceSlice), + }} diff --git a/lib/builtin/resource.k8s.io@v1alpha3/mod.ts b/lib/builtin/resource.k8s.io@v1alpha3/mod.ts index 1149dd8..9a8878b 100644 --- a/lib/builtin/resource.k8s.io@v1alpha3/mod.ts +++ b/lib/builtin/resource.k8s.io@v1alpha3/mod.ts @@ -13,591 +13,121 @@ export class ResourceV1alpha3Api { this.#client = client; } - namespace(name: string): ResourceV1alpha3NamespacedApi { - return new ResourceV1alpha3NamespacedApi(this.#client, name); - } - myNamespace(): ResourceV1alpha3NamespacedApi { - if (!this.#client.defaultNamespace) throw new Error("No current namespace is set"); - return new ResourceV1alpha3NamespacedApi(this.#client, this.#client.defaultNamespace); - } - - async getDeviceClassList( - opts: operations.GetListOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "GET", - path: `${this.#root}deviceclasses`, - expectJson: true, - querystring: operations.formatGetListOpts(opts), - abortSignal: opts.abortSignal, - }); - return ResourceV1alpha3.toDeviceClassList(resp); - } - - async watchDeviceClassList( - opts: operations.WatchListOpts = {}, - ): Promise> { - const resp = await this.#client.performRequest({ - method: "GET", - path: `${this.#root}deviceclasses`, - expectJson: true, - expectStream: true, - querystring: operations.formatWatchListOpts(opts), - abortSignal: opts.abortSignal, - }); - return resp.pipeThrough(new c.WatchEventTransformer(ResourceV1alpha3.toDeviceClass, MetaV1.toStatus)); - } - - async createDeviceClass( - body: ResourceV1alpha3.DeviceClass, - opts: operations.PutOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "POST", - path: `${this.#root}deviceclasses`, - expectJson: true, - querystring: operations.formatPutOpts(opts), - bodyJson: ResourceV1alpha3.fromDeviceClass(body), - abortSignal: opts.abortSignal, - }); - return ResourceV1alpha3.toDeviceClass(resp); - } - - async deleteDeviceClassList( - opts: operations.DeleteListOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "DELETE", - path: `${this.#root}deviceclasses`, - expectJson: true, - querystring: operations.formatDeleteListOpts(opts), - abortSignal: opts.abortSignal, - }); - return ResourceV1alpha3.toDeviceClassList(resp); - } - - async getDeviceClass( - name: string, - opts: operations.NoOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "GET", - path: `${this.#root}deviceclasses/${name}`, - expectJson: true, - abortSignal: opts.abortSignal, - }); - return ResourceV1alpha3.toDeviceClass(resp); - } - - async deleteDeviceClass( - name: string, - opts: operations.DeleteOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "DELETE", - path: `${this.#root}deviceclasses/${name}`, - expectJson: true, - querystring: operations.formatDeleteOpts(opts), - abortSignal: opts.abortSignal, - }); - if (c.isStatusKind(resp)) return MetaV1.toStatus(resp); - return ResourceV1alpha3.toDeviceClass(resp); - } - - async replaceDeviceClass( - name: string, - body: ResourceV1alpha3.DeviceClass, - opts: operations.PutOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "PUT", - path: `${this.#root}deviceclasses/${name}`, - expectJson: true, - querystring: operations.formatPutOpts(opts), - bodyJson: ResourceV1alpha3.fromDeviceClass(body), - abortSignal: opts.abortSignal, - }); - return ResourceV1alpha3.toDeviceClass(resp); - } - - async patchDeviceClass( - name: string, - type: c.PatchType, - body: ResourceV1alpha3.DeviceClass | c.JsonPatch, - opts: operations.PatchOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "PATCH", - path: `${this.#root}deviceclasses/${name}`, - expectJson: true, - querystring: operations.formatPatchOpts(opts), - contentType: c.getPatchContentType(type), - bodyJson: Array.isArray(body) ? body : ResourceV1alpha3.fromDeviceClass(body), - abortSignal: opts.abortSignal, - }); - return ResourceV1alpha3.toDeviceClass(resp); - } - - async getResourceClaimListForAllNamespaces( - opts: operations.GetListOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "GET", - path: `${this.#root}resourceclaims`, - expectJson: true, - querystring: operations.formatGetListOpts(opts), - abortSignal: opts.abortSignal, - }); - return ResourceV1alpha3.toResourceClaimList(resp); - } - - async watchResourceClaimListForAllNamespaces( - opts: operations.WatchListOpts = {}, - ): Promise> { - const resp = await this.#client.performRequest({ - method: "GET", - path: `${this.#root}resourceclaims`, - expectJson: true, - expectStream: true, - querystring: operations.formatWatchListOpts(opts), - abortSignal: opts.abortSignal, - }); - return resp.pipeThrough(new c.WatchEventTransformer(ResourceV1alpha3.toResourceClaim, MetaV1.toStatus)); - } - - async getResourceClaimTemplateListForAllNamespaces( - opts: operations.GetListOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "GET", - path: `${this.#root}resourceclaimtemplates`, - expectJson: true, - querystring: operations.formatGetListOpts(opts), - abortSignal: opts.abortSignal, - }); - return ResourceV1alpha3.toResourceClaimTemplateList(resp); - } - - async watchResourceClaimTemplateListForAllNamespaces( - opts: operations.WatchListOpts = {}, - ): Promise> { - const resp = await this.#client.performRequest({ - method: "GET", - path: `${this.#root}resourceclaimtemplates`, - expectJson: true, - expectStream: true, - querystring: operations.formatWatchListOpts(opts), - abortSignal: opts.abortSignal, - }); - return resp.pipeThrough(new c.WatchEventTransformer(ResourceV1alpha3.toResourceClaimTemplate, MetaV1.toStatus)); - } - - async getResourceSliceList( - opts: operations.GetListOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "GET", - path: `${this.#root}resourceslices`, - expectJson: true, - querystring: operations.formatGetListOpts(opts), - abortSignal: opts.abortSignal, - }); - return ResourceV1alpha3.toResourceSliceList(resp); - } - - async watchResourceSliceList( - opts: operations.WatchListOpts = {}, - ): Promise> { - const resp = await this.#client.performRequest({ - method: "GET", - path: `${this.#root}resourceslices`, - expectJson: true, - expectStream: true, - querystring: operations.formatWatchListOpts(opts), - abortSignal: opts.abortSignal, - }); - return resp.pipeThrough(new c.WatchEventTransformer(ResourceV1alpha3.toResourceSlice, MetaV1.toStatus)); - } - - async createResourceSlice( - body: ResourceV1alpha3.ResourceSlice, - opts: operations.PutOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "POST", - path: `${this.#root}resourceslices`, - expectJson: true, - querystring: operations.formatPutOpts(opts), - bodyJson: ResourceV1alpha3.fromResourceSlice(body), - abortSignal: opts.abortSignal, - }); - return ResourceV1alpha3.toResourceSlice(resp); - } - - async deleteResourceSliceList( - opts: operations.DeleteListOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "DELETE", - path: `${this.#root}resourceslices`, - expectJson: true, - querystring: operations.formatDeleteListOpts(opts), - abortSignal: opts.abortSignal, - }); - return ResourceV1alpha3.toResourceSliceList(resp); - } - - async getResourceSlice( - name: string, - opts: operations.NoOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "GET", - path: `${this.#root}resourceslices/${name}`, - expectJson: true, - abortSignal: opts.abortSignal, - }); - return ResourceV1alpha3.toResourceSlice(resp); - } - - async deleteResourceSlice( - name: string, - opts: operations.DeleteOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "DELETE", - path: `${this.#root}resourceslices/${name}`, - expectJson: true, - querystring: operations.formatDeleteOpts(opts), - abortSignal: opts.abortSignal, - }); - if (c.isStatusKind(resp)) return MetaV1.toStatus(resp); - return ResourceV1alpha3.toResourceSlice(resp); - } - - async replaceResourceSlice( - name: string, - body: ResourceV1alpha3.ResourceSlice, - opts: operations.PutOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "PUT", - path: `${this.#root}resourceslices/${name}`, - expectJson: true, - querystring: operations.formatPutOpts(opts), - bodyJson: ResourceV1alpha3.fromResourceSlice(body), - abortSignal: opts.abortSignal, - }); - return ResourceV1alpha3.toResourceSlice(resp); - } - - async patchResourceSlice( - name: string, - type: c.PatchType, - body: ResourceV1alpha3.ResourceSlice | c.JsonPatch, - opts: operations.PatchOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "PATCH", - path: `${this.#root}resourceslices/${name}`, - expectJson: true, - querystring: operations.formatPatchOpts(opts), - contentType: c.getPatchContentType(type), - bodyJson: Array.isArray(body) ? body : ResourceV1alpha3.fromResourceSlice(body), - abortSignal: opts.abortSignal, - }); - return ResourceV1alpha3.toResourceSlice(resp); - } - -} - -export class ResourceV1alpha3NamespacedApi { - #client: c.RestClient - #root: string - constructor(client: c.RestClient, namespace: string) { - this.#client = client; - this.#root = `/apis/resource.k8s.io/v1alpha3/namespaces/${namespace}/`; - } - - async getResourceClaimList( - opts: operations.GetListOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "GET", - path: `${this.#root}resourceclaims`, - expectJson: true, - querystring: operations.formatGetListOpts(opts), - abortSignal: opts.abortSignal, - }); - return ResourceV1alpha3.toResourceClaimList(resp); - } - - async watchResourceClaimList( - opts: operations.WatchListOpts = {}, - ): Promise> { - const resp = await this.#client.performRequest({ - method: "GET", - path: `${this.#root}resourceclaims`, - expectJson: true, - expectStream: true, - querystring: operations.formatWatchListOpts(opts), - abortSignal: opts.abortSignal, - }); - return resp.pipeThrough(new c.WatchEventTransformer(ResourceV1alpha3.toResourceClaim, MetaV1.toStatus)); - } - - async createResourceClaim( - body: ResourceV1alpha3.ResourceClaim, - opts: operations.PutOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "POST", - path: `${this.#root}resourceclaims`, - expectJson: true, - querystring: operations.formatPutOpts(opts), - bodyJson: ResourceV1alpha3.fromResourceClaim(body), - abortSignal: opts.abortSignal, - }); - return ResourceV1alpha3.toResourceClaim(resp); - } - - async deleteResourceClaimList( - opts: operations.DeleteListOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "DELETE", - path: `${this.#root}resourceclaims`, - expectJson: true, - querystring: operations.formatDeleteListOpts(opts), - abortSignal: opts.abortSignal, - }); - return ResourceV1alpha3.toResourceClaimList(resp); - } - - async getResourceClaim( - name: string, - opts: operations.NoOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "GET", - path: `${this.#root}resourceclaims/${name}`, - expectJson: true, - abortSignal: opts.abortSignal, - }); - return ResourceV1alpha3.toResourceClaim(resp); - } - - async deleteResourceClaim( - name: string, - opts: operations.DeleteOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "DELETE", - path: `${this.#root}resourceclaims/${name}`, - expectJson: true, - querystring: operations.formatDeleteOpts(opts), - abortSignal: opts.abortSignal, - }); - if (c.isStatusKind(resp)) return MetaV1.toStatus(resp); - return ResourceV1alpha3.toResourceClaim(resp); - } - - async replaceResourceClaim( - name: string, - body: ResourceV1alpha3.ResourceClaim, - opts: operations.PutOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "PUT", - path: `${this.#root}resourceclaims/${name}`, - expectJson: true, - querystring: operations.formatPutOpts(opts), - bodyJson: ResourceV1alpha3.fromResourceClaim(body), - abortSignal: opts.abortSignal, - }); - return ResourceV1alpha3.toResourceClaim(resp); - } - - async patchResourceClaim( - name: string, - type: c.PatchType, - body: ResourceV1alpha3.ResourceClaim | c.JsonPatch, - opts: operations.PatchOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "PATCH", - path: `${this.#root}resourceclaims/${name}`, - expectJson: true, - querystring: operations.formatPatchOpts(opts), - contentType: c.getPatchContentType(type), - bodyJson: Array.isArray(body) ? body : ResourceV1alpha3.fromResourceClaim(body), - abortSignal: opts.abortSignal, - }); - return ResourceV1alpha3.toResourceClaim(resp); - } - - async getResourceClaimStatus( - name: string, - opts: operations.NoOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "GET", - path: `${this.#root}resourceclaims/${name}/status`, - expectJson: true, - abortSignal: opts.abortSignal, - }); - return ResourceV1alpha3.toResourceClaim(resp); - } - - async replaceResourceClaimStatus( - name: string, - body: ResourceV1alpha3.ResourceClaim, - opts: operations.PutOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "PUT", - path: `${this.#root}resourceclaims/${name}/status`, - expectJson: true, - querystring: operations.formatPutOpts(opts), - bodyJson: ResourceV1alpha3.fromResourceClaim(body), - abortSignal: opts.abortSignal, - }); - return ResourceV1alpha3.toResourceClaim(resp); - } - - async patchResourceClaimStatus( - name: string, - type: c.PatchType, - body: ResourceV1alpha3.ResourceClaim | c.JsonPatch, - opts: operations.PatchOpts = {}, - ): Promise { - const resp = await this.#client.performRequest({ - method: "PATCH", - path: `${this.#root}resourceclaims/${name}/status`, - expectJson: true, - querystring: operations.formatPatchOpts(opts), - contentType: c.getPatchContentType(type), - bodyJson: Array.isArray(body) ? body : ResourceV1alpha3.fromResourceClaim(body), - abortSignal: opts.abortSignal, - }); - return ResourceV1alpha3.toResourceClaim(resp); - } - - async getResourceClaimTemplateList( + async getDeviceTaintRuleList( opts: operations.GetListOpts = {}, - ): Promise { + ): Promise { const resp = await this.#client.performRequest({ method: "GET", - path: `${this.#root}resourceclaimtemplates`, + path: `${this.#root}devicetaintrules`, expectJson: true, querystring: operations.formatGetListOpts(opts), abortSignal: opts.abortSignal, }); - return ResourceV1alpha3.toResourceClaimTemplateList(resp); + return ResourceV1alpha3.toDeviceTaintRuleList(resp); } - async watchResourceClaimTemplateList( + async watchDeviceTaintRuleList( opts: operations.WatchListOpts = {}, - ): Promise> { + ): Promise> { const resp = await this.#client.performRequest({ method: "GET", - path: `${this.#root}resourceclaimtemplates`, + path: `${this.#root}devicetaintrules`, expectJson: true, expectStream: true, querystring: operations.formatWatchListOpts(opts), abortSignal: opts.abortSignal, }); - return resp.pipeThrough(new c.WatchEventTransformer(ResourceV1alpha3.toResourceClaimTemplate, MetaV1.toStatus)); + return resp.pipeThrough(new c.WatchEventTransformer(ResourceV1alpha3.toDeviceTaintRule, MetaV1.toStatus)); } - async createResourceClaimTemplate( - body: ResourceV1alpha3.ResourceClaimTemplate, + async createDeviceTaintRule( + body: ResourceV1alpha3.DeviceTaintRule, opts: operations.PutOpts = {}, - ): Promise { + ): Promise { const resp = await this.#client.performRequest({ method: "POST", - path: `${this.#root}resourceclaimtemplates`, + path: `${this.#root}devicetaintrules`, expectJson: true, querystring: operations.formatPutOpts(opts), - bodyJson: ResourceV1alpha3.fromResourceClaimTemplate(body), + bodyJson: ResourceV1alpha3.fromDeviceTaintRule(body), abortSignal: opts.abortSignal, }); - return ResourceV1alpha3.toResourceClaimTemplate(resp); + return ResourceV1alpha3.toDeviceTaintRule(resp); } - async deleteResourceClaimTemplateList( + async deleteDeviceTaintRuleList( opts: operations.DeleteListOpts = {}, - ): Promise { + ): Promise { const resp = await this.#client.performRequest({ method: "DELETE", - path: `${this.#root}resourceclaimtemplates`, + path: `${this.#root}devicetaintrules`, expectJson: true, querystring: operations.formatDeleteListOpts(opts), abortSignal: opts.abortSignal, }); - return ResourceV1alpha3.toResourceClaimTemplateList(resp); + return ResourceV1alpha3.toDeviceTaintRuleList(resp); } - async getResourceClaimTemplate( + async getDeviceTaintRule( name: string, opts: operations.NoOpts = {}, - ): Promise { + ): Promise { const resp = await this.#client.performRequest({ method: "GET", - path: `${this.#root}resourceclaimtemplates/${name}`, + path: `${this.#root}devicetaintrules/${name}`, expectJson: true, abortSignal: opts.abortSignal, }); - return ResourceV1alpha3.toResourceClaimTemplate(resp); + return ResourceV1alpha3.toDeviceTaintRule(resp); } - async deleteResourceClaimTemplate( + async deleteDeviceTaintRule( name: string, opts: operations.DeleteOpts = {}, - ): Promise { + ): Promise { const resp = await this.#client.performRequest({ method: "DELETE", - path: `${this.#root}resourceclaimtemplates/${name}`, + path: `${this.#root}devicetaintrules/${name}`, expectJson: true, querystring: operations.formatDeleteOpts(opts), abortSignal: opts.abortSignal, }); if (c.isStatusKind(resp)) return MetaV1.toStatus(resp); - return ResourceV1alpha3.toResourceClaimTemplate(resp); + return ResourceV1alpha3.toDeviceTaintRule(resp); } - async replaceResourceClaimTemplate( + async replaceDeviceTaintRule( name: string, - body: ResourceV1alpha3.ResourceClaimTemplate, + body: ResourceV1alpha3.DeviceTaintRule, opts: operations.PutOpts = {}, - ): Promise { + ): Promise { const resp = await this.#client.performRequest({ method: "PUT", - path: `${this.#root}resourceclaimtemplates/${name}`, + path: `${this.#root}devicetaintrules/${name}`, expectJson: true, querystring: operations.formatPutOpts(opts), - bodyJson: ResourceV1alpha3.fromResourceClaimTemplate(body), + bodyJson: ResourceV1alpha3.fromDeviceTaintRule(body), abortSignal: opts.abortSignal, }); - return ResourceV1alpha3.toResourceClaimTemplate(resp); + return ResourceV1alpha3.toDeviceTaintRule(resp); } - async patchResourceClaimTemplate( + async patchDeviceTaintRule( name: string, type: c.PatchType, - body: ResourceV1alpha3.ResourceClaimTemplate | c.JsonPatch, + body: ResourceV1alpha3.DeviceTaintRule | c.JsonPatch, opts: operations.PatchOpts = {}, - ): Promise { + ): Promise { const resp = await this.#client.performRequest({ method: "PATCH", - path: `${this.#root}resourceclaimtemplates/${name}`, + path: `${this.#root}devicetaintrules/${name}`, expectJson: true, querystring: operations.formatPatchOpts(opts), contentType: c.getPatchContentType(type), - bodyJson: Array.isArray(body) ? body : ResourceV1alpha3.fromResourceClaimTemplate(body), + bodyJson: Array.isArray(body) ? body : ResourceV1alpha3.fromDeviceTaintRule(body), abortSignal: opts.abortSignal, }); - return ResourceV1alpha3.toResourceClaimTemplate(resp); + return ResourceV1alpha3.toDeviceTaintRule(resp); } } diff --git a/lib/builtin/resource.k8s.io@v1alpha3/structs.ts b/lib/builtin/resource.k8s.io@v1alpha3/structs.ts index 1ac0937..b9bbb4c 100644 --- a/lib/builtin/resource.k8s.io@v1alpha3/structs.ts +++ b/lib/builtin/resource.k8s.io@v1alpha3/structs.ts @@ -1,188 +1,12 @@ // Autogenerated Schema file for ResourceV1alpha3 import * as c from "../../common.ts"; -import * as CoreV1 from "../core@v1/structs.ts"; import * as MetaV1 from "../meta@v1/structs.ts"; type ListOf = { metadata: MetaV1.ListMeta; items: Array; }; -/** AllocatedDeviceStatus contains the status of an allocated device, if the driver chooses to report it. This may include driver-specific information. */ -export interface AllocatedDeviceStatus { - conditions?: Array | null; - data?: c.JSONValue | null; - device: string; - driver: string; - networkData?: NetworkDeviceData | null; - pool: string; -} -export function toAllocatedDeviceStatus(input: c.JSONValue): AllocatedDeviceStatus { - const obj = c.checkObj(input); - return { - conditions: c.readOpt(obj["conditions"], x => c.readList(x, MetaV1.toCondition)), - data: c.readOpt(obj["data"], c.identity), - device: c.checkStr(obj["device"]), - driver: c.checkStr(obj["driver"]), - networkData: c.readOpt(obj["networkData"], toNetworkDeviceData), - pool: c.checkStr(obj["pool"]), - }} -export function fromAllocatedDeviceStatus(input: AllocatedDeviceStatus): c.JSONValue { - return { - ...input, - conditions: input.conditions?.map(MetaV1.fromCondition), - networkData: input.networkData != null ? fromNetworkDeviceData(input.networkData) : undefined, - }} - -/** NetworkDeviceData provides network-related details for the allocated device. This information may be filled by drivers or other components to configure or identify the device within a network context. */ -export interface NetworkDeviceData { - hardwareAddress?: string | null; - interfaceName?: string | null; - ips?: Array | null; -} -export function toNetworkDeviceData(input: c.JSONValue): NetworkDeviceData { - const obj = c.checkObj(input); - return { - hardwareAddress: c.readOpt(obj["hardwareAddress"], c.checkStr), - interfaceName: c.readOpt(obj["interfaceName"], c.checkStr), - ips: c.readOpt(obj["ips"], x => c.readList(x, c.checkStr)), - }} -export function fromNetworkDeviceData(input: NetworkDeviceData): c.JSONValue { - return { - ...input, - }} - -/** AllocationResult contains attributes of an allocated resource. */ -export interface AllocationResult { - devices?: DeviceAllocationResult | null; - nodeSelector?: CoreV1.NodeSelector | null; -} -export function toAllocationResult(input: c.JSONValue): AllocationResult { - const obj = c.checkObj(input); - return { - devices: c.readOpt(obj["devices"], toDeviceAllocationResult), - nodeSelector: c.readOpt(obj["nodeSelector"], CoreV1.toNodeSelector), - }} -export function fromAllocationResult(input: AllocationResult): c.JSONValue { - return { - ...input, - devices: input.devices != null ? fromDeviceAllocationResult(input.devices) : undefined, - nodeSelector: input.nodeSelector != null ? CoreV1.fromNodeSelector(input.nodeSelector) : undefined, - }} - -/** DeviceAllocationResult is the result of allocating devices. */ -export interface DeviceAllocationResult { - config?: Array | null; - results?: Array | null; -} -export function toDeviceAllocationResult(input: c.JSONValue): DeviceAllocationResult { - const obj = c.checkObj(input); - return { - config: c.readOpt(obj["config"], x => c.readList(x, toDeviceAllocationConfiguration)), - results: c.readOpt(obj["results"], x => c.readList(x, toDeviceRequestAllocationResult)), - }} -export function fromDeviceAllocationResult(input: DeviceAllocationResult): c.JSONValue { - return { - ...input, - config: input.config?.map(fromDeviceAllocationConfiguration), - results: input.results?.map(fromDeviceRequestAllocationResult), - }} - -/** DeviceAllocationConfiguration gets embedded in an AllocationResult. */ -export interface DeviceAllocationConfiguration { - opaque?: OpaqueDeviceConfiguration | null; - requests?: Array | null; - source: string; -} -export function toDeviceAllocationConfiguration(input: c.JSONValue): DeviceAllocationConfiguration { - const obj = c.checkObj(input); - return { - opaque: c.readOpt(obj["opaque"], toOpaqueDeviceConfiguration), - requests: c.readOpt(obj["requests"], x => c.readList(x, c.checkStr)), - source: c.checkStr(obj["source"]), - }} -export function fromDeviceAllocationConfiguration(input: DeviceAllocationConfiguration): c.JSONValue { - return { - ...input, - opaque: input.opaque != null ? fromOpaqueDeviceConfiguration(input.opaque) : undefined, - }} - -/** OpaqueDeviceConfiguration contains configuration parameters for a driver in a format defined by the driver vendor. */ -export interface OpaqueDeviceConfiguration { - driver: string; - parameters: c.JSONValue; -} -export function toOpaqueDeviceConfiguration(input: c.JSONValue): OpaqueDeviceConfiguration { - const obj = c.checkObj(input); - return { - driver: c.checkStr(obj["driver"]), - parameters: c.identity(obj["parameters"]), - }} -export function fromOpaqueDeviceConfiguration(input: OpaqueDeviceConfiguration): c.JSONValue { - return { - ...input, - }} - -/** DeviceRequestAllocationResult contains the allocation result for one request. */ -export interface DeviceRequestAllocationResult { - adminAccess?: boolean | null; - device: string; - driver: string; - pool: string; - request: string; -} -export function toDeviceRequestAllocationResult(input: c.JSONValue): DeviceRequestAllocationResult { - const obj = c.checkObj(input); - return { - adminAccess: c.readOpt(obj["adminAccess"], c.checkBool), - device: c.checkStr(obj["device"]), - driver: c.checkStr(obj["driver"]), - pool: c.checkStr(obj["pool"]), - request: c.checkStr(obj["request"]), - }} -export function fromDeviceRequestAllocationResult(input: DeviceRequestAllocationResult): c.JSONValue { - return { - ...input, - }} - -/** BasicDevice defines one device instance. */ -export interface BasicDevice { - attributes?: Record | null; - capacity?: Record | null; -} -export function toBasicDevice(input: c.JSONValue): BasicDevice { - const obj = c.checkObj(input); - return { - attributes: c.readOpt(obj["attributes"], x => c.readMap(x, toDeviceAttribute)), - capacity: c.readOpt(obj["capacity"], x => c.readMap(x, c.toQuantity)), - }} -export function fromBasicDevice(input: BasicDevice): c.JSONValue { - return { - ...input, - attributes: c.writeMap(input.attributes, fromDeviceAttribute), - capacity: c.writeMap(input.capacity, c.fromQuantity), - }} - -/** DeviceAttribute must have exactly one field set. */ -export interface DeviceAttribute { - bool?: boolean | null; - int?: number | null; - string?: string | null; - version?: string | null; -} -export function toDeviceAttribute(input: c.JSONValue): DeviceAttribute { - const obj = c.checkObj(input); - return { - bool: c.readOpt(obj["bool"], c.checkBool), - int: c.readOpt(obj["int"], c.checkNum), - string: c.readOpt(obj["string"], c.checkStr), - version: c.readOpt(obj["version"], c.checkStr), - }} -export function fromDeviceAttribute(input: DeviceAttribute): c.JSONValue { - return { - ...input, - }} - /** CELDeviceSelector contains a CEL expression for selecting a device. */ export interface CELDeviceSelector { expression: string; @@ -197,104 +21,6 @@ export function fromCELDeviceSelector(input: CELDeviceSelector): c.JSONValue { ...input, }} -/** Device represents one individual hardware instance that can be selected based on its attributes. Besides the name, exactly one field must be set. */ -export interface Device { - basic?: BasicDevice | null; - name: string; -} -export function toDevice(input: c.JSONValue): Device { - const obj = c.checkObj(input); - return { - basic: c.readOpt(obj["basic"], toBasicDevice), - name: c.checkStr(obj["name"]), - }} -export function fromDevice(input: Device): c.JSONValue { - return { - ...input, - basic: input.basic != null ? fromBasicDevice(input.basic) : undefined, - }} - -/** DeviceClaim defines how to request devices with a ResourceClaim. */ -export interface DeviceClaim { - config?: Array | null; - constraints?: Array | null; - requests?: Array | null; -} -export function toDeviceClaim(input: c.JSONValue): DeviceClaim { - const obj = c.checkObj(input); - return { - config: c.readOpt(obj["config"], x => c.readList(x, toDeviceClaimConfiguration)), - constraints: c.readOpt(obj["constraints"], x => c.readList(x, toDeviceConstraint)), - requests: c.readOpt(obj["requests"], x => c.readList(x, toDeviceRequest)), - }} -export function fromDeviceClaim(input: DeviceClaim): c.JSONValue { - return { - ...input, - config: input.config?.map(fromDeviceClaimConfiguration), - constraints: input.constraints?.map(fromDeviceConstraint), - requests: input.requests?.map(fromDeviceRequest), - }} - -/** DeviceClaimConfiguration is used for configuration parameters in DeviceClaim. */ -export interface DeviceClaimConfiguration { - opaque?: OpaqueDeviceConfiguration | null; - requests?: Array | null; -} -export function toDeviceClaimConfiguration(input: c.JSONValue): DeviceClaimConfiguration { - const obj = c.checkObj(input); - return { - opaque: c.readOpt(obj["opaque"], toOpaqueDeviceConfiguration), - requests: c.readOpt(obj["requests"], x => c.readList(x, c.checkStr)), - }} -export function fromDeviceClaimConfiguration(input: DeviceClaimConfiguration): c.JSONValue { - return { - ...input, - opaque: input.opaque != null ? fromOpaqueDeviceConfiguration(input.opaque) : undefined, - }} - -/** DeviceConstraint must have exactly one field set besides Requests. */ -export interface DeviceConstraint { - matchAttribute?: string | null; - requests?: Array | null; -} -export function toDeviceConstraint(input: c.JSONValue): DeviceConstraint { - const obj = c.checkObj(input); - return { - matchAttribute: c.readOpt(obj["matchAttribute"], c.checkStr), - requests: c.readOpt(obj["requests"], x => c.readList(x, c.checkStr)), - }} -export function fromDeviceConstraint(input: DeviceConstraint): c.JSONValue { - return { - ...input, - }} - -/** DeviceRequest is a request for devices required for a claim. This is typically a request for a single resource like a device, but can also ask for several identical devices. - -A DeviceClassName is currently required. Clients must check that it is indeed set. It's absence indicates that something changed in a way that is not supported by the client yet, in which case it must refuse to handle the request. */ -export interface DeviceRequest { - adminAccess?: boolean | null; - allocationMode?: string | null; - count?: number | null; - deviceClassName: string; - name: string; - selectors?: Array | null; -} -export function toDeviceRequest(input: c.JSONValue): DeviceRequest { - const obj = c.checkObj(input); - return { - adminAccess: c.readOpt(obj["adminAccess"], c.checkBool), - allocationMode: c.readOpt(obj["allocationMode"], c.checkStr), - count: c.readOpt(obj["count"], c.checkNum), - deviceClassName: c.checkStr(obj["deviceClassName"]), - name: c.checkStr(obj["name"]), - selectors: c.readOpt(obj["selectors"], x => c.readList(x, toDeviceSelector)), - }} -export function fromDeviceRequest(input: DeviceRequest): c.JSONValue { - return { - ...input, - selectors: input.selectors?.map(fromDeviceSelector), - }} - /** DeviceSelector must have exactly one field set. */ export interface DeviceSelector { cel?: CELDeviceSelector | null; @@ -310,313 +36,99 @@ export function fromDeviceSelector(input: DeviceSelector): c.JSONValue { cel: input.cel != null ? fromCELDeviceSelector(input.cel) : undefined, }} -/** DeviceClass is a vendor- or admin-provided resource that contains device configuration and selectors. It can be referenced in the device requests of a claim to apply these presets. Cluster scoped. - -This is an alpha type and requires enabling the DynamicResourceAllocation feature gate. */ -export interface DeviceClass { - apiVersion?: "resource.k8s.io/v1alpha3"; - kind?: "DeviceClass"; - metadata?: MetaV1.ObjectMeta | null; - spec: DeviceClassSpec; +/** The device this taint is attached to has the "effect" on any claim which does not tolerate the taint and, through the claim, to pods using the claim. */ +export interface DeviceTaint { + effect: string; + key: string; + timeAdded?: c.Time | null; + value?: string | null; } -export function toDeviceClass(input: c.JSONValue): DeviceClass & c.ApiKind { +export function toDeviceTaint(input: c.JSONValue): DeviceTaint { const obj = c.checkObj(input); return { - ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1alpha3", "DeviceClass"), - metadata: c.readOpt(obj["metadata"], MetaV1.toObjectMeta), - spec: toDeviceClassSpec(obj["spec"]), + effect: c.checkStr(obj["effect"]), + key: c.checkStr(obj["key"]), + timeAdded: c.readOpt(obj["timeAdded"], c.toTime), + value: c.readOpt(obj["value"], c.checkStr), }} -export function fromDeviceClass(input: DeviceClass): c.JSONValue { +export function fromDeviceTaint(input: DeviceTaint): c.JSONValue { return { - ...c.assertOrAddApiVersionAndKind(input, "resource.k8s.io/v1alpha3", "DeviceClass"), ...input, - metadata: input.metadata != null ? MetaV1.fromObjectMeta(input.metadata) : undefined, - spec: input.spec != null ? fromDeviceClassSpec(input.spec) : undefined, - }} - -/** DeviceClassSpec is used in a [DeviceClass] to define what can be allocated and how to configure it. */ -export interface DeviceClassSpec { - config?: Array | null; - selectors?: Array | null; -} -export function toDeviceClassSpec(input: c.JSONValue): DeviceClassSpec { - const obj = c.checkObj(input); - return { - config: c.readOpt(obj["config"], x => c.readList(x, toDeviceClassConfiguration)), - selectors: c.readOpt(obj["selectors"], x => c.readList(x, toDeviceSelector)), - }} -export function fromDeviceClassSpec(input: DeviceClassSpec): c.JSONValue { - return { - ...input, - config: input.config?.map(fromDeviceClassConfiguration), - selectors: input.selectors?.map(fromDeviceSelector), - }} - -/** DeviceClassConfiguration is used in DeviceClass. */ -export interface DeviceClassConfiguration { - opaque?: OpaqueDeviceConfiguration | null; -} -export function toDeviceClassConfiguration(input: c.JSONValue): DeviceClassConfiguration { - const obj = c.checkObj(input); - return { - opaque: c.readOpt(obj["opaque"], toOpaqueDeviceConfiguration), - }} -export function fromDeviceClassConfiguration(input: DeviceClassConfiguration): c.JSONValue { - return { - ...input, - opaque: input.opaque != null ? fromOpaqueDeviceConfiguration(input.opaque) : undefined, - }} - -/** DeviceClassList is a collection of classes. */ -export interface DeviceClassList extends ListOf { - apiVersion?: "resource.k8s.io/v1alpha3"; - kind?: "DeviceClassList"; -}; -export function toDeviceClassList(input: c.JSONValue): DeviceClassList & c.ApiKind { - const obj = c.checkObj(input); - return { - ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1alpha3", "DeviceClassList"), - metadata: MetaV1.toListMeta(obj.metadata), - items: c.readList(obj.items, toDeviceClass), + timeAdded: input.timeAdded != null ? c.fromTime(input.timeAdded) : undefined, }} -/** ResourceClaim describes a request for access to resources in the cluster, for use by workloads. For example, if a workload needs an accelerator device with specific properties, this is how that request is expressed. The status stanza tracks whether this claim has been satisfied and what specific resources have been allocated. - -This is an alpha type and requires enabling the DynamicResourceAllocation feature gate. */ -export interface ResourceClaim { +/** DeviceTaintRule adds one taint to all devices which match the selector. This has the same effect as if the taint was specified directly in the ResourceSlice by the DRA driver. */ +export interface DeviceTaintRule { apiVersion?: "resource.k8s.io/v1alpha3"; - kind?: "ResourceClaim"; + kind?: "DeviceTaintRule"; metadata?: MetaV1.ObjectMeta | null; - spec: ResourceClaimSpec; - status?: ResourceClaimStatus | null; + spec: DeviceTaintRuleSpec; } -export function toResourceClaim(input: c.JSONValue): ResourceClaim & c.ApiKind { +export function toDeviceTaintRule(input: c.JSONValue): DeviceTaintRule & c.ApiKind { const obj = c.checkObj(input); return { - ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1alpha3", "ResourceClaim"), + ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1alpha3", "DeviceTaintRule"), metadata: c.readOpt(obj["metadata"], MetaV1.toObjectMeta), - spec: toResourceClaimSpec(obj["spec"]), - status: c.readOpt(obj["status"], toResourceClaimStatus), + spec: toDeviceTaintRuleSpec(obj["spec"]), }} -export function fromResourceClaim(input: ResourceClaim): c.JSONValue { +export function fromDeviceTaintRule(input: DeviceTaintRule): c.JSONValue { return { - ...c.assertOrAddApiVersionAndKind(input, "resource.k8s.io/v1alpha3", "ResourceClaim"), + ...c.assertOrAddApiVersionAndKind(input, "resource.k8s.io/v1alpha3", "DeviceTaintRule"), ...input, metadata: input.metadata != null ? MetaV1.fromObjectMeta(input.metadata) : undefined, - spec: input.spec != null ? fromResourceClaimSpec(input.spec) : undefined, - status: input.status != null ? fromResourceClaimStatus(input.status) : undefined, + spec: input.spec != null ? fromDeviceTaintRuleSpec(input.spec) : undefined, }} -/** ResourceClaimSpec defines what is being requested in a ResourceClaim and how to configure it. */ -export interface ResourceClaimSpec { - devices?: DeviceClaim | null; +/** DeviceTaintRuleSpec specifies the selector and one taint. */ +export interface DeviceTaintRuleSpec { + deviceSelector?: DeviceTaintSelector | null; + taint: DeviceTaint; } -export function toResourceClaimSpec(input: c.JSONValue): ResourceClaimSpec { +export function toDeviceTaintRuleSpec(input: c.JSONValue): DeviceTaintRuleSpec { const obj = c.checkObj(input); return { - devices: c.readOpt(obj["devices"], toDeviceClaim), + deviceSelector: c.readOpt(obj["deviceSelector"], toDeviceTaintSelector), + taint: toDeviceTaint(obj["taint"]), }} -export function fromResourceClaimSpec(input: ResourceClaimSpec): c.JSONValue { +export function fromDeviceTaintRuleSpec(input: DeviceTaintRuleSpec): c.JSONValue { return { ...input, - devices: input.devices != null ? fromDeviceClaim(input.devices) : undefined, + deviceSelector: input.deviceSelector != null ? fromDeviceTaintSelector(input.deviceSelector) : undefined, + taint: input.taint != null ? fromDeviceTaint(input.taint) : undefined, }} -/** ResourceClaimStatus tracks whether the resource has been allocated and what the result of that was. */ -export interface ResourceClaimStatus { - allocation?: AllocationResult | null; - devices?: Array | null; - reservedFor?: Array | null; -} -export function toResourceClaimStatus(input: c.JSONValue): ResourceClaimStatus { - const obj = c.checkObj(input); - return { - allocation: c.readOpt(obj["allocation"], toAllocationResult), - devices: c.readOpt(obj["devices"], x => c.readList(x, toAllocatedDeviceStatus)), - reservedFor: c.readOpt(obj["reservedFor"], x => c.readList(x, toResourceClaimConsumerReference)), - }} -export function fromResourceClaimStatus(input: ResourceClaimStatus): c.JSONValue { - return { - ...input, - allocation: input.allocation != null ? fromAllocationResult(input.allocation) : undefined, - devices: input.devices?.map(fromAllocatedDeviceStatus), - reservedFor: input.reservedFor?.map(fromResourceClaimConsumerReference), - }} - -/** ResourceClaimConsumerReference contains enough information to let you locate the consumer of a ResourceClaim. The user must be a resource in the same namespace as the ResourceClaim. */ -export interface ResourceClaimConsumerReference { - apiGroup?: string | null; - name: string; - resource: string; - uid: string; -} -export function toResourceClaimConsumerReference(input: c.JSONValue): ResourceClaimConsumerReference { - const obj = c.checkObj(input); - return { - apiGroup: c.readOpt(obj["apiGroup"], c.checkStr), - name: c.checkStr(obj["name"]), - resource: c.checkStr(obj["resource"]), - uid: c.checkStr(obj["uid"]), - }} -export function fromResourceClaimConsumerReference(input: ResourceClaimConsumerReference): c.JSONValue { - return { - ...input, - }} - -/** ResourceClaimList is a collection of claims. */ -export interface ResourceClaimList extends ListOf { - apiVersion?: "resource.k8s.io/v1alpha3"; - kind?: "ResourceClaimList"; -}; -export function toResourceClaimList(input: c.JSONValue): ResourceClaimList & c.ApiKind { - const obj = c.checkObj(input); - return { - ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1alpha3", "ResourceClaimList"), - metadata: MetaV1.toListMeta(obj.metadata), - items: c.readList(obj.items, toResourceClaim), - }} - -/** ResourceClaimTemplate is used to produce ResourceClaim objects. - -This is an alpha type and requires enabling the DynamicResourceAllocation feature gate. */ -export interface ResourceClaimTemplate { - apiVersion?: "resource.k8s.io/v1alpha3"; - kind?: "ResourceClaimTemplate"; - metadata?: MetaV1.ObjectMeta | null; - spec: ResourceClaimTemplateSpec; -} -export function toResourceClaimTemplate(input: c.JSONValue): ResourceClaimTemplate & c.ApiKind { - const obj = c.checkObj(input); - return { - ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1alpha3", "ResourceClaimTemplate"), - metadata: c.readOpt(obj["metadata"], MetaV1.toObjectMeta), - spec: toResourceClaimTemplateSpec(obj["spec"]), - }} -export function fromResourceClaimTemplate(input: ResourceClaimTemplate): c.JSONValue { - return { - ...c.assertOrAddApiVersionAndKind(input, "resource.k8s.io/v1alpha3", "ResourceClaimTemplate"), - ...input, - metadata: input.metadata != null ? MetaV1.fromObjectMeta(input.metadata) : undefined, - spec: input.spec != null ? fromResourceClaimTemplateSpec(input.spec) : undefined, - }} - -/** ResourceClaimTemplateSpec contains the metadata and fields for a ResourceClaim. */ -export interface ResourceClaimTemplateSpec { - metadata?: MetaV1.ObjectMeta | null; - spec: ResourceClaimSpec; -} -export function toResourceClaimTemplateSpec(input: c.JSONValue): ResourceClaimTemplateSpec { - const obj = c.checkObj(input); - return { - metadata: c.readOpt(obj["metadata"], MetaV1.toObjectMeta), - spec: toResourceClaimSpec(obj["spec"]), - }} -export function fromResourceClaimTemplateSpec(input: ResourceClaimTemplateSpec): c.JSONValue { - return { - ...input, - metadata: input.metadata != null ? MetaV1.fromObjectMeta(input.metadata) : undefined, - spec: input.spec != null ? fromResourceClaimSpec(input.spec) : undefined, - }} - -/** ResourceClaimTemplateList is a collection of claim templates. */ -export interface ResourceClaimTemplateList extends ListOf { - apiVersion?: "resource.k8s.io/v1alpha3"; - kind?: "ResourceClaimTemplateList"; -}; -export function toResourceClaimTemplateList(input: c.JSONValue): ResourceClaimTemplateList & c.ApiKind { - const obj = c.checkObj(input); - return { - ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1alpha3", "ResourceClaimTemplateList"), - metadata: MetaV1.toListMeta(obj.metadata), - items: c.readList(obj.items, toResourceClaimTemplate), - }} - -/** ResourcePool describes the pool that ResourceSlices belong to. */ -export interface ResourcePool { - generation: number; - name: string; - resourceSliceCount: number; -} -export function toResourcePool(input: c.JSONValue): ResourcePool { - const obj = c.checkObj(input); - return { - generation: c.checkNum(obj["generation"]), - name: c.checkStr(obj["name"]), - resourceSliceCount: c.checkNum(obj["resourceSliceCount"]), - }} -export function fromResourcePool(input: ResourcePool): c.JSONValue { - return { - ...input, - }} - -/** ResourceSlice represents one or more resources in a pool of similar resources, managed by a common driver. A pool may span more than one ResourceSlice, and exactly how many ResourceSlices comprise a pool is determined by the driver. - -At the moment, the only supported resources are devices with attributes and capacities. Each device in a given pool, regardless of how many ResourceSlices, must have a unique name. The ResourceSlice in which a device gets published may change over time. The unique identifier for a device is the tuple , , . - -Whenever a driver needs to update a pool, it increments the pool.Spec.Pool.Generation number and updates all ResourceSlices with that new number and new resource definitions. A consumer must only use ResourceSlices with the highest generation number and ignore all others. - -When allocating all resources in a pool matching certain criteria or when looking for the best solution among several different alternatives, a consumer should check the number of ResourceSlices in a pool (included in each ResourceSlice) to determine whether its view of a pool is complete and if not, should wait until the driver has completed updating the pool. - -For resources that are not local to a node, the node name is not set. Instead, the driver may use a node selector to specify where the devices are available. - -This is an alpha type and requires enabling the DynamicResourceAllocation feature gate. */ -export interface ResourceSlice { - apiVersion?: "resource.k8s.io/v1alpha3"; - kind?: "ResourceSlice"; - metadata?: MetaV1.ObjectMeta | null; - spec: ResourceSliceSpec; -} -export function toResourceSlice(input: c.JSONValue): ResourceSlice & c.ApiKind { - const obj = c.checkObj(input); - return { - ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1alpha3", "ResourceSlice"), - metadata: c.readOpt(obj["metadata"], MetaV1.toObjectMeta), - spec: toResourceSliceSpec(obj["spec"]), - }} -export function fromResourceSlice(input: ResourceSlice): c.JSONValue { - return { - ...c.assertOrAddApiVersionAndKind(input, "resource.k8s.io/v1alpha3", "ResourceSlice"), - ...input, - metadata: input.metadata != null ? MetaV1.fromObjectMeta(input.metadata) : undefined, - spec: input.spec != null ? fromResourceSliceSpec(input.spec) : undefined, - }} - -/** ResourceSliceSpec contains the information published by the driver in one ResourceSlice. */ -export interface ResourceSliceSpec { - allNodes?: boolean | null; - devices?: Array | null; - driver: string; - nodeName?: string | null; - nodeSelector?: CoreV1.NodeSelector | null; - pool: ResourcePool; +/** DeviceTaintSelector defines which device(s) a DeviceTaintRule applies to. The empty selector matches all devices. Without a selector, no devices are matched. */ +export interface DeviceTaintSelector { + device?: string | null; + deviceClassName?: string | null; + driver?: string | null; + pool?: string | null; + selectors?: Array | null; } -export function toResourceSliceSpec(input: c.JSONValue): ResourceSliceSpec { +export function toDeviceTaintSelector(input: c.JSONValue): DeviceTaintSelector { const obj = c.checkObj(input); return { - allNodes: c.readOpt(obj["allNodes"], c.checkBool), - devices: c.readOpt(obj["devices"], x => c.readList(x, toDevice)), - driver: c.checkStr(obj["driver"]), - nodeName: c.readOpt(obj["nodeName"], c.checkStr), - nodeSelector: c.readOpt(obj["nodeSelector"], CoreV1.toNodeSelector), - pool: toResourcePool(obj["pool"]), + device: c.readOpt(obj["device"], c.checkStr), + deviceClassName: c.readOpt(obj["deviceClassName"], c.checkStr), + driver: c.readOpt(obj["driver"], c.checkStr), + pool: c.readOpt(obj["pool"], c.checkStr), + selectors: c.readOpt(obj["selectors"], x => c.readList(x, toDeviceSelector)), }} -export function fromResourceSliceSpec(input: ResourceSliceSpec): c.JSONValue { +export function fromDeviceTaintSelector(input: DeviceTaintSelector): c.JSONValue { return { ...input, - devices: input.devices?.map(fromDevice), - nodeSelector: input.nodeSelector != null ? CoreV1.fromNodeSelector(input.nodeSelector) : undefined, - pool: input.pool != null ? fromResourcePool(input.pool) : undefined, + selectors: input.selectors?.map(fromDeviceSelector), }} -/** ResourceSliceList is a collection of ResourceSlices. */ -export interface ResourceSliceList extends ListOf { +/** DeviceTaintRuleList is a collection of DeviceTaintRules. */ +export interface DeviceTaintRuleList extends ListOf { apiVersion?: "resource.k8s.io/v1alpha3"; - kind?: "ResourceSliceList"; + kind?: "DeviceTaintRuleList"; }; -export function toResourceSliceList(input: c.JSONValue): ResourceSliceList & c.ApiKind { +export function toDeviceTaintRuleList(input: c.JSONValue): DeviceTaintRuleList & c.ApiKind { const obj = c.checkObj(input); return { - ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1alpha3", "ResourceSliceList"), + ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1alpha3", "DeviceTaintRuleList"), metadata: MetaV1.toListMeta(obj.metadata), - items: c.readList(obj.items, toResourceSlice), + items: c.readList(obj.items, toDeviceTaintRule), }} diff --git a/lib/builtin/resource.k8s.io@v1beta1/structs.ts b/lib/builtin/resource.k8s.io@v1beta1/structs.ts index 0926dd5..a53d6a8 100644 --- a/lib/builtin/resource.k8s.io@v1beta1/structs.ts +++ b/lib/builtin/resource.k8s.io@v1beta1/structs.ts @@ -8,7 +8,9 @@ type ListOf = { items: Array; }; -/** AllocatedDeviceStatus contains the status of an allocated device, if the driver chooses to report it. This may include driver-specific information. */ +/** AllocatedDeviceStatus contains the status of an allocated device, if the driver chooses to report it. This may include driver-specific information. + +The combination of Driver, Pool, Device, and ShareID must match the corresponding key in Status.Allocation.Devices. */ export interface AllocatedDeviceStatus { conditions?: Array | null; data?: c.JSONValue | null; @@ -16,6 +18,7 @@ export interface AllocatedDeviceStatus { driver: string; networkData?: NetworkDeviceData | null; pool: string; + shareID?: string | null; } export function toAllocatedDeviceStatus(input: c.JSONValue): AllocatedDeviceStatus { const obj = c.checkObj(input); @@ -26,6 +29,7 @@ export function toAllocatedDeviceStatus(input: c.JSONValue): AllocatedDeviceStat driver: c.checkStr(obj["driver"]), networkData: c.readOpt(obj["networkData"], toNetworkDeviceData), pool: c.checkStr(obj["pool"]), + shareID: c.readOpt(obj["shareID"], c.checkStr), }} export function fromAllocatedDeviceStatus(input: AllocatedDeviceStatus): c.JSONValue { return { @@ -54,18 +58,21 @@ export function fromNetworkDeviceData(input: NetworkDeviceData): c.JSONValue { /** AllocationResult contains attributes of an allocated resource. */ export interface AllocationResult { + allocationTimestamp?: c.Time | null; devices?: DeviceAllocationResult | null; nodeSelector?: CoreV1.NodeSelector | null; } export function toAllocationResult(input: c.JSONValue): AllocationResult { const obj = c.checkObj(input); return { + allocationTimestamp: c.readOpt(obj["allocationTimestamp"], c.toTime), devices: c.readOpt(obj["devices"], toDeviceAllocationResult), nodeSelector: c.readOpt(obj["nodeSelector"], CoreV1.toNodeSelector), }} export function fromAllocationResult(input: AllocationResult): c.JSONValue { return { ...input, + allocationTimestamp: input.allocationTimestamp != null ? c.fromTime(input.allocationTimestamp) : undefined, devices: input.devices != null ? fromDeviceAllocationResult(input.devices) : undefined, nodeSelector: input.nodeSelector != null ? CoreV1.fromNodeSelector(input.nodeSelector) : undefined, }} @@ -126,41 +133,96 @@ export function fromOpaqueDeviceConfiguration(input: OpaqueDeviceConfiguration): /** DeviceRequestAllocationResult contains the allocation result for one request. */ export interface DeviceRequestAllocationResult { adminAccess?: boolean | null; + bindingConditions?: Array | null; + bindingFailureConditions?: Array | null; + consumedCapacity?: Record | null; device: string; driver: string; pool: string; request: string; + shareID?: string | null; + tolerations?: Array | null; } export function toDeviceRequestAllocationResult(input: c.JSONValue): DeviceRequestAllocationResult { const obj = c.checkObj(input); return { adminAccess: c.readOpt(obj["adminAccess"], c.checkBool), + bindingConditions: c.readOpt(obj["bindingConditions"], x => c.readList(x, c.checkStr)), + bindingFailureConditions: c.readOpt(obj["bindingFailureConditions"], x => c.readList(x, c.checkStr)), + consumedCapacity: c.readOpt(obj["consumedCapacity"], x => c.readMap(x, c.toQuantity)), device: c.checkStr(obj["device"]), driver: c.checkStr(obj["driver"]), pool: c.checkStr(obj["pool"]), request: c.checkStr(obj["request"]), + shareID: c.readOpt(obj["shareID"], c.checkStr), + tolerations: c.readOpt(obj["tolerations"], x => c.readList(x, toDeviceToleration)), }} export function fromDeviceRequestAllocationResult(input: DeviceRequestAllocationResult): c.JSONValue { + return { + ...input, + consumedCapacity: c.writeMap(input.consumedCapacity, c.fromQuantity), + tolerations: input.tolerations?.map(fromDeviceToleration), + }} + +/** The ResourceClaim this DeviceToleration is attached to tolerates any taint that matches the triple using the matching operator . */ +export interface DeviceToleration { + effect?: string | null; + key?: string | null; + operator?: string | null; + tolerationSeconds?: number | null; + value?: string | null; +} +export function toDeviceToleration(input: c.JSONValue): DeviceToleration { + const obj = c.checkObj(input); + return { + effect: c.readOpt(obj["effect"], c.checkStr), + key: c.readOpt(obj["key"], c.checkStr), + operator: c.readOpt(obj["operator"], c.checkStr), + tolerationSeconds: c.readOpt(obj["tolerationSeconds"], c.checkNum), + value: c.readOpt(obj["value"], c.checkStr), + }} +export function fromDeviceToleration(input: DeviceToleration): c.JSONValue { return { ...input, }} /** BasicDevice defines one device instance. */ export interface BasicDevice { + allNodes?: boolean | null; + allowMultipleAllocations?: boolean | null; attributes?: Record | null; + bindingConditions?: Array | null; + bindingFailureConditions?: Array | null; + bindsToNode?: boolean | null; capacity?: Record | null; + consumesCounters?: Array | null; + nodeName?: string | null; + nodeSelector?: CoreV1.NodeSelector | null; + taints?: Array | null; } export function toBasicDevice(input: c.JSONValue): BasicDevice { const obj = c.checkObj(input); return { + allNodes: c.readOpt(obj["allNodes"], c.checkBool), + allowMultipleAllocations: c.readOpt(obj["allowMultipleAllocations"], c.checkBool), attributes: c.readOpt(obj["attributes"], x => c.readMap(x, toDeviceAttribute)), + bindingConditions: c.readOpt(obj["bindingConditions"], x => c.readList(x, c.checkStr)), + bindingFailureConditions: c.readOpt(obj["bindingFailureConditions"], x => c.readList(x, c.checkStr)), + bindsToNode: c.readOpt(obj["bindsToNode"], c.checkBool), capacity: c.readOpt(obj["capacity"], x => c.readMap(x, toDeviceCapacity)), + consumesCounters: c.readOpt(obj["consumesCounters"], x => c.readList(x, toDeviceCounterConsumption)), + nodeName: c.readOpt(obj["nodeName"], c.checkStr), + nodeSelector: c.readOpt(obj["nodeSelector"], CoreV1.toNodeSelector), + taints: c.readOpt(obj["taints"], x => c.readList(x, toDeviceTaint)), }} export function fromBasicDevice(input: BasicDevice): c.JSONValue { return { ...input, attributes: c.writeMap(input.attributes, fromDeviceAttribute), capacity: c.writeMap(input.capacity, fromDeviceCapacity), + consumesCounters: input.consumesCounters?.map(fromDeviceCounterConsumption), + nodeSelector: input.nodeSelector != null ? CoreV1.fromNodeSelector(input.nodeSelector) : undefined, + taints: input.taints?.map(fromDeviceTaint), }} /** DeviceAttribute must have exactly one field set. */ @@ -185,19 +247,126 @@ export function fromDeviceAttribute(input: DeviceAttribute): c.JSONValue { /** DeviceCapacity describes a quantity associated with a device. */ export interface DeviceCapacity { + requestPolicy?: CapacityRequestPolicy | null; value: c.Quantity; } export function toDeviceCapacity(input: c.JSONValue): DeviceCapacity { const obj = c.checkObj(input); return { + requestPolicy: c.readOpt(obj["requestPolicy"], toCapacityRequestPolicy), value: c.toQuantity(obj["value"]), }} export function fromDeviceCapacity(input: DeviceCapacity): c.JSONValue { + return { + ...input, + requestPolicy: input.requestPolicy != null ? fromCapacityRequestPolicy(input.requestPolicy) : undefined, + value: input.value != null ? c.fromQuantity(input.value) : undefined, + }} + +/** CapacityRequestPolicy defines how requests consume device capacity. + +Must not set more than one ValidRequestValues. */ +export interface CapacityRequestPolicy { + default?: c.Quantity | null; + validRange?: CapacityRequestPolicyRange | null; + validValues?: Array | null; +} +export function toCapacityRequestPolicy(input: c.JSONValue): CapacityRequestPolicy { + const obj = c.checkObj(input); + return { + default: c.readOpt(obj["default"], c.toQuantity), + validRange: c.readOpt(obj["validRange"], toCapacityRequestPolicyRange), + validValues: c.readOpt(obj["validValues"], x => c.readList(x, c.toQuantity)), + }} +export function fromCapacityRequestPolicy(input: CapacityRequestPolicy): c.JSONValue { + return { + ...input, + default: input.default != null ? c.fromQuantity(input.default) : undefined, + validRange: input.validRange != null ? fromCapacityRequestPolicyRange(input.validRange) : undefined, + validValues: input.validValues?.map(c.fromQuantity), + }} + +/** CapacityRequestPolicyRange defines a valid range for consumable capacity values. + + - If the requested amount is less than Min, it is rounded up to the Min value. + - If Step is set and the requested amount is between Min and Max but not aligned with Step, + it will be rounded up to the next value equal to Min + (n * Step). + - If Step is not set, the requested amount is used as-is if it falls within the range Min to Max (if set). + - If the requested or rounded amount exceeds Max (if set), the request does not satisfy the policy, + and the device cannot be allocated. */ +export interface CapacityRequestPolicyRange { + max?: c.Quantity | null; + min: c.Quantity; + step?: c.Quantity | null; +} +export function toCapacityRequestPolicyRange(input: c.JSONValue): CapacityRequestPolicyRange { + const obj = c.checkObj(input); + return { + max: c.readOpt(obj["max"], c.toQuantity), + min: c.toQuantity(obj["min"]), + step: c.readOpt(obj["step"], c.toQuantity), + }} +export function fromCapacityRequestPolicyRange(input: CapacityRequestPolicyRange): c.JSONValue { + return { + ...input, + max: input.max != null ? c.fromQuantity(input.max) : undefined, + min: input.min != null ? c.fromQuantity(input.min) : undefined, + step: input.step != null ? c.fromQuantity(input.step) : undefined, + }} + +/** DeviceCounterConsumption defines a set of counters that a device will consume from a CounterSet. */ +export interface DeviceCounterConsumption { + counterSet: string; + counters: Record; +} +export function toDeviceCounterConsumption(input: c.JSONValue): DeviceCounterConsumption { + const obj = c.checkObj(input); + return { + counterSet: c.checkStr(obj["counterSet"]), + counters: c.readMap(obj["counters"], toCounter), + }} +export function fromDeviceCounterConsumption(input: DeviceCounterConsumption): c.JSONValue { + return { + ...input, + counters: c.writeMap(input.counters, fromCounter), + }} + +/** Counter describes a quantity associated with a device. */ +export interface Counter { + value: c.Quantity; +} +export function toCounter(input: c.JSONValue): Counter { + const obj = c.checkObj(input); + return { + value: c.toQuantity(obj["value"]), + }} +export function fromCounter(input: Counter): c.JSONValue { return { ...input, value: input.value != null ? c.fromQuantity(input.value) : undefined, }} +/** The device this taint is attached to has the "effect" on any claim which does not tolerate the taint and, through the claim, to pods using the claim. */ +export interface DeviceTaint { + effect: string; + key: string; + timeAdded?: c.Time | null; + value?: string | null; +} +export function toDeviceTaint(input: c.JSONValue): DeviceTaint { + const obj = c.checkObj(input); + return { + effect: c.checkStr(obj["effect"]), + key: c.checkStr(obj["key"]), + timeAdded: c.readOpt(obj["timeAdded"], c.toTime), + value: c.readOpt(obj["value"], c.checkStr), + }} +export function fromDeviceTaint(input: DeviceTaint): c.JSONValue { + return { + ...input, + timeAdded: input.timeAdded != null ? c.fromTime(input.timeAdded) : undefined, + }} + /** CELDeviceSelector contains a CEL expression for selecting a device. */ export interface CELDeviceSelector { expression: string; @@ -212,6 +381,40 @@ export function fromCELDeviceSelector(input: CELDeviceSelector): c.JSONValue { ...input, }} +/** CapacityRequirements defines the capacity requirements for a specific device request. */ +export interface CapacityRequirements { + requests?: Record | null; +} +export function toCapacityRequirements(input: c.JSONValue): CapacityRequirements { + const obj = c.checkObj(input); + return { + requests: c.readOpt(obj["requests"], x => c.readMap(x, c.toQuantity)), + }} +export function fromCapacityRequirements(input: CapacityRequirements): c.JSONValue { + return { + ...input, + requests: c.writeMap(input.requests, c.fromQuantity), + }} + +/** CounterSet defines a named set of counters that are available to be used by devices defined in the ResourceSlice. + +The counters are not allocatable by themselves, but can be referenced by devices. When a device is allocated, the portion of counters it uses will no longer be available for use by other devices. */ +export interface CounterSet { + counters: Record; + name: string; +} +export function toCounterSet(input: c.JSONValue): CounterSet { + const obj = c.checkObj(input); + return { + counters: c.readMap(obj["counters"], toCounter), + name: c.checkStr(obj["name"]), + }} +export function fromCounterSet(input: CounterSet): c.JSONValue { + return { + ...input, + counters: c.writeMap(input.counters, fromCounter), + }} + /** Device represents one individual hardware instance that can be selected based on its attributes. Besides the name, exactly one field must be set. */ export interface Device { basic?: BasicDevice | null; @@ -269,12 +472,14 @@ export function fromDeviceClaimConfiguration(input: DeviceClaimConfiguration): c /** DeviceConstraint must have exactly one field set besides Requests. */ export interface DeviceConstraint { + distinctAttribute?: string | null; matchAttribute?: string | null; requests?: Array | null; } export function toDeviceConstraint(input: c.JSONValue): DeviceConstraint { const obj = c.checkObj(input); return { + distinctAttribute: c.readOpt(obj["distinctAttribute"], c.checkStr), matchAttribute: c.readOpt(obj["matchAttribute"], c.checkStr), requests: c.readOpt(obj["requests"], x => c.readList(x, c.checkStr)), }} @@ -283,31 +488,69 @@ export function fromDeviceConstraint(input: DeviceConstraint): c.JSONValue { ...input, }} -/** DeviceRequest is a request for devices required for a claim. This is typically a request for a single resource like a device, but can also ask for several identical devices. - -A DeviceClassName is currently required. Clients must check that it is indeed set. It's absence indicates that something changed in a way that is not supported by the client yet, in which case it must refuse to handle the request. */ +/** DeviceRequest is a request for devices required for a claim. This is typically a request for a single resource like a device, but can also ask for several identical devices. */ export interface DeviceRequest { adminAccess?: boolean | null; allocationMode?: string | null; + capacity?: CapacityRequirements | null; count?: number | null; - deviceClassName: string; + deviceClassName?: string | null; + firstAvailable?: Array | null; name: string; selectors?: Array | null; + tolerations?: Array | null; } export function toDeviceRequest(input: c.JSONValue): DeviceRequest { const obj = c.checkObj(input); return { adminAccess: c.readOpt(obj["adminAccess"], c.checkBool), allocationMode: c.readOpt(obj["allocationMode"], c.checkStr), + capacity: c.readOpt(obj["capacity"], toCapacityRequirements), count: c.readOpt(obj["count"], c.checkNum), - deviceClassName: c.checkStr(obj["deviceClassName"]), + deviceClassName: c.readOpt(obj["deviceClassName"], c.checkStr), + firstAvailable: c.readOpt(obj["firstAvailable"], x => c.readList(x, toDeviceSubRequest)), name: c.checkStr(obj["name"]), selectors: c.readOpt(obj["selectors"], x => c.readList(x, toDeviceSelector)), + tolerations: c.readOpt(obj["tolerations"], x => c.readList(x, toDeviceToleration)), }} export function fromDeviceRequest(input: DeviceRequest): c.JSONValue { return { ...input, + capacity: input.capacity != null ? fromCapacityRequirements(input.capacity) : undefined, + firstAvailable: input.firstAvailable?.map(fromDeviceSubRequest), + selectors: input.selectors?.map(fromDeviceSelector), + tolerations: input.tolerations?.map(fromDeviceToleration), + }} + +/** DeviceSubRequest describes a request for device provided in the claim.spec.devices.requests[].firstAvailable array. Each is typically a request for a single resource like a device, but can also ask for several identical devices. + +DeviceSubRequest is similar to Request, but doesn't expose the AdminAccess or FirstAvailable fields, as those can only be set on the top-level request. AdminAccess is not supported for requests with a prioritized list, and recursive FirstAvailable fields are not supported. */ +export interface DeviceSubRequest { + allocationMode?: string | null; + capacity?: CapacityRequirements | null; + count?: number | null; + deviceClassName: string; + name: string; + selectors?: Array | null; + tolerations?: Array | null; +} +export function toDeviceSubRequest(input: c.JSONValue): DeviceSubRequest { + const obj = c.checkObj(input); + return { + allocationMode: c.readOpt(obj["allocationMode"], c.checkStr), + capacity: c.readOpt(obj["capacity"], toCapacityRequirements), + count: c.readOpt(obj["count"], c.checkNum), + deviceClassName: c.checkStr(obj["deviceClassName"]), + name: c.checkStr(obj["name"]), + selectors: c.readOpt(obj["selectors"], x => c.readList(x, toDeviceSelector)), + tolerations: c.readOpt(obj["tolerations"], x => c.readList(x, toDeviceToleration)), + }} +export function fromDeviceSubRequest(input: DeviceSubRequest): c.JSONValue { + return { + ...input, + capacity: input.capacity != null ? fromCapacityRequirements(input.capacity) : undefined, selectors: input.selectors?.map(fromDeviceSelector), + tolerations: input.tolerations?.map(fromDeviceToleration), }} /** DeviceSelector must have exactly one field set. */ @@ -352,12 +595,14 @@ export function fromDeviceClass(input: DeviceClass): c.JSONValue { /** DeviceClassSpec is used in a [DeviceClass] to define what can be allocated and how to configure it. */ export interface DeviceClassSpec { config?: Array | null; + extendedResourceName?: string | null; selectors?: Array | null; } export function toDeviceClassSpec(input: c.JSONValue): DeviceClassSpec { const obj = c.checkObj(input); return { config: c.readOpt(obj["config"], x => c.readList(x, toDeviceClassConfiguration)), + extendedResourceName: c.readOpt(obj["extendedResourceName"], c.checkStr), selectors: c.readOpt(obj["selectors"], x => c.readList(x, toDeviceSelector)), }} export function fromDeviceClassSpec(input: DeviceClassSpec): c.JSONValue { @@ -603,7 +848,9 @@ export interface ResourceSliceSpec { driver: string; nodeName?: string | null; nodeSelector?: CoreV1.NodeSelector | null; + perDeviceNodeSelection?: boolean | null; pool: ResourcePool; + sharedCounters?: Array | null; } export function toResourceSliceSpec(input: c.JSONValue): ResourceSliceSpec { const obj = c.checkObj(input); @@ -613,7 +860,9 @@ export function toResourceSliceSpec(input: c.JSONValue): ResourceSliceSpec { driver: c.checkStr(obj["driver"]), nodeName: c.readOpt(obj["nodeName"], c.checkStr), nodeSelector: c.readOpt(obj["nodeSelector"], CoreV1.toNodeSelector), + perDeviceNodeSelection: c.readOpt(obj["perDeviceNodeSelection"], c.checkBool), pool: toResourcePool(obj["pool"]), + sharedCounters: c.readOpt(obj["sharedCounters"], x => c.readList(x, toCounterSet)), }} export function fromResourceSliceSpec(input: ResourceSliceSpec): c.JSONValue { return { @@ -621,6 +870,7 @@ export function fromResourceSliceSpec(input: ResourceSliceSpec): c.JSONValue { devices: input.devices?.map(fromDevice), nodeSelector: input.nodeSelector != null ? CoreV1.fromNodeSelector(input.nodeSelector) : undefined, pool: input.pool != null ? fromResourcePool(input.pool) : undefined, + sharedCounters: input.sharedCounters?.map(fromCounterSet), }} /** ResourceSliceList is a collection of ResourceSlices. */ diff --git a/lib/builtin/resource.k8s.io@v1beta2/mod.ts b/lib/builtin/resource.k8s.io@v1beta2/mod.ts new file mode 100644 index 0000000..5969900 --- /dev/null +++ b/lib/builtin/resource.k8s.io@v1beta2/mod.ts @@ -0,0 +1,603 @@ +export * from "./structs.ts"; + +// Autogenerated API file for ResourceV1beta2 +import * as c from "../../common.ts"; +import * as operations from "../../operations.ts"; +import * as MetaV1 from "../meta@v1/structs.ts"; +import * as ResourceV1beta2 from "./structs.ts"; + +export class ResourceV1beta2Api { + #client: c.RestClient; + #root = "/apis/resource.k8s.io/v1beta2/"; + constructor(client: c.RestClient) { + this.#client = client; + } + + namespace(name: string): ResourceV1beta2NamespacedApi { + return new ResourceV1beta2NamespacedApi(this.#client, name); + } + myNamespace(): ResourceV1beta2NamespacedApi { + if (!this.#client.defaultNamespace) throw new Error("No current namespace is set"); + return new ResourceV1beta2NamespacedApi(this.#client, this.#client.defaultNamespace); + } + + async getDeviceClassList( + opts: operations.GetListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}deviceclasses`, + expectJson: true, + querystring: operations.formatGetListOpts(opts), + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toDeviceClassList(resp); + } + + async watchDeviceClassList( + opts: operations.WatchListOpts = {}, + ): Promise> { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}deviceclasses`, + expectJson: true, + expectStream: true, + querystring: operations.formatWatchListOpts(opts), + abortSignal: opts.abortSignal, + }); + return resp.pipeThrough(new c.WatchEventTransformer(ResourceV1beta2.toDeviceClass, MetaV1.toStatus)); + } + + async createDeviceClass( + body: ResourceV1beta2.DeviceClass, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "POST", + path: `${this.#root}deviceclasses`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: ResourceV1beta2.fromDeviceClass(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toDeviceClass(resp); + } + + async deleteDeviceClassList( + opts: operations.DeleteListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}deviceclasses`, + expectJson: true, + querystring: operations.formatDeleteListOpts(opts), + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toDeviceClassList(resp); + } + + async getDeviceClass( + name: string, + opts: operations.NoOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}deviceclasses/${name}`, + expectJson: true, + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toDeviceClass(resp); + } + + async deleteDeviceClass( + name: string, + opts: operations.DeleteOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}deviceclasses/${name}`, + expectJson: true, + querystring: operations.formatDeleteOpts(opts), + abortSignal: opts.abortSignal, + }); + if (c.isStatusKind(resp)) return MetaV1.toStatus(resp); + return ResourceV1beta2.toDeviceClass(resp); + } + + async replaceDeviceClass( + name: string, + body: ResourceV1beta2.DeviceClass, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PUT", + path: `${this.#root}deviceclasses/${name}`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: ResourceV1beta2.fromDeviceClass(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toDeviceClass(resp); + } + + async patchDeviceClass( + name: string, + type: c.PatchType, + body: ResourceV1beta2.DeviceClass | c.JsonPatch, + opts: operations.PatchOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PATCH", + path: `${this.#root}deviceclasses/${name}`, + expectJson: true, + querystring: operations.formatPatchOpts(opts), + contentType: c.getPatchContentType(type), + bodyJson: Array.isArray(body) ? body : ResourceV1beta2.fromDeviceClass(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toDeviceClass(resp); + } + + async getResourceClaimListForAllNamespaces( + opts: operations.GetListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceclaims`, + expectJson: true, + querystring: operations.formatGetListOpts(opts), + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toResourceClaimList(resp); + } + + async watchResourceClaimListForAllNamespaces( + opts: operations.WatchListOpts = {}, + ): Promise> { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceclaims`, + expectJson: true, + expectStream: true, + querystring: operations.formatWatchListOpts(opts), + abortSignal: opts.abortSignal, + }); + return resp.pipeThrough(new c.WatchEventTransformer(ResourceV1beta2.toResourceClaim, MetaV1.toStatus)); + } + + async getResourceClaimTemplateListForAllNamespaces( + opts: operations.GetListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceclaimtemplates`, + expectJson: true, + querystring: operations.formatGetListOpts(opts), + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toResourceClaimTemplateList(resp); + } + + async watchResourceClaimTemplateListForAllNamespaces( + opts: operations.WatchListOpts = {}, + ): Promise> { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceclaimtemplates`, + expectJson: true, + expectStream: true, + querystring: operations.formatWatchListOpts(opts), + abortSignal: opts.abortSignal, + }); + return resp.pipeThrough(new c.WatchEventTransformer(ResourceV1beta2.toResourceClaimTemplate, MetaV1.toStatus)); + } + + async getResourceSliceList( + opts: operations.GetListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceslices`, + expectJson: true, + querystring: operations.formatGetListOpts(opts), + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toResourceSliceList(resp); + } + + async watchResourceSliceList( + opts: operations.WatchListOpts = {}, + ): Promise> { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceslices`, + expectJson: true, + expectStream: true, + querystring: operations.formatWatchListOpts(opts), + abortSignal: opts.abortSignal, + }); + return resp.pipeThrough(new c.WatchEventTransformer(ResourceV1beta2.toResourceSlice, MetaV1.toStatus)); + } + + async createResourceSlice( + body: ResourceV1beta2.ResourceSlice, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "POST", + path: `${this.#root}resourceslices`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: ResourceV1beta2.fromResourceSlice(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toResourceSlice(resp); + } + + async deleteResourceSliceList( + opts: operations.DeleteListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}resourceslices`, + expectJson: true, + querystring: operations.formatDeleteListOpts(opts), + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toResourceSliceList(resp); + } + + async getResourceSlice( + name: string, + opts: operations.NoOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceslices/${name}`, + expectJson: true, + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toResourceSlice(resp); + } + + async deleteResourceSlice( + name: string, + opts: operations.DeleteOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}resourceslices/${name}`, + expectJson: true, + querystring: operations.formatDeleteOpts(opts), + abortSignal: opts.abortSignal, + }); + if (c.isStatusKind(resp)) return MetaV1.toStatus(resp); + return ResourceV1beta2.toResourceSlice(resp); + } + + async replaceResourceSlice( + name: string, + body: ResourceV1beta2.ResourceSlice, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PUT", + path: `${this.#root}resourceslices/${name}`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: ResourceV1beta2.fromResourceSlice(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toResourceSlice(resp); + } + + async patchResourceSlice( + name: string, + type: c.PatchType, + body: ResourceV1beta2.ResourceSlice | c.JsonPatch, + opts: operations.PatchOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PATCH", + path: `${this.#root}resourceslices/${name}`, + expectJson: true, + querystring: operations.formatPatchOpts(opts), + contentType: c.getPatchContentType(type), + bodyJson: Array.isArray(body) ? body : ResourceV1beta2.fromResourceSlice(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toResourceSlice(resp); + } + +} + +export class ResourceV1beta2NamespacedApi { + #client: c.RestClient + #root: string + constructor(client: c.RestClient, namespace: string) { + this.#client = client; + this.#root = `/apis/resource.k8s.io/v1beta2/namespaces/${namespace}/`; + } + + async getResourceClaimList( + opts: operations.GetListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceclaims`, + expectJson: true, + querystring: operations.formatGetListOpts(opts), + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toResourceClaimList(resp); + } + + async watchResourceClaimList( + opts: operations.WatchListOpts = {}, + ): Promise> { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceclaims`, + expectJson: true, + expectStream: true, + querystring: operations.formatWatchListOpts(opts), + abortSignal: opts.abortSignal, + }); + return resp.pipeThrough(new c.WatchEventTransformer(ResourceV1beta2.toResourceClaim, MetaV1.toStatus)); + } + + async createResourceClaim( + body: ResourceV1beta2.ResourceClaim, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "POST", + path: `${this.#root}resourceclaims`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: ResourceV1beta2.fromResourceClaim(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toResourceClaim(resp); + } + + async deleteResourceClaimList( + opts: operations.DeleteListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}resourceclaims`, + expectJson: true, + querystring: operations.formatDeleteListOpts(opts), + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toResourceClaimList(resp); + } + + async getResourceClaim( + name: string, + opts: operations.NoOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceclaims/${name}`, + expectJson: true, + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toResourceClaim(resp); + } + + async deleteResourceClaim( + name: string, + opts: operations.DeleteOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}resourceclaims/${name}`, + expectJson: true, + querystring: operations.formatDeleteOpts(opts), + abortSignal: opts.abortSignal, + }); + if (c.isStatusKind(resp)) return MetaV1.toStatus(resp); + return ResourceV1beta2.toResourceClaim(resp); + } + + async replaceResourceClaim( + name: string, + body: ResourceV1beta2.ResourceClaim, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PUT", + path: `${this.#root}resourceclaims/${name}`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: ResourceV1beta2.fromResourceClaim(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toResourceClaim(resp); + } + + async patchResourceClaim( + name: string, + type: c.PatchType, + body: ResourceV1beta2.ResourceClaim | c.JsonPatch, + opts: operations.PatchOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PATCH", + path: `${this.#root}resourceclaims/${name}`, + expectJson: true, + querystring: operations.formatPatchOpts(opts), + contentType: c.getPatchContentType(type), + bodyJson: Array.isArray(body) ? body : ResourceV1beta2.fromResourceClaim(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toResourceClaim(resp); + } + + async getResourceClaimStatus( + name: string, + opts: operations.NoOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceclaims/${name}/status`, + expectJson: true, + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toResourceClaim(resp); + } + + async replaceResourceClaimStatus( + name: string, + body: ResourceV1beta2.ResourceClaim, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PUT", + path: `${this.#root}resourceclaims/${name}/status`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: ResourceV1beta2.fromResourceClaim(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toResourceClaim(resp); + } + + async patchResourceClaimStatus( + name: string, + type: c.PatchType, + body: ResourceV1beta2.ResourceClaim | c.JsonPatch, + opts: operations.PatchOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PATCH", + path: `${this.#root}resourceclaims/${name}/status`, + expectJson: true, + querystring: operations.formatPatchOpts(opts), + contentType: c.getPatchContentType(type), + bodyJson: Array.isArray(body) ? body : ResourceV1beta2.fromResourceClaim(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toResourceClaim(resp); + } + + async getResourceClaimTemplateList( + opts: operations.GetListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceclaimtemplates`, + expectJson: true, + querystring: operations.formatGetListOpts(opts), + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toResourceClaimTemplateList(resp); + } + + async watchResourceClaimTemplateList( + opts: operations.WatchListOpts = {}, + ): Promise> { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceclaimtemplates`, + expectJson: true, + expectStream: true, + querystring: operations.formatWatchListOpts(opts), + abortSignal: opts.abortSignal, + }); + return resp.pipeThrough(new c.WatchEventTransformer(ResourceV1beta2.toResourceClaimTemplate, MetaV1.toStatus)); + } + + async createResourceClaimTemplate( + body: ResourceV1beta2.ResourceClaimTemplate, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "POST", + path: `${this.#root}resourceclaimtemplates`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: ResourceV1beta2.fromResourceClaimTemplate(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toResourceClaimTemplate(resp); + } + + async deleteResourceClaimTemplateList( + opts: operations.DeleteListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}resourceclaimtemplates`, + expectJson: true, + querystring: operations.formatDeleteListOpts(opts), + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toResourceClaimTemplateList(resp); + } + + async getResourceClaimTemplate( + name: string, + opts: operations.NoOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}resourceclaimtemplates/${name}`, + expectJson: true, + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toResourceClaimTemplate(resp); + } + + async deleteResourceClaimTemplate( + name: string, + opts: operations.DeleteOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}resourceclaimtemplates/${name}`, + expectJson: true, + querystring: operations.formatDeleteOpts(opts), + abortSignal: opts.abortSignal, + }); + if (c.isStatusKind(resp)) return MetaV1.toStatus(resp); + return ResourceV1beta2.toResourceClaimTemplate(resp); + } + + async replaceResourceClaimTemplate( + name: string, + body: ResourceV1beta2.ResourceClaimTemplate, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PUT", + path: `${this.#root}resourceclaimtemplates/${name}`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: ResourceV1beta2.fromResourceClaimTemplate(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toResourceClaimTemplate(resp); + } + + async patchResourceClaimTemplate( + name: string, + type: c.PatchType, + body: ResourceV1beta2.ResourceClaimTemplate | c.JsonPatch, + opts: operations.PatchOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PATCH", + path: `${this.#root}resourceclaimtemplates/${name}`, + expectJson: true, + querystring: operations.formatPatchOpts(opts), + contentType: c.getPatchContentType(type), + bodyJson: Array.isArray(body) ? body : ResourceV1beta2.fromResourceClaimTemplate(body), + abortSignal: opts.abortSignal, + }); + return ResourceV1beta2.toResourceClaimTemplate(resp); + } + +} diff --git a/lib/builtin/resource.k8s.io@v1beta2/structs.ts b/lib/builtin/resource.k8s.io@v1beta2/structs.ts new file mode 100644 index 0000000..59ca59d --- /dev/null +++ b/lib/builtin/resource.k8s.io@v1beta2/structs.ts @@ -0,0 +1,887 @@ +// Autogenerated Schema file for ResourceV1beta2 +import * as c from "../../common.ts"; + +import * as CoreV1 from "../core@v1/structs.ts"; +import * as MetaV1 from "../meta@v1/structs.ts"; +type ListOf = { + metadata: MetaV1.ListMeta; + items: Array; +}; + +/** AllocatedDeviceStatus contains the status of an allocated device, if the driver chooses to report it. This may include driver-specific information. + +The combination of Driver, Pool, Device, and ShareID must match the corresponding key in Status.Allocation.Devices. */ +export interface AllocatedDeviceStatus { + conditions?: Array | null; + data?: c.JSONValue | null; + device: string; + driver: string; + networkData?: NetworkDeviceData | null; + pool: string; + shareID?: string | null; +} +export function toAllocatedDeviceStatus(input: c.JSONValue): AllocatedDeviceStatus { + const obj = c.checkObj(input); + return { + conditions: c.readOpt(obj["conditions"], x => c.readList(x, MetaV1.toCondition)), + data: c.readOpt(obj["data"], c.identity), + device: c.checkStr(obj["device"]), + driver: c.checkStr(obj["driver"]), + networkData: c.readOpt(obj["networkData"], toNetworkDeviceData), + pool: c.checkStr(obj["pool"]), + shareID: c.readOpt(obj["shareID"], c.checkStr), + }} +export function fromAllocatedDeviceStatus(input: AllocatedDeviceStatus): c.JSONValue { + return { + ...input, + conditions: input.conditions?.map(MetaV1.fromCondition), + networkData: input.networkData != null ? fromNetworkDeviceData(input.networkData) : undefined, + }} + +/** NetworkDeviceData provides network-related details for the allocated device. This information may be filled by drivers or other components to configure or identify the device within a network context. */ +export interface NetworkDeviceData { + hardwareAddress?: string | null; + interfaceName?: string | null; + ips?: Array | null; +} +export function toNetworkDeviceData(input: c.JSONValue): NetworkDeviceData { + const obj = c.checkObj(input); + return { + hardwareAddress: c.readOpt(obj["hardwareAddress"], c.checkStr), + interfaceName: c.readOpt(obj["interfaceName"], c.checkStr), + ips: c.readOpt(obj["ips"], x => c.readList(x, c.checkStr)), + }} +export function fromNetworkDeviceData(input: NetworkDeviceData): c.JSONValue { + return { + ...input, + }} + +/** AllocationResult contains attributes of an allocated resource. */ +export interface AllocationResult { + allocationTimestamp?: c.Time | null; + devices?: DeviceAllocationResult | null; + nodeSelector?: CoreV1.NodeSelector | null; +} +export function toAllocationResult(input: c.JSONValue): AllocationResult { + const obj = c.checkObj(input); + return { + allocationTimestamp: c.readOpt(obj["allocationTimestamp"], c.toTime), + devices: c.readOpt(obj["devices"], toDeviceAllocationResult), + nodeSelector: c.readOpt(obj["nodeSelector"], CoreV1.toNodeSelector), + }} +export function fromAllocationResult(input: AllocationResult): c.JSONValue { + return { + ...input, + allocationTimestamp: input.allocationTimestamp != null ? c.fromTime(input.allocationTimestamp) : undefined, + devices: input.devices != null ? fromDeviceAllocationResult(input.devices) : undefined, + nodeSelector: input.nodeSelector != null ? CoreV1.fromNodeSelector(input.nodeSelector) : undefined, + }} + +/** DeviceAllocationResult is the result of allocating devices. */ +export interface DeviceAllocationResult { + config?: Array | null; + results?: Array | null; +} +export function toDeviceAllocationResult(input: c.JSONValue): DeviceAllocationResult { + const obj = c.checkObj(input); + return { + config: c.readOpt(obj["config"], x => c.readList(x, toDeviceAllocationConfiguration)), + results: c.readOpt(obj["results"], x => c.readList(x, toDeviceRequestAllocationResult)), + }} +export function fromDeviceAllocationResult(input: DeviceAllocationResult): c.JSONValue { + return { + ...input, + config: input.config?.map(fromDeviceAllocationConfiguration), + results: input.results?.map(fromDeviceRequestAllocationResult), + }} + +/** DeviceAllocationConfiguration gets embedded in an AllocationResult. */ +export interface DeviceAllocationConfiguration { + opaque?: OpaqueDeviceConfiguration | null; + requests?: Array | null; + source: string; +} +export function toDeviceAllocationConfiguration(input: c.JSONValue): DeviceAllocationConfiguration { + const obj = c.checkObj(input); + return { + opaque: c.readOpt(obj["opaque"], toOpaqueDeviceConfiguration), + requests: c.readOpt(obj["requests"], x => c.readList(x, c.checkStr)), + source: c.checkStr(obj["source"]), + }} +export function fromDeviceAllocationConfiguration(input: DeviceAllocationConfiguration): c.JSONValue { + return { + ...input, + opaque: input.opaque != null ? fromOpaqueDeviceConfiguration(input.opaque) : undefined, + }} + +/** OpaqueDeviceConfiguration contains configuration parameters for a driver in a format defined by the driver vendor. */ +export interface OpaqueDeviceConfiguration { + driver: string; + parameters: c.JSONValue; +} +export function toOpaqueDeviceConfiguration(input: c.JSONValue): OpaqueDeviceConfiguration { + const obj = c.checkObj(input); + return { + driver: c.checkStr(obj["driver"]), + parameters: c.identity(obj["parameters"]), + }} +export function fromOpaqueDeviceConfiguration(input: OpaqueDeviceConfiguration): c.JSONValue { + return { + ...input, + }} + +/** DeviceRequestAllocationResult contains the allocation result for one request. */ +export interface DeviceRequestAllocationResult { + adminAccess?: boolean | null; + bindingConditions?: Array | null; + bindingFailureConditions?: Array | null; + consumedCapacity?: Record | null; + device: string; + driver: string; + pool: string; + request: string; + shareID?: string | null; + tolerations?: Array | null; +} +export function toDeviceRequestAllocationResult(input: c.JSONValue): DeviceRequestAllocationResult { + const obj = c.checkObj(input); + return { + adminAccess: c.readOpt(obj["adminAccess"], c.checkBool), + bindingConditions: c.readOpt(obj["bindingConditions"], x => c.readList(x, c.checkStr)), + bindingFailureConditions: c.readOpt(obj["bindingFailureConditions"], x => c.readList(x, c.checkStr)), + consumedCapacity: c.readOpt(obj["consumedCapacity"], x => c.readMap(x, c.toQuantity)), + device: c.checkStr(obj["device"]), + driver: c.checkStr(obj["driver"]), + pool: c.checkStr(obj["pool"]), + request: c.checkStr(obj["request"]), + shareID: c.readOpt(obj["shareID"], c.checkStr), + tolerations: c.readOpt(obj["tolerations"], x => c.readList(x, toDeviceToleration)), + }} +export function fromDeviceRequestAllocationResult(input: DeviceRequestAllocationResult): c.JSONValue { + return { + ...input, + consumedCapacity: c.writeMap(input.consumedCapacity, c.fromQuantity), + tolerations: input.tolerations?.map(fromDeviceToleration), + }} + +/** The ResourceClaim this DeviceToleration is attached to tolerates any taint that matches the triple using the matching operator . */ +export interface DeviceToleration { + effect?: string | null; + key?: string | null; + operator?: string | null; + tolerationSeconds?: number | null; + value?: string | null; +} +export function toDeviceToleration(input: c.JSONValue): DeviceToleration { + const obj = c.checkObj(input); + return { + effect: c.readOpt(obj["effect"], c.checkStr), + key: c.readOpt(obj["key"], c.checkStr), + operator: c.readOpt(obj["operator"], c.checkStr), + tolerationSeconds: c.readOpt(obj["tolerationSeconds"], c.checkNum), + value: c.readOpt(obj["value"], c.checkStr), + }} +export function fromDeviceToleration(input: DeviceToleration): c.JSONValue { + return { + ...input, + }} + +/** CELDeviceSelector contains a CEL expression for selecting a device. */ +export interface CELDeviceSelector { + expression: string; +} +export function toCELDeviceSelector(input: c.JSONValue): CELDeviceSelector { + const obj = c.checkObj(input); + return { + expression: c.checkStr(obj["expression"]), + }} +export function fromCELDeviceSelector(input: CELDeviceSelector): c.JSONValue { + return { + ...input, + }} + +/** CapacityRequestPolicy defines how requests consume device capacity. + +Must not set more than one ValidRequestValues. */ +export interface CapacityRequestPolicy { + default?: c.Quantity | null; + validRange?: CapacityRequestPolicyRange | null; + validValues?: Array | null; +} +export function toCapacityRequestPolicy(input: c.JSONValue): CapacityRequestPolicy { + const obj = c.checkObj(input); + return { + default: c.readOpt(obj["default"], c.toQuantity), + validRange: c.readOpt(obj["validRange"], toCapacityRequestPolicyRange), + validValues: c.readOpt(obj["validValues"], x => c.readList(x, c.toQuantity)), + }} +export function fromCapacityRequestPolicy(input: CapacityRequestPolicy): c.JSONValue { + return { + ...input, + default: input.default != null ? c.fromQuantity(input.default) : undefined, + validRange: input.validRange != null ? fromCapacityRequestPolicyRange(input.validRange) : undefined, + validValues: input.validValues?.map(c.fromQuantity), + }} + +/** CapacityRequestPolicyRange defines a valid range for consumable capacity values. + + - If the requested amount is less than Min, it is rounded up to the Min value. + - If Step is set and the requested amount is between Min and Max but not aligned with Step, + it will be rounded up to the next value equal to Min + (n * Step). + - If Step is not set, the requested amount is used as-is if it falls within the range Min to Max (if set). + - If the requested or rounded amount exceeds Max (if set), the request does not satisfy the policy, + and the device cannot be allocated. */ +export interface CapacityRequestPolicyRange { + max?: c.Quantity | null; + min: c.Quantity; + step?: c.Quantity | null; +} +export function toCapacityRequestPolicyRange(input: c.JSONValue): CapacityRequestPolicyRange { + const obj = c.checkObj(input); + return { + max: c.readOpt(obj["max"], c.toQuantity), + min: c.toQuantity(obj["min"]), + step: c.readOpt(obj["step"], c.toQuantity), + }} +export function fromCapacityRequestPolicyRange(input: CapacityRequestPolicyRange): c.JSONValue { + return { + ...input, + max: input.max != null ? c.fromQuantity(input.max) : undefined, + min: input.min != null ? c.fromQuantity(input.min) : undefined, + step: input.step != null ? c.fromQuantity(input.step) : undefined, + }} + +/** CapacityRequirements defines the capacity requirements for a specific device request. */ +export interface CapacityRequirements { + requests?: Record | null; +} +export function toCapacityRequirements(input: c.JSONValue): CapacityRequirements { + const obj = c.checkObj(input); + return { + requests: c.readOpt(obj["requests"], x => c.readMap(x, c.toQuantity)), + }} +export function fromCapacityRequirements(input: CapacityRequirements): c.JSONValue { + return { + ...input, + requests: c.writeMap(input.requests, c.fromQuantity), + }} + +/** Counter describes a quantity associated with a device. */ +export interface Counter { + value: c.Quantity; +} +export function toCounter(input: c.JSONValue): Counter { + const obj = c.checkObj(input); + return { + value: c.toQuantity(obj["value"]), + }} +export function fromCounter(input: Counter): c.JSONValue { + return { + ...input, + value: input.value != null ? c.fromQuantity(input.value) : undefined, + }} + +/** CounterSet defines a named set of counters that are available to be used by devices defined in the ResourceSlice. + +The counters are not allocatable by themselves, but can be referenced by devices. When a device is allocated, the portion of counters it uses will no longer be available for use by other devices. */ +export interface CounterSet { + counters: Record; + name: string; +} +export function toCounterSet(input: c.JSONValue): CounterSet { + const obj = c.checkObj(input); + return { + counters: c.readMap(obj["counters"], toCounter), + name: c.checkStr(obj["name"]), + }} +export function fromCounterSet(input: CounterSet): c.JSONValue { + return { + ...input, + counters: c.writeMap(input.counters, fromCounter), + }} + +/** Device represents one individual hardware instance that can be selected based on its attributes. Besides the name, exactly one field must be set. */ +export interface Device { + allNodes?: boolean | null; + allowMultipleAllocations?: boolean | null; + attributes?: Record | null; + bindingConditions?: Array | null; + bindingFailureConditions?: Array | null; + bindsToNode?: boolean | null; + capacity?: Record | null; + consumesCounters?: Array | null; + name: string; + nodeName?: string | null; + nodeSelector?: CoreV1.NodeSelector | null; + taints?: Array | null; +} +export function toDevice(input: c.JSONValue): Device { + const obj = c.checkObj(input); + return { + allNodes: c.readOpt(obj["allNodes"], c.checkBool), + allowMultipleAllocations: c.readOpt(obj["allowMultipleAllocations"], c.checkBool), + attributes: c.readOpt(obj["attributes"], x => c.readMap(x, toDeviceAttribute)), + bindingConditions: c.readOpt(obj["bindingConditions"], x => c.readList(x, c.checkStr)), + bindingFailureConditions: c.readOpt(obj["bindingFailureConditions"], x => c.readList(x, c.checkStr)), + bindsToNode: c.readOpt(obj["bindsToNode"], c.checkBool), + capacity: c.readOpt(obj["capacity"], x => c.readMap(x, toDeviceCapacity)), + consumesCounters: c.readOpt(obj["consumesCounters"], x => c.readList(x, toDeviceCounterConsumption)), + name: c.checkStr(obj["name"]), + nodeName: c.readOpt(obj["nodeName"], c.checkStr), + nodeSelector: c.readOpt(obj["nodeSelector"], CoreV1.toNodeSelector), + taints: c.readOpt(obj["taints"], x => c.readList(x, toDeviceTaint)), + }} +export function fromDevice(input: Device): c.JSONValue { + return { + ...input, + attributes: c.writeMap(input.attributes, fromDeviceAttribute), + capacity: c.writeMap(input.capacity, fromDeviceCapacity), + consumesCounters: input.consumesCounters?.map(fromDeviceCounterConsumption), + nodeSelector: input.nodeSelector != null ? CoreV1.fromNodeSelector(input.nodeSelector) : undefined, + taints: input.taints?.map(fromDeviceTaint), + }} + +/** DeviceAttribute must have exactly one field set. */ +export interface DeviceAttribute { + bool?: boolean | null; + int?: number | null; + string?: string | null; + version?: string | null; +} +export function toDeviceAttribute(input: c.JSONValue): DeviceAttribute { + const obj = c.checkObj(input); + return { + bool: c.readOpt(obj["bool"], c.checkBool), + int: c.readOpt(obj["int"], c.checkNum), + string: c.readOpt(obj["string"], c.checkStr), + version: c.readOpt(obj["version"], c.checkStr), + }} +export function fromDeviceAttribute(input: DeviceAttribute): c.JSONValue { + return { + ...input, + }} + +/** DeviceCapacity describes a quantity associated with a device. */ +export interface DeviceCapacity { + requestPolicy?: CapacityRequestPolicy | null; + value: c.Quantity; +} +export function toDeviceCapacity(input: c.JSONValue): DeviceCapacity { + const obj = c.checkObj(input); + return { + requestPolicy: c.readOpt(obj["requestPolicy"], toCapacityRequestPolicy), + value: c.toQuantity(obj["value"]), + }} +export function fromDeviceCapacity(input: DeviceCapacity): c.JSONValue { + return { + ...input, + requestPolicy: input.requestPolicy != null ? fromCapacityRequestPolicy(input.requestPolicy) : undefined, + value: input.value != null ? c.fromQuantity(input.value) : undefined, + }} + +/** DeviceCounterConsumption defines a set of counters that a device will consume from a CounterSet. */ +export interface DeviceCounterConsumption { + counterSet: string; + counters: Record; +} +export function toDeviceCounterConsumption(input: c.JSONValue): DeviceCounterConsumption { + const obj = c.checkObj(input); + return { + counterSet: c.checkStr(obj["counterSet"]), + counters: c.readMap(obj["counters"], toCounter), + }} +export function fromDeviceCounterConsumption(input: DeviceCounterConsumption): c.JSONValue { + return { + ...input, + counters: c.writeMap(input.counters, fromCounter), + }} + +/** The device this taint is attached to has the "effect" on any claim which does not tolerate the taint and, through the claim, to pods using the claim. */ +export interface DeviceTaint { + effect: string; + key: string; + timeAdded?: c.Time | null; + value?: string | null; +} +export function toDeviceTaint(input: c.JSONValue): DeviceTaint { + const obj = c.checkObj(input); + return { + effect: c.checkStr(obj["effect"]), + key: c.checkStr(obj["key"]), + timeAdded: c.readOpt(obj["timeAdded"], c.toTime), + value: c.readOpt(obj["value"], c.checkStr), + }} +export function fromDeviceTaint(input: DeviceTaint): c.JSONValue { + return { + ...input, + timeAdded: input.timeAdded != null ? c.fromTime(input.timeAdded) : undefined, + }} + +/** DeviceClaim defines how to request devices with a ResourceClaim. */ +export interface DeviceClaim { + config?: Array | null; + constraints?: Array | null; + requests?: Array | null; +} +export function toDeviceClaim(input: c.JSONValue): DeviceClaim { + const obj = c.checkObj(input); + return { + config: c.readOpt(obj["config"], x => c.readList(x, toDeviceClaimConfiguration)), + constraints: c.readOpt(obj["constraints"], x => c.readList(x, toDeviceConstraint)), + requests: c.readOpt(obj["requests"], x => c.readList(x, toDeviceRequest)), + }} +export function fromDeviceClaim(input: DeviceClaim): c.JSONValue { + return { + ...input, + config: input.config?.map(fromDeviceClaimConfiguration), + constraints: input.constraints?.map(fromDeviceConstraint), + requests: input.requests?.map(fromDeviceRequest), + }} + +/** DeviceClaimConfiguration is used for configuration parameters in DeviceClaim. */ +export interface DeviceClaimConfiguration { + opaque?: OpaqueDeviceConfiguration | null; + requests?: Array | null; +} +export function toDeviceClaimConfiguration(input: c.JSONValue): DeviceClaimConfiguration { + const obj = c.checkObj(input); + return { + opaque: c.readOpt(obj["opaque"], toOpaqueDeviceConfiguration), + requests: c.readOpt(obj["requests"], x => c.readList(x, c.checkStr)), + }} +export function fromDeviceClaimConfiguration(input: DeviceClaimConfiguration): c.JSONValue { + return { + ...input, + opaque: input.opaque != null ? fromOpaqueDeviceConfiguration(input.opaque) : undefined, + }} + +/** DeviceConstraint must have exactly one field set besides Requests. */ +export interface DeviceConstraint { + distinctAttribute?: string | null; + matchAttribute?: string | null; + requests?: Array | null; +} +export function toDeviceConstraint(input: c.JSONValue): DeviceConstraint { + const obj = c.checkObj(input); + return { + distinctAttribute: c.readOpt(obj["distinctAttribute"], c.checkStr), + matchAttribute: c.readOpt(obj["matchAttribute"], c.checkStr), + requests: c.readOpt(obj["requests"], x => c.readList(x, c.checkStr)), + }} +export function fromDeviceConstraint(input: DeviceConstraint): c.JSONValue { + return { + ...input, + }} + +/** DeviceRequest is a request for devices required for a claim. This is typically a request for a single resource like a device, but can also ask for several identical devices. With FirstAvailable it is also possible to provide a prioritized list of requests. */ +export interface DeviceRequest { + exactly?: ExactDeviceRequest | null; + firstAvailable?: Array | null; + name: string; +} +export function toDeviceRequest(input: c.JSONValue): DeviceRequest { + const obj = c.checkObj(input); + return { + exactly: c.readOpt(obj["exactly"], toExactDeviceRequest), + firstAvailable: c.readOpt(obj["firstAvailable"], x => c.readList(x, toDeviceSubRequest)), + name: c.checkStr(obj["name"]), + }} +export function fromDeviceRequest(input: DeviceRequest): c.JSONValue { + return { + ...input, + exactly: input.exactly != null ? fromExactDeviceRequest(input.exactly) : undefined, + firstAvailable: input.firstAvailable?.map(fromDeviceSubRequest), + }} + +/** ExactDeviceRequest is a request for one or more identical devices. */ +export interface ExactDeviceRequest { + adminAccess?: boolean | null; + allocationMode?: string | null; + capacity?: CapacityRequirements | null; + count?: number | null; + deviceClassName: string; + selectors?: Array | null; + tolerations?: Array | null; +} +export function toExactDeviceRequest(input: c.JSONValue): ExactDeviceRequest { + const obj = c.checkObj(input); + return { + adminAccess: c.readOpt(obj["adminAccess"], c.checkBool), + allocationMode: c.readOpt(obj["allocationMode"], c.checkStr), + capacity: c.readOpt(obj["capacity"], toCapacityRequirements), + count: c.readOpt(obj["count"], c.checkNum), + deviceClassName: c.checkStr(obj["deviceClassName"]), + selectors: c.readOpt(obj["selectors"], x => c.readList(x, toDeviceSelector)), + tolerations: c.readOpt(obj["tolerations"], x => c.readList(x, toDeviceToleration)), + }} +export function fromExactDeviceRequest(input: ExactDeviceRequest): c.JSONValue { + return { + ...input, + capacity: input.capacity != null ? fromCapacityRequirements(input.capacity) : undefined, + selectors: input.selectors?.map(fromDeviceSelector), + tolerations: input.tolerations?.map(fromDeviceToleration), + }} + +/** DeviceSelector must have exactly one field set. */ +export interface DeviceSelector { + cel?: CELDeviceSelector | null; +} +export function toDeviceSelector(input: c.JSONValue): DeviceSelector { + const obj = c.checkObj(input); + return { + cel: c.readOpt(obj["cel"], toCELDeviceSelector), + }} +export function fromDeviceSelector(input: DeviceSelector): c.JSONValue { + return { + ...input, + cel: input.cel != null ? fromCELDeviceSelector(input.cel) : undefined, + }} + +/** DeviceSubRequest describes a request for device provided in the claim.spec.devices.requests[].firstAvailable array. Each is typically a request for a single resource like a device, but can also ask for several identical devices. + +DeviceSubRequest is similar to ExactDeviceRequest, but doesn't expose the AdminAccess field as that one is only supported when requesting a specific device. */ +export interface DeviceSubRequest { + allocationMode?: string | null; + capacity?: CapacityRequirements | null; + count?: number | null; + deviceClassName: string; + name: string; + selectors?: Array | null; + tolerations?: Array | null; +} +export function toDeviceSubRequest(input: c.JSONValue): DeviceSubRequest { + const obj = c.checkObj(input); + return { + allocationMode: c.readOpt(obj["allocationMode"], c.checkStr), + capacity: c.readOpt(obj["capacity"], toCapacityRequirements), + count: c.readOpt(obj["count"], c.checkNum), + deviceClassName: c.checkStr(obj["deviceClassName"]), + name: c.checkStr(obj["name"]), + selectors: c.readOpt(obj["selectors"], x => c.readList(x, toDeviceSelector)), + tolerations: c.readOpt(obj["tolerations"], x => c.readList(x, toDeviceToleration)), + }} +export function fromDeviceSubRequest(input: DeviceSubRequest): c.JSONValue { + return { + ...input, + capacity: input.capacity != null ? fromCapacityRequirements(input.capacity) : undefined, + selectors: input.selectors?.map(fromDeviceSelector), + tolerations: input.tolerations?.map(fromDeviceToleration), + }} + +/** DeviceClass is a vendor- or admin-provided resource that contains device configuration and selectors. It can be referenced in the device requests of a claim to apply these presets. Cluster scoped. + +This is an alpha type and requires enabling the DynamicResourceAllocation feature gate. */ +export interface DeviceClass { + apiVersion?: "resource.k8s.io/v1beta2"; + kind?: "DeviceClass"; + metadata?: MetaV1.ObjectMeta | null; + spec: DeviceClassSpec; +} +export function toDeviceClass(input: c.JSONValue): DeviceClass & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1beta2", "DeviceClass"), + metadata: c.readOpt(obj["metadata"], MetaV1.toObjectMeta), + spec: toDeviceClassSpec(obj["spec"]), + }} +export function fromDeviceClass(input: DeviceClass): c.JSONValue { + return { + ...c.assertOrAddApiVersionAndKind(input, "resource.k8s.io/v1beta2", "DeviceClass"), + ...input, + metadata: input.metadata != null ? MetaV1.fromObjectMeta(input.metadata) : undefined, + spec: input.spec != null ? fromDeviceClassSpec(input.spec) : undefined, + }} + +/** DeviceClassSpec is used in a [DeviceClass] to define what can be allocated and how to configure it. */ +export interface DeviceClassSpec { + config?: Array | null; + extendedResourceName?: string | null; + selectors?: Array | null; +} +export function toDeviceClassSpec(input: c.JSONValue): DeviceClassSpec { + const obj = c.checkObj(input); + return { + config: c.readOpt(obj["config"], x => c.readList(x, toDeviceClassConfiguration)), + extendedResourceName: c.readOpt(obj["extendedResourceName"], c.checkStr), + selectors: c.readOpt(obj["selectors"], x => c.readList(x, toDeviceSelector)), + }} +export function fromDeviceClassSpec(input: DeviceClassSpec): c.JSONValue { + return { + ...input, + config: input.config?.map(fromDeviceClassConfiguration), + selectors: input.selectors?.map(fromDeviceSelector), + }} + +/** DeviceClassConfiguration is used in DeviceClass. */ +export interface DeviceClassConfiguration { + opaque?: OpaqueDeviceConfiguration | null; +} +export function toDeviceClassConfiguration(input: c.JSONValue): DeviceClassConfiguration { + const obj = c.checkObj(input); + return { + opaque: c.readOpt(obj["opaque"], toOpaqueDeviceConfiguration), + }} +export function fromDeviceClassConfiguration(input: DeviceClassConfiguration): c.JSONValue { + return { + ...input, + opaque: input.opaque != null ? fromOpaqueDeviceConfiguration(input.opaque) : undefined, + }} + +/** DeviceClassList is a collection of classes. */ +export interface DeviceClassList extends ListOf { + apiVersion?: "resource.k8s.io/v1beta2"; + kind?: "DeviceClassList"; +}; +export function toDeviceClassList(input: c.JSONValue): DeviceClassList & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1beta2", "DeviceClassList"), + metadata: MetaV1.toListMeta(obj.metadata), + items: c.readList(obj.items, toDeviceClass), + }} + +/** ResourceClaim describes a request for access to resources in the cluster, for use by workloads. For example, if a workload needs an accelerator device with specific properties, this is how that request is expressed. The status stanza tracks whether this claim has been satisfied and what specific resources have been allocated. + +This is an alpha type and requires enabling the DynamicResourceAllocation feature gate. */ +export interface ResourceClaim { + apiVersion?: "resource.k8s.io/v1beta2"; + kind?: "ResourceClaim"; + metadata?: MetaV1.ObjectMeta | null; + spec: ResourceClaimSpec; + status?: ResourceClaimStatus | null; +} +export function toResourceClaim(input: c.JSONValue): ResourceClaim & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1beta2", "ResourceClaim"), + metadata: c.readOpt(obj["metadata"], MetaV1.toObjectMeta), + spec: toResourceClaimSpec(obj["spec"]), + status: c.readOpt(obj["status"], toResourceClaimStatus), + }} +export function fromResourceClaim(input: ResourceClaim): c.JSONValue { + return { + ...c.assertOrAddApiVersionAndKind(input, "resource.k8s.io/v1beta2", "ResourceClaim"), + ...input, + metadata: input.metadata != null ? MetaV1.fromObjectMeta(input.metadata) : undefined, + spec: input.spec != null ? fromResourceClaimSpec(input.spec) : undefined, + status: input.status != null ? fromResourceClaimStatus(input.status) : undefined, + }} + +/** ResourceClaimSpec defines what is being requested in a ResourceClaim and how to configure it. */ +export interface ResourceClaimSpec { + devices?: DeviceClaim | null; +} +export function toResourceClaimSpec(input: c.JSONValue): ResourceClaimSpec { + const obj = c.checkObj(input); + return { + devices: c.readOpt(obj["devices"], toDeviceClaim), + }} +export function fromResourceClaimSpec(input: ResourceClaimSpec): c.JSONValue { + return { + ...input, + devices: input.devices != null ? fromDeviceClaim(input.devices) : undefined, + }} + +/** ResourceClaimStatus tracks whether the resource has been allocated and what the result of that was. */ +export interface ResourceClaimStatus { + allocation?: AllocationResult | null; + devices?: Array | null; + reservedFor?: Array | null; +} +export function toResourceClaimStatus(input: c.JSONValue): ResourceClaimStatus { + const obj = c.checkObj(input); + return { + allocation: c.readOpt(obj["allocation"], toAllocationResult), + devices: c.readOpt(obj["devices"], x => c.readList(x, toAllocatedDeviceStatus)), + reservedFor: c.readOpt(obj["reservedFor"], x => c.readList(x, toResourceClaimConsumerReference)), + }} +export function fromResourceClaimStatus(input: ResourceClaimStatus): c.JSONValue { + return { + ...input, + allocation: input.allocation != null ? fromAllocationResult(input.allocation) : undefined, + devices: input.devices?.map(fromAllocatedDeviceStatus), + reservedFor: input.reservedFor?.map(fromResourceClaimConsumerReference), + }} + +/** ResourceClaimConsumerReference contains enough information to let you locate the consumer of a ResourceClaim. The user must be a resource in the same namespace as the ResourceClaim. */ +export interface ResourceClaimConsumerReference { + apiGroup?: string | null; + name: string; + resource: string; + uid: string; +} +export function toResourceClaimConsumerReference(input: c.JSONValue): ResourceClaimConsumerReference { + const obj = c.checkObj(input); + return { + apiGroup: c.readOpt(obj["apiGroup"], c.checkStr), + name: c.checkStr(obj["name"]), + resource: c.checkStr(obj["resource"]), + uid: c.checkStr(obj["uid"]), + }} +export function fromResourceClaimConsumerReference(input: ResourceClaimConsumerReference): c.JSONValue { + return { + ...input, + }} + +/** ResourceClaimList is a collection of claims. */ +export interface ResourceClaimList extends ListOf { + apiVersion?: "resource.k8s.io/v1beta2"; + kind?: "ResourceClaimList"; +}; +export function toResourceClaimList(input: c.JSONValue): ResourceClaimList & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1beta2", "ResourceClaimList"), + metadata: MetaV1.toListMeta(obj.metadata), + items: c.readList(obj.items, toResourceClaim), + }} + +/** ResourceClaimTemplate is used to produce ResourceClaim objects. + +This is an alpha type and requires enabling the DynamicResourceAllocation feature gate. */ +export interface ResourceClaimTemplate { + apiVersion?: "resource.k8s.io/v1beta2"; + kind?: "ResourceClaimTemplate"; + metadata?: MetaV1.ObjectMeta | null; + spec: ResourceClaimTemplateSpec; +} +export function toResourceClaimTemplate(input: c.JSONValue): ResourceClaimTemplate & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1beta2", "ResourceClaimTemplate"), + metadata: c.readOpt(obj["metadata"], MetaV1.toObjectMeta), + spec: toResourceClaimTemplateSpec(obj["spec"]), + }} +export function fromResourceClaimTemplate(input: ResourceClaimTemplate): c.JSONValue { + return { + ...c.assertOrAddApiVersionAndKind(input, "resource.k8s.io/v1beta2", "ResourceClaimTemplate"), + ...input, + metadata: input.metadata != null ? MetaV1.fromObjectMeta(input.metadata) : undefined, + spec: input.spec != null ? fromResourceClaimTemplateSpec(input.spec) : undefined, + }} + +/** ResourceClaimTemplateSpec contains the metadata and fields for a ResourceClaim. */ +export interface ResourceClaimTemplateSpec { + metadata?: MetaV1.ObjectMeta | null; + spec: ResourceClaimSpec; +} +export function toResourceClaimTemplateSpec(input: c.JSONValue): ResourceClaimTemplateSpec { + const obj = c.checkObj(input); + return { + metadata: c.readOpt(obj["metadata"], MetaV1.toObjectMeta), + spec: toResourceClaimSpec(obj["spec"]), + }} +export function fromResourceClaimTemplateSpec(input: ResourceClaimTemplateSpec): c.JSONValue { + return { + ...input, + metadata: input.metadata != null ? MetaV1.fromObjectMeta(input.metadata) : undefined, + spec: input.spec != null ? fromResourceClaimSpec(input.spec) : undefined, + }} + +/** ResourceClaimTemplateList is a collection of claim templates. */ +export interface ResourceClaimTemplateList extends ListOf { + apiVersion?: "resource.k8s.io/v1beta2"; + kind?: "ResourceClaimTemplateList"; +}; +export function toResourceClaimTemplateList(input: c.JSONValue): ResourceClaimTemplateList & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1beta2", "ResourceClaimTemplateList"), + metadata: MetaV1.toListMeta(obj.metadata), + items: c.readList(obj.items, toResourceClaimTemplate), + }} + +/** ResourcePool describes the pool that ResourceSlices belong to. */ +export interface ResourcePool { + generation: number; + name: string; + resourceSliceCount: number; +} +export function toResourcePool(input: c.JSONValue): ResourcePool { + const obj = c.checkObj(input); + return { + generation: c.checkNum(obj["generation"]), + name: c.checkStr(obj["name"]), + resourceSliceCount: c.checkNum(obj["resourceSliceCount"]), + }} +export function fromResourcePool(input: ResourcePool): c.JSONValue { + return { + ...input, + }} + +/** ResourceSlice represents one or more resources in a pool of similar resources, managed by a common driver. A pool may span more than one ResourceSlice, and exactly how many ResourceSlices comprise a pool is determined by the driver. + +At the moment, the only supported resources are devices with attributes and capacities. Each device in a given pool, regardless of how many ResourceSlices, must have a unique name. The ResourceSlice in which a device gets published may change over time. The unique identifier for a device is the tuple , , . + +Whenever a driver needs to update a pool, it increments the pool.Spec.Pool.Generation number and updates all ResourceSlices with that new number and new resource definitions. A consumer must only use ResourceSlices with the highest generation number and ignore all others. + +When allocating all resources in a pool matching certain criteria or when looking for the best solution among several different alternatives, a consumer should check the number of ResourceSlices in a pool (included in each ResourceSlice) to determine whether its view of a pool is complete and if not, should wait until the driver has completed updating the pool. + +For resources that are not local to a node, the node name is not set. Instead, the driver may use a node selector to specify where the devices are available. + +This is an alpha type and requires enabling the DynamicResourceAllocation feature gate. */ +export interface ResourceSlice { + apiVersion?: "resource.k8s.io/v1beta2"; + kind?: "ResourceSlice"; + metadata?: MetaV1.ObjectMeta | null; + spec: ResourceSliceSpec; +} +export function toResourceSlice(input: c.JSONValue): ResourceSlice & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1beta2", "ResourceSlice"), + metadata: c.readOpt(obj["metadata"], MetaV1.toObjectMeta), + spec: toResourceSliceSpec(obj["spec"]), + }} +export function fromResourceSlice(input: ResourceSlice): c.JSONValue { + return { + ...c.assertOrAddApiVersionAndKind(input, "resource.k8s.io/v1beta2", "ResourceSlice"), + ...input, + metadata: input.metadata != null ? MetaV1.fromObjectMeta(input.metadata) : undefined, + spec: input.spec != null ? fromResourceSliceSpec(input.spec) : undefined, + }} + +/** ResourceSliceSpec contains the information published by the driver in one ResourceSlice. */ +export interface ResourceSliceSpec { + allNodes?: boolean | null; + devices?: Array | null; + driver: string; + nodeName?: string | null; + nodeSelector?: CoreV1.NodeSelector | null; + perDeviceNodeSelection?: boolean | null; + pool: ResourcePool; + sharedCounters?: Array | null; +} +export function toResourceSliceSpec(input: c.JSONValue): ResourceSliceSpec { + const obj = c.checkObj(input); + return { + allNodes: c.readOpt(obj["allNodes"], c.checkBool), + devices: c.readOpt(obj["devices"], x => c.readList(x, toDevice)), + driver: c.checkStr(obj["driver"]), + nodeName: c.readOpt(obj["nodeName"], c.checkStr), + nodeSelector: c.readOpt(obj["nodeSelector"], CoreV1.toNodeSelector), + perDeviceNodeSelection: c.readOpt(obj["perDeviceNodeSelection"], c.checkBool), + pool: toResourcePool(obj["pool"]), + sharedCounters: c.readOpt(obj["sharedCounters"], x => c.readList(x, toCounterSet)), + }} +export function fromResourceSliceSpec(input: ResourceSliceSpec): c.JSONValue { + return { + ...input, + devices: input.devices?.map(fromDevice), + nodeSelector: input.nodeSelector != null ? CoreV1.fromNodeSelector(input.nodeSelector) : undefined, + pool: input.pool != null ? fromResourcePool(input.pool) : undefined, + sharedCounters: input.sharedCounters?.map(fromCounterSet), + }} + +/** ResourceSliceList is a collection of ResourceSlices. */ +export interface ResourceSliceList extends ListOf { + apiVersion?: "resource.k8s.io/v1beta2"; + kind?: "ResourceSliceList"; +}; +export function toResourceSliceList(input: c.JSONValue): ResourceSliceList & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "resource.k8s.io/v1beta2", "ResourceSliceList"), + metadata: MetaV1.toListMeta(obj.metadata), + items: c.readList(obj.items, toResourceSlice), + }} diff --git a/lib/builtin/storage.k8s.io@v1/mod.ts b/lib/builtin/storage.k8s.io@v1/mod.ts index 40fee83..8e467fc 100644 --- a/lib/builtin/storage.k8s.io@v1/mod.ts +++ b/lib/builtin/storage.k8s.io@v1/mod.ts @@ -563,6 +563,123 @@ export class StorageV1Api { return StorageV1.toVolumeAttachment(resp); } + async getVolumeAttributesClassList( + opts: operations.GetListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}volumeattributesclasses`, + expectJson: true, + querystring: operations.formatGetListOpts(opts), + abortSignal: opts.abortSignal, + }); + return StorageV1.toVolumeAttributesClassList(resp); + } + + async watchVolumeAttributesClassList( + opts: operations.WatchListOpts = {}, + ): Promise> { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}volumeattributesclasses`, + expectJson: true, + expectStream: true, + querystring: operations.formatWatchListOpts(opts), + abortSignal: opts.abortSignal, + }); + return resp.pipeThrough(new c.WatchEventTransformer(StorageV1.toVolumeAttributesClass, MetaV1.toStatus)); + } + + async createVolumeAttributesClass( + body: StorageV1.VolumeAttributesClass, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "POST", + path: `${this.#root}volumeattributesclasses`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: StorageV1.fromVolumeAttributesClass(body), + abortSignal: opts.abortSignal, + }); + return StorageV1.toVolumeAttributesClass(resp); + } + + async deleteVolumeAttributesClassList( + opts: operations.DeleteListOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}volumeattributesclasses`, + expectJson: true, + querystring: operations.formatDeleteListOpts(opts), + abortSignal: opts.abortSignal, + }); + return StorageV1.toVolumeAttributesClassList(resp); + } + + async getVolumeAttributesClass( + name: string, + opts: operations.NoOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "GET", + path: `${this.#root}volumeattributesclasses/${name}`, + expectJson: true, + abortSignal: opts.abortSignal, + }); + return StorageV1.toVolumeAttributesClass(resp); + } + + async deleteVolumeAttributesClass( + name: string, + opts: operations.DeleteOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "DELETE", + path: `${this.#root}volumeattributesclasses/${name}`, + expectJson: true, + querystring: operations.formatDeleteOpts(opts), + abortSignal: opts.abortSignal, + }); + if (c.isStatusKind(resp)) return MetaV1.toStatus(resp); + return StorageV1.toVolumeAttributesClass(resp); + } + + async replaceVolumeAttributesClass( + name: string, + body: StorageV1.VolumeAttributesClass, + opts: operations.PutOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PUT", + path: `${this.#root}volumeattributesclasses/${name}`, + expectJson: true, + querystring: operations.formatPutOpts(opts), + bodyJson: StorageV1.fromVolumeAttributesClass(body), + abortSignal: opts.abortSignal, + }); + return StorageV1.toVolumeAttributesClass(resp); + } + + async patchVolumeAttributesClass( + name: string, + type: c.PatchType, + body: StorageV1.VolumeAttributesClass | c.JsonPatch, + opts: operations.PatchOpts = {}, + ): Promise { + const resp = await this.#client.performRequest({ + method: "PATCH", + path: `${this.#root}volumeattributesclasses/${name}`, + expectJson: true, + querystring: operations.formatPatchOpts(opts), + contentType: c.getPatchContentType(type), + bodyJson: Array.isArray(body) ? body : StorageV1.fromVolumeAttributesClass(body), + abortSignal: opts.abortSignal, + }); + return StorageV1.toVolumeAttributesClass(resp); + } + } export class StorageV1NamespacedApi { diff --git a/lib/builtin/storage.k8s.io@v1/structs.ts b/lib/builtin/storage.k8s.io@v1/structs.ts index 630654f..3dffe79 100644 --- a/lib/builtin/storage.k8s.io@v1/structs.ts +++ b/lib/builtin/storage.k8s.io@v1/structs.ts @@ -34,6 +34,7 @@ export function fromCSIDriver(input: CSIDriver): c.JSONValue { export interface CSIDriverSpec { attachRequired?: boolean | null; fsGroupPolicy?: string | null; + nodeAllocatableUpdatePeriodSeconds?: number | null; podInfoOnMount?: boolean | null; requiresRepublish?: boolean | null; seLinuxMount?: boolean | null; @@ -46,6 +47,7 @@ export function toCSIDriverSpec(input: c.JSONValue): CSIDriverSpec { return { attachRequired: c.readOpt(obj["attachRequired"], c.checkBool), fsGroupPolicy: c.readOpt(obj["fsGroupPolicy"], c.checkStr), + nodeAllocatableUpdatePeriodSeconds: c.readOpt(obj["nodeAllocatableUpdatePeriodSeconds"], c.checkNum), podInfoOnMount: c.readOpt(obj["podInfoOnMount"], c.checkBool), requiresRepublish: c.readOpt(obj["requiresRepublish"], c.checkBool), seLinuxMount: c.readOpt(obj["seLinuxMount"], c.checkBool), @@ -360,12 +362,14 @@ export function fromVolumeAttachmentStatus(input: VolumeAttachmentStatus): c.JSO /** VolumeError captures an error encountered during a volume operation. */ export interface VolumeError { + errorCode?: number | null; message?: string | null; time?: c.Time | null; } export function toVolumeError(input: c.JSONValue): VolumeError { const obj = c.checkObj(input); return { + errorCode: c.readOpt(obj["errorCode"], c.checkNum), message: c.readOpt(obj["message"], c.checkStr), time: c.readOpt(obj["time"], c.toTime), }} @@ -387,3 +391,39 @@ export function toVolumeAttachmentList(input: c.JSONValue): VolumeAttachmentList metadata: MetaV1.toListMeta(obj.metadata), items: c.readList(obj.items, toVolumeAttachment), }} + +/** VolumeAttributesClass represents a specification of mutable volume attributes defined by the CSI driver. The class can be specified during dynamic provisioning of PersistentVolumeClaims, and changed in the PersistentVolumeClaim spec after provisioning. */ +export interface VolumeAttributesClass { + apiVersion?: "storage.k8s.io/v1"; + kind?: "VolumeAttributesClass"; + driverName: string; + metadata?: MetaV1.ObjectMeta | null; + parameters?: Record | null; +} +export function toVolumeAttributesClass(input: c.JSONValue): VolumeAttributesClass & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "storage.k8s.io/v1", "VolumeAttributesClass"), + driverName: c.checkStr(obj["driverName"]), + metadata: c.readOpt(obj["metadata"], MetaV1.toObjectMeta), + parameters: c.readOpt(obj["parameters"], x => c.readMap(x, c.checkStr)), + }} +export function fromVolumeAttributesClass(input: VolumeAttributesClass): c.JSONValue { + return { + ...c.assertOrAddApiVersionAndKind(input, "storage.k8s.io/v1", "VolumeAttributesClass"), + ...input, + metadata: input.metadata != null ? MetaV1.fromObjectMeta(input.metadata) : undefined, + }} + +/** VolumeAttributesClassList is a collection of VolumeAttributesClass objects. */ +export interface VolumeAttributesClassList extends ListOf { + apiVersion?: "storage.k8s.io/v1"; + kind?: "VolumeAttributesClassList"; +}; +export function toVolumeAttributesClassList(input: c.JSONValue): VolumeAttributesClassList & c.ApiKind { + const obj = c.checkObj(input); + return { + ...c.assertOrAddApiVersionAndKind(obj, "storage.k8s.io/v1", "VolumeAttributesClassList"), + metadata: MetaV1.toListMeta(obj.metadata), + items: c.readList(obj.items, toVolumeAttributesClass), + }} diff --git a/lib/cert-manager/acme.cert-manager.io@v1/structs.ts b/lib/cert-manager/acme.cert-manager.io@v1/structs.ts index fef6a92..39d9d32 100644 --- a/lib/cert-manager/acme.cert-manager.io@v1/structs.ts +++ b/lib/cert-manager/acme.cert-manager.io@v1/structs.ts @@ -109,6 +109,7 @@ export interface Order { kind?: string | null; name: string; }; + profile?: string | null; request: string; }; status?: { @@ -157,6 +158,7 @@ function toOrder_spec(input: c.JSONValue) { duration: c.readOpt(obj["duration"], c.checkStr), ipAddresses: c.readOpt(obj["ipAddresses"], x => c.readList(x, c.checkStr)), issuerRef: toOrder_spec_issuerRef(obj["issuerRef"]), + profile: c.readOpt(obj["profile"], c.checkStr), request: c.checkStr(obj["request"]), }} function toOrder_status(input: c.JSONValue) { diff --git a/lib/cert-manager/cert-manager.io@v1/structs.ts b/lib/cert-manager/cert-manager.io@v1/structs.ts index 98cd689..c521287 100644 --- a/lib/cert-manager/cert-manager.io@v1/structs.ts +++ b/lib/cert-manager/cert-manager.io@v1/structs.ts @@ -165,11 +165,13 @@ export interface Certificate { jks?: { alias?: string | null; create: boolean; - passwordSecretRef: SecretRef; + password?: string | null; + passwordSecretRef?: SecretRef | null; } | null; pkcs12?: { create: boolean; - passwordSecretRef: SecretRef; + password?: string | null; + passwordSecretRef?: SecretRef | null; profile?: "LegacyRC2" | "LegacyDES" | "Modern2023" | c.UnexpectedEnumValue | null; } | null; } | null; @@ -207,6 +209,7 @@ export interface Certificate { annotations?: Record | null; labels?: Record | null; } | null; + signatureAlgorithm?: "SHA256WithRSA" | "SHA384WithRSA" | "SHA512WithRSA" | "ECDSAWithSHA256" | "ECDSAWithSHA384" | "ECDSAWithSHA512" | "PureEd25519" | c.UnexpectedEnumValue | null; subject?: { countries?: Array | null; localities?: Array | null; @@ -299,6 +302,7 @@ function toCertificate_spec(input: c.JSONValue) { revisionHistoryLimit: c.readOpt(obj["revisionHistoryLimit"], c.checkNum), secretName: c.checkStr(obj["secretName"]), secretTemplate: c.readOpt(obj["secretTemplate"], toCertificate_spec_secretTemplate), + signatureAlgorithm: c.readOpt(obj["signatureAlgorithm"], (x => c.readEnum<"SHA256WithRSA" | "SHA384WithRSA" | "SHA512WithRSA" | "ECDSAWithSHA256" | "ECDSAWithSHA384" | "ECDSAWithSHA512" | "PureEd25519" | c.UnexpectedEnumValue>(x))), subject: c.readOpt(obj["subject"], toCertificate_spec_subject), uris: c.readOpt(obj["uris"], x => c.readList(x, c.checkStr)), usages: c.readOpt(obj["usages"], x => c.readList(x, (x => c.readEnum<"signing" | "digital signature" | "content commitment" | "key encipherment" | "key agreement" | "data encipherment" | "cert sign" | "crl sign" | "encipher only" | "decipher only" | "any" | "server auth" | "client auth" | "code signing" | "email protection" | "s/mime" | "ipsec end system" | "ipsec tunnel" | "ipsec user" | "timestamping" | "ocsp signing" | "microsoft sgc" | "netscape sgc" | c.UnexpectedEnumValue>(x)))), @@ -387,13 +391,15 @@ function toCertificate_spec_keystores_jks(input: c.JSONValue) { return { alias: c.readOpt(obj["alias"], c.checkStr), create: c.checkBool(obj["create"]), - passwordSecretRef: toSecretRef(obj["passwordSecretRef"]), + password: c.readOpt(obj["password"], c.checkStr), + passwordSecretRef: c.readOpt(obj["passwordSecretRef"], toSecretRef), }} function toCertificate_spec_keystores_pkcs12(input: c.JSONValue) { const obj = c.checkObj(input); return { create: c.checkBool(obj["create"]), - passwordSecretRef: toSecretRef(obj["passwordSecretRef"]), + password: c.readOpt(obj["password"], c.checkStr), + passwordSecretRef: c.readOpt(obj["passwordSecretRef"], toSecretRef), profile: c.readOpt(obj["profile"], (x => c.readEnum<"LegacyRC2" | "LegacyDES" | "Modern2023" | c.UnexpectedEnumValue>(x))), }} function toCertificate_spec_nameConstraints_excluded(input: c.JSONValue) { @@ -439,6 +445,7 @@ export interface IssuerSpec { } | null; preferredChain?: string | null; privateKeySecretRef: SecretRef; + profile?: string | null; server: string; skipTLSVerify?: boolean | null; solvers?: Array | null; @@ -482,6 +489,7 @@ export interface IssuerSpec { namespace?: string | null; path: string; server: string; + serverName?: string | null; } | null; venafi?: { cloud?: { @@ -560,6 +568,7 @@ function toIssuerSpec_acme(input: c.JSONValue) { externalAccountBinding: c.readOpt(obj["externalAccountBinding"], toIssuerSpec_acme_externalAccountBinding), preferredChain: c.readOpt(obj["preferredChain"], c.checkStr), privateKeySecretRef: toSecretRef(obj["privateKeySecretRef"]), + profile: c.readOpt(obj["profile"], c.checkStr), server: c.checkStr(obj["server"]), skipTLSVerify: c.readOpt(obj["skipTLSVerify"], c.checkBool), solvers: c.readOpt(obj["solvers"], x => c.readList(x, toSolverSpec)), @@ -588,6 +597,7 @@ function toIssuerSpec_vault(input: c.JSONValue) { namespace: c.readOpt(obj["namespace"], c.checkStr), path: c.checkStr(obj["path"]), server: c.checkStr(obj["server"]), + serverName: c.readOpt(obj["serverName"], c.checkStr), }} function toIssuerSpec_venafi(input: c.JSONValue) { const obj = c.checkObj(input); @@ -682,6 +692,7 @@ export interface SolverSpec { managedIdentity?: { clientID?: string | null; resourceID?: string | null; + tenantID?: string | null; } | null; resourceGroupName: string; subscriptionID: string; @@ -1043,6 +1054,7 @@ function toSolverSpec_dns01_azureDNS_managedIdentity(input: c.JSONValue) { return { clientID: c.readOpt(obj["clientID"], c.checkStr), resourceID: c.readOpt(obj["resourceID"], c.checkStr), + tenantID: c.readOpt(obj["tenantID"], c.checkStr), }} function toSolverSpec_dns01_route53_auth(input: c.JSONValue) { const obj = c.checkObj(input); diff --git a/lib/deno.json b/lib/deno.json index 8b7aea3..6732c6e 100644 --- a/lib/deno.json +++ b/lib/deno.json @@ -1,6 +1,6 @@ { "name": "@cloudydeno/kubernetes-apis", - "version": "0.5.5", + "version": "0.5.6", "imports": { "@cloudydeno/kubernetes-client": "jsr:@cloudydeno/kubernetes-client@^0.7" }, diff --git a/lib/external-dns/externaldns.k8s.io@v1alpha1/structs.ts b/lib/external-dns/externaldns.k8s.io@v1alpha1/structs.ts index ed016ca..ad2cac7 100644 --- a/lib/external-dns/externaldns.k8s.io@v1alpha1/structs.ts +++ b/lib/external-dns/externaldns.k8s.io@v1alpha1/structs.ts @@ -7,6 +7,8 @@ type ListOf = { items: Array; }; +/** DNSEndpoint is a contract that a user-specified CRD must implement to be used as a source for external-dns. +The user-specified CRD should also have the status sub-resource. */ export interface DNSEndpoint { apiVersion?: "externaldns.k8s.io/v1alpha1"; kind?: "DNSEndpoint"; diff --git a/lib/vpa/autoscaling.k8s.io@v1/structs.ts b/lib/vpa/autoscaling.k8s.io@v1/structs.ts index c339f6d..3273ab6 100644 --- a/lib/vpa/autoscaling.k8s.io@v1/structs.ts +++ b/lib/vpa/autoscaling.k8s.io@v1/structs.ts @@ -7,7 +7,8 @@ type ListOf = { items: Array; }; -/** VerticalPodAutoscalerCheckpoint is the checkpoint of the internal state of VPA that is used for recovery after recommender's restart. */ +/** VerticalPodAutoscalerCheckpoint is the checkpoint of the internal state of VPA that +is used for recovery after recommender's restart. */ export interface VerticalPodAutoscalerCheckpoint { apiVersion?: "autoscaling.k8s.io/v1"; kind?: "VerticalPodAutoscalerCheckpoint"; @@ -106,7 +107,9 @@ export function toVerticalPodAutoscalerCheckpointList(input: c.JSONValue): Verti items: c.readList(obj.items, toVerticalPodAutoscalerCheckpoint), }} -/** VerticalPodAutoscaler is the configuration for a vertical pod autoscaler, which automatically manages pod resources based on historical and real time resource utilization. */ +/** VerticalPodAutoscaler is the configuration for a vertical pod +autoscaler, which automatically manages pod resources based on historical and +real time resource utilization. */ export interface VerticalPodAutoscaler { apiVersion?: "autoscaling.k8s.io/v1"; kind?: "VerticalPodAutoscaler"; @@ -136,7 +139,7 @@ export interface VerticalPodAutoscaler { resources: Array; }> | null; minReplicas?: number | null; - updateMode?: "Off" | "Initial" | "Recreate" | "Auto" | c.UnexpectedEnumValue | null; + updateMode?: "Off" | "Initial" | "Recreate" | "InPlaceOrRecreate" | "Auto" | c.UnexpectedEnumValue | null; } | null; }; status?: { @@ -215,7 +218,7 @@ function toVerticalPodAutoscaler_spec_updatePolicy(input: c.JSONValue) { return { evictionRequirements: c.readOpt(obj["evictionRequirements"], x => c.readList(x, toVerticalPodAutoscaler_spec_updatePolicy_evictionRequirements)), minReplicas: c.readOpt(obj["minReplicas"], c.checkNum), - updateMode: c.readOpt(obj["updateMode"], (x => c.readEnum<"Off" | "Initial" | "Recreate" | "Auto" | c.UnexpectedEnumValue>(x))), + updateMode: c.readOpt(obj["updateMode"], (x => c.readEnum<"Off" | "Initial" | "Recreate" | "InPlaceOrRecreate" | "Auto" | c.UnexpectedEnumValue>(x))), }} function toVerticalPodAutoscaler_status_conditions(input: c.JSONValue) { const obj = c.checkObj(input); From e1eb20dc8eddc1b034e2326cf66cd918a0a3ab8e Mon Sep 17 00:00:00 2001 From: Daniel Lamando Date: Fri, 19 Sep 2025 23:52:33 +0200 Subject: [PATCH 2/4] Update package exports for new Kubernetes APIs --- lib/README.md | 11 ++++++++--- lib/deno.json | 5 ++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/README.md b/lib/README.md index 9e81f1f..338951a 100644 --- a/lib/README.md +++ b/lib/README.md @@ -1,6 +1,6 @@ -![Deno CI](https://github.com/danopia/deno-kubernetes_apis/workflows/CI/badge.svg?branch=main) +[![CI](https://github.com/cloudydeno/kubernetes-apis/actions/workflows/deno-ci.yaml/badge.svg)](https://github.com/cloudydeno/kubernetes-apis/actions/workflows/deno-ci.yaml) -# `/x/kubernetes_apis` +# `@cloudydeno/kubernetes-apis` ## Purpose @@ -44,9 +44,14 @@ for more information. ## Changelog +* `v0.5.6` on `2025-09-20`: + * Includes 'builtin' APIs generated from K8s `v1.34.1`. + * Several API versions were changed, removed, or added. + * You may need to update imports if you used a non-stable API version which has been moved. + * `cert-manager` and `argo-cd` CRDs have been updated. + * `v0.5.5` on `2025-09-19`: * Fully adopt JSR. Remove remnants of `/x/` and `/std/` dependencies. - * * `v0.5.4` on `2025-01-18`: * Includes 'builtin' APIs generated from K8s `v1.32.0`. diff --git a/lib/deno.json b/lib/deno.json index 6732c6e..5f89b79 100644 --- a/lib/deno.json +++ b/lib/deno.json @@ -13,15 +13,16 @@ "./apiregistration.k8s.io/v1": "./builtin/apiregistration.k8s.io@v1/mod.ts", "./apps/v1": "./builtin/apps@v1/mod.ts", "./authentication.k8s.io/v1": "./builtin/authentication.k8s.io@v1/mod.ts", - "./authentication.k8s.io/v1beta1": "./builtin/authentication.k8s.io@v1beta1/mod.ts", "./authorization.k8s.io/v1": "./builtin/authorization.k8s.io@v1/mod.ts", "./autoscaling/v1": "./builtin/autoscaling@v1/mod.ts", "./autoscaling/v2": "./builtin/autoscaling@v2/mod.ts", "./batch/v1": "./builtin/batch@v1/mod.ts", "./certificates.k8s.io/v1": "./builtin/certificates.k8s.io@v1/mod.ts", "./certificates.k8s.io/v1alpha1": "./builtin/certificates.k8s.io@v1alpha1/mod.ts", + "./certificates.k8s.io/v1beta1": "./builtin/certificates.k8s.io@v1beta1/mod.ts", "./coordination.k8s.io/v1": "./builtin/coordination.k8s.io@v1/mod.ts", "./coordination.k8s.io/v1alpha2": "./builtin/coordination.k8s.io@v1alpha2/mod.ts", + "./coordination.k8s.io/v1beta1": "./builtin/coordination.k8s.io@v1beta1/mod.ts", "./core/v1": "./builtin/core@v1/mod.ts", "./discovery.k8s.io/v1": "./builtin/discovery.k8s.io@v1/mod.ts", "./events.k8s.io/v1": "./builtin/events.k8s.io@v1/mod.ts", @@ -33,8 +34,10 @@ "./node.k8s.io/v1": "./builtin/node.k8s.io@v1/mod.ts", "./policy/v1": "./builtin/policy@v1/mod.ts", "./rbac.authorization.k8s.io/v1": "./builtin/rbac.authorization.k8s.io@v1/mod.ts", + "./resource.k8s.io/v1": "./builtin/resource.k8s.io@v1/mod.ts", "./resource.k8s.io/v1alpha3": "./builtin/resource.k8s.io@v1alpha3/mod.ts", "./resource.k8s.io/v1beta1": "./builtin/resource.k8s.io@v1beta1/mod.ts", + "./resource.k8s.io/v1beta2": "./builtin/resource.k8s.io@v1beta2/mod.ts", "./scheduling.k8s.io/v1": "./builtin/scheduling.k8s.io@v1/mod.ts", "./storage.k8s.io/v1": "./builtin/storage.k8s.io@v1/mod.ts", "./storage.k8s.io/v1alpha1": "./builtin/storage.k8s.io@v1alpha1/mod.ts", From c0d3a565bd2e2226646fc3e6221a227861cf1848 Mon Sep 17 00:00:00 2001 From: Daniel Lamando Date: Sat, 20 Sep 2025 00:13:21 +0200 Subject: [PATCH 3/4] Release notes for v0.6.0 --- lib/README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/README.md b/lib/README.md index 338951a..de480ae 100644 --- a/lib/README.md +++ b/lib/README.md @@ -44,11 +44,16 @@ for more information. ## Changelog -* `v0.5.6` on `2025-09-20`: +* `v0.6.0` on `2025-09-20`: * Includes 'builtin' APIs generated from K8s `v1.34.1`. - * Several API versions were changed, removed, or added. - * You may need to update imports if you used a non-stable API version which has been moved. - * `cert-manager` and `argo-cd` CRDs have been updated. + * New APIs: + * `certificates.k8s.io/v1beta1` with kind `ClusterTrustBundle` + * `coordination.k8s.io/v1beta1` with kind `LeaseCandidate` + * `resource.k8s.io/v1` with `DeviceClass`, `ResourceSlice`, `ResourceClaim`, etc + * Other new kinds include `PodCertificateRequest`, `IPAddress`, and `VolumeAttributesClass` + * Removed API versions: (BREAKING) + * `authentication.k8s.io/v1beta1` ⚠ migrate to `authentication.k8s.io/v1` + * `argo-cd`, `cert-manager`, and `vpa` CRDs have been updated to latest. * `v0.5.5` on `2025-09-19`: * Fully adopt JSR. Remove remnants of `/x/` and `/std/` dependencies. From e86e579542de5f2674de0974a59fba14164f95b4 Mon Sep 17 00:00:00 2001 From: Daniel Lamando Date: Sat, 20 Sep 2025 00:32:07 +0200 Subject: [PATCH 4/4] Add a flux-cd generation script, not in use tho Pretty big API (halfway to Kubernetes's builtin APIs by module size) Think this might get published as a separate package instead --- generation/generate-all.sh | 3 +++ generation/sources/flux-cd.sh | 31 +++++++++++++++++++++++++++++++ lib/deps.ts | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100755 generation/sources/flux-cd.sh diff --git a/generation/generate-all.sh b/generation/generate-all.sh index cbf0cfb..6bc0662 100755 --- a/generation/generate-all.sh +++ b/generation/generate-all.sh @@ -12,5 +12,8 @@ # https://github.com/kubernetes-sigs/external-dns/releases ./generation/sources/external-dns.sh v0.19.0 +# https://github.com/fluxcd/flux2/releases +#./generation/sources/flux-cd.sh v2.6.4 + # https://github.com/kubernetes/autoscaler/releases?q=vertical ./generation/sources/vpa.sh 1.4.1 diff --git a/generation/sources/flux-cd.sh b/generation/sources/flux-cd.sh new file mode 100755 index 0000000..5ecbef4 --- /dev/null +++ b/generation/sources/flux-cd.sh @@ -0,0 +1,31 @@ +#!/bin/sh -eux + +rawapi="raw.githubusercontent.com" +upstream="fluxcd/flux2" +kustomizationpath="manifests/crds/kustomization.yaml" +projectname="flux-cd" +specdir="generation/api-specs/$projectname-$1" + +if [ ! -d "$specdir" ] +then { + echo 'mkdir '"$specdir" + echo 'cd '"$specdir" + wget -O - "https://$rawapi/$upstream/refs/tags/$1/$kustomizationpath" \ + | grep -E 'https:.+[.]yaml' \ + | sed 's/^- /wget /' +} | sh -eux +fi + +mkdir -p "lib/$projectname" +rm -r "lib/$projectname"/* \ +|| true + +deno run \ + --allow-read="generation/api-specs" \ + --allow-write="lib/$projectname" \ + generation/run-on-crds.ts \ + "$specdir" \ + "$projectname" + +deno check "lib/$projectname"/*/mod.ts +git status "lib/$projectname" diff --git a/lib/deps.ts b/lib/deps.ts index b91bd99..aa86739 100644 --- a/lib/deps.ts +++ b/lib/deps.ts @@ -1,4 +1,4 @@ -// This file is just the entire matching kubernetes_client version. +// This file is just the entire matching kubernetes-client version. // kubernetes-apis itself only depends on specific files, // so this is provided an optional utility.