Skip to content

Commit

Permalink
Merge pull request #112 from huwshimi/support-pattern-properties
Browse files Browse the repository at this point in the history
Add support for pattern properties
  • Loading branch information
huwshimi authored Jun 29, 2023
2 parents 278c06f + aaf09b2 commit 9ccb81e
Show file tree
Hide file tree
Showing 137 changed files with 2,637 additions and 892 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ Detailed Facade documentation is available as part of the [full API documentatio
| ActionPruner | <ul><li>[ActionPrunerV1.ts](/api/facades/action-pruner/ActionPrunerV1.ts)</li></ul> |
| Action | <ul><li>[ActionV6.ts](/api/facades/action/ActionV6.ts)</li><li>[ActionV7.ts](/api/facades/action/ActionV7.ts)</li></ul> |
| Admin | <ul><li>[AdminV3.ts](/api/facades/admin/AdminV3.ts)</li></ul> |
| AgentLifeFlag | <ul><li>[AgentLifeFlagV1.ts](/api/facades/agent-life-flag/AgentLifeFlagV1.ts)</li></ul> |
| AgentTools | <ul><li>[AgentToolsV1.ts](/api/facades/agent-tools/AgentToolsV1.ts)</li></ul> |
| Agent | <ul><li>[AgentV2.ts](/api/facades/agent/AgentV2.ts)</li><li>[AgentV3.ts](/api/facades/agent/AgentV3.ts)</li></ul> |
| AllModelWatcher | <ul><li>[AllModelWatcherV2.ts](/api/facades/all-model-watcher/AllModelWatcherV2.ts)</li><li>[AllModelWatcherV3.ts](/api/facades/all-model-watcher/AllModelWatcherV3.ts)</li><li>[AllModelWatcherV4.ts](/api/facades/all-model-watcher/AllModelWatcherV4.ts)</li></ul> |
Expand Down Expand Up @@ -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.

Expand Down
7 changes: 4 additions & 3 deletions api/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import { Bakery } from "@canonical/macaroon-bakery";
import AdminV3, {
AuthUserInfo,
FacadeVersions,
LoginRequest,
LoginResult,
Expand All @@ -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;
Expand All @@ -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[][];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion api/facades/action-pruner/ActionPrunerV1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/

Expand Down
4 changes: 2 additions & 2 deletions api/facades/action/ActionV7.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/

Expand Down Expand Up @@ -53,7 +53,7 @@ export interface Actions {
}

export interface ApplicationCharmActionsResult {
actions: AdditionalProperties;
actions: Record<string, ActionSpec>;
"application-tag": string;
error: Error;
}
Expand Down
3 changes: 2 additions & 1 deletion api/facades/admin/AdminV3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/

Expand Down Expand Up @@ -63,6 +63,7 @@ export interface LoginRequest {
credentials: string;
macaroons: Macaroon[][];
nonce: string;
token?: string;
"user-data": string;
}

Expand Down
108 changes: 108 additions & 0 deletions api/facades/agent-life-flag/AgentLifeFlagV1.ts
Original file line number Diff line number Diff line change
@@ -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<LifeResults> {
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<NotifyWatchResults> {
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;
11 changes: 11 additions & 0 deletions api/facades/agent-life-flag/index.ts
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion api/facades/agent-tools/AgentToolsV1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/

Expand Down
4 changes: 2 additions & 2 deletions api/facades/agent/AgentV3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/

Expand All @@ -27,7 +27,7 @@ export interface AgentGetEntitiesResults {
}

export interface CloudCredential {
attrs?: AdditionalProperties;
attrs?: Record<string, string>;
"auth-type": string;
redacted?: string[];
}
Expand Down
12 changes: 6 additions & 6 deletions api/facades/all-model-watcher/AllModelWatcherV4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/

Expand All @@ -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 {
Expand Down Expand Up @@ -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<AllWatcherNextResults> {
next(params: { id: string }): Promise<AllWatcherNextResults> {
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);
Expand All @@ -69,13 +69,13 @@ class AllModelWatcherV4 implements Facade {
/**
Stop stops the watcher.
*/
stop(params: any): Promise<any> {
stop(params: { id: string }): Promise<any> {
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);
Expand Down
16 changes: 8 additions & 8 deletions api/facades/all-watcher/AllWatcherV3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/

Expand All @@ -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 {
Expand Down Expand Up @@ -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<AllWatcherNextResults> {
next(params: { id: string }): Promise<AllWatcherNextResults> {
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);
Expand All @@ -69,13 +69,13 @@ class AllWatcherV3 implements Facade {
/**
Stop stops the watcher.
*/
stop(id: number): Promise<any> {
stop(params: { id: string }): Promise<any> {
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);
Expand Down
6 changes: 3 additions & 3 deletions api/facades/annotations/AnnotationsV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/

Expand All @@ -14,7 +14,7 @@ import { Facade } from "../../types.js";
import { autoBind } from "../../utils.js";

export interface AnnotationsGetResult {
annotations: AdditionalProperties;
annotations: Record<string, string>;
entity: string;
error?: ErrorResult;
}
Expand All @@ -36,7 +36,7 @@ export interface Entity {
}

export interface EntityAnnotations {
annotations: AdditionalProperties;
annotations: Record<string, string>;
entity: string;
}

Expand Down
Loading

0 comments on commit 9ccb81e

Please sign in to comment.