diff --git a/README.md b/README.md index 8fedd000e..9b13d1ba8 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,7 @@ Detailed Facade documentation is available as part of the [full API documentatio | ActionPruner | | | Action | | | Admin | | +| AgentLifeFlag | | | AgentTools | | | Agent | | | AllModelWatcher | | @@ -231,11 +232,11 @@ Detailed Facade documentation is available as part of the [full API documentatio The Juju facade API files are generated from a supplied Juju schema. -To generate this schema you will need to clone the [Juju repository](https://github.com/juju/juju/) and then run `go run github.com/juju/juju/generate/schemagen -admin-facades --facade-group=client,jimm ./apiserver/facades/schema.json` to generate a schema file that contains the publicly available facades as well as the set of facades for JAAS. Other `--facade-group` options are `latest` and `all`. +To generate this schema you will need to clone the [Juju repository](https://github.com/juju/juju/) and then run `make rebuild-schema` or `go run github.com/juju/juju/generate/schemagen -admin-facades --facade-group=client,jimm ./apiserver/facades/schema.json` to generate a schema file that contains the publicly available facades as well as the set of facades for JAAS. Other `--facade-group` options are `latest` and `all`. After generating a new schema run `yarn store-schema ../path/to/juju` which will store the updated schema and necessary meta data in this project. -To update the facades, run `yarn build` on this project. This will generate the facades using the locally stored schema, sha, and version the schema was generated from. +To update the facades, run `yarn generate-facades` on this project. This will generate the facades using the locally stored schema, sha, and version the schema was generated from. Finally, update `CLIENT_VERSION` in `api/client.ts` with the highest support version. diff --git a/api/client.ts b/api/client.ts index f4bd5a5e2..1d0d93805 100644 --- a/api/client.ts +++ b/api/client.ts @@ -9,6 +9,7 @@ import { Bakery } from "@canonical/macaroon-bakery"; import AdminV3, { + AuthUserInfo, FacadeVersions, LoginRequest, LoginResult, @@ -29,7 +30,7 @@ import { } from "./types.js"; import { createAsyncHandler } from "./utils.js"; -export const CLIENT_VERSION = "3.2.0"; +export const CLIENT_VERSION = "3.2.1"; export interface ConnectOptions { bakery?: Bakery | null; @@ -44,14 +45,14 @@ export interface ConnectionInfo { controllerTag?: string; serverVersion?: string; servers?: object[]; - user?: object; + user?: AuthUserInfo; getFacade?: (name: string) => Facade; } export interface Credentials { username?: string; password?: string; - macaroons?: object; + macaroons?: MacaroonObject[][]; } /** diff --git a/api/facades/action-pruner/ActionPrunerV1.ts b/api/facades/action-pruner/ActionPrunerV1.ts index a831d3564..c8ecf513f 100644 --- a/api/facades/action-pruner/ActionPrunerV1.ts +++ b/api/facades/action-pruner/ActionPrunerV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/action/ActionV7.ts b/api/facades/action/ActionV7.ts index f4f586565..e88baef01 100644 --- a/api/facades/action/ActionV7.ts +++ b/api/facades/action/ActionV7.ts @@ -4,7 +4,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -53,7 +53,7 @@ export interface Actions { } export interface ApplicationCharmActionsResult { - actions: AdditionalProperties; + actions: Record; "application-tag": string; error: Error; } diff --git a/api/facades/admin/AdminV3.ts b/api/facades/admin/AdminV3.ts index be936740e..a3ba57189 100644 --- a/api/facades/admin/AdminV3.ts +++ b/api/facades/admin/AdminV3.ts @@ -8,7 +8,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -63,6 +63,7 @@ export interface LoginRequest { credentials: string; macaroons: Macaroon[][]; nonce: string; + token?: string; "user-data": string; } diff --git a/api/facades/agent-life-flag/AgentLifeFlagV1.ts b/api/facades/agent-life-flag/AgentLifeFlagV1.ts new file mode 100644 index 000000000..144b3564d --- /dev/null +++ b/api/facades/agent-life-flag/AgentLifeFlagV1.ts @@ -0,0 +1,108 @@ +/** + Juju AgentLifeFlag version 1. + This facade is available on: + Controller-machine-agent + Machine-agent + Unit-agent + Models + + NOTE: This file was generated using the Juju schema + from Juju 3.2.1 at the git SHA 06eb3f6c7c. + Do not manually edit this file. +*/ + +import type { JujuRequest } from "../../../generator/interfaces.js"; +import { ConnectionInfo, Transport } from "../../client.js"; +import { Facade } from "../../types.js"; +import { autoBind } from "../../utils.js"; + +export interface Entities { + entities: Entity[]; +} + +export interface Entity { + tag: string; +} + +export interface Error { + code: string; + info?: AdditionalProperties; + message: string; +} + +export interface LifeResult { + error?: Error; + life: string; +} + +export interface LifeResults { + results: LifeResult[]; +} + +export interface NotifyWatchResult { + NotifyWatcherId: string; + error?: Error; +} + +export interface NotifyWatchResults { + results: NotifyWatchResult[]; +} + +export interface AdditionalProperties { + [key: string]: any; +} + +/** + +*/ +class AgentLifeFlagV1 implements Facade { + static NAME = "AgentLifeFlag"; + static VERSION = 1; + + NAME = "AgentLifeFlag"; + VERSION = 1; + + _transport: Transport; + _info: ConnectionInfo; + + constructor(transport: Transport, info: ConnectionInfo) { + this._transport = transport; + this._info = info; + + // Automatically bind all methods to instances. + autoBind(this); + } + /** + Life returns the life status of every supplied entity, where available. + */ + life(params: Entities): Promise { + return new Promise((resolve, reject) => { + const req: JujuRequest = { + type: "AgentLifeFlag", + request: "Life", + version: 1, + params: params, + }; + + this._transport.write(req, resolve, reject); + }); + } + + /** + Watch starts an NotifyWatcher for each given entity. + */ + watch(params: Entities): Promise { + return new Promise((resolve, reject) => { + const req: JujuRequest = { + type: "AgentLifeFlag", + request: "Watch", + version: 1, + params: params, + }; + + this._transport.write(req, resolve, reject); + }); + } +} + +export default AgentLifeFlagV1; diff --git a/api/facades/agent-life-flag/index.ts b/api/facades/agent-life-flag/index.ts new file mode 100644 index 000000000..34a1e4d81 --- /dev/null +++ b/api/facades/agent-life-flag/index.ts @@ -0,0 +1,11 @@ +import { GenericFacade } from "../../types"; +import AgentLifeFlagV1 from "./AgentLifeFlagV1.js"; + +export * as AgentLifeFlagV1 from "./AgentLifeFlagV1.js"; + +const AgentLifeFlag: GenericFacade = { + name: "AgentLifeFlag", + versions: [AgentLifeFlagV1], +}; + +export default AgentLifeFlag; diff --git a/api/facades/agent-tools/AgentToolsV1.ts b/api/facades/agent-tools/AgentToolsV1.ts index 27221aeef..55cd0f62c 100644 --- a/api/facades/agent-tools/AgentToolsV1.ts +++ b/api/facades/agent-tools/AgentToolsV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/agent/AgentV3.ts b/api/facades/agent/AgentV3.ts index 0045909c1..364d9996e 100644 --- a/api/facades/agent/AgentV3.ts +++ b/api/facades/agent/AgentV3.ts @@ -6,7 +6,7 @@ Unit-agent NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -27,7 +27,7 @@ export interface AgentGetEntitiesResults { } export interface CloudCredential { - attrs?: AdditionalProperties; + attrs?: Record; "auth-type": string; redacted?: string[]; } diff --git a/api/facades/all-model-watcher/AllModelWatcherV4.ts b/api/facades/all-model-watcher/AllModelWatcherV4.ts index 2a4b74eac..a42dcbc8c 100644 --- a/api/facades/all-model-watcher/AllModelWatcherV4.ts +++ b/api/facades/all-model-watcher/AllModelWatcherV4.ts @@ -4,7 +4,7 @@ Controllers NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -14,7 +14,7 @@ import { Facade } from "../../types.js"; import { autoBind } from "../../utils.js"; export interface AllWatcherNextResults { - deltas: Delta[]; + deltas: [string, string, unknown][]; } export interface Delta { @@ -53,13 +53,13 @@ class AllModelWatcherV4 implements Facade { Next will return the current state of everything on the first call and subsequent calls will */ - next(params: any): Promise { + next(params: { id: string }): Promise { return new Promise((resolve, reject) => { const req: JujuRequest = { type: "AllModelWatcher", request: "Next", version: 4, - params: params, + id: params.id, }; this._transport.write(req, resolve, reject); @@ -69,13 +69,13 @@ class AllModelWatcherV4 implements Facade { /** Stop stops the watcher. */ - stop(params: any): Promise { + stop(params: { id: string }): Promise { return new Promise((resolve, reject) => { const req: JujuRequest = { type: "AllModelWatcher", request: "Stop", version: 4, - params: params, + id: params.id, }; this._transport.write(req, resolve, reject); diff --git a/api/facades/all-watcher/AllWatcherV3.ts b/api/facades/all-watcher/AllWatcherV3.ts index 64bed9e1f..3ef8fb2c8 100644 --- a/api/facades/all-watcher/AllWatcherV3.ts +++ b/api/facades/all-watcher/AllWatcherV3.ts @@ -4,7 +4,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -14,7 +14,7 @@ import { Facade } from "../../types.js"; import { autoBind } from "../../utils.js"; export interface AllWatcherNextResults { - deltas: Delta[]; + deltas: [string, string, unknown][]; } export interface Delta { @@ -53,13 +53,13 @@ class AllWatcherV3 implements Facade { Next will return the current state of everything on the first call and subsequent calls will */ - next(id: number): Promise { + next(params: { id: string }): Promise { return new Promise((resolve, reject) => { - const req: JujuRequest & { id: number } = { + const req: JujuRequest = { type: "AllWatcher", request: "Next", version: 3, - id, + id: params.id, }; this._transport.write(req, resolve, reject); @@ -69,13 +69,13 @@ class AllWatcherV3 implements Facade { /** Stop stops the watcher. */ - stop(id: number): Promise { + stop(params: { id: string }): Promise { return new Promise((resolve, reject) => { - const req: JujuRequest & { id: number } = { + const req: JujuRequest = { type: "AllWatcher", request: "Stop", version: 3, - id, + id: params.id, }; this._transport.write(req, resolve, reject); diff --git a/api/facades/annotations/AnnotationsV2.ts b/api/facades/annotations/AnnotationsV2.ts index 932e6868d..e18238104 100644 --- a/api/facades/annotations/AnnotationsV2.ts +++ b/api/facades/annotations/AnnotationsV2.ts @@ -4,7 +4,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -14,7 +14,7 @@ import { Facade } from "../../types.js"; import { autoBind } from "../../utils.js"; export interface AnnotationsGetResult { - annotations: AdditionalProperties; + annotations: Record; entity: string; error?: ErrorResult; } @@ -36,7 +36,7 @@ export interface Entity { } export interface EntityAnnotations { - annotations: AdditionalProperties; + annotations: Record; entity: string; } diff --git a/api/facades/application-offers/ApplicationOffersV4.ts b/api/facades/application-offers/ApplicationOffersV4.ts index 5bb6d88ad..1cc9a9a2b 100644 --- a/api/facades/application-offers/ApplicationOffersV4.ts +++ b/api/facades/application-offers/ApplicationOffersV4.ts @@ -7,7 +7,7 @@ Controllers NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -19,7 +19,7 @@ import { autoBind } from "../../utils.js"; export interface AddApplicationOffer { "application-description": string; "application-name": string; - endpoints: AdditionalProperties; + endpoints: Record; "model-tag": string; "offer-name": string; "owner-tag"?: string; @@ -33,7 +33,7 @@ export interface ApplicationOfferAdminDetails { ApplicationOfferDetails: ApplicationOfferDetails; "application-description": string; "application-name": string; - bindings?: AdditionalProperties; + bindings?: Record; "charm-url": string; connections?: OfferConnection[]; endpoints?: RemoteEndpoint[]; @@ -47,7 +47,7 @@ export interface ApplicationOfferAdminDetails { export interface ApplicationOfferDetails { "application-description": string; - bindings?: AdditionalProperties; + bindings?: Record; endpoints?: RemoteEndpoint[]; "offer-name": string; "offer-url": string; @@ -67,6 +67,7 @@ export interface ApplicationOffersResults { } export interface ConsumeOfferDetails { + "auth-token": string; "external-controller": ExternalControllerInfo; macaroon: Macaroon; offer: ApplicationOfferDetails; @@ -79,6 +80,7 @@ export interface ConsumeOfferDetailsArg { export interface ConsumeOfferDetailsResult { ConsumeOfferDetails: ConsumeOfferDetails; + "auth-token"?: string; error?: Error; "external-controller"?: ExternalControllerInfo; macaroon?: Macaroon; diff --git a/api/facades/application-scaler/ApplicationScalerV1.ts b/api/facades/application-scaler/ApplicationScalerV1.ts index 97515363f..bc595e9d2 100644 --- a/api/facades/application-scaler/ApplicationScalerV1.ts +++ b/api/facades/application-scaler/ApplicationScalerV1.ts @@ -4,7 +4,7 @@ Controller-machine-agent NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/application/ApplicationV18.ts b/api/facades/application/ApplicationV18.ts index 572f045b9..f20b743c2 100644 --- a/api/facades/application/ApplicationV18.ts +++ b/api/facades/application/ApplicationV18.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.2-rc1 at the git SHA 3a098707a1. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -34,7 +34,7 @@ export interface AddRelation { } export interface AddRelationResults { - endpoints: AdditionalProperties; + endpoints: Record; } export interface ApplicationCharmRelations { @@ -61,21 +61,21 @@ export interface ApplicationDeploy { channel: string; "charm-origin"?: CharmOrigin; "charm-url": string; - config?: AdditionalProperties; + config?: Record; "config-yaml": string; constraints: Value; - devices?: AdditionalProperties; - "endpoint-bindings"?: AdditionalProperties; + devices?: Record; + "endpoint-bindings"?: Record; "num-units": number; placement?: Placement[]; policy?: string; - resources?: AdditionalProperties; - storage?: AdditionalProperties; + resources?: Record; + storage?: Record; } export interface ApplicationExpose { application: string; - "exposed-endpoints"?: AdditionalProperties; + "exposed-endpoints"?: Record; } export interface ApplicationGet { @@ -103,7 +103,7 @@ export interface ApplicationGetResults { charm: string; config: AdditionalProperties; constraints: Value; - "endpoint-bindings"?: AdditionalProperties; + "endpoint-bindings"?: Record; } export interface ApplicationInfoResult { @@ -117,7 +117,7 @@ export interface ApplicationInfoResults { export interface ApplicationMergeBindings { "application-tag": string; - bindings: AdditionalProperties; + bindings: Record; force: boolean; } @@ -136,7 +136,7 @@ export interface ApplicationMetricCredentials { export interface ApplicationOfferDetails { "application-description": string; - bindings?: AdditionalProperties; + bindings?: Record; endpoints?: RemoteEndpoint[]; "offer-name": string; "offer-url": string; @@ -151,9 +151,9 @@ export interface ApplicationResult { channel?: string; charm?: string; constraints?: Value; - "endpoint-bindings"?: AdditionalProperties; + "endpoint-bindings"?: Record; exposed: boolean; - "exposed-endpoints"?: AdditionalProperties; + "exposed-endpoints"?: Record; life: string; principal: boolean; remote: boolean; @@ -165,15 +165,15 @@ export interface ApplicationSetCharm { channel: string; "charm-origin"?: CharmOrigin; "charm-url": string; - "config-settings"?: AdditionalProperties; + "config-settings"?: Record; "config-settings-yaml"?: string; - "endpoint-bindings"?: AdditionalProperties; + "endpoint-bindings"?: Record; force: boolean; "force-base": boolean; "force-units": boolean; generation: string; - "resource-ids"?: AdditionalProperties; - "storage-constraints"?: AdditionalProperties; + "resource-ids"?: Record; + "storage-constraints"?: Record; } export interface ApplicationUnexpose { @@ -232,7 +232,7 @@ export interface ConfigResult { export interface ConfigSet { application: string; - config: AdditionalProperties; + config: Record; "config-yaml": string; generation: string; } @@ -252,7 +252,7 @@ export interface ConsumeApplicationArg { "application-alias"?: string; "application-description": string; "auth-token"?: string; - bindings?: AdditionalProperties; + bindings?: Record; endpoints?: RemoteEndpoint[]; "external-controller"?: ExternalControllerInfo; macaroon?: Macaroon; @@ -274,17 +274,17 @@ export interface DeployFromRepositoryArg { CharmName: string; ConfigYAML: string; Cons: Value; - Devices: AdditionalProperties; + Devices: Record; DryRun: boolean; Placement: Placement[]; - Storage: AdditionalProperties; + Storage: Record; Trust: boolean; base?: Base; channel?: string; - "endpoint-bindings"?: AdditionalProperties; + "endpoint-bindings"?: Record; force?: boolean; "num-units"?: number; - resources?: AdditionalProperties; + resources?: Record; revision?: number; } @@ -387,7 +387,7 @@ export interface EndpointRelationData { endpoint: string; "related-endpoint": string; "relation-id": number; - "unit-relation-data": AdditionalProperties; + "unit-relation-data": Record; } export interface Entities { diff --git a/api/facades/backups/BackupsV3.ts b/api/facades/backups/BackupsV3.ts index 92dd5c57d..4f9cb6f79 100644 --- a/api/facades/backups/BackupsV3.ts +++ b/api/facades/backups/BackupsV3.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/block/BlockV2.ts b/api/facades/block/BlockV2.ts index b376e7829..4c4ceda61 100644 --- a/api/facades/block/BlockV2.ts +++ b/api/facades/block/BlockV2.ts @@ -4,7 +4,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/bundle/BundleV6.ts b/api/facades/bundle/BundleV6.ts index a432e28a3..1e993b0ce 100644 --- a/api/facades/bundle/BundleV6.ts +++ b/api/facades/bundle/BundleV6.ts @@ -5,7 +5,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/caasadmission/CAASAdmissionV1.ts b/api/facades/caasadmission/CAASAdmissionV1.ts index 6e84c9dc3..98c93ac0f 100644 --- a/api/facades/caasadmission/CAASAdmissionV1.ts +++ b/api/facades/caasadmission/CAASAdmissionV1.ts @@ -5,7 +5,7 @@ Machine-agent NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/caasagent/CAASAgentV2.ts b/api/facades/caasagent/CAASAgentV2.ts index 333d552bd..b9b4ee516 100644 --- a/api/facades/caasagent/CAASAgentV2.ts +++ b/api/facades/caasagent/CAASAgentV2.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -17,7 +17,7 @@ import { Facade } from "../../types.js"; import { autoBind } from "../../utils.js"; export interface CloudCredential { - attrs?: AdditionalProperties; + attrs?: Record; "auth-type": string; redacted?: string[]; } diff --git a/api/facades/caasapplication-provisioner/CAASApplicationProvisionerV1.ts b/api/facades/caasapplication-provisioner/CAASApplicationProvisionerV1.ts index ee9da7967..368924621 100644 --- a/api/facades/caasapplication-provisioner/CAASApplicationProvisionerV1.ts +++ b/api/facades/caasapplication-provisioner/CAASApplicationProvisionerV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -38,18 +38,6 @@ export interface Base { name: string; } -export interface CAASApplicationGarbageCollectArg { - "active-pod-names": string[]; - application: Entity; - "desired-replicas": number; - force: boolean; - "observed-units": Entities; -} - -export interface CAASApplicationGarbageCollectArgs { - args: CAASApplicationGarbageCollectArg[]; -} - export interface CAASApplicationOCIResourceResult { error: Error; result: CAASApplicationOCIResources; @@ -60,7 +48,16 @@ export interface CAASApplicationOCIResourceResults { } export interface CAASApplicationOCIResources { - images: AdditionalProperties; + images: Record; +} + +export interface CAASApplicationProvisionerConfig { + "unmanaged-applications": Entities; +} + +export interface CAASApplicationProvisionerConfigResult { + error: Error; + "provisioner-config": CAASApplicationProvisionerConfig; } export interface CAASApplicationProvisioningInfo { @@ -75,7 +72,7 @@ export interface CAASApplicationProvisioningInfo { filesystems?: KubernetesFilesystemParams[]; "image-repo"?: DockerImageInfo; scale?: number; - tags?: AdditionalProperties; + tags?: Record; trust?: boolean; version: Number; volumes?: KubernetesVolumeParams[]; @@ -85,6 +82,21 @@ export interface CAASApplicationProvisioningInfoResults { results: CAASApplicationProvisioningInfo[]; } +export interface CAASApplicationProvisioningState { + "scale-target": number; + scaling: boolean; +} + +export interface CAASApplicationProvisioningStateArg { + application: Entity; + "provisioning-state": CAASApplicationProvisioningState; +} + +export interface CAASApplicationProvisioningStateResult { + error: Error; + "provisioning-state": CAASApplicationProvisioningState; +} + export interface CAASUnitInfo { tag: string; "unit-status"?: UnitStatus; @@ -101,7 +113,7 @@ export interface CAASUnitsResults { export interface Charm { actions?: CharmActions; - config: AdditionalProperties; + config: Record; "lxd-profile"?: CharmLXDProfile; manifest?: CharmManifest; meta?: CharmMeta; @@ -116,7 +128,7 @@ export interface CharmActionSpec { } export interface CharmActions { - specs: AdditionalProperties; + specs: Record; } export interface CharmBase { @@ -146,9 +158,9 @@ export interface CharmDevice { } export interface CharmLXDProfile { - config: AdditionalProperties; + config: Record; description: string; - devices: AdditionalProperties; + devices: Record>; } export interface CharmManifest { @@ -158,20 +170,20 @@ export interface CharmManifest { export interface CharmMeta { "assumes-expr"?: ExpressionTree; categories?: string[]; - containers?: AdditionalProperties; + containers?: Record; deployment?: CharmDeployment; description: string; - devices?: AdditionalProperties; - "extra-bindings"?: AdditionalProperties; + devices?: Record; + "extra-bindings"?: Record; "min-juju-version"?: string; name: string; - "payload-classes"?: AdditionalProperties; - peers?: AdditionalProperties; - provides?: AdditionalProperties; - requires?: AdditionalProperties; - resources?: AdditionalProperties; + "payload-classes"?: Record; + peers?: Record; + provides?: Record; + requires?: Record; + resources?: Record; series?: string[]; - storage?: AdditionalProperties; + storage?: Record; subordinate: boolean; summary: string; tags?: string[]; @@ -184,7 +196,7 @@ export interface CharmMetric { } export interface CharmMetrics { - metrics: AdditionalProperties; + metrics: Record; plan: CharmPlan; } @@ -241,6 +253,32 @@ export interface CharmURL { url: string; } +export interface DestroyUnitInfo { + "destroyed-storage": Entity[]; + "detached-storage": Entity[]; +} + +export interface DestroyUnitParams { + "destroy-storage"?: boolean; + "dry-run"?: boolean; + force?: boolean; + "max-wait"?: number; + "unit-tag": string; +} + +export interface DestroyUnitResult { + error: Error; + info: DestroyUnitInfo; +} + +export interface DestroyUnitResults { + results: DestroyUnitResult[]; +} + +export interface DestroyUnitsParams { + units: DestroyUnitParams[]; +} + export interface DetailedStatus { data: AdditionalProperties; err?: Error; @@ -314,7 +352,7 @@ export interface ExpressionTree { } export interface KubernetesDeviceParams { - Attributes: AdditionalProperties; + Attributes: Record; Count: number; Type: string; } @@ -344,7 +382,7 @@ export interface KubernetesFilesystemParams { provider: string; size: number; storagename: string; - tags?: AdditionalProperties; + tags?: Record; } export interface KubernetesVolumeAttachmentParams { @@ -368,7 +406,7 @@ export interface KubernetesVolumeParams { provider: string; size: number; storagename: string; - tags?: AdditionalProperties; + tags?: Record; } export interface LifeResult { @@ -420,7 +458,7 @@ export interface UnitStatus { "opened-ports": string[]; "provider-id"?: string; "public-address": string; - subordinates: AdditionalProperties; + subordinates: Record; "workload-status": DetailedStatus; "workload-version": string; } @@ -456,6 +494,7 @@ export interface Value { container: string; cores: number; "cpu-power": number; + "image-id": string; "instance-role": string; "instance-type": string; mem: number; @@ -526,17 +565,13 @@ class CAASApplicationProvisionerV1 implements Facade { } /** - CAASApplicationGarbageCollect cleans up units that have gone away permanently. - Only observed units will be deleted as new units could have surfaced between - the capturing of kuberentes pod state/application state and this call. + CharmInfo returns information about the requested charm. */ - cAASApplicationGarbageCollect( - params: CAASApplicationGarbageCollectArgs - ): Promise { + charmInfo(params: CharmURL): Promise { return new Promise((resolve, reject) => { const req: JujuRequest = { type: "CAASApplicationProvisioner", - request: "CAASApplicationGarbageCollect", + request: "CharmInfo", version: 1, params: params, }; @@ -546,13 +581,14 @@ class CAASApplicationProvisionerV1 implements Facade { } /** - CharmInfo returns information about the requested charm. + ClearApplicationsResources clears the flags which indicate + applications still have resources in the cluster. */ - charmInfo(params: CharmURL): Promise { + clearApplicationsResources(params: Entities): Promise { return new Promise((resolve, reject) => { const req: JujuRequest = { type: "CAASApplicationProvisioner", - request: "CharmInfo", + request: "ClearApplicationsResources", version: 1, params: params, }; @@ -562,14 +598,14 @@ class CAASApplicationProvisionerV1 implements Facade { } /** - ClearApplicationsResources clears the flags which indicate - applications still have resources in the cluster. + DestroyUnits is responsible for scaling down a set of units on the this + Application. */ - clearApplicationsResources(params: Entities): Promise { + destroyUnits(params: DestroyUnitsParams): Promise { return new Promise((resolve, reject) => { const req: JujuRequest = { type: "CAASApplicationProvisioner", - request: "ClearApplicationsResources", + request: "DestroyUnits", version: 1, params: params, }; @@ -594,6 +630,24 @@ class CAASApplicationProvisionerV1 implements Facade { }); } + /** + ProvisionerConfig returns the provisioner's configuration. + */ + provisionerConfig( + params: any + ): Promise { + return new Promise((resolve, reject) => { + const req: JujuRequest = { + type: "CAASApplicationProvisioner", + request: "ProvisionerConfig", + version: 1, + params: params, + }; + + this._transport.write(req, resolve, reject); + }); + } + /** ProvisioningInfo returns the info needed to provision a caas application. */ @@ -612,6 +666,24 @@ class CAASApplicationProvisionerV1 implements Facade { }); } + /** + ProvisioningState returns the provisioning state for the application. + */ + provisioningState( + params: Entity + ): Promise { + return new Promise((resolve, reject) => { + const req: JujuRequest = { + type: "CAASApplicationProvisioner", + request: "ProvisioningState", + version: 1, + params: params, + }; + + this._transport.write(req, resolve, reject); + }); + } + /** Remove removes every given entity from state, calling EnsureDead first, then Remove. It will fail if the entity is not present. @@ -661,6 +733,24 @@ class CAASApplicationProvisionerV1 implements Facade { }); } + /** + SetProvisioningState sets the provisioning state for the application. + */ + setProvisioningState( + params: CAASApplicationProvisioningStateArg + ): Promise { + return new Promise((resolve, reject) => { + const req: JujuRequest = { + type: "CAASApplicationProvisioner", + request: "SetProvisioningState", + version: 1, + params: params, + }; + + this._transport.write(req, resolve, reject); + }); + } + /** Units returns all the units for each application specified. */ @@ -729,6 +819,24 @@ class CAASApplicationProvisionerV1 implements Facade { }); } + /** + WatchProvisioningInfo provides a watcher for changes that affect the + information returned by ProvisioningInfo. This is useful for ensuring the + latest application stated is ensured. + */ + watchProvisioningInfo(params: Entities): Promise { + return new Promise((resolve, reject) => { + const req: JujuRequest = { + type: "CAASApplicationProvisioner", + request: "WatchProvisioningInfo", + version: 1, + params: params, + }; + + this._transport.write(req, resolve, reject); + }); + } + /** WatchUnits starts a StringsWatcher to watch changes to the lifecycle states of units for the specified applications in diff --git a/api/facades/caasapplication/CAASApplicationV1.ts b/api/facades/caasapplication/CAASApplicationV1.ts index 0d2a7b1ee..e87a4b4f4 100644 --- a/api/facades/caasapplication/CAASApplicationV1.ts +++ b/api/facades/caasapplication/CAASApplicationV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/caasfirewaller-sidecar/CAASFirewallerSidecarV1.ts b/api/facades/caasfirewaller-sidecar/CAASFirewallerSidecarV1.ts index 9c212d3a7..442e8d76b 100644 --- a/api/facades/caasfirewaller-sidecar/CAASFirewallerSidecarV1.ts +++ b/api/facades/caasfirewaller-sidecar/CAASFirewallerSidecarV1.ts @@ -4,7 +4,7 @@ Controller-machine-agent NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -17,6 +17,20 @@ export interface ApplicationGetConfigResults { Results: ConfigResult[]; } +export interface ApplicationOpenedPorts { + endpoint: string; + "port-ranges": PortRange[]; +} + +export interface ApplicationOpenedPortsResult { + "application-port-ranges": ApplicationOpenedPorts[]; + error?: Error; +} + +export interface ApplicationOpenedPortsResults { + results: ApplicationOpenedPortsResult[]; +} + export interface BoolResult { error?: Error; result: boolean; @@ -28,7 +42,7 @@ export interface BoolResults { export interface Charm { actions?: CharmActions; - config: AdditionalProperties; + config: Record; "lxd-profile"?: CharmLXDProfile; manifest?: CharmManifest; meta?: CharmMeta; @@ -43,7 +57,7 @@ export interface CharmActionSpec { } export interface CharmActions { - specs: AdditionalProperties; + specs: Record; } export interface CharmBase { @@ -73,9 +87,9 @@ export interface CharmDevice { } export interface CharmLXDProfile { - config: AdditionalProperties; + config: Record; description: string; - devices: AdditionalProperties; + devices: Record>; } export interface CharmManifest { @@ -85,20 +99,20 @@ export interface CharmManifest { export interface CharmMeta { "assumes-expr"?: ExpressionTree; categories?: string[]; - containers?: AdditionalProperties; + containers?: Record; deployment?: CharmDeployment; description: string; - devices?: AdditionalProperties; - "extra-bindings"?: AdditionalProperties; + devices?: Record; + "extra-bindings"?: Record; "min-juju-version"?: string; name: string; - "payload-classes"?: AdditionalProperties; - peers?: AdditionalProperties; - provides?: AdditionalProperties; - requires?: AdditionalProperties; - resources?: AdditionalProperties; + "payload-classes"?: Record; + peers?: Record; + provides?: Record; + requires?: Record; + resources?: Record; series?: string[]; - storage?: AdditionalProperties; + storage?: Record; subordinate: boolean; summary: string; tags?: string[]; @@ -111,7 +125,7 @@ export interface CharmMetric { } export interface CharmMetrics { - metrics: AdditionalProperties; + metrics: Record; plan: CharmPlan; } @@ -209,6 +223,12 @@ export interface NotifyWatchResults { results: NotifyWatchResult[]; } +export interface PortRange { + "from-port": number; + protocol: string; + "to-port": number; +} + export interface StringsWatchResult { changes?: string[]; error?: Error; @@ -291,6 +311,22 @@ class CAASFirewallerSidecarV1 implements Facade { }); } + /** + GetOpenedPorts returns all the opened ports for each given application tag. + */ + getOpenedPorts(params: Entity): Promise { + return new Promise((resolve, reject) => { + const req: JujuRequest = { + type: "CAASFirewallerSidecar", + request: "GetOpenedPorts", + version: 1, + params: params, + }; + + this._transport.write(req, resolve, reject); + }); + } + /** IsExposed returns whether the specified applications are exposed. */ diff --git a/api/facades/caasfirewaller/CAASFirewallerV1.ts b/api/facades/caasfirewaller/CAASFirewallerV1.ts index c20c7d72a..ea6a44b90 100644 --- a/api/facades/caasfirewaller/CAASFirewallerV1.ts +++ b/api/facades/caasfirewaller/CAASFirewallerV1.ts @@ -4,7 +4,7 @@ Controller-machine-agent NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -28,7 +28,7 @@ export interface BoolResults { export interface Charm { actions?: CharmActions; - config: AdditionalProperties; + config: Record; "lxd-profile"?: CharmLXDProfile; manifest?: CharmManifest; meta?: CharmMeta; @@ -43,7 +43,7 @@ export interface CharmActionSpec { } export interface CharmActions { - specs: AdditionalProperties; + specs: Record; } export interface CharmBase { @@ -73,9 +73,9 @@ export interface CharmDevice { } export interface CharmLXDProfile { - config: AdditionalProperties; + config: Record; description: string; - devices: AdditionalProperties; + devices: Record>; } export interface CharmManifest { @@ -85,20 +85,20 @@ export interface CharmManifest { export interface CharmMeta { "assumes-expr"?: ExpressionTree; categories?: string[]; - containers?: AdditionalProperties; + containers?: Record; deployment?: CharmDeployment; description: string; - devices?: AdditionalProperties; - "extra-bindings"?: AdditionalProperties; + devices?: Record; + "extra-bindings"?: Record; "min-juju-version"?: string; name: string; - "payload-classes"?: AdditionalProperties; - peers?: AdditionalProperties; - provides?: AdditionalProperties; - requires?: AdditionalProperties; - resources?: AdditionalProperties; + "payload-classes"?: Record; + peers?: Record; + provides?: Record; + requires?: Record; + resources?: Record; series?: string[]; - storage?: AdditionalProperties; + storage?: Record; subordinate: boolean; summary: string; tags?: string[]; @@ -111,7 +111,7 @@ export interface CharmMetric { } export interface CharmMetrics { - metrics: AdditionalProperties; + metrics: Record; plan: CharmPlan; } diff --git a/api/facades/caasmodel-config-manager/CAASModelConfigManagerV1.ts b/api/facades/caasmodel-config-manager/CAASModelConfigManagerV1.ts index 9f6aa07f0..e63d01bec 100644 --- a/api/facades/caasmodel-config-manager/CAASModelConfigManagerV1.ts +++ b/api/facades/caasmodel-config-manager/CAASModelConfigManagerV1.ts @@ -4,7 +4,7 @@ Controller-machine-agent NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/caasmodel-operator/CAASModelOperatorV1.ts b/api/facades/caasmodel-operator/CAASModelOperatorV1.ts index 629256cc8..cc08ae4e9 100644 --- a/api/facades/caasmodel-operator/CAASModelOperatorV1.ts +++ b/api/facades/caasmodel-operator/CAASModelOperatorV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/caasoperator-provisioner/CAASOperatorProvisionerV1.ts b/api/facades/caasoperator-provisioner/CAASOperatorProvisionerV1.ts index 37207858e..a7e6f62c2 100644 --- a/api/facades/caasoperator-provisioner/CAASOperatorProvisionerV1.ts +++ b/api/facades/caasoperator-provisioner/CAASOperatorProvisionerV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -33,7 +33,7 @@ export interface Address { export interface Charm { actions?: CharmActions; - config: AdditionalProperties; + config: Record; "lxd-profile"?: CharmLXDProfile; manifest?: CharmManifest; meta?: CharmMeta; @@ -48,7 +48,7 @@ export interface CharmActionSpec { } export interface CharmActions { - specs: AdditionalProperties; + specs: Record; } export interface CharmBase { @@ -78,9 +78,9 @@ export interface CharmDevice { } export interface CharmLXDProfile { - config: AdditionalProperties; + config: Record; description: string; - devices: AdditionalProperties; + devices: Record>; } export interface CharmManifest { @@ -90,20 +90,20 @@ export interface CharmManifest { export interface CharmMeta { "assumes-expr"?: ExpressionTree; categories?: string[]; - containers?: AdditionalProperties; + containers?: Record; deployment?: CharmDeployment; description: string; - devices?: AdditionalProperties; - "extra-bindings"?: AdditionalProperties; + devices?: Record; + "extra-bindings"?: Record; "min-juju-version"?: string; name: string; - "payload-classes"?: AdditionalProperties; - peers?: AdditionalProperties; - provides?: AdditionalProperties; - requires?: AdditionalProperties; - resources?: AdditionalProperties; + "payload-classes"?: Record; + peers?: Record; + provides?: Record; + requires?: Record; + resources?: Record; series?: string[]; - storage?: AdditionalProperties; + storage?: Record; subordinate: boolean; summary: string; tags?: string[]; @@ -116,7 +116,7 @@ export interface CharmMetric { } export interface CharmMetrics { - metrics: AdditionalProperties; + metrics: Record; plan: CharmPlan; } @@ -256,7 +256,7 @@ export interface KubernetesFilesystemParams { provider: string; size: number; storagename: string; - tags?: AdditionalProperties; + tags?: Record; } export interface LifeResult { @@ -287,7 +287,7 @@ export interface OperatorProvisioningInfo { "charm-storage"?: KubernetesFilesystemParams; error?: Error; "image-details": DockerImageInfo; - tags?: AdditionalProperties; + tags?: Record; version: Number; } diff --git a/api/facades/caasoperator-upgrader/CAASOperatorUpgraderV1.ts b/api/facades/caasoperator-upgrader/CAASOperatorUpgraderV1.ts index 3c98ca012..070997f93 100644 --- a/api/facades/caasoperator-upgrader/CAASOperatorUpgraderV1.ts +++ b/api/facades/caasoperator-upgrader/CAASOperatorUpgraderV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/caasoperator/CAASOperatorV1.ts b/api/facades/caasoperator/CAASOperatorV1.ts index e4d891676..df7865030 100644 --- a/api/facades/caasoperator/CAASOperatorV1.ts +++ b/api/facades/caasoperator/CAASOperatorV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/caasunit-provisioner/CAASUnitProvisionerV2.ts b/api/facades/caasunit-provisioner/CAASUnitProvisionerV2.ts index eb543abe8..934ece74e 100644 --- a/api/facades/caasunit-provisioner/CAASUnitProvisionerV2.ts +++ b/api/facades/caasunit-provisioner/CAASUnitProvisionerV2.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -59,7 +59,7 @@ export interface BoolResults { export interface Charm { actions?: CharmActions; - config: AdditionalProperties; + config: Record; "lxd-profile"?: CharmLXDProfile; manifest?: CharmManifest; meta?: CharmMeta; @@ -74,7 +74,7 @@ export interface CharmActionSpec { } export interface CharmActions { - specs: AdditionalProperties; + specs: Record; } export interface CharmBase { @@ -104,9 +104,9 @@ export interface CharmDevice { } export interface CharmLXDProfile { - config: AdditionalProperties; + config: Record; description: string; - devices: AdditionalProperties; + devices: Record>; } export interface CharmManifest { @@ -116,20 +116,20 @@ export interface CharmManifest { export interface CharmMeta { "assumes-expr"?: ExpressionTree; categories?: string[]; - containers?: AdditionalProperties; + containers?: Record; deployment?: CharmDeployment; description: string; - devices?: AdditionalProperties; - "extra-bindings"?: AdditionalProperties; + devices?: Record; + "extra-bindings"?: Record; "min-juju-version"?: string; name: string; - "payload-classes"?: AdditionalProperties; - peers?: AdditionalProperties; - provides?: AdditionalProperties; - requires?: AdditionalProperties; - resources?: AdditionalProperties; + "payload-classes"?: Record; + peers?: Record; + provides?: Record; + requires?: Record; + resources?: Record; series?: string[]; - storage?: AdditionalProperties; + storage?: Record; subordinate: boolean; summary: string; tags?: string[]; @@ -142,7 +142,7 @@ export interface CharmMetric { } export interface CharmMetrics { - metrics: AdditionalProperties; + metrics: Record; plan: CharmPlan; } @@ -271,7 +271,7 @@ export interface KubernetesDeploymentInfo { } export interface KubernetesDeviceParams { - Attributes: AdditionalProperties; + Attributes: Record; Count: number; Type: string; } @@ -301,7 +301,7 @@ export interface KubernetesFilesystemParams { provider: string; size: number; storagename: string; - tags?: AdditionalProperties; + tags?: Record; } export interface KubernetesProvisioningInfo { @@ -313,7 +313,7 @@ export interface KubernetesProvisioningInfo { "image-repo"?: DockerImageInfo; "pod-spec": string; "raw-k8s-spec"?: string; - tags?: AdditionalProperties; + tags?: Record; volumes?: KubernetesVolumeParams[]; } @@ -347,7 +347,7 @@ export interface KubernetesVolumeParams { provider: string; size: number; storagename: string; - tags?: AdditionalProperties; + tags?: Record; } export interface LifeResult { @@ -434,6 +434,7 @@ export interface Value { container: string; cores: number; "cpu-power": number; + "image-id": string; "instance-role": string; "instance-type": string; mem: number; diff --git a/api/facades/charm-downloader/CharmDownloaderV1.ts b/api/facades/charm-downloader/CharmDownloaderV1.ts index f66181a6e..8c40a12c6 100644 --- a/api/facades/charm-downloader/CharmDownloaderV1.ts +++ b/api/facades/charm-downloader/CharmDownloaderV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/charm-revision-updater/CharmRevisionUpdaterV2.ts b/api/facades/charm-revision-updater/CharmRevisionUpdaterV2.ts index 52b231dee..e06cdde09 100644 --- a/api/facades/charm-revision-updater/CharmRevisionUpdaterV2.ts +++ b/api/facades/charm-revision-updater/CharmRevisionUpdaterV2.ts @@ -4,7 +4,7 @@ Controller-machine-agent NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/charms/CharmsV6.ts b/api/facades/charms/CharmsV6.ts index 2431359e4..e52682919 100644 --- a/api/facades/charms/CharmsV6.ts +++ b/api/facades/charms/CharmsV6.ts @@ -4,7 +4,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.2-rc1 at the git SHA 3a098707a1. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -35,7 +35,7 @@ export interface Base { export interface Charm { actions?: CharmActions; - config: AdditionalProperties; + config: Record; "lxd-profile"?: CharmLXDProfile; manifest?: CharmManifest; meta?: CharmMeta; @@ -50,7 +50,7 @@ export interface CharmActionSpec { } export interface CharmActions { - specs: AdditionalProperties; + specs: Record; } export interface CharmBase { @@ -80,9 +80,9 @@ export interface CharmDevice { } export interface CharmLXDProfile { - config: AdditionalProperties; + config: Record; description: string; - devices: AdditionalProperties; + devices: Record>; } export interface CharmManifest { @@ -92,20 +92,20 @@ export interface CharmManifest { export interface CharmMeta { "assumes-expr"?: ExpressionTree; categories?: string[]; - containers?: AdditionalProperties; + containers?: Record; deployment?: CharmDeployment; description: string; - devices?: AdditionalProperties; - "extra-bindings"?: AdditionalProperties; + devices?: Record; + "extra-bindings"?: Record; "min-juju-version"?: string; name: string; - "payload-classes"?: AdditionalProperties; - peers?: AdditionalProperties; - provides?: AdditionalProperties; - requires?: AdditionalProperties; - resources?: AdditionalProperties; + "payload-classes"?: Record; + peers?: Record; + provides?: Record; + requires?: Record; + resources?: Record; series?: string[]; - storage?: AdditionalProperties; + storage?: Record; subordinate: boolean; summary: string; tags?: string[]; @@ -118,7 +118,7 @@ export interface CharmMetric { } export interface CharmMetrics { - metrics: AdditionalProperties; + metrics: Record; plan: CharmPlan; } diff --git a/api/facades/cleaner/CleanerV2.ts b/api/facades/cleaner/CleanerV2.ts index cc0f376b8..38c33641e 100644 --- a/api/facades/cleaner/CleanerV2.ts +++ b/api/facades/cleaner/CleanerV2.ts @@ -4,7 +4,7 @@ Controller-machine-agent NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/client/ClientV6.ts b/api/facades/client/ClientV6.ts index a5c9aaddd..0f03ffb1e 100644 --- a/api/facades/client/ClientV6.ts +++ b/api/facades/client/ClientV6.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -24,7 +24,7 @@ export interface ApplicationOfferStatus { "active-connected-count": number; "application-name": string; charm: string; - endpoints: AdditionalProperties; + endpoints: Record; err?: Error; "offer-name": string; "total-connected-count": number; @@ -37,19 +37,19 @@ export interface ApplicationStatus { "charm-channel"?: string; "charm-profile": string; "charm-version": string; - "endpoint-bindings": AdditionalProperties; + "endpoint-bindings": Record; err?: Error; exposed: boolean; - "exposed-endpoints"?: AdditionalProperties; + "exposed-endpoints"?: Record; int?: number; life: string; - "meter-statuses": AdditionalProperties; + "meter-statuses": Record; "provider-id"?: string; "public-address": string; - relations: AdditionalProperties; + relations: Record; status: DetailedStatus; "subordinate-to": string[]; - units: AdditionalProperties; + units: Record; "workload-version": string; } @@ -70,7 +70,7 @@ export interface Binary { } export interface BranchStatus { - "assigned-units": AdditionalProperties; + "assigned-units": Record; created: number; "created-by": string; } @@ -108,7 +108,6 @@ export interface FindToolsParams { agentstream: string; arch: string; major: number; - minor: number; number: Number; "os-type": string; } @@ -119,14 +118,14 @@ export interface FindToolsResult { } export interface FullStatus { - applications: AdditionalProperties; - branches: AdditionalProperties; + applications: Record; + branches: Record; "controller-timestamp": string; - machines: AdditionalProperties; + machines: Record; model: ModelStatusInfo; - offers: AdditionalProperties; + offers: Record; relations: RelationStatus[]; - "remote-applications": AdditionalProperties; + "remote-applications": Record; } export interface History { @@ -135,16 +134,16 @@ export interface History { } export interface LXDProfile { - config: AdditionalProperties; + config: Record; description: string; - devices: AdditionalProperties; + devices: Record>; } export interface MachineStatus { "agent-status": DetailedStatus; base: Base; constraints: string; - containers: AdditionalProperties; + containers: Record; "display-name": string; "dns-name": string; hardware: string; @@ -155,9 +154,9 @@ export interface MachineStatus { "instance-status": DetailedStatus; "ip-addresses"?: string[]; jobs: string[]; - "lxd-profiles"?: AdditionalProperties; + "lxd-profiles"?: Record; "modification-status": DetailedStatus; - "network-interfaces"?: AdditionalProperties; + "network-interfaces"?: Record; "primary-controller-machine"?: boolean; "wants-vote": boolean; } @@ -211,7 +210,7 @@ export interface RemoteApplicationStatus { life: string; "offer-name": string; "offer-url": string; - relations: AdditionalProperties; + relations: Record; status: DetailedStatus; } @@ -269,7 +268,7 @@ export interface UnitStatus { "opened-ports": string[]; "provider-id"?: string; "public-address": string; - subordinates: AdditionalProperties; + subordinates: Record; "workload-status": DetailedStatus; "workload-version": string; } @@ -300,6 +299,7 @@ class ClientV6 implements Facade { } /** FindTools returns a List containing all tools matching the given parameters. + TODO(juju 3.1) - remove, used by 2.9 client only */ findTools(params: FindToolsParams): Promise { return new Promise((resolve, reject) => { diff --git a/api/facades/cloud/CloudV7.ts b/api/facades/cloud/CloudV7.ts index 3e6a9c425..b995158b7 100644 --- a/api/facades/cloud/CloudV7.ts +++ b/api/facades/cloud/CloudV7.ts @@ -7,7 +7,7 @@ Controllers NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -38,7 +38,7 @@ export interface Cloud { } export interface CloudCredential { - attrs?: AdditionalProperties; + attrs?: Record; "auth-type": string; redacted?: string[]; } @@ -118,7 +118,7 @@ export interface CloudUserInfo { } export interface CloudsResult { - clouds: AdditionalProperties; + clouds: Record; } export interface ControllerCredentialInfo { @@ -127,7 +127,7 @@ export interface ControllerCredentialInfo { } export interface CredentialContent { - attrs?: AdditionalProperties; + attrs?: Record; "auth-type": string; cloud: string; name: string; @@ -290,6 +290,7 @@ export interface Value { container: string; cores: number; "cpu-power": number; + "image-id": string; "instance-role": string; "instance-type": string; mem: number; diff --git a/api/facades/controller/ControllerV11.ts b/api/facades/controller/ControllerV11.ts index 50d124206..43900c95f 100644 --- a/api/facades/controller/ControllerV11.ts +++ b/api/facades/controller/ControllerV11.ts @@ -7,7 +7,7 @@ Controllers NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -21,7 +21,7 @@ export interface AllWatcherId { } export interface CloudCredential { - attrs?: AdditionalProperties; + attrs?: Record; "auth-type": string; redacted?: string[]; } @@ -78,17 +78,14 @@ export interface ControllerVersionResults { export interface DashboardConnectionInfo { error?: Error; - "proxy-connection": DashboardConnectionProxy; + "proxy-connection": Proxy; "ssh-connection": DashboardConnectionSSHTunnel; } -export interface DashboardConnectionProxy { - config: AdditionalProperties; - type: string; -} - export interface DashboardConnectionSSHTunnel { + entity?: string; host: string; + model?: string; port: string; } @@ -156,6 +153,7 @@ export interface MachineHardware { mem: number; "root-disk": number; tags: string[]; + "virt-type": string; } export interface MigrationSpec { @@ -180,6 +178,10 @@ export interface Model { uuid: string; } +export interface ModelApplicationInfo { + name: string; +} + export interface ModelBlockInfo { blocks: string[]; "model-uuid": string; @@ -192,7 +194,7 @@ export interface ModelBlockInfoList { } export interface ModelConfigResults { - config: AdditionalProperties; + config: Record; } export interface ModelFilesystemInfo { @@ -217,6 +219,7 @@ export interface ModelMachineInfo { export interface ModelStatus { "application-count": number; + applications?: ModelApplicationInfo[]; error?: Error; filesystems?: ModelFilesystemInfo[]; "hosted-machine-count": number; @@ -264,6 +267,11 @@ export interface NotifyWatchResults { results: NotifyWatchResult[]; } +export interface Proxy { + config: AdditionalProperties; + type: string; +} + export interface RemoveBlocksArgs { all: boolean; } diff --git a/api/facades/credential-manager/CredentialManagerV1.ts b/api/facades/credential-manager/CredentialManagerV1.ts index 11a069388..1b318e9e6 100644 --- a/api/facades/credential-manager/CredentialManagerV1.ts +++ b/api/facades/credential-manager/CredentialManagerV1.ts @@ -4,7 +4,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/credential-validator/CredentialValidatorV2.ts b/api/facades/credential-validator/CredentialValidatorV2.ts index e7fd3a841..885aba8c6 100644 --- a/api/facades/credential-validator/CredentialValidatorV2.ts +++ b/api/facades/credential-validator/CredentialValidatorV2.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/cross-controller/CrossControllerV1.ts b/api/facades/cross-controller/CrossControllerV1.ts index 95f45f40c..43b283c2b 100644 --- a/api/facades/cross-controller/CrossControllerV1.ts +++ b/api/facades/cross-controller/CrossControllerV1.ts @@ -7,7 +7,7 @@ Controllers NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/cross-model-relations/CrossModelRelationsV2.ts b/api/facades/cross-model-relations/CrossModelRelationsV2.ts index 17295ce89..582058a93 100644 --- a/api/facades/cross-model-relations/CrossModelRelationsV2.ts +++ b/api/facades/cross-model-relations/CrossModelRelationsV2.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -38,7 +38,6 @@ export interface ErrorResults { } export interface IngressNetworksChangeEvent { - "application-token": string; "bakery-version"?: number; "ingress-required": boolean; macaroons?: Macaroon[]; @@ -81,6 +80,7 @@ export interface OfferStatusWatchResults { export interface RegisterRemoteRelationArg { "application-token": string; + "auth-token"?: string; "bakery-version"?: number; "consume-version"?: number; "local-endpoint-name": string; @@ -187,6 +187,21 @@ export interface RemoteSpace { subnets: Subnet[]; } +export interface SecretRevisionChange { + revision: number; + uri: string; +} + +export interface SecretRevisionWatchResult { + changes: SecretRevisionChange[]; + error?: Error; + "watcher-id": string; +} + +export interface SecretRevisionWatchResults { + results: SecretRevisionWatchResult[]; +} + export interface StringsWatchResult { changes?: string[]; error?: Error; @@ -209,6 +224,17 @@ export interface Subnet { zones: string[]; } +export interface WatchRemoteSecretChangesArg { + "application-token": string; + "bakery-version"?: number; + macaroons?: Macaroon[]; + "relation-token": string; +} + +export interface WatchRemoteSecretChangesArgs { + relations: WatchRemoteSecretChangesArg[]; +} + export interface AdditionalProperties { [key: string]: any; } @@ -290,6 +316,25 @@ class CrossModelRelationsV2 implements Facade { }); } + /** + WatchConsumedSecretsChanges returns a watcher which notifies of changes to any secrets + for the specified remote consumers. + */ + watchConsumedSecretsChanges( + params: WatchRemoteSecretChangesArgs + ): Promise { + return new Promise((resolve, reject) => { + const req: JujuRequest = { + type: "CrossModelRelations", + request: "WatchConsumedSecretsChanges", + version: 2, + params: params, + }; + + this._transport.write(req, resolve, reject); + }); + } + /** WatchEgressAddressesForRelations creates a watcher that notifies when addresses, from which connections will originate for the relation, change. diff --git a/api/facades/cross-model-secrets/CrossModelSecretsV1.ts b/api/facades/cross-model-secrets/CrossModelSecretsV1.ts index 496bf78e4..b65e7085a 100644 --- a/api/facades/cross-model-secrets/CrossModelSecretsV1.ts +++ b/api/facades/cross-model-secrets/CrossModelSecretsV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.2-rc1 at the git SHA 3a098707a1. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -65,7 +65,7 @@ export interface SecretBackendConfigResult { } export interface SecretContentParams { - data: AdditionalProperties; + data: Record; "value-ref": SecretValueRef; } diff --git a/api/facades/deployer/DeployerV1.ts b/api/facades/deployer/DeployerV1.ts index 42a29148f..b2687d618 100644 --- a/api/facades/deployer/DeployerV1.ts +++ b/api/facades/deployer/DeployerV1.ts @@ -5,7 +5,7 @@ Machine-agent NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/disk-manager/DiskManagerV2.ts b/api/facades/disk-manager/DiskManagerV2.ts index 6053af375..f82cd10d9 100644 --- a/api/facades/disk-manager/DiskManagerV2.ts +++ b/api/facades/disk-manager/DiskManagerV2.ts @@ -5,7 +5,7 @@ Machine-agent NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/entity-watcher/EntityWatcherV2.ts b/api/facades/entity-watcher/EntityWatcherV2.ts index 722ffa821..e59fe19c5 100644 --- a/api/facades/entity-watcher/EntityWatcherV2.ts +++ b/api/facades/entity-watcher/EntityWatcherV2.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/environ-upgrader/EnvironUpgraderV1.ts b/api/facades/environ-upgrader/EnvironUpgraderV1.ts index 92f3cfd18..8fe3a1800 100644 --- a/api/facades/environ-upgrader/EnvironUpgraderV1.ts +++ b/api/facades/environ-upgrader/EnvironUpgraderV1.ts @@ -4,7 +4,7 @@ Controller-machine-agent NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/external-controller-updater/ExternalControllerUpdaterV1.ts b/api/facades/external-controller-updater/ExternalControllerUpdaterV1.ts index 50c3863fb..6d445e844 100644 --- a/api/facades/external-controller-updater/ExternalControllerUpdaterV1.ts +++ b/api/facades/external-controller-updater/ExternalControllerUpdaterV1.ts @@ -4,7 +4,7 @@ Controller-machine-agent NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/fan-configurer/FanConfigurerV1.ts b/api/facades/fan-configurer/FanConfigurerV1.ts index f7b0bfe4f..3d1e63fdd 100644 --- a/api/facades/fan-configurer/FanConfigurerV1.ts +++ b/api/facades/fan-configurer/FanConfigurerV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/filesystem-attachments-watcher/FilesystemAttachmentsWatcherV2.ts b/api/facades/filesystem-attachments-watcher/FilesystemAttachmentsWatcherV2.ts index df7c48879..26bb715ec 100644 --- a/api/facades/filesystem-attachments-watcher/FilesystemAttachmentsWatcherV2.ts +++ b/api/facades/filesystem-attachments-watcher/FilesystemAttachmentsWatcherV2.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/firewaller/FirewallerV7.ts b/api/facades/firewaller/FirewallerV7.ts index 25f35156d..8625435e9 100644 --- a/api/facades/firewaller/FirewallerV7.ts +++ b/api/facades/firewaller/FirewallerV7.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -26,7 +26,7 @@ export interface BoolResults { } export interface CloudCredential { - attrs?: AdditionalProperties; + attrs?: Record; "auth-type": string; redacted?: string[]; } @@ -99,7 +99,7 @@ export interface ErrorResults { export interface ExposeInfoResult { error: Error; exposed: boolean; - "exposed-endpoints": AdditionalProperties; + "exposed-endpoints": Record; } export interface ExposeInfoResults { @@ -116,13 +116,14 @@ export interface FanConfigEntry { underlay: string; } -export interface FirewallRule { - "known-service": string; - "whitelist-cidrs"?: string[]; +export interface IngressRule { + "port-range": PortRange; + "source-cidrs": string[]; } -export interface KnownServiceArgs { - "known-services": string[]; +export interface IngressRulesResult { + error?: Error; + rules: IngressRule[]; } export interface LifeResult { @@ -134,10 +135,6 @@ export interface LifeResults { results: LifeResult[]; } -export interface ListFirewallRulesResults { - Rules: FirewallRule[]; -} - export interface Macaroon { [key: string]: AdditionalProperties; } @@ -170,7 +167,7 @@ export interface NotifyWatchResults { export interface OpenMachinePortRangesResult { error?: Error; - "unit-port-ranges": AdditionalProperties; + "unit-port-ranges": Record; } export interface OpenMachinePortRangesResults { @@ -362,22 +359,6 @@ class FirewallerV7 implements Facade { }); } - /** - FirewallRules returns the firewall rules for the specified well known service types. - */ - firewallRules(params: KnownServiceArgs): Promise { - return new Promise((resolve, reject) => { - const req: JujuRequest = { - type: "Firewaller", - request: "FirewallRules", - version: 7, - params: params, - }; - - this._transport.write(req, resolve, reject); - }); - } - /** GetAssignedMachine returns the assigned machine tag (if any) for each given unit. @@ -493,6 +474,23 @@ class FirewallerV7 implements Facade { }); } + /** + ModelFirewallRules returns the firewall rules that this model is + configured to open + */ + modelFirewallRules(params: any): Promise { + return new Promise((resolve, reject) => { + const req: JujuRequest = { + type: "Firewaller", + request: "ModelFirewallRules", + version: 7, + params: params, + }; + + this._transport.write(req, resolve, reject); + }); + } + /** OpenedMachinePortRanges returns a list of the opened port ranges for the specified machines where each result is broken down by unit. The list of @@ -638,6 +636,23 @@ class FirewallerV7 implements Facade { }); } + /** + WatchModelFirewallRules returns a NotifyWatcher that notifies of + potential changes to a model's configured firewall rules + */ + watchModelFirewallRules(params: any): Promise { + return new Promise((resolve, reject) => { + const req: JujuRequest = { + type: "Firewaller", + request: "WatchModelFirewallRules", + version: 7, + params: params, + }; + + this._transport.write(req, resolve, reject); + }); + } + /** WatchModelMachineStartTimes watches the non-container machines in the model for changes to the Life or AgentStartTime fields and reports them as a batch. diff --git a/api/facades/high-availability/HighAvailabilityV2.ts b/api/facades/high-availability/HighAvailabilityV2.ts index 99eb95ca0..c5aa24ed5 100644 --- a/api/facades/high-availability/HighAvailabilityV2.ts +++ b/api/facades/high-availability/HighAvailabilityV2.ts @@ -5,7 +5,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -52,6 +52,7 @@ export interface Value { container: string; cores: number; "cpu-power": number; + "image-id": string; "instance-role": string; "instance-type": string; mem: number; diff --git a/api/facades/host-key-reporter/HostKeyReporterV1.ts b/api/facades/host-key-reporter/HostKeyReporterV1.ts index 1b848ccdd..3fe0651d1 100644 --- a/api/facades/host-key-reporter/HostKeyReporterV1.ts +++ b/api/facades/host-key-reporter/HostKeyReporterV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/image-metadata-manager/ImageMetadataManagerV1.ts b/api/facades/image-metadata-manager/ImageMetadataManagerV1.ts index a1c5a7245..1f3ef1077 100644 --- a/api/facades/image-metadata-manager/ImageMetadataManagerV1.ts +++ b/api/facades/image-metadata-manager/ImageMetadataManagerV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/image-metadata/ImageMetadataV3.ts b/api/facades/image-metadata/ImageMetadataV3.ts index 6e632912d..7486322cd 100644 --- a/api/facades/image-metadata/ImageMetadataV3.ts +++ b/api/facades/image-metadata/ImageMetadataV3.ts @@ -4,7 +4,7 @@ Controller-machine-agent NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/instance-mutater/InstanceMutaterV3.ts b/api/facades/instance-mutater/InstanceMutaterV3.ts index ba45989f6..5aeaaa366 100644 --- a/api/facades/instance-mutater/InstanceMutaterV3.ts +++ b/api/facades/instance-mutater/InstanceMutaterV3.ts @@ -5,7 +5,7 @@ Machine-agent NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -15,9 +15,9 @@ import { Facade } from "../../types.js"; import { autoBind } from "../../utils.js"; export interface CharmLXDProfile { - config: AdditionalProperties; + config: Record; description: string; - devices: AdditionalProperties; + devices: Record>; } export interface CharmProfilingInfoResult { diff --git a/api/facades/instance-poller/InstancePollerV4.ts b/api/facades/instance-poller/InstancePollerV4.ts index b34025e17..8c09c98c8 100644 --- a/api/facades/instance-poller/InstancePollerV4.ts +++ b/api/facades/instance-poller/InstancePollerV4.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/key-manager/KeyManagerV1.ts b/api/facades/key-manager/KeyManagerV1.ts index 6c60f1242..aed3fcd62 100644 --- a/api/facades/key-manager/KeyManagerV1.ts +++ b/api/facades/key-manager/KeyManagerV1.ts @@ -4,7 +4,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -59,8 +59,7 @@ export interface AdditionalProperties { } /** - KeyManagerAPI implements the KeyUpdater interface and is the concrete - implementation of the api end point. + KeyManagerAPI provides api endpoints for manipulating ssh keys */ class KeyManagerV1 implements Facade { static NAME = "KeyManager"; diff --git a/api/facades/key-updater/KeyUpdaterV1.ts b/api/facades/key-updater/KeyUpdaterV1.ts index c8b91918f..c7578b229 100644 --- a/api/facades/key-updater/KeyUpdaterV1.ts +++ b/api/facades/key-updater/KeyUpdaterV1.ts @@ -5,7 +5,7 @@ Machine-agent NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/leadership-service/LeadershipServiceV2.ts b/api/facades/leadership-service/LeadershipServiceV2.ts index 5e9b4831d..7046ac0e6 100644 --- a/api/facades/leadership-service/LeadershipServiceV2.ts +++ b/api/facades/leadership-service/LeadershipServiceV2.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/life-flag/LifeFlagV1.ts b/api/facades/life-flag/LifeFlagV1.ts index d613cd796..de2138acc 100644 --- a/api/facades/life-flag/LifeFlagV1.ts +++ b/api/facades/life-flag/LifeFlagV1.ts @@ -4,7 +4,7 @@ Controller-machine-agent NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/log-forwarding/LogForwardingV1.ts b/api/facades/log-forwarding/LogForwardingV1.ts index a55a7056c..8dff917b7 100644 --- a/api/facades/log-forwarding/LogForwardingV1.ts +++ b/api/facades/log-forwarding/LogForwardingV1.ts @@ -4,7 +4,7 @@ Controller-machine-agent NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/logger/LoggerV1.ts b/api/facades/logger/LoggerV1.ts index 61881fc8e..597ac0e40 100644 --- a/api/facades/logger/LoggerV1.ts +++ b/api/facades/logger/LoggerV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/machine-actions/MachineActionsV1.ts b/api/facades/machine-actions/MachineActionsV1.ts index 2b35fcef3..465c4d4cd 100644 --- a/api/facades/machine-actions/MachineActionsV1.ts +++ b/api/facades/machine-actions/MachineActionsV1.ts @@ -5,7 +5,7 @@ Machine-agent NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/machine-manager/MachineManagerV10.ts b/api/facades/machine-manager/MachineManagerV10.ts index d8969c95e..4acf1a51a 100644 --- a/api/facades/machine-manager/MachineManagerV10.ts +++ b/api/facades/machine-manager/MachineManagerV10.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.2-rc1 at the git SHA 3a098707a1. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/machine-undertaker/MachineUndertakerV1.ts b/api/facades/machine-undertaker/MachineUndertakerV1.ts index 59284c3fd..6fc8b9be1 100644 --- a/api/facades/machine-undertaker/MachineUndertakerV1.ts +++ b/api/facades/machine-undertaker/MachineUndertakerV1.ts @@ -4,7 +4,7 @@ Controller-machine-agent NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/machiner/MachinerV5.ts b/api/facades/machiner/MachinerV5.ts index 66a794fc8..04114d3ca 100644 --- a/api/facades/machiner/MachinerV5.ts +++ b/api/facades/machiner/MachinerV5.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/meter-status/MeterStatusV2.ts b/api/facades/meter-status/MeterStatusV2.ts index 9816d2650..3648f52e8 100644 --- a/api/facades/meter-status/MeterStatusV2.ts +++ b/api/facades/meter-status/MeterStatusV2.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -58,9 +58,9 @@ export interface NotifyWatchResults { } export interface SetUnitStateArg { - "charm-state"?: AdditionalProperties; + "charm-state"?: Record; "meter-status-state"?: string; - "relation-state"?: AdditionalProperties; + "relation-state"?: Record; "secret-state"?: string; "storage-state"?: string; tag: string; @@ -72,10 +72,10 @@ export interface SetUnitStateArgs { } export interface UnitStateResult { - "charm-state": AdditionalProperties; + "charm-state": Record; error: Error; "meter-status-state": string; - "relation-state": AdditionalProperties; + "relation-state": Record; "secret-state": string; "storage-state": string; "uniter-state": string; diff --git a/api/facades/metrics-adder/MetricsAdderV2.ts b/api/facades/metrics-adder/MetricsAdderV2.ts index 55ae7fdc8..de4ac5ebd 100644 --- a/api/facades/metrics-adder/MetricsAdderV2.ts +++ b/api/facades/metrics-adder/MetricsAdderV2.ts @@ -6,7 +6,7 @@ Unit-agent NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -31,7 +31,7 @@ export interface ErrorResults { export interface Metric { key: string; - labels?: AdditionalProperties; + labels?: Record; time: string; value: string; } diff --git a/api/facades/metrics-debug/MetricsDebugV2.ts b/api/facades/metrics-debug/MetricsDebugV2.ts index 22a884a96..e77d17afb 100644 --- a/api/facades/metrics-debug/MetricsDebugV2.ts +++ b/api/facades/metrics-debug/MetricsDebugV2.ts @@ -4,7 +4,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -52,7 +52,7 @@ export interface MeterStatusParams { export interface MetricResult { key: string; - labels: AdditionalProperties; + labels: Record; time: string; unit: string; value: string; diff --git a/api/facades/metrics-manager/MetricsManagerV1.ts b/api/facades/metrics-manager/MetricsManagerV1.ts index 57d5d31ac..a7c92324f 100644 --- a/api/facades/metrics-manager/MetricsManagerV1.ts +++ b/api/facades/metrics-manager/MetricsManagerV1.ts @@ -4,7 +4,7 @@ Controller-machine-agent NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/migration-flag/MigrationFlagV1.ts b/api/facades/migration-flag/MigrationFlagV1.ts index ecd435eec..f89aadccb 100644 --- a/api/facades/migration-flag/MigrationFlagV1.ts +++ b/api/facades/migration-flag/MigrationFlagV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/migration-master/MigrationMasterV3.ts b/api/facades/migration-master/MigrationMasterV3.ts index a8ad3af00..f06051ebf 100644 --- a/api/facades/migration-master/MigrationMasterV3.ts +++ b/api/facades/migration-master/MigrationMasterV3.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -30,13 +30,21 @@ export interface MasterMigrationStatus { } export interface MigrationModelInfo { - "agent-version": Number; + "agent-version": string; "controller-agent-version": Number; name: string; "owner-tag": string; uuid: string; } +export interface MigrationSourceInfo { + addrs: string[]; + "ca-cert": string; + "controller-alias"?: string; + "controller-tag": string; + "local-related-models": string[]; +} + export interface MigrationSpec { "model-tag": string; "target-info": MigrationTargetInfo; @@ -94,7 +102,7 @@ export interface SerializedModelResource { "application-revision": SerializedModelResourceRevision; "charmstore-revision": SerializedModelResourceRevision; name: string; - "unit-revisions": AdditionalProperties; + "unit-revisions": Record; } export interface SerializedModelResourceRevision { @@ -324,6 +332,23 @@ class MigrationMasterV3 implements Facade { }); } + /** + SourceControllerInfo returns the details required to connect to + the source controller for model migration. + */ + sourceControllerInfo(params: any): Promise { + return new Promise((resolve, reject) => { + const req: JujuRequest = { + type: "MigrationMaster", + request: "SourceControllerInfo", + version: 3, + params: params, + }; + + this._transport.write(req, resolve, reject); + }); + } + /** Watch starts watching for an active migration for the model associated with the API connection. The returned id should be used diff --git a/api/facades/migration-minion/MigrationMinionV1.ts b/api/facades/migration-minion/MigrationMinionV1.ts index 8f4387072..642cf816f 100644 --- a/api/facades/migration-minion/MigrationMinionV1.ts +++ b/api/facades/migration-minion/MigrationMinionV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/migration-status-watcher/MigrationStatusWatcherV1.ts b/api/facades/migration-status-watcher/MigrationStatusWatcherV1.ts index 965de3cc4..59c9d3744 100644 --- a/api/facades/migration-status-watcher/MigrationStatusWatcherV1.ts +++ b/api/facades/migration-status-watcher/MigrationStatusWatcherV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/migration-target/MigrationTargetV2.ts b/api/facades/migration-target/MigrationTargetV2.ts index 379c2b1e1..587178834 100644 --- a/api/facades/migration-target/MigrationTargetV2.ts +++ b/api/facades/migration-target/MigrationTargetV2.ts @@ -4,7 +4,7 @@ Controllers NOTE: This file was generated using the Juju schema - from Juju 3.2-rc1 at the git SHA 3a098707a1. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -46,7 +46,7 @@ export interface ErrorResults { } export interface MigrationModelInfo { - "agent-version": Number; + "agent-version": string; "controller-agent-version": Number; name: string; "owner-tag": string; @@ -77,7 +77,7 @@ export interface SerializedModelResource { "application-revision": SerializedModelResourceRevision; "charmstore-revision": SerializedModelResourceRevision; name: string; - "unit-revisions": AdditionalProperties; + "unit-revisions": Record; } export interface SerializedModelResourceRevision { diff --git a/api/facades/model-config/ModelConfigV3.ts b/api/facades/model-config/ModelConfigV3.ts index ad4abcc06..5bbfc7705 100644 --- a/api/facades/model-config/ModelConfigV3.ts +++ b/api/facades/model-config/ModelConfigV3.ts @@ -8,7 +8,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -33,7 +33,7 @@ export interface GetConstraintsResults { } export interface ModelConfigResults { - config: AdditionalProperties; + config: Record; } export interface ModelSLA { @@ -49,7 +49,7 @@ export interface ModelSLAInfo { } export interface ModelSequencesResult { - sequences: AdditionalProperties; + sequences: Record; } export interface ModelSet { @@ -76,6 +76,7 @@ export interface Value { container: string; cores: number; "cpu-power": number; + "image-id": string; "instance-role": string; "instance-type": string; mem: number; diff --git a/api/facades/model-generation/ModelGenerationV4.ts b/api/facades/model-generation/ModelGenerationV4.ts index 3750664a6..c6e633a2c 100644 --- a/api/facades/model-generation/ModelGenerationV4.ts +++ b/api/facades/model-generation/ModelGenerationV4.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/model-manager/ModelManagerV9.ts b/api/facades/model-manager/ModelManagerV9.ts index 7cab2e411..0ce18a7ec 100644 --- a/api/facades/model-manager/ModelManagerV9.ts +++ b/api/facades/model-manager/ModelManagerV9.ts @@ -7,7 +7,7 @@ Controllers NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -79,6 +79,7 @@ export interface MachineHardware { mem: number; "root-disk": number; tags: string[]; + "virt-type": string; } export interface MapResult { @@ -97,6 +98,10 @@ export interface Model { uuid: string; } +export interface ModelApplicationInfo { + name: string; +} + export interface ModelCreateArgs { "cloud-tag"?: string; config?: AdditionalProperties; @@ -119,7 +124,7 @@ export interface ModelDefaults { } export interface ModelDefaultsResult { - config: AdditionalProperties; + config: Record; error?: Error; } @@ -141,12 +146,13 @@ export interface ModelFilesystemInfo { } export interface ModelInfo { - "agent-version": Number; + "agent-version": string; "cloud-credential-tag"?: string; "cloud-credential-validity"?: boolean; "cloud-region"?: string; "cloud-tag": string; "controller-uuid": string; + "default-base"?: string; "default-series"?: string; "is-controller": boolean; life: string; @@ -155,6 +161,7 @@ export interface ModelInfo { name: string; "owner-tag": string; "provider-type"?: string; + "secret-backends": SecretBackendResult[]; sla: ModelSLAInfo; status?: EntityStatus; "supported-features"?: SupportedFeature[]; @@ -197,6 +204,7 @@ export interface ModelSLAInfo { export interface ModelStatus { "application-count": number; + applications?: ModelApplicationInfo[]; error?: Error; filesystems?: ModelFilesystemInfo[]; "hosted-machine-count": number; @@ -219,7 +227,7 @@ export interface ModelSummariesRequest { } export interface ModelSummary { - "agent-version": Number; + "agent-version": string; "cloud-credential-tag"?: string; "cloud-region"?: string; "cloud-tag": string; @@ -295,6 +303,22 @@ export interface RegionDefaults { value: AdditionalProperties; } +export interface SecretBackend { + "backend-type": string; + config: AdditionalProperties; + name: string; + "token-rotate-interval"?: number; +} + +export interface SecretBackendResult { + error?: Error; + id: string; + message?: string; + "num-secrets": number; + result: SecretBackend; + status: string; +} + export interface SetModelDefaults { config: ModelDefaultValues[]; } diff --git a/api/facades/model-summary-watcher/ModelSummaryWatcherV1.ts b/api/facades/model-summary-watcher/ModelSummaryWatcherV1.ts index 9e24a522a..6d4c49460 100644 --- a/api/facades/model-summary-watcher/ModelSummaryWatcherV1.ts +++ b/api/facades/model-summary-watcher/ModelSummaryWatcherV1.ts @@ -4,7 +4,7 @@ Controllers NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -15,7 +15,7 @@ import { autoBind } from "../../utils.js"; export interface ModelAbstract { admins?: string[]; - annotations?: AdditionalProperties; + annotations?: Record; cloud?: string; controller?: string; credential?: string; diff --git a/api/facades/model-upgrader/ModelUpgraderV1.ts b/api/facades/model-upgrader/ModelUpgraderV1.ts index 22c8a6e89..1e7f17480 100644 --- a/api/facades/model-upgrader/ModelUpgraderV1.ts +++ b/api/facades/model-upgrader/ModelUpgraderV1.ts @@ -7,7 +7,7 @@ Controllers NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/notify-watcher/NotifyWatcherV1.ts b/api/facades/notify-watcher/NotifyWatcherV1.ts index a40f72ee1..a56840430 100644 --- a/api/facades/notify-watcher/NotifyWatcherV1.ts +++ b/api/facades/notify-watcher/NotifyWatcherV1.ts @@ -8,7 +8,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/offer-status-watcher/OfferStatusWatcherV1.ts b/api/facades/offer-status-watcher/OfferStatusWatcherV1.ts index 394d6508e..1eb835967 100644 --- a/api/facades/offer-status-watcher/OfferStatusWatcherV1.ts +++ b/api/facades/offer-status-watcher/OfferStatusWatcherV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/payloads-hook-context/PayloadsHookContextV1.ts b/api/facades/payloads-hook-context/PayloadsHookContextV1.ts index 15ab5baab..c376c5f89 100644 --- a/api/facades/payloads-hook-context/PayloadsHookContextV1.ts +++ b/api/facades/payloads-hook-context/PayloadsHookContextV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/payloads/PayloadsV1.ts b/api/facades/payloads/PayloadsV1.ts index 8798cd200..2777e56bf 100644 --- a/api/facades/payloads/PayloadsV1.ts +++ b/api/facades/payloads/PayloadsV1.ts @@ -4,7 +4,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/pinger/PingerV1.ts b/api/facades/pinger/PingerV1.ts index 982dcb51d..fb3afbac9 100644 --- a/api/facades/pinger/PingerV1.ts +++ b/api/facades/pinger/PingerV1.ts @@ -8,7 +8,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/provisioner/ProvisionerV11.ts b/api/facades/provisioner/ProvisionerV11.ts index ffb1ec0d7..ce6ea8453 100644 --- a/api/facades/provisioner/ProvisionerV11.ts +++ b/api/facades/provisioner/ProvisionerV11.ts @@ -5,7 +5,7 @@ Machine-agent NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -59,9 +59,9 @@ export interface BytesResult { } export interface CharmLXDProfile { - config: AdditionalProperties; + config: Record; description: string; - devices: AdditionalProperties; + devices: Record>; } export interface CloudImageMetadata { @@ -109,7 +109,7 @@ export interface ContainerLXDProfile { } export interface ContainerManagerConfig { - config: AdditionalProperties; + config: Record; } export interface ContainerManagerConfigParams { @@ -196,7 +196,6 @@ export interface FindToolsParams { agentstream: string; arch: string; major: number; - minor: number; number: Number; "os-type": string; } @@ -215,6 +214,7 @@ export interface HardwareCharacteristics { "root-disk": number; "root-disk-source": string; tags: string[]; + "virt-type": string; } export interface HostNetworkChange { @@ -248,7 +248,7 @@ export interface InstanceInfo { "network-config": NetworkConfig[]; nonce: string; tag: string; - "volume-attachments": AdditionalProperties; + "volume-attachments": Record; volumes: Volume[]; } @@ -353,14 +353,14 @@ export interface ProvisioningInfo { "cloudinit-userdata"?: AdditionalProperties; constraints: Value; "controller-config"?: AdditionalProperties; - "endpoint-bindings"?: AdditionalProperties; + "endpoint-bindings"?: Record; "image-metadata"?: CloudImageMetadata[]; jobs: string[]; placement: string; "root-disk"?: VolumeParams; - "space-subnets": AdditionalProperties; - "subnet-zones": AdditionalProperties; - tags?: AdditionalProperties; + "space-subnets": Record; + "subnet-zones": Record; + tags?: Record; "volume-attachments"?: VolumeAttachmentParams[]; volumes?: VolumeParams[]; } @@ -375,8 +375,8 @@ export interface ProvisioningInfoResults { } export interface ProvisioningNetworkTopology { - "space-subnets": AdditionalProperties; - "subnet-zones": AdditionalProperties; + "space-subnets": Record; + "subnet-zones": Record; } export interface SetMachineNetworkConfig { @@ -474,6 +474,7 @@ export interface Value { container: string; cores: number; "cpu-power": number; + "image-id": string; "instance-role": string; "instance-type": string; mem: number; @@ -508,7 +509,7 @@ export interface VolumeAttachmentParams { } export interface VolumeAttachmentPlanInfo { - "device-attributes": AdditionalProperties; + "device-attributes": Record; "device-type": string; } @@ -526,7 +527,7 @@ export interface VolumeParams { attributes?: AdditionalProperties; provider: string; size: number; - tags?: AdditionalProperties; + tags?: Record; "volume-tag": string; } diff --git a/api/facades/proxy-updater/ProxyUpdaterV2.ts b/api/facades/proxy-updater/ProxyUpdaterV2.ts index e958f6ab6..d88b503dc 100644 --- a/api/facades/proxy-updater/ProxyUpdaterV2.ts +++ b/api/facades/proxy-updater/ProxyUpdaterV2.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/reboot/RebootV2.ts b/api/facades/reboot/RebootV2.ts index f1fe43a8d..44b9f9211 100644 --- a/api/facades/reboot/RebootV2.ts +++ b/api/facades/reboot/RebootV2.ts @@ -5,7 +5,7 @@ Machine-agent NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/relation-status-watcher/RelationStatusWatcherV1.ts b/api/facades/relation-status-watcher/RelationStatusWatcherV1.ts index 241ae1979..9536cacf6 100644 --- a/api/facades/relation-status-watcher/RelationStatusWatcherV1.ts +++ b/api/facades/relation-status-watcher/RelationStatusWatcherV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/relation-units-watcher/RelationUnitsWatcherV1.ts b/api/facades/relation-units-watcher/RelationUnitsWatcherV1.ts index 180f46bb0..49368d72a 100644 --- a/api/facades/relation-units-watcher/RelationUnitsWatcherV1.ts +++ b/api/facades/relation-units-watcher/RelationUnitsWatcherV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -23,8 +23,8 @@ export interface Error { } export interface RelationUnitsChange { - "app-changed"?: AdditionalProperties; - changed: AdditionalProperties; + "app-changed"?: Record; + changed: Record; departed?: string[]; } diff --git a/api/facades/remote-relation-watcher/RemoteRelationWatcherV1.ts b/api/facades/remote-relation-watcher/RemoteRelationWatcherV1.ts index 3c0f30c5c..aa6db6e6f 100644 --- a/api/facades/remote-relation-watcher/RemoteRelationWatcherV1.ts +++ b/api/facades/remote-relation-watcher/RemoteRelationWatcherV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/remote-relations/RemoteRelationsV2.ts b/api/facades/remote-relations/RemoteRelationsV2.ts index ea23822b3..4674c4b12 100644 --- a/api/facades/remote-relations/RemoteRelationsV2.ts +++ b/api/facades/remote-relations/RemoteRelationsV2.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -83,6 +83,10 @@ export interface GetTokenArgs { Args: GetTokenArg[]; } +export interface LatestSecretRevisionChanges { + changes: SecretRevisionChange[]; +} + export interface Macaroon { [key: string]: AdditionalProperties; } @@ -179,6 +183,11 @@ export interface RemoteRelationsChanges { changes: RemoteRelationChangeEvent[]; } +export interface SecretRevisionChange { + revision: number; + uri: string; +} + export interface SetStatus { entities: EntityStatusArgs[]; } @@ -263,6 +272,25 @@ class RemoteRelationsV2 implements Facade { }); } + /** + ConsumeRemoteSecretChanges updates the local model with secret revision changes + originating from the remote/offering model. + */ + consumeRemoteSecretChanges( + params: LatestSecretRevisionChanges + ): Promise { + return new Promise((resolve, reject) => { + const req: JujuRequest = { + type: "RemoteRelations", + request: "ConsumeRemoteSecretChanges", + version: 2, + params: params, + }; + + this._transport.write(req, resolve, reject); + }); + } + /** ControllerAPIInfoForModels returns the controller api connection details for the specified models. */ diff --git a/api/facades/resources-hook-context/ResourcesHookContextV1.ts b/api/facades/resources-hook-context/ResourcesHookContextV1.ts index 507a5ab74..29d63ee54 100644 --- a/api/facades/resources-hook-context/ResourcesHookContextV1.ts +++ b/api/facades/resources-hook-context/ResourcesHookContextV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/resources/ResourcesV3.ts b/api/facades/resources/ResourcesV3.ts index d4e0adccf..acc1b66be 100644 --- a/api/facades/resources/ResourcesV3.ts +++ b/api/facades/resources/ResourcesV3.ts @@ -4,7 +4,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -111,7 +111,7 @@ export interface ResourcesResults { export interface UnitResources { Entity: Entity; - "download-progress": AdditionalProperties; + "download-progress": Record; resources: Resource[]; tag: string; } @@ -143,7 +143,7 @@ class ResourcesV3 implements Facade { /** AddPendingResources adds the provided resources (info) to the Juju model in a pending state, meaning they are not available until - resolved. Handles CharmHub, CharmStore and Local charms. + resolved. Handles CharmHub and Local charms. */ addPendingResources( params: AddPendingResourcesArgsV2 diff --git a/api/facades/retry-strategy/RetryStrategyV1.ts b/api/facades/retry-strategy/RetryStrategyV1.ts index 6c5a32ed0..4f68ed11f 100644 --- a/api/facades/retry-strategy/RetryStrategyV1.ts +++ b/api/facades/retry-strategy/RetryStrategyV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/secret-backends-manager/SecretBackendsManagerV1.ts b/api/facades/secret-backends-manager/SecretBackendsManagerV1.ts index ea43a5141..b38a82a5b 100644 --- a/api/facades/secret-backends-manager/SecretBackendsManagerV1.ts +++ b/api/facades/secret-backends-manager/SecretBackendsManagerV1.ts @@ -4,7 +4,7 @@ Controller-machine-agent NOTE: This file was generated using the Juju schema - from Juju 3.2-rc1 at the git SHA 3a098707a1. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/secret-backends-rotate-watcher/SecretBackendsRotateWatcherV1.ts b/api/facades/secret-backends-rotate-watcher/SecretBackendsRotateWatcherV1.ts index d32854bf7..50688b10d 100644 --- a/api/facades/secret-backends-rotate-watcher/SecretBackendsRotateWatcherV1.ts +++ b/api/facades/secret-backends-rotate-watcher/SecretBackendsRotateWatcherV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.2-rc1 at the git SHA 3a098707a1. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/secret-backends/SecretBackendsV1.ts b/api/facades/secret-backends/SecretBackendsV1.ts index 540501570..e1ba70964 100644 --- a/api/facades/secret-backends/SecretBackendsV1.ts +++ b/api/facades/secret-backends/SecretBackendsV1.ts @@ -4,7 +4,7 @@ Controllers NOTE: This file was generated using the Juju schema - from Juju 3.2-rc1 at the git SHA 3a098707a1. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/secrets-drain/SecretsDrainV1.ts b/api/facades/secrets-drain/SecretsDrainV1.ts index cec5eacbd..450a9a475 100644 --- a/api/facades/secrets-drain/SecretsDrainV1.ts +++ b/api/facades/secrets-drain/SecretsDrainV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.2-rc1 at the git SHA 3a098707a1. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -66,7 +66,7 @@ export interface NotifyWatchResult { } export interface SecretContentParams { - data: AdditionalProperties; + data: Record; "value-ref": SecretValueRef; } @@ -85,7 +85,7 @@ export interface SecretValueRef { } export interface SecretValueResult { - data: AdditionalProperties; + data: Record; error: Error; } diff --git a/api/facades/secrets-manager/SecretsManagerV2.ts b/api/facades/secrets-manager/SecretsManagerV2.ts index 6898a6d90..8d6e1c0f8 100644 --- a/api/facades/secrets-manager/SecretsManagerV2.ts +++ b/api/facades/secrets-manager/SecretsManagerV2.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.2-rc1 at the git SHA 3a098707a1. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -133,7 +133,7 @@ export interface SecretBackendConfigResult { export interface SecretBackendConfigResults { "active-id": string; - results?: AdditionalProperties; + results?: Record; } export interface SecretConsumerInfoResult { @@ -147,7 +147,7 @@ export interface SecretConsumerInfoResults { } export interface SecretContentParams { - data: AdditionalProperties; + data: Record; "value-ref": SecretValueRef; } @@ -205,7 +205,7 @@ export interface SecretValueRef { } export interface SecretValueResult { - data: AdditionalProperties; + data: Record; error: Error; } @@ -381,7 +381,6 @@ class SecretsManagerV2 implements Facade { /** GetSecretRevisionContentInfo returns the secret values for the specified secret revisions. - Used when deleting a secret; only returns external revision info. */ getSecretRevisionContentInfo( params: SecretRevisionArg diff --git a/api/facades/secrets-revision-watcher/SecretsRevisionWatcherV1.ts b/api/facades/secrets-revision-watcher/SecretsRevisionWatcherV1.ts index 5b5ffe2cb..650efa0f1 100644 --- a/api/facades/secrets-revision-watcher/SecretsRevisionWatcherV1.ts +++ b/api/facades/secrets-revision-watcher/SecretsRevisionWatcherV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.2-rc1 at the git SHA 3a098707a1. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/secrets-trigger-watcher/SecretsTriggerWatcherV1.ts b/api/facades/secrets-trigger-watcher/SecretsTriggerWatcherV1.ts index 067b941e9..10f61504e 100644 --- a/api/facades/secrets-trigger-watcher/SecretsTriggerWatcherV1.ts +++ b/api/facades/secrets-trigger-watcher/SecretsTriggerWatcherV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/secrets/SecretsV1.ts b/api/facades/secrets/SecretsV1.ts index 8d416642b..ec9e3f275 100644 --- a/api/facades/secrets/SecretsV1.ts +++ b/api/facades/secrets/SecretsV1.ts @@ -4,7 +4,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -45,15 +45,21 @@ export interface ListSecretsArgs { } export interface SecretRevision { + "backend-name"?: string; "create-time"?: string; "expire-time"?: string; - "provider-id"?: string; revision: number; "update-time"?: string; + "value-ref"?: SecretValueRef; +} + +export interface SecretValueRef { + "backend-id": string; + "revision-id": string; } export interface SecretValueResult { - data: AdditionalProperties; + data: Record; error: Error; } diff --git a/api/facades/singular/SingularV2.ts b/api/facades/singular/SingularV2.ts index 68047899b..c946c52b4 100644 --- a/api/facades/singular/SingularV2.ts +++ b/api/facades/singular/SingularV2.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/spaces/SpacesV6.ts b/api/facades/spaces/SpacesV6.ts index 2d2c82d90..31e3abcc7 100644 --- a/api/facades/spaces/SpacesV6.ts +++ b/api/facades/spaces/SpacesV6.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/sshclient/SSHClientV4.ts b/api/facades/sshclient/SSHClientV4.ts index 94d0ee46b..8ab88cb21 100644 --- a/api/facades/sshclient/SSHClientV4.ts +++ b/api/facades/sshclient/SSHClientV4.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -17,7 +17,7 @@ import { Facade } from "../../types.js"; import { autoBind } from "../../utils.js"; export interface CloudCredential { - attrs?: AdditionalProperties; + attrs?: Record; "auth-type": string; redacted?: string[]; } diff --git a/api/facades/status-history/StatusHistoryV2.ts b/api/facades/status-history/StatusHistoryV2.ts index c14dd0dad..abc24edd0 100644 --- a/api/facades/status-history/StatusHistoryV2.ts +++ b/api/facades/status-history/StatusHistoryV2.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/storage-provisioner/StorageProvisionerV4.ts b/api/facades/storage-provisioner/StorageProvisionerV4.ts index c36bd7cbd..061afacf3 100644 --- a/api/facades/storage-provisioner/StorageProvisionerV4.ts +++ b/api/facades/storage-provisioner/StorageProvisionerV4.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -130,7 +130,7 @@ export interface FilesystemParams { "filesystem-tag": string; provider: string; size: number; - tags?: AdditionalProperties; + tags?: Record; "volume-tag"?: string; } @@ -292,7 +292,7 @@ export interface VolumeAttachmentPlan { } export interface VolumeAttachmentPlanInfo { - "device-attributes": AdditionalProperties; + "device-attributes": Record; "device-type": string; } @@ -336,7 +336,7 @@ export interface VolumeParams { attributes?: AdditionalProperties; provider: string; size: number; - tags?: AdditionalProperties; + tags?: Record; "volume-tag": string; } diff --git a/api/facades/storage/StorageV6.ts b/api/facades/storage/StorageV6.ts index 0937ca696..73c5e2744 100644 --- a/api/facades/storage/StorageV6.ts +++ b/api/facades/storage/StorageV6.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -78,10 +78,10 @@ export interface FilesystemDetails { "filesystem-tag": string; info: FilesystemInfo; life?: string; - "machine-attachments"?: AdditionalProperties; + "machine-attachments"?: Record; status: EntityStatus; storage?: StorageDetails; - "unit-attachments"?: AdditionalProperties; + "unit-attachments"?: Record; "volume-tag"?: string; } @@ -176,7 +176,7 @@ export interface StorageDetachmentParams { } export interface StorageDetails { - attachments?: AdditionalProperties; + attachments?: Record; kind: number; life?: string; "owner-tag": string; @@ -270,17 +270,17 @@ export interface VolumeAttachmentInfo { } export interface VolumeAttachmentPlanInfo { - "device-attributes": AdditionalProperties; + "device-attributes": Record; "device-type": string; } export interface VolumeDetails { info: VolumeInfo; life?: string; - "machine-attachments"?: AdditionalProperties; + "machine-attachments"?: Record; status: EntityStatus; storage?: StorageDetails; - "unit-attachments"?: AdditionalProperties; + "unit-attachments"?: Record; "volume-tag": string; } diff --git a/api/facades/strings-watcher/StringsWatcherV1.ts b/api/facades/strings-watcher/StringsWatcherV1.ts index 153e4262e..391dd22f9 100644 --- a/api/facades/strings-watcher/StringsWatcherV1.ts +++ b/api/facades/strings-watcher/StringsWatcherV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/subnets/SubnetsV5.ts b/api/facades/subnets/SubnetsV5.ts index bf40da9fe..0f49dfd44 100644 --- a/api/facades/subnets/SubnetsV5.ts +++ b/api/facades/subnets/SubnetsV5.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/undertaker/UndertakerV1.ts b/api/facades/undertaker/UndertakerV1.ts index edd026d26..560ca36fd 100644 --- a/api/facades/undertaker/UndertakerV1.ts +++ b/api/facades/undertaker/UndertakerV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/unit-assigner/UnitAssignerV1.ts b/api/facades/unit-assigner/UnitAssignerV1.ts index dbe580340..7fd514877 100644 --- a/api/facades/unit-assigner/UnitAssignerV1.ts +++ b/api/facades/unit-assigner/UnitAssignerV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/uniter/UniterV18.ts b/api/facades/uniter/UniterV18.ts index 45092f471..f0781fdd5 100644 --- a/api/facades/uniter/UniterV18.ts +++ b/api/facades/uniter/UniterV18.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -76,10 +76,24 @@ export interface Address { value: string; } +export interface ApplicationOpenedPorts { + endpoint: string; + "port-ranges": PortRange[]; +} + +export interface ApplicationOpenedPortsResult { + "application-port-ranges": ApplicationOpenedPorts[]; + error?: Error; +} + +export interface ApplicationOpenedPortsResults { + results: ApplicationOpenedPortsResult[]; +} + export interface ApplicationStatusResult { application: StatusResult; error?: Error; - units: AdditionalProperties; + units: Record; } export interface ApplicationStatusResults { @@ -113,7 +127,7 @@ export interface CharmURLs { } export interface CloudCredential { - attrs?: AdditionalProperties; + attrs?: Record; "auth-type": string; redacted?: string[]; } @@ -266,7 +280,7 @@ export interface GetLeadershipSettingsBulkResults { export interface GetLeadershipSettingsResult { error?: Error; - settings: AdditionalProperties; + settings: Record; } export interface GetSecretConsumerInfoArgs { @@ -277,7 +291,7 @@ export interface GetSecretConsumerInfoArgs { export interface GetSecretContentArg { label?: string; peek?: boolean; - update?: boolean; + refresh?: boolean; uri: string; } @@ -286,8 +300,8 @@ export interface GetSecretContentArgs { } export interface GoalState { - relations: AdditionalProperties; - units: AdditionalProperties; + relations: Record>; + units: Record; } export interface GoalStateResult { @@ -378,7 +392,7 @@ export interface MergeLeadershipSettingsBulkParams { export interface MergeLeadershipSettingsParam { "application-tag"?: string; - settings: AdditionalProperties; + settings: Record; "unit-tag"?: string; } @@ -394,7 +408,7 @@ export interface MeterStatusResults { export interface Metric { key: string; - labels?: AdditionalProperties; + labels?: Record; time: string; value: string; } @@ -446,7 +460,7 @@ export interface NetworkInfoResult { } export interface NetworkInfoResults { - results: AdditionalProperties; + results: Record; } export interface NotifyWatchResult { @@ -458,13 +472,13 @@ export interface NotifyWatchResults { results: NotifyWatchResult[]; } -export interface OpenMachinePortRangesByEndpointResult { +export interface OpenPortRangesByEndpointResult { error?: Error; - "unit-port-ranges": AdditionalProperties; + "unit-port-ranges": Record; } -export interface OpenMachinePortRangesByEndpointResults { - results: OpenMachinePortRangesByEndpointResult[]; +export interface OpenPortRangesByEndpointResults { + results: OpenPortRangesByEndpointResult[]; } export interface OpenUnitPortRangesByEndpoint { @@ -528,9 +542,9 @@ export interface RelationUnitPairs { } export interface RelationUnitSettings { - "application-settings": AdditionalProperties; + "application-settings": Record; relation: string; - settings: AdditionalProperties; + settings: Record; unit: string; } @@ -554,8 +568,8 @@ export interface RelationUnits { } export interface RelationUnitsChange { - "app-changed"?: AdditionalProperties; - changed: AdditionalProperties; + "app-changed"?: Record; + changed: Record; departed?: string[]; } @@ -578,6 +592,28 @@ export interface ResolvedModeResults { results: ResolvedModeResult[]; } +export interface SecretBackendArgs { + "backend-ids": string[]; +} + +export interface SecretBackendConfig { + params?: AdditionalProperties; + type: string; +} + +export interface SecretBackendConfigResult { + config?: SecretBackendConfig; + draining: boolean; + "model-controller": string; + "model-name": string; + "model-uuid": string; +} + +export interface SecretBackendConfigResults { + "active-id": string; + results?: Record; +} + export interface SecretConsumerInfoResult { error?: Error; label: string; @@ -589,13 +625,15 @@ export interface SecretConsumerInfoResults { } export interface SecretContentParams { - data: AdditionalProperties; - "provider-id": string; + data: Record; + "value-ref": SecretValueRef; } export interface SecretContentResult { + "backend-config"?: SecretBackendConfigResult; content: SecretContentParams; error?: Error; + "latest-revision"?: number; } export interface SecretContentResults { @@ -603,11 +641,18 @@ export interface SecretContentResults { } export interface SecretRevision { + "backend-name"?: string; "create-time"?: string; "expire-time"?: string; - "provider-id"?: string; revision: number; "update-time"?: string; + "value-ref"?: SecretValueRef; +} + +export interface SecretRevisionArg { + "pending-delete": boolean; + revisions: number[]; + uri: string; } export interface SecretRotatedArg { @@ -620,11 +665,6 @@ export interface SecretRotatedArgs { args: SecretRotatedArg[]; } -export interface SecretStoreConfig { - params?: AdditionalProperties; - type: string; -} - export interface SecretTriggerChange { "next-trigger-time": string; revision?: number; @@ -637,8 +677,13 @@ export interface SecretTriggerWatchResult { "watcher-id": string; } +export interface SecretValueRef { + "backend-id": string; + "revision-id": string; +} + export interface SecretValueResult { - data: AdditionalProperties; + data: Record; error: Error; } @@ -647,9 +692,9 @@ export interface SetStatus { } export interface SetUnitStateArg { - "charm-state"?: AdditionalProperties; + "charm-state"?: Record; "meter-status-state"?: string; - "relation-state"?: AdditionalProperties; + "relation-state"?: Record; "secret-state"?: string; "storage-state"?: string; tag: string; @@ -662,7 +707,7 @@ export interface SetUnitStateArgs { export interface SettingsResult { error?: Error; - settings: AdditionalProperties; + settings: Record; } export interface SettingsResults { @@ -781,10 +826,10 @@ export interface UnitSettings { } export interface UnitStateResult { - "charm-state": AdditionalProperties; + "charm-state": Record; error: Error; "meter-status-state": string; - "relation-state": AdditionalProperties; + "relation-state": Record; "secret-state": string; "storage-state": string; "uniter-state": string; @@ -1314,6 +1359,7 @@ class UniterV18 implements Facade { /** GetConsumerSecretsRevisionInfo returns the latest secret revisions for the specified secrets. + This facade method is used for remote watcher to get the latest secret revisions and labels for a secret changed hook. */ getConsumerSecretsRevisionInfo( params: GetSecretConsumerInfoArgs @@ -1395,6 +1441,24 @@ class UniterV18 implements Facade { }); } + /** + GetSecretBackendConfigs gets the config needed to create a client to secret backends. + */ + getSecretBackendConfigs( + params: SecretBackendArgs + ): Promise { + return new Promise((resolve, reject) => { + const req: JujuRequest = { + type: "Uniter", + request: "GetSecretBackendConfigs", + version: 18, + params: params, + }; + + this._transport.write(req, resolve, reject); + }); + } + /** GetSecretContentInfo returns the secret values for the specified secrets. */ @@ -1430,13 +1494,15 @@ class UniterV18 implements Facade { } /** - GetSecretStoreConfig gets the config needed to create a client to the model's secret store. + GetSecretRevisionContentInfo returns the secret values for the specified secret revisions. */ - getSecretStoreConfig(params: any): Promise { + getSecretRevisionContentInfo( + params: SecretRevisionArg + ): Promise { return new Promise((resolve, reject) => { const req: JujuRequest = { type: "Uniter", - request: "GetSecretStoreConfig", + request: "GetSecretRevisionContentInfo", version: 18, params: params, }; @@ -1627,13 +1693,31 @@ class UniterV18 implements Facade { }); } + /** + OpenedApplicationPortRangesByEndpoint returns the port ranges opened by each application. + */ + openedApplicationPortRangesByEndpoint( + params: Entity + ): Promise { + return new Promise((resolve, reject) => { + const req: JujuRequest = { + type: "Uniter", + request: "OpenedApplicationPortRangesByEndpoint", + version: 18, + params: params, + }; + + this._transport.write(req, resolve, reject); + }); + } + /** OpenedMachinePortRangesByEndpoint returns the port ranges opened by each unit on the provided machines grouped by application endpoint. */ openedMachinePortRangesByEndpoint( params: Entities - ): Promise { + ): Promise { return new Promise((resolve, reject) => { const req: JujuRequest = { type: "Uniter", @@ -1646,6 +1730,24 @@ class UniterV18 implements Facade { }); } + /** + OpenedPortRangesByEndpoint returns the port ranges opened by the unit. + */ + openedPortRangesByEndpoint( + params: any + ): Promise { + return new Promise((resolve, reject) => { + const req: JujuRequest = { + type: "Uniter", + request: "OpenedPortRangesByEndpoint", + version: 18, + params: params, + }; + + this._transport.write(req, resolve, reject); + }); + } + /** PrivateAddress returns the private address for each given unit, if set. */ diff --git a/api/facades/upgrade-series/UpgradeSeriesV3.ts b/api/facades/upgrade-series/UpgradeSeriesV3.ts index 58aad4d2c..7f9fff843 100644 --- a/api/facades/upgrade-series/UpgradeSeriesV3.ts +++ b/api/facades/upgrade-series/UpgradeSeriesV3.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -73,7 +73,8 @@ export interface PinApplicationsResults { } export interface PinnedLeadershipResult { - result: AdditionalProperties; + error: Error; + result: Record; } export interface SetStatus { diff --git a/api/facades/upgrade-steps/UpgradeStepsV2.ts b/api/facades/upgrade-steps/UpgradeStepsV2.ts index 9e68461a7..5da5e4d59 100644 --- a/api/facades/upgrade-steps/UpgradeStepsV2.ts +++ b/api/facades/upgrade-steps/UpgradeStepsV2.ts @@ -6,7 +6,7 @@ Unit-agent NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ @@ -34,9 +34,9 @@ export interface ErrorResults { } export interface SetUnitStateArg { - "charm-state"?: AdditionalProperties; + "charm-state"?: Record; "meter-status-state"?: string; - "relation-state"?: AdditionalProperties; + "relation-state"?: Record; "secret-state"?: string; "storage-state"?: string; tag: string; diff --git a/api/facades/upgrader/UpgraderV1.ts b/api/facades/upgrader/UpgraderV1.ts index 3e4128144..3cb0ff47b 100644 --- a/api/facades/upgrader/UpgraderV1.ts +++ b/api/facades/upgrader/UpgraderV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/user-manager/UserManagerV3.ts b/api/facades/user-manager/UserManagerV3.ts index fb1798313..bded322f5 100644 --- a/api/facades/user-manager/UserManagerV3.ts +++ b/api/facades/user-manager/UserManagerV3.ts @@ -4,7 +4,7 @@ Controllers NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/volume-attachment-plans-watcher/VolumeAttachmentPlansWatcherV1.ts b/api/facades/volume-attachment-plans-watcher/VolumeAttachmentPlansWatcherV1.ts index c0219fa5b..b65b09104 100644 --- a/api/facades/volume-attachment-plans-watcher/VolumeAttachmentPlansWatcherV1.ts +++ b/api/facades/volume-attachment-plans-watcher/VolumeAttachmentPlansWatcherV1.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/facades/volume-attachments-watcher/VolumeAttachmentsWatcherV2.ts b/api/facades/volume-attachments-watcher/VolumeAttachmentsWatcherV2.ts index 28e152fdf..355c0ff35 100644 --- a/api/facades/volume-attachments-watcher/VolumeAttachmentsWatcherV2.ts +++ b/api/facades/volume-attachments-watcher/VolumeAttachmentsWatcherV2.ts @@ -7,7 +7,7 @@ Models NOTE: This file was generated using the Juju schema - from Juju 3.0 at the git SHA deb94d4. + from Juju 3.2.1 at the git SHA 06eb3f6c7c. Do not manually edit this file. */ diff --git a/api/tests/test-client.ts b/api/tests/test-client.ts index 2e1fbea43..2f6a25a06 100644 --- a/api/tests/test-client.ts +++ b/api/tests/test-client.ts @@ -353,7 +353,7 @@ describe("connect", () => { expect(err).toBe(null); expect(juju).not.toBe(null); juju - ?.login({ macaroons: ["m"] }) + ?.login({ macaroons: [["m"]] }) .then(() => fail) .catch((err) => { validateLoginDischargeRequiredFailure(err); @@ -376,7 +376,7 @@ describe("connect", () => { }; connect("wss://1.2.3.4", options).then((juju: Client) => { juju - .login({ macaroons: ["m"] }) + .login({ macaroons: [["m"]] }) .then(() => fail) .catch((error) => { validateLoginDischargeRequiredFailure(error); @@ -408,7 +408,7 @@ describe("connect", () => { connect("wss://1.2.3.4", options, (err?: CallbackError, juju?: Client) => { expect(err).toBe(null); expect(juju).not.toBe(null); - juju?.login({ macaroons: ["m"] }).then(() => { + juju?.login({ macaroons: [["m"]] }).then(() => { validateLoginDischargeRequiredSuccess(); done(); }); @@ -435,7 +435,7 @@ describe("connect", () => { }; connect("wss://1.2.3.4", options).then((juju: Client) => { juju - ?.login({ macaroons: ["m"] }) + ?.login({ macaroons: [["m"]] }) .then((_conn) => { validateLoginDischargeRequiredSuccess(); done(); diff --git a/generator/generator.ts b/generator/generator.ts new file mode 100644 index 000000000..67fdd1483 --- /dev/null +++ b/generator/generator.ts @@ -0,0 +1,376 @@ +import { execSync } from "child_process"; +import { + existsSync, + mkdirSync, + readdirSync, + readFileSync, + writeFileSync, +} from "fs"; +import glob from "glob"; +import { join, resolve } from "path"; + +import { + FacadeMethod, + FacadeTemplate, + FileInfo, + InterfaceData, + InterfaceType, + InterfaceValueType, + ReadmeTemplate, +} from "./interfaces.js"; +import generateFacadeIndexTemplate from "./templates/facade-index.js"; +import generateFacadeTemplate from "./templates/facade.js"; +import readmeTemplateGenerator from "./templates/readme.js"; +import { + DefinitionProperties, + Facade, + FacadeList, + JSONSchemaType, + SchemaDefinition, + SchemaDefinitions, + SchemaMethod, + SchemaMethods, + SchemaProperties, +} from "./templates/types.js"; +import { + attributeOverrides, + definitionsOverrides, + methodOverrides, +} from "./overrides.js"; + +export function generator() { + // if present, only generate the README and use links to docs instead of Github repo + const onlyReadmeForDocs = Boolean(process.env.README_FOR_DOCS); + if (!onlyReadmeForDocs) generateFacadeFiles(); + const facadesGroupedByName: FacadeList = {}; + type ExistingFacade = { + folder: string; + name: string; + version: number; + }; + const allExistingFacades: ExistingFacade[] = glob + .sync("./api/facades/*/*V[0-9]*.ts") + .map((f: string) => f.split("/")) + .map((f: string[]) => { + // e.g. ClientV5.ts + const filename = f[f.length - 1].match( + /(?[a-z-]+)V(?\d+)\.ts/i + )!.groups!; + return { folder: f[f.length - 2], ...filename }; + }) as ExistingFacade[]; + + allExistingFacades.forEach((facade) => { + if (!facadesGroupedByName[facade.name]) { + facadesGroupedByName[facade.name] = []; + } + facadesGroupedByName[facade.name].push(facade.version); + }); + if (!onlyReadmeForDocs) generateFacadeIndexTemplate(facadesGroupedByName); + + const clientAPIInfo: string = execSync( + "./node_modules/.bin/documentation build api/client.ts --document-exported --shallow --markdown-toc false -f md", + { encoding: "utf8" } + ); + + const facadeList: { + [key: string]: FileInfo[]; + } = {}; + Object.keys(facadesGroupedByName).forEach((facadeName) => { + facadeList[facadeName] = facadesGroupedByName[facadeName].map( + (FacadeVersion) => ({ + name: `${facadeName}V${FacadeVersion}.ts`, + path: `/api/facades/${facadeFolderName( + facadeName + )}/${facadeName}V${FacadeVersion}.ts`, + }) + ); + }); + + const readmeTemplateData: ReadmeTemplate = { + clientAPIInfo, + exampleList: readdirSync("examples").map((f) => ({ + name: f, + path: `examples/${f}`, + })), + facadeList, + }; + generateReadmeFile(readmeTemplateData, onlyReadmeForDocs); +} + +function getRefString(ref: string): string { + const parts = ref.split("/"); + return parts[parts.length - 1]; +} + +function extractType( + method: SchemaMethod, + segment: keyof SchemaProperties +): string | undefined { + if (method.properties?.[segment]) { + const ref = method.properties[segment]?.["$ref"]; + const type = method.properties[segment]?.["type"]; + if (ref) { + return getRefString(ref); + } + return type; + } + return undefined; +} + +function generateFacadeFiles() { + const schemaLocation: string = process.env.SCHEMA || ""; + const jujuVersion: string = process.env.JUJU_VERSION || ""; + const jujuGitSHA: string = process.env.JUJU_GIT_SHA || ""; + let schema: Array; + try { + const schemaData: string = readFileSync(resolve(schemaLocation), { + encoding: "utf8", + }); + schema = JSON.parse(schemaData); + } catch (e) { + console.error("Unable to parse schema", e); + process.exit(1); + } + + schema.forEach(async (facade) => { + const facadeTemplateData: FacadeTemplate = { + name: facade.Name, + version: facade.Version, + methods: generateMethods(facade.Schema.properties, facade.Name), + interfaces: generateInterfaces(facade.Schema.definitions, facade.Name), + availableTo: facade.AvailableTo, + docBlock: facade.Description, + jujuVersion, + jujuGitSHA, + }; + + generateFile(facadeTemplateData); + }); +} + +/** + Generate the list of methods available for the facade. While the API may + expose methods, the actual data sent over the wire is an RPC call. +*/ +export function generateMethods( + methods: SchemaMethods, + facadeName: string +): FacadeMethod[] { + const facadeMethods: FacadeMethod[] = Object.entries(methods).map( + ([name, method]) => { + const generatedMethod: FacadeMethod = { + name, + params: + methodOverrides[facadeName]?.[name]?.Params || + extractType(method, "Params") || + "any", + result: + methodOverrides[facadeName]?.[name]?.Result || + extractType(method, "Result") || + "any", + docBlock: method.description, + }; + if (methodOverrides[facadeName]?.[name]?.paramsAtTop) { + generatedMethod.paramsAtTop = true; + } + return generatedMethod; + } + ); + return facadeMethods; +} + +export function generateInterfaces( + definitions: SchemaDefinitions, + facadeName: string +): InterfaceData[] { + if (!definitions) { + return []; + } + const interfaces = Object.entries(definitions).map(([name, definition]) => { + return generateInterface([ + name, + definitionsOverrides[facadeName]?.[name] ?? definition, + ]); + }); + interfaces.push( + generateInterface([ + "AdditionalProperties", + { properties: { "[key: string]": { type: "any" } }, type: "object" }, + ]) + ); + return interfaces; +} + +function generateInterface([name, definition]: [ + string, + SchemaDefinition +]): InterfaceData { + let types: InterfaceType[]; + if (definition.properties) { + types = generateTypes(definition.properties, definition.required || []); + } else { + types = [ + { + name: "[key: string]", + type: "AdditionalProperties", + // This isn't actually required but we don't want to add the ? for + // optional with this key type. + required: true, + }, + ]; + } + return { + name, + types, + }; +} + +export function generateTypes( + properties: DefinitionProperties, + required: string[] +): InterfaceType[] { + function extractType(values: JSONSchemaType): InterfaceValueType { + if (values.type) { + if (values.type === "object") { + if (values.patternProperties) { + const regex = Object.keys(values.patternProperties)?.[0]; + // Handle the pattern properties if the regex is matching all keys. + if ( + Object.keys(values.patternProperties).length === 1 && + regex === ".*" + ) { + const patternProperty = values.patternProperties[regex]; + // If pattern is a ref then use that for the object value type. + if (patternProperty["$ref"]) { + return { + type: "object", + valueType: getRefString(patternProperty["$ref"]), + }; + } + const valueType = extractType(patternProperty); + // If the pattern is additionalProperties then use that as the + // object type. + if (valueType === "AdditionalProperties") { + return valueType; + } + // If the pattern has an explicit primitive type then use that for + // the object value type. + if (patternProperty.type) + return { + type: "object", + valueType, + }; + } + // Return unknown if the schema doesn't match what we expect. This + // shouldn't occur. + return "unknown"; + } + if (values.additionalProperties) { + // There are additional unknown properties defined. + return "AdditionalProperties"; + } + } + // TODO: Recirsify this conditional. + if (values.type === "array" && values.items) { + if (values.items["$ref"]) { + return `${getRefString(values.items["$ref"])}[]`; + } + if (values.items.type === "integer") { + values.items.type = "number"; + } else if (values.items.type === "array" && values.items.items) { + // multi-dimensional array + if (values.items.items["$ref"]) { + return `${getRefString(values.items.items["$ref"])}[][]`; + } + return "[]"; + } + return `${values.items.type}[]`; + } + if (values.type === "integer") { + return "number"; + } + return values.type; + } + if (values["$ref"]) { + return getRefString(values["$ref"]); + } + return "any"; // If we don't know the type then type it as any. + } + + function isRequired(requiredArgs: string[], propertyName: string): boolean { + if (!requiredArgs.length) { + // If requiredArgs doesn't exist then it's likely that this is a + // response interface. + return true; + } + return requiredArgs.includes(propertyName); + } + + return Object.entries(properties).map(([name, property]) => { + let valueType: string; + const extractedType = extractType(property); + const hasOverride = name in attributeOverrides; + if (hasOverride) { + valueType = attributeOverrides[name]; + } else { + valueType = + typeof extractedType === "object" ? extractedType.type : extractedType; + } + const interfaceType: InterfaceType = { + name, + type: valueType, + required: isRequired(required, name), + }; + if (!hasOverride && typeof extractedType === "object") { + interfaceType.valueType = extractedType.valueType; + } + return interfaceType; + }); +} + +function generateFile(facadeTemplateData: FacadeTemplate): void { + const output: string = generateFacadeTemplate(facadeTemplateData); + const filename = `${facadeTemplateData.name}V${facadeTemplateData.version}`; + const facadeFoldername = facadeFolderName(facadeTemplateData.name); + + const outputFolder = `api/facades/${facadeFoldername}/`; + mkdirSync(outputFolder, { recursive: true }); + const newFacadeFilePath = join(outputFolder, `${filename}.ts`); + // Avoid overriding existing files, in case you need to regenerate + // given files, delete the files first + if (!existsSync(newFacadeFilePath)) + writeFileSync(join(outputFolder, `${filename}.ts`), output); +} + +function generateReadmeFile( + readmeTemplateData: ReadmeTemplate, + onlyReadmeForDocs: boolean +): void { + if (onlyReadmeForDocs) { + readmeTemplateData.exampleList.forEach((example) => { + // instead of relative path for docs page which will 404 + // return the example page on the Github repo + example.path = `https://github.com/juju/js-libjuju/blob/master/${example.path}`; + }); + Object.entries(readmeTemplateData.facadeList).forEach( + ([facadeName, facade]) => + facade.forEach((facadeVersion) => { + // instead of the default (404) /api/facades/action-pruner/v1.ts + // return https://juju.github.io/js-libjuju/modules/facades_action_pruner_ActionPrunerV1.html + facadeVersion.path = `https://juju.github.io/js-libjuju/modules/facades_${facadeFolderName( + facadeName + ).replace(/-/g, "_")}_${facadeVersion.name.split(".")[0]}.html`; + }) + ); + } + const output: string = readmeTemplateGenerator(readmeTemplateData); + writeFileSync("README.md", output); +} + +export function facadeFolderName(facadeName: string) { + // from CamelCase to kebab-case + return facadeName + .replace(/\W+/g, "-") + .replace(/([a-z\d])([A-Z])/g, "$1-$2") + .toLowerCase(); +} diff --git a/generator/index.ts b/generator/index.ts index 849a63e0d..b24a3eb07 100644 --- a/generator/index.ts +++ b/generator/index.ts @@ -1,308 +1,3 @@ -import { execSync } from "child_process"; -import { - existsSync, - mkdirSync, - readdirSync, - readFileSync, - writeFileSync, -} from "fs"; -import glob from "glob"; -import { join, resolve } from "path"; -import { - FacadeMethod, - FacadeTemplate, - FileInfo, - InterfaceData, - InterfaceType, - ReadmeTemplate, -} from "./interfaces.js"; -import generateFacadeIndexTemplate from "./templates/facade-index.js"; -import generateFacadeTemplate from "./templates/facade.js"; -import readmeTemplateGenerator from "./templates/readme.js"; -import { - DefinitionProperties, - Facade, - FacadeList, - JSONSchemaType, - SchemaDefinition, - SchemaDefinitions, - SchemaMethod, - SchemaMethods, - SchemaProperties, -} from "./templates/types.js"; +import { generator } from "./generator.js"; -function main() { - // if present, only generate the README and use links to docs instead of Github repo - const onlyReadmeForDocs = Boolean(process.env.README_FOR_DOCS); - if (!onlyReadmeForDocs) generateFacadeFiles(); - const facadesGroupedByName: FacadeList = {}; - type ExistingFacade = { - folder: string; - name: string; - version: number; - }; - const allExistingFacades: ExistingFacade[] = glob - .sync("./api/facades/*/*V[0-9]*.ts") - .map((f: string) => f.split("/")) - .map((f: string[]) => { - // e.g. ClientV5.ts - const filename = f[f.length - 1].match( - /(?[a-z-]+)V(?\d+)\.ts/i - )!.groups!; - return { folder: f[f.length - 2], ...filename }; - }) as ExistingFacade[]; - - allExistingFacades.forEach((facade) => { - if (!facadesGroupedByName[facade.name]) { - facadesGroupedByName[facade.name] = []; - } - facadesGroupedByName[facade.name].push(facade.version); - }); - if (!onlyReadmeForDocs) generateFacadeIndexTemplate(facadesGroupedByName); - - const clientAPIInfo: string = execSync( - "./node_modules/.bin/documentation build api/client.ts --document-exported --shallow --markdown-toc false -f md", - { encoding: "utf8" } - ); - - const facadeList: { - [key: string]: FileInfo[]; - } = {}; - Object.keys(facadesGroupedByName).forEach((facadeName) => { - facadeList[facadeName] = facadesGroupedByName[facadeName].map( - (FacadeVersion) => ({ - name: `${facadeName}V${FacadeVersion}.ts`, - path: `/api/facades/${facadeFolderName( - facadeName - )}/${facadeName}V${FacadeVersion}.ts`, - }) - ); - }); - - const readmeTemplateData: ReadmeTemplate = { - clientAPIInfo, - exampleList: readdirSync("examples").map((f) => ({ - name: f, - path: `examples/${f}`, - })), - facadeList, - }; - generateReadmeFile(readmeTemplateData, onlyReadmeForDocs); -} - -function getRefString(ref: string): string { - const parts = ref.split("/"); - return parts[parts.length - 1]; -} - -function extractType( - method: SchemaMethod, - segment: keyof SchemaProperties -): string | undefined { - if (method.properties?.[segment]) { - const ref = method.properties[segment]["$ref"]; - const type = method.properties[segment]["type"]; - if (ref) { - return getRefString(ref); - } - return type; - } - return undefined; -} - -function generateFacadeFiles() { - const schemaLocation: string = process.env.SCHEMA || ""; - const jujuVersion: string = process.env.JUJU_VERSION || ""; - const jujuGitSHA: string = process.env.JUJU_GIT_SHA || ""; - let schema: Array; - try { - const schemaData: string = readFileSync(resolve(schemaLocation), { - encoding: "utf8", - }); - schema = JSON.parse(schemaData); - } catch (e) { - console.error("Unable to parse schema", e); - process.exit(1); - } - - schema.forEach(async (facade) => { - const facadeTemplateData: FacadeTemplate = { - name: facade.Name, - version: facade.Version, - methods: generateMethods(facade.Schema.properties), - interfaces: generateInterfaces(facade.Schema.definitions), - availableTo: facade.AvailableTo, - docBlock: facade.Description, - jujuVersion, - jujuGitSHA, - }; - - generateFile(facadeTemplateData); - }); -} - -/** - Generate the list of methods available for the facade. While the API may - expose methods, the actual data sent over the wire is an RPC call. -*/ -function generateMethods(methods: SchemaMethods): FacadeMethod[] { - const facadeMethods: FacadeMethod[] = Object.entries(methods).map( - (method) => { - const generatedMethod: FacadeMethod = { - name: method[0], - params: extractType(method[1], "Params") || "any", - result: extractType(method[1], "Result") || "any", - docBlock: method[1].description, - }; - return generatedMethod; - } - ); - return facadeMethods; -} - -function generateInterfaces(definitions?: SchemaDefinitions): InterfaceData[] { - if (!definitions) { - return []; - } - const interfaces = Object.entries(definitions).map(generateInterface); - interfaces.push( - generateInterface([ - "AdditionalProperties", - { properties: { "[key: string]": { type: "any" } }, type: "object" }, - ]) - ); - return interfaces; -} - -function generateInterface( - definition: [string, SchemaDefinition] -): InterfaceData { - let types: InterfaceType[]; - if (definition[1].properties) { - types = generateTypes( - definition[1].properties, - definition[1].required || [] - ); - } else { - types = [ - { - name: "[key: string]", - type: "AdditionalProperties", - // This isn't actually required but we don't want to add the ? for - // optional with this key type. - required: true, - }, - ]; - } - return { - name: definition[0], - types, - }; -} - -function generateTypes( - properties: DefinitionProperties, - required: string[] -): InterfaceType[] { - function extractType(values: JSONSchemaType): string { - if (values.type) { - if ( - values.patternProperties || - (values.additionalProperties && values.type === "object") - ) { - // There are additional unknown properties defined. - return "AdditionalProperties"; - } - // TODO: Recirsify this conditional. - if (values.type === "array" && values.items) { - if (values.items["$ref"]) { - return `${getRefString(values.items["$ref"])}[]`; - } - if (values.items.type === "integer") { - values.items.type = "number"; - } else if (values.items.type === "array" && values.items.items) { - // multi-dimensional array - if (values.items.items["$ref"]) { - return `${getRefString(values.items.items["$ref"])}[][]`; - } - return "[]"; - } - return `${values.items.type}[]`; - } - if (values.type === "integer") { - return "number"; - } - return values.type; - } - if (values["$ref"]) { - return getRefString(values["$ref"]); - } - return "any"; // If we don't know the type then type it as any. - } - - function isRequired(requiredArgs: string[], propertyName: string): boolean { - if (!requiredArgs.length) { - // If requiredArgs doesn't exist then it's likely that this is a - // response interface. - return true; - } - return requiredArgs.includes(propertyName); - } - - return Object.entries(properties).map((property) => { - return { - name: property[0], - type: extractType(property[1]), - required: isRequired(required, property[0]), - }; - }); -} - -function generateFile(facadeTemplateData: FacadeTemplate): void { - const output: string = generateFacadeTemplate(facadeTemplateData); - const filename = `${facadeTemplateData.name}V${facadeTemplateData.version}`; - const facadeFoldername = facadeFolderName(facadeTemplateData.name); - - const outputFolder = `api/facades/${facadeFoldername}/`; - mkdirSync(outputFolder, { recursive: true }); - const newFacadeFilePath = join(outputFolder, `${filename}.ts`); - // Avoid overriding existing files, in case you need to regenerate - // given files, delete the files first - if (!existsSync(newFacadeFilePath)) - writeFileSync(join(outputFolder, `${filename}.ts`), output); -} - -function generateReadmeFile( - readmeTemplateData: ReadmeTemplate, - onlyReadmeForDocs: boolean -): void { - if (onlyReadmeForDocs) { - readmeTemplateData.exampleList.forEach((example) => { - // instead of relative path for docs page which will 404 - // return the example page on the Github repo - example.path = `https://github.com/juju/js-libjuju/blob/master/${example.path}`; - }); - Object.entries(readmeTemplateData.facadeList).forEach( - ([facadeName, facade]) => - facade.forEach((facadeVersion) => { - // instead of the default (404) /api/facades/action-pruner/v1.ts - // return https://juju.github.io/js-libjuju/modules/facades_action_pruner_ActionPrunerV1.html - facadeVersion.path = `https://juju.github.io/js-libjuju/modules/facades_${facadeFolderName( - facadeName - ).replace(/-/g, "_")}_${facadeVersion.name.split(".")[0]}.html`; - }) - ); - } - const output: string = readmeTemplateGenerator(readmeTemplateData); - writeFileSync("README.md", output); -} - -export function facadeFolderName(facadeName: string) { - // from CamelCase to kebab-case - return facadeName - .replace(/\W+/g, "-") - .replace(/([a-z\d])([A-Z])/g, "$1-$2") - .toLowerCase(); -} - -main(); +generator(); diff --git a/generator/interfaces.ts b/generator/interfaces.ts index 8346db10e..8cb7d3e8a 100644 --- a/generator/interfaces.ts +++ b/generator/interfaces.ts @@ -12,11 +12,21 @@ export interface InterfaceData { name: string; types: InterfaceType[]; } -export interface InterfaceType { + +export type InterfaceValueType = + | string + | { + type: string; + valueType: InterfaceValueType; + }; + +export type InterfaceType = { name: string; type: string; required: boolean; -} + valueType?: InterfaceValueType; +}; + export interface ReadmeTemplate { clientAPIInfo: string; exampleList: FileInfo[]; @@ -30,9 +40,10 @@ export interface FileInfo { export interface FacadeMethod { name: string; - params: string; - result: string; - docBlock: string; + params: string | Record; + paramsAtTop?: boolean; + result: string | Record; + docBlock?: string; } export interface JujuRequest { @@ -41,6 +52,7 @@ export interface JujuRequest { "request-id"?: number; version: number; params?: any; // Typed by the call signature of the facade method. + [key: string]: any; // Some calls pass additional params e.g. AllWatcher.next passes `id`. } export type CallbackError = string | number | null; diff --git a/generator/overrides.ts b/generator/overrides.ts new file mode 100644 index 000000000..1d48980db --- /dev/null +++ b/generator/overrides.ts @@ -0,0 +1,100 @@ +import { SchemaDefinition } from "./templates/types.js"; + +type MethodOverrides = Record< + string, + Record< + string, + { + Params?: Record; + paramsAtTop?: boolean; + Result?: Record; + } + > +>; + +type DefinitionsOverrides = Record>; + +export const methodOverrides: MethodOverrides = { + AllWatcher: { + Next: { + Params: { + // The schema does not specify the id param for this method. + // https://bugs.launchpad.net/juju/+bug/2025110 + id: "string", + }, + // Unlike other methods the id needs to be at the top level instead of inside the params object. + // https://bugs.launchpad.net/juju/+bug/2025110 + paramsAtTop: true, + }, + Stop: { + Params: { + // The schema does not specify the id param for this method. + // https://bugs.launchpad.net/juju/+bug/2025110 + id: "string", + }, + // Unlike other methods the id needs to be at the top level instead of inside the params object. + // https://bugs.launchpad.net/juju/+bug/2025110 + paramsAtTop: true, + }, + }, + AllModelWatcher: { + Next: { + Params: { + // The schema does not specify the id param for this method. + // https://bugs.launchpad.net/juju/+bug/2025110 + id: "string", + }, + // Unlike other methods the id needs to be at the top level instead of inside the params object. + // https://bugs.launchpad.net/juju/+bug/2025110 + paramsAtTop: true, + }, + Stop: { + Params: { + // The schema does not specify the id param for this method. + // https://bugs.launchpad.net/juju/+bug/2025110 + id: "string", + }, + // Unlike other methods the id needs to be at the top level instead of inside the params object. + // https://bugs.launchpad.net/juju/+bug/2025110 + paramsAtTop: true, + }, + }, +}; + +export const definitionsOverrides: DefinitionsOverrides = { + AllWatcher: { + AllWatcherNextResults: { + type: "object", + properties: { + deltas: { + // The schema defines the delta as an object instead of a tuple. + // https://bugs.launchpad.net/juju/+bug/2025105 + type: "[string, string, unknown][]", + }, + }, + additionalProperties: false, + required: ["deltas"], + }, + }, + AllModelWatcher: { + AllWatcherNextResults: { + type: "object", + properties: { + deltas: { + // The schema defines the delta as an object instead of a tuple. + // https://bugs.launchpad.net/juju/+bug/2025105 + type: "[string, string, unknown][]", + }, + }, + additionalProperties: false, + required: ["deltas"], + }, + }, +}; + +export const attributeOverrides: Record = { + // The schema defines agent-version as a `Number` object but it is returned by the + // API as a string. + // https://bugs.launchpad.net/juju/+bug/2025108 + "agent-version": "string", +}; diff --git a/generator/schema/juju-git-sha.txt b/generator/schema/juju-git-sha.txt index 5e9f53373..be8923f98 100644 --- a/generator/schema/juju-git-sha.txt +++ b/generator/schema/juju-git-sha.txt @@ -1 +1 @@ -3a098707a1 \ No newline at end of file +06eb3f6c7c \ No newline at end of file diff --git a/generator/schema/juju-version.txt b/generator/schema/juju-version.txt index f250bde35..0444f3207 100644 --- a/generator/schema/juju-version.txt +++ b/generator/schema/juju-version.txt @@ -1 +1 @@ -3.2-rc1 \ No newline at end of file +3.2.1 \ No newline at end of file diff --git a/generator/schema/schema-history.json b/generator/schema/schema-history.json index a2267c1cd..d36bd9cbc 100644 --- a/generator/schema/schema-history.json +++ b/generator/schema/schema-history.json @@ -23,5 +23,10 @@ "juju-git-sha": "deb94d4", "juju-version": "3.0", "schema": "https://raw.githubusercontent.com/juju/js-libjuju/63c31f0991cdbd43ba2de0048cd98ee7ba36945c/schema/schema.json" + }, + { + "juju-git-sha": "3a098707a1", + "juju-version": "3.2", + "schema": "https://raw.githubusercontent.com/juju/js-libjuju/278c06f91a9c0b3a0cd69dd61c941280d6c81f3d/generator/schema/schema.json" } ] diff --git a/generator/schema/schema.json b/generator/schema/schema.json index d06df17a6..9ec3136bf 100644 --- a/generator/schema/schema.json +++ b/generator/schema/schema.json @@ -1403,6 +1403,145 @@ } } }, + { + "Name": "AgentLifeFlag", + "Description": "", + "Version": 1, + "AvailableTo": [ + "controller-machine-agent", + "machine-agent", + "unit-agent", + "model-user" + ], + "Schema": { + "type": "object", + "properties": { + "Life": { + "type": "object", + "properties": { + "Params": { + "$ref": "#/definitions/Entities" + }, + "Result": { + "$ref": "#/definitions/LifeResults" + } + }, + "description": "Life returns the life status of every supplied entity, where available." + }, + "Watch": { + "type": "object", + "properties": { + "Params": { + "$ref": "#/definitions/Entities" + }, + "Result": { + "$ref": "#/definitions/NotifyWatchResults" + } + }, + "description": "Watch starts an NotifyWatcher for each given entity." + } + }, + "definitions": { + "Entities": { + "type": "object", + "properties": { + "entities": { + "type": "array", + "items": { + "$ref": "#/definitions/Entity" + } + } + }, + "additionalProperties": false, + "required": ["entities"] + }, + "Entity": { + "type": "object", + "properties": { + "tag": { + "type": "string" + } + }, + "additionalProperties": false, + "required": ["tag"] + }, + "Error": { + "type": "object", + "properties": { + "code": { + "type": "string" + }, + "info": { + "type": "object", + "patternProperties": { + ".*": { + "type": "object", + "additionalProperties": true + } + } + }, + "message": { + "type": "string" + } + }, + "additionalProperties": false, + "required": ["message", "code"] + }, + "LifeResult": { + "type": "object", + "properties": { + "error": { + "$ref": "#/definitions/Error" + }, + "life": { + "type": "string" + } + }, + "additionalProperties": false, + "required": ["life"] + }, + "LifeResults": { + "type": "object", + "properties": { + "results": { + "type": "array", + "items": { + "$ref": "#/definitions/LifeResult" + } + } + }, + "additionalProperties": false, + "required": ["results"] + }, + "NotifyWatchResult": { + "type": "object", + "properties": { + "NotifyWatcherId": { + "type": "string" + }, + "error": { + "$ref": "#/definitions/Error" + } + }, + "additionalProperties": false, + "required": ["NotifyWatcherId"] + }, + "NotifyWatchResults": { + "type": "object", + "properties": { + "results": { + "type": "array", + "items": { + "$ref": "#/definitions/NotifyWatchResult" + } + } + }, + "additionalProperties": false, + "required": ["results"] + } + } + } + }, { "Name": "AgentTools", "Description": "AgentToolsAPI implements the API used by the machine model worker.", @@ -6033,18 +6172,6 @@ }, "description": "ApplicationOCIResources returns the OCI image resources for an application." }, - "CAASApplicationGarbageCollect": { - "type": "object", - "properties": { - "Params": { - "$ref": "#/definitions/CAASApplicationGarbageCollectArgs" - }, - "Result": { - "$ref": "#/definitions/ErrorResults" - } - }, - "description": "CAASApplicationGarbageCollect cleans up units that have gone away permanently.\nOnly observed units will be deleted as new units could have surfaced between\nthe capturing of kuberentes pod state/application state and this call." - }, "CharmInfo": { "type": "object", "properties": { @@ -6069,6 +6196,18 @@ }, "description": "ClearApplicationsResources clears the flags which indicate\napplications still have resources in the cluster." }, + "DestroyUnits": { + "type": "object", + "properties": { + "Params": { + "$ref": "#/definitions/DestroyUnitsParams" + }, + "Result": { + "$ref": "#/definitions/DestroyUnitResults" + } + }, + "description": "DestroyUnits is responsible for scaling down a set of units on the this\nApplication." + }, "Life": { "type": "object", "properties": { @@ -6081,6 +6220,15 @@ }, "description": "Life returns the life status of every supplied entity, where available." }, + "ProvisionerConfig": { + "type": "object", + "properties": { + "Result": { + "$ref": "#/definitions/CAASApplicationProvisionerConfigResult" + } + }, + "description": "ProvisionerConfig returns the provisioner's configuration." + }, "ProvisioningInfo": { "type": "object", "properties": { @@ -6093,6 +6241,18 @@ }, "description": "ProvisioningInfo returns the info needed to provision a caas application." }, + "ProvisioningState": { + "type": "object", + "properties": { + "Params": { + "$ref": "#/definitions/Entity" + }, + "Result": { + "$ref": "#/definitions/CAASApplicationProvisioningStateResult" + } + }, + "description": "ProvisioningState returns the provisioning state for the application." + }, "Remove": { "type": "object", "properties": { @@ -6129,6 +6289,18 @@ }, "description": "SetPasswords sets the given password for each supplied entity, if possible." }, + "SetProvisioningState": { + "type": "object", + "properties": { + "Params": { + "$ref": "#/definitions/CAASApplicationProvisioningStateArg" + }, + "Result": { + "$ref": "#/definitions/ErrorResult" + } + }, + "description": "SetProvisioningState sets the provisioning state for the application." + }, "Units": { "type": "object", "properties": { @@ -6279,50 +6451,6 @@ "additionalProperties": false, "required": ["name", "channel"] }, - "CAASApplicationGarbageCollectArg": { - "type": "object", - "properties": { - "active-pod-names": { - "type": "array", - "items": { - "type": "string" - } - }, - "application": { - "$ref": "#/definitions/Entity" - }, - "desired-replicas": { - "type": "integer" - }, - "force": { - "type": "boolean" - }, - "observed-units": { - "$ref": "#/definitions/Entities" - } - }, - "additionalProperties": false, - "required": [ - "application", - "observed-units", - "desired-replicas", - "active-pod-names", - "force" - ] - }, - "CAASApplicationGarbageCollectArgs": { - "type": "object", - "properties": { - "args": { - "type": "array", - "items": { - "$ref": "#/definitions/CAASApplicationGarbageCollectArg" - } - } - }, - "additionalProperties": false, - "required": ["args"] - }, "CAASApplicationOCIResourceResult": { "type": "object", "properties": { @@ -6363,6 +6491,27 @@ "additionalProperties": false, "required": ["images"] }, + "CAASApplicationProvisionerConfig": { + "type": "object", + "properties": { + "unmanaged-applications": { + "$ref": "#/definitions/Entities" + } + }, + "additionalProperties": false + }, + "CAASApplicationProvisionerConfigResult": { + "type": "object", + "properties": { + "error": { + "$ref": "#/definitions/Error" + }, + "provisioner-config": { + "$ref": "#/definitions/CAASApplicationProvisionerConfig" + } + }, + "additionalProperties": false + }, "CAASApplicationProvisioningInfo": { "type": "object", "properties": { @@ -6445,6 +6594,44 @@ "additionalProperties": false, "required": ["results"] }, + "CAASApplicationProvisioningState": { + "type": "object", + "properties": { + "scale-target": { + "type": "integer" + }, + "scaling": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": ["scaling", "scale-target"] + }, + "CAASApplicationProvisioningStateArg": { + "type": "object", + "properties": { + "application": { + "$ref": "#/definitions/Entity" + }, + "provisioning-state": { + "$ref": "#/definitions/CAASApplicationProvisioningState" + } + }, + "additionalProperties": false, + "required": ["application", "provisioning-state"] + }, + "CAASApplicationProvisioningStateResult": { + "type": "object", + "properties": { + "error": { + "$ref": "#/definitions/Error" + }, + "provisioning-state": { + "$ref": "#/definitions/CAASApplicationProvisioningState" + } + }, + "additionalProperties": false + }, "CAASUnitInfo": { "type": "object", "properties": { @@ -6989,6 +7176,83 @@ "additionalProperties": false, "required": ["url"] }, + "DestroyUnitInfo": { + "type": "object", + "properties": { + "destroyed-storage": { + "type": "array", + "items": { + "$ref": "#/definitions/Entity" + } + }, + "detached-storage": { + "type": "array", + "items": { + "$ref": "#/definitions/Entity" + } + } + }, + "additionalProperties": false + }, + "DestroyUnitParams": { + "type": "object", + "properties": { + "destroy-storage": { + "type": "boolean" + }, + "dry-run": { + "type": "boolean" + }, + "force": { + "type": "boolean" + }, + "max-wait": { + "type": "integer" + }, + "unit-tag": { + "type": "string" + } + }, + "additionalProperties": false, + "required": ["unit-tag"] + }, + "DestroyUnitResult": { + "type": "object", + "properties": { + "error": { + "$ref": "#/definitions/Error" + }, + "info": { + "$ref": "#/definitions/DestroyUnitInfo" + } + }, + "additionalProperties": false + }, + "DestroyUnitResults": { + "type": "object", + "properties": { + "results": { + "type": "array", + "items": { + "$ref": "#/definitions/DestroyUnitResult" + } + } + }, + "additionalProperties": false + }, + "DestroyUnitsParams": { + "type": "object", + "properties": { + "units": { + "type": "array", + "items": { + "$ref": "#/definitions/DestroyUnitParams" + } + } + }, + "additionalProperties": false, + "required": ["units"] + }, "DetailedStatus": { "type": "object", "properties": { @@ -18380,9 +18644,6 @@ "IngressNetworksChangeEvent": { "type": "object", "properties": { - "application-token": { - "type": "string" - }, "bakery-version": { "type": "integer" }, @@ -18406,11 +18667,7 @@ } }, "additionalProperties": false, - "required": [ - "relation-token", - "application-token", - "ingress-required" - ] + "required": ["relation-token", "ingress-required"] }, "IngressNetworksChanges": { "type": "object", @@ -18999,10 +19256,13 @@ "items": { "$ref": "#/definitions/Macaroon" } + }, + "relation-token": { + "type": "string" } }, "additionalProperties": false, - "required": ["application-token"] + "required": ["application-token", "relation-token"] }, "WatchRemoteSecretChangesArgs": { "type": "object", @@ -36941,7 +37201,7 @@ "$ref": "#/definitions/SecretContentResults" } }, - "description": "GetSecretRevisionContentInfo returns the secret values for the specified secret revisions.\nUsed when deleting a secret; only returns external revision info." + "description": "GetSecretRevisionContentInfo returns the secret values for the specified secret revisions." }, "RemoveSecrets": { "type": "object", @@ -42368,7 +42628,7 @@ "$ref": "#/definitions/SecretContentResults" } }, - "description": "GetSecretRevisionContentInfo returns the secret values for the specified secret revisions.\nUsed when deleting a secret; only returns external revision info." + "description": "GetSecretRevisionContentInfo returns the secret values for the specified secret revisions." }, "GoalStates": { "type": "object", diff --git a/generator/templates/facade-index.ts b/generator/templates/facade-index.ts index 96bff072b..4a3d5439a 100644 --- a/generator/templates/facade-index.ts +++ b/generator/templates/facade-index.ts @@ -1,6 +1,6 @@ import { mkdirSync, writeFileSync } from "fs"; import { join } from "path"; -import { facadeFolderName } from "../index.js"; +import { facadeFolderName } from "../generator.js"; import { FacadeList } from "./types.js"; function facadeIndexTS(facadeName: string, versions: number[]): string { diff --git a/generator/templates/facade.ts b/generator/templates/facade.ts index 50b6c4e8e..79556f055 100644 --- a/generator/templates/facade.ts +++ b/generator/templates/facade.ts @@ -1,36 +1,35 @@ -import type { FacadeTemplate, InterfaceData } from "../interfaces.js"; +import type { + FacadeTemplate, + InterfaceData, + InterfaceType, + InterfaceValueType, +} from "../interfaces.js"; -export default function generateFacadeTemplate( - facadeTemplate: FacadeTemplate -): string { - const lowerCaseFirstChar = (name: string): string => - name.charAt(0).toLowerCase() + name.slice(1); - - const upperCaseFirstChar = (name: string): string => - name.charAt(0).toUpperCase() + name.slice(1); - - const padString = (doc: string, indent: number): string => { - if (!doc) { - return ""; - } - const segments = doc - .split("\n") - .map((segment) => - segment ? segment.padStart(segment.length + indent) : "" - ); - return segments.join("\n"); - }; - - const generateAvailableList = (availableTo: string[]) => - padString( - availableTo - .map((env) => upperCaseFirstChar(env.replace("-user", "s"))) - .join("\n"), - 4 +const padString = (doc: string, indent: number): string => { + if (!doc) { + return ""; + } + const segments = doc + .split("\n") + .map((segment) => + segment ? segment.padStart(segment.length + indent) : "" ); + return segments.join("\n"); +}; + +const generateType = ( + interfaceType: InterfaceType | InterfaceValueType +): string => { + if (typeof interfaceType === "string") { + return interfaceType; + } + return interfaceType.type === "object" && interfaceType.valueType + ? `Record` + : interfaceType.type; +}; - const generateInterface = (i: InterfaceData) => { - return ` +export const generateInterface = (i: InterfaceData) => { + return ` export interface ${i.name} { ${i.types .map((t) => { @@ -39,12 +38,70 @@ ${i.types name = `"${name}"`; } const optional = !t.required ? "?" : ""; - return padString(`${name}${optional}: ${t.type};`, 2); + return padString(`${name}${optional}: ${generateType(t)};`, 2); }) .join("\n")} }`; - }; +}; + +const lowerCaseFirstChar = (name: string): string => + name.charAt(0).toLowerCase() + name.slice(1); + +const upperCaseFirstChar = (name: string): string => + name.charAt(0).toUpperCase() + name.slice(1); + +const generateAvailableList = (availableTo: string[]) => + padString( + availableTo + .map((env) => upperCaseFirstChar(env.replace("-user", "s"))) + .join("\n"), + 4 + ); + +export function generateMethods(facadeTemplate: FacadeTemplate): string { + return facadeTemplate.methods + .map((m) => { + const paramsType = + m.params && typeof m.params === "object" + ? `{ ${Object.entries(m.params) + .map(([key, value]) => `${key}: ${value};`) + .join(" ")} }` + : m.params; + + const paramsBlock = m.params + ? `${ + typeof m.params === "object" + ? Object.keys(m.params) + .map((key) => ` ${key}: params.${key},`) + .join("\n") + : " params: params," + } + };` + : null; + return `/** +${padString(m.docBlock || "", 4)} + */ + ${lowerCaseFirstChar(m.name)}(${ + m.params ? `params: ${paramsType}` : "" + }): Promise<${m.result}> { + return new Promise((resolve, reject) => { + const req: JujuRequest = { + type: "${facadeTemplate.name}", + request: "${m.name}", + version: ${facadeTemplate.version}, +${paramsBlock ?? " };"} + this._transport.write(req, resolve, reject); + }); + } +`; + }) + .join("\n"); +} + +export default function generateFacadeTemplate( + facadeTemplate: FacadeTemplate +): string { return `/** Juju ${facadeTemplate.name} version ${facadeTemplate.version}. This facade is available on: @@ -83,32 +140,7 @@ class ${facadeTemplate.name}V${facadeTemplate.version} implements Facade { // Automatically bind all methods to instances. autoBind(this); } - ${facadeTemplate.methods - .map( - (m) => `/** -${padString(m.docBlock, 4)} - */ - ${lowerCaseFirstChar(m.name)}(${ - m.params ? `params: ${m.params}` : "" - }): Promise<${m.result}> { - return new Promise((resolve, reject) => { - const req: JujuRequest = { - type: "${facadeTemplate.name}", - request: "${m.name}", - version: ${facadeTemplate.version}, - ${ - m.params - ? ` params: params, - };` - : "};" - } - - this._transport.write(req, resolve, reject); - }); - } -` - ) - .join("\n")} + ${generateMethods(facadeTemplate)} } export default ${facadeTemplate.name}V${facadeTemplate.version}; diff --git a/generator/templates/test-facade.ts b/generator/templates/test-facade.ts new file mode 100644 index 000000000..3c3409878 --- /dev/null +++ b/generator/templates/test-facade.ts @@ -0,0 +1,253 @@ +import { generateInterface, generateMethods } from "./facade"; + +describe("generateInterface", () => { + it("generates an interface", () => { + expect( + generateInterface({ + name: "action", + types: [ + { name: "applications", required: true, type: "string[]" }, + { name: "commands", required: true, type: "number" }, + ], + }) + ).toBe(` +export interface action { + applications: string[]; + commands: number; +}`); + }); + + it("handles optional params", () => { + expect( + generateInterface({ + name: "action", + types: [{ name: "application", required: false, type: "string" }], + }) + ).toBe(` +export interface action { + application?: string; +}`); + }); + + it("handles additional properties", () => { + expect( + generateInterface({ + name: "action", + types: [ + { name: "actions", required: true, type: "AdditionalProperties" }, + ], + }) + ).toBe(` +export interface action { + actions: AdditionalProperties; +}`); + }); + + it("handles named types", () => { + expect( + generateInterface({ + name: "action", + types: [ + { + name: "actions", + required: true, + type: "object", + valueType: "ActionParams", + }, + ], + }) + ).toBe(` +export interface action { + actions: Record; +}`); + }); + + it("handles object types", () => { + expect( + generateInterface({ + name: "action", + types: [ + { + name: "actions", + required: true, + type: "object", + valueType: "string", + }, + ], + }) + ).toBe(` +export interface action { + actions: Record; +}`); + }); + + it("handles objects with arrays", () => { + expect( + generateInterface({ + name: "action", + types: [ + { + name: "actions", + required: true, + type: "object", + valueType: "string[]", + }, + ], + }) + ).toBe(` +export interface action { + actions: Record; +}`); + }); + + it("handles nested objects", () => { + expect( + generateInterface({ + name: "action", + types: [ + { + name: "actions", + required: true, + type: "object", + valueType: { + type: "object", + valueType: "string", + }, + }, + ], + }) + ).toBe(` +export interface action { + actions: Record>; +}`); + }); +}); + +describe("generateMethods", () => { + it("generates methods", () => { + expect( + generateMethods({ + name: "VolumeAttachmentsWatcher", + version: 2, + methods: [ + { + name: "Next", + params: "any", + result: "MachineStorageIdsWatchResult", + docBlock: + "Next returns when a change has occurred to an entity of the\n" + + "collection being watched since the most recent call to Next\n" + + "or the Watch call that created the srvMachineStorageIdsWatcher.", + }, + { + name: "Stop", + params: "any", + result: "any", + docBlock: "Stop stops the watcher.", + }, + ], + interfaces: [ + { + name: "Error", + types: [{ name: "message", required: true, type: "string" }], + }, + { + name: "MachineStorageId", + types: [ + { name: "disk", required: true, type: "string[]" }, + { name: "version", required: true, type: "number" }, + ], + }, + { name: "AdditionalProperties", types: [] }, + ], + availableTo: [ + "controller-machine-agent", + "machine-agent", + "unit-agent", + "model-user", + ], + docBlock: + "srvMachineStorageIdsWatcher defines the API wrapping a state.StringsWatcher\n" + + "watching machine/storage attachments. This watcher notifies about storage\n" + + "entities (volumes/filesystems) being attached to and detached from machines.\n" + + "\n" + + "TODO(axw) state needs a new watcher, this is a bt of a hack. State watchers\n" + + "could do with some deduplication of logic, and I don't want to add to that\n" + + "spaghetti right now.", + jujuVersion: "3.2", + jujuGitSHA: "3a098707a1", + }) + ).toBe(`/** + Next returns when a change has occurred to an entity of the + collection being watched since the most recent call to Next + or the Watch call that created the srvMachineStorageIdsWatcher. + */ + next(params: any): Promise { + return new Promise((resolve, reject) => { + const req: JujuRequest = { + type: "VolumeAttachmentsWatcher", + request: "Next", + version: 2, + params: params, + }; + + this._transport.write(req, resolve, reject); + }); + } + +/** + Stop stops the watcher. + */ + stop(params: any): Promise { + return new Promise((resolve, reject) => { + const req: JujuRequest = { + type: "VolumeAttachmentsWatcher", + request: "Stop", + version: 2, + params: params, + }; + + this._transport.write(req, resolve, reject); + }); + } +`); + }); + + it("handles top level params", () => { + expect( + generateMethods({ + name: "VolumeAttachmentsWatcher", + version: 2, + methods: [ + { + name: "Stop", + params: { id: "string", restart: "boolean" }, + result: "any", + docBlock: "Stop stops the watcher.", + }, + ], + interfaces: [], + availableTo: [], + docBlock: "", + jujuVersion: "3.2", + jujuGitSHA: "3a098707a1", + }) + ).toBe(`/** + Stop stops the watcher. + */ + stop(params: { id: string; restart: boolean; }): Promise { + return new Promise((resolve, reject) => { + const req: JujuRequest = { + type: "VolumeAttachmentsWatcher", + request: "Stop", + version: 2, + id: params.id, + restart: params.restart, + }; + + this._transport.write(req, resolve, reject); + }); + } +`); + }); +}); diff --git a/generator/templates/types.d.ts b/generator/templates/types.d.ts index 62b5399d0..96db805a3 100644 --- a/generator/templates/types.d.ts +++ b/generator/templates/types.d.ts @@ -22,8 +22,8 @@ export interface SchemaDefinitions { export interface SchemaMethod { type: string; - properties: SchemaProperties; - description: string; + properties?: SchemaProperties; + description?: string; } export interface SchemaDefinition { @@ -38,15 +38,15 @@ export interface DefinitionProperties { } export interface JSONSchemaType { - type: string; + type?: string; items?: JSONSchemaType; additionalProperties?: boolean; - patternProperties?: any; + patternProperties?: Record; $ref?: string; } export interface SchemaProperties { - Params: SchemaPropertyValue; + Params?: SchemaPropertyValue; Result: SchemaPropertyValue; } export interface SchemaPropertyValue { diff --git a/generator/test-generator.ts b/generator/test-generator.ts new file mode 100644 index 000000000..19a57a0c9 --- /dev/null +++ b/generator/test-generator.ts @@ -0,0 +1,477 @@ +import { + generateInterfaces, + generateMethods, + generateTypes, +} from "./generator"; + +describe("generateMethods", () => { + it("generates methods", () => { + expect( + generateMethods( + { + DesiredVersion: { + description: "Gets the desired version.", + type: "object", + properties: { + Params: { $ref: "#/definitions/Entities" }, + Result: { $ref: "#/definitions/VersionResults" }, + }, + }, + SetTools: { + type: "object", + properties: { + Params: { $ref: "#/definitions/EntitiesVersion" }, + Result: { $ref: "#/definitions/ErrorResults" }, + }, + }, + }, + "Upgrader" + ) + ).toStrictEqual([ + { + name: "DesiredVersion", + params: "Entities", + result: "VersionResults", + docBlock: "Gets the desired version.", + }, + { + name: "SetTools", + params: "EntitiesVersion", + result: "ErrorResults", + docBlock: undefined, + }, + ]); + }); + + it("overrides AllWatcher methods", () => { + expect( + generateMethods( + { + Next: { + type: "object", + properties: { + Result: { $ref: "#/definitions/AllWatcherNextResults" }, + }, + description: + "Next will return the current state of everything on the first call\n" + + "and subsequent calls will", + }, + Stop: { type: "object", description: "Stop stops the watcher." }, + }, + "AllWatcher" + ) + ).toStrictEqual([ + { + name: "Next", + params: { id: "string" }, + paramsAtTop: true, + result: "AllWatcherNextResults", + docBlock: + "Next will return the current state of everything on the first call\n" + + "and subsequent calls will", + }, + { + name: "Stop", + paramsAtTop: true, + params: { id: "string" }, + result: "any", + docBlock: "Stop stops the watcher.", + }, + ]); + }); +}); + +describe("generateInterfaces", () => { + it("generates interfaces", () => { + expect( + generateInterfaces( + { + UserInfoRequest: { + type: "object", + properties: { + entities: { type: "array", $ref: "#/definitions/Entity" }, + "include-disabled": { + type: "boolean", + }, + }, + }, + UserInfoResult: { + type: "object", + properties: { + error: { + $ref: "#/definitions/Error", + }, + result: { + $ref: "#/definitions/UserInfo", + }, + }, + }, + }, + "UserInfo" + ) + ).toStrictEqual([ + { + name: "UserInfoRequest", + types: [ + { name: "entities", required: true, type: "array" }, + { name: "include-disabled", required: true, type: "boolean" }, + ], + }, + { + name: "UserInfoResult", + types: [ + { name: "error", required: true, type: "Error" }, + { name: "result", required: true, type: "UserInfo" }, + ], + }, + { + name: "AdditionalProperties", + types: [{ name: "[key: string]", required: true, type: "any" }], + }, + ]); + }); + + it("handles required properties", () => { + expect( + generateInterfaces( + { + UserInfoRequest: { + type: "object", + properties: { + entities: { type: "array", $ref: "#/definitions/Entity" }, + "include-disabled": { + type: "boolean", + }, + }, + required: ["entities"], + }, + }, + "UserInfo" + ) + ).toStrictEqual([ + { + name: "UserInfoRequest", + types: [ + { name: "entities", required: true, type: "array" }, + { name: "include-disabled", required: false, type: "boolean" }, + ], + }, + { + name: "AdditionalProperties", + types: [{ name: "[key: string]", required: true, type: "any" }], + }, + ]); + }); + + it("handles additionalProperties", () => { + expect( + generateInterfaces( + { + UserInfoRequest: { + type: "object", + properties: { + entities: { + type: "object", + additionalProperties: true, + }, + }, + required: ["entities", "include-disabled"], + }, + }, + "UserInfo" + ) + ).toStrictEqual([ + { + name: "UserInfoRequest", + types: [ + { name: "entities", required: true, type: "AdditionalProperties" }, + ], + }, + { + name: "AdditionalProperties", + types: [{ name: "[key: string]", required: true, type: "any" }], + }, + ]); + }); + + it("overrides AllWatcher methods", () => { + expect( + generateInterfaces( + { + AllWatcherNextResults: { + type: "object", + properties: { + deltas: { + type: "array", + $ref: "#/definitions/Delta", + }, + }, + additionalProperties: false, + required: ["removed", "entity"], + }, + Delta: { + type: "object", + properties: { + entity: { + type: "object", + additionalProperties: true, + }, + removed: { + type: "boolean", + }, + }, + additionalProperties: false, + required: ["removed", "entity"], + }, + }, + "AllWatcher" + ) + ).toStrictEqual([ + { + name: "AllWatcherNextResults", + types: [ + { + name: "deltas", + required: true, + type: "[string, string, unknown][]", + }, + ], + }, + { + name: "Delta", + types: [ + { name: "entity", required: true, type: "AdditionalProperties" }, + { name: "removed", required: true, type: "boolean" }, + ], + }, + { + name: "AdditionalProperties", + types: [{ name: "[key: string]", required: true, type: "any" }], + }, + ]); + }); +}); + +describe("generateTypes", () => { + it("generates types for a set of properties", () => { + expect( + generateTypes( + { + applications: { type: "array", items: { type: "string" } }, + commands: { type: "string" }, + "execution-group": { type: "string" }, + parallel: { type: "boolean" }, + timeout: { type: "integer" }, + }, + [] + ) + ).toStrictEqual([ + { name: "applications", required: true, type: "string[]" }, + { name: "commands", required: true, type: "string" }, + { name: "execution-group", required: true, type: "string" }, + { name: "parallel", required: true, type: "boolean" }, + { name: "timeout", required: true, type: "number" }, + ]); + }); + + it("handles required properties", () => { + expect( + generateTypes( + { + parallel: { type: "boolean" }, + timeout: { type: "integer" }, + }, + ["parallel"] + ) + ).toStrictEqual([ + { name: "parallel", required: true, type: "boolean" }, + { name: "timeout", required: false, type: "number" }, + ]); + }); + + it("handles additionalProperties", () => { + expect( + generateTypes( + { + actions: { + type: "object", + additionalProperties: true, + }, + }, + [] + ) + ).toStrictEqual([ + { name: "actions", required: true, type: "AdditionalProperties" }, + ]); + }); + + it("handles patternProperties with with more than one key", () => { + // This is a bail out condition in case the schema returns something unexpected. + expect( + generateTypes( + { + actions: { + type: "object", + patternProperties: { + ".*": { + type: "object", + additionalProperties: true, + }, + "^.": { + type: "object", + additionalProperties: true, + }, + }, + }, + }, + [] + ) + ).toStrictEqual([{ name: "actions", required: true, type: "unknown" }]); + }); + + it("handles patternProperties with additionalProperties", () => { + expect( + generateTypes( + { + actions: { + type: "object", + patternProperties: { + ".*": { + type: "object", + additionalProperties: true, + }, + }, + }, + }, + [] + ) + ).toStrictEqual([ + { name: "actions", required: true, type: "AdditionalProperties" }, + ]); + }); + + it("handles patternProperties with refs", () => { + expect( + generateTypes( + { + actions: { + type: "object", + patternProperties: { + ".*": { + type: "object", + $ref: "#/definitions/ActionParams", + }, + }, + }, + }, + [] + ) + ).toStrictEqual([ + { + name: "actions", + required: true, + type: "object", + valueType: "ActionParams", + }, + ]); + }); + + it("handles patternProperties with explicit value types", () => { + expect( + generateTypes( + { + actions: { + type: "object", + patternProperties: { + ".*": { + type: "string", + }, + }, + }, + }, + [] + ) + ).toStrictEqual([ + { + name: "actions", + required: true, + type: "object", + valueType: "string", + }, + ]); + }); + + it("handles patternProperties with explicit array type", () => { + expect( + generateTypes( + { + actions: { + type: "object", + patternProperties: { + ".*": { + type: "array", + items: { + type: "string", + }, + }, + }, + }, + }, + [] + ) + ).toStrictEqual([ + { + name: "actions", + required: true, + type: "object", + valueType: "string[]", + }, + ]); + }); + + it("handles nested patternProperties", () => { + expect( + generateTypes( + { + actions: { + type: "object", + patternProperties: { + ".*": { + type: "object", + patternProperties: { + ".*": { + type: "string", + }, + }, + }, + }, + }, + }, + [] + ) + ).toStrictEqual([ + { + name: "actions", + required: true, + type: "object", + valueType: { + type: "object", + valueType: "string", + }, + }, + ]); + }); + + it("overrides agent-version", () => { + expect( + generateTypes( + { + "agent-version": { $ref: "#/definitions/Number" }, + }, + [] + ) + ).toStrictEqual([ + { name: "agent-version", required: true, type: "string" }, + ]); + }); +}); diff --git a/generator/tsconfig.json b/generator/tsconfig.json new file mode 100644 index 000000000..6ad7cbd51 --- /dev/null +++ b/generator/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../tsconfig.json", + "include": ["**/*.ts"], + "ts-node": { + "esm": true + } +} diff --git a/jest.config.ts b/jest.config.ts index c6d27d375..fc82d1bf8 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -6,7 +6,10 @@ export default { }, preset: "ts-jest", testEnvironment: "node", - testMatch: ["/api/tests/**/test-*.[jt]s"], + testMatch: [ + "/api/tests/**/test-*.[jt]s", + "/generator/**/test-*.[jt]s", + ], transform: { "^.+\\.[jt]s$": ["ts-jest", { useESM: true }], }, diff --git a/package.json b/package.json index 1b3b54999..c8d688842 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@canonical/jujulib", - "version": "3.2.1", + "version": "4.0.0", "description": "Juju API client", "main": "dist/api/client.js", "types": "dist/api/client.d.ts", @@ -8,7 +8,7 @@ "scripts": { "build": "tsc", "clean": "rm -rf node_modules dist", - "generate-facades": "SCHEMA=generator/schema/schema.json JUJU_VERSION=`cat generator/schema/juju-version.txt` JUJU_GIT_SHA=`cat generator/schema/juju-git-sha.txt` node --enable-source-maps dist/generator/index.js", + "generate-facades": "SCHEMA=generator/schema/schema.json JUJU_VERSION=$(cat generator/schema/juju-version.txt) JUJU_GIT_SHA=$(cat generator/schema/juju-git-sha.txt) ts-node generator/index.ts", "regenerate-all-facades": "node generator/schema/regenerate-all.js", "store-schema": "./generator/scripts/store-schema.sh", "generate-docs": "README_FOR_DOCS=true yarn generate-facades && typedoc api/* --out docs --entryPointStrategy expand --includeVersion --gitRemote upstream",