6.0.0 • Published 2 months ago

@canonical/jujulib v6.0.0

Weekly downloads
22
License
LGPL-3.0
Repository
github
Last release
2 months ago

JS Jujulib

This project provides a JavaScript API client library for interacting with the Juju WebSocket API.

Getting Started

To access the Juju API, a connection must be made to either a Juju controller or a Juju model.

import { connect } from "@canonical/jujulib";

import Client from "@canonical/jujulib/dist/api/facades/client";
import ModelManager from "@canonical/jujulib/dist/api/facades/model-manager";

// Nodejs
// import WebSocket from "ws";

const serverURL = "ws://localhost:17070";
const credentials = {
  username: "admin",
  password: "test",
};

// Connect to the controller
const controller = await connect(`${serverURL}/api`, {
  facades: [ModelManager],
  wsclass: WebSocket,
});
let conn = await controller.login(credentials);

// Get the list of models
const modelManager = conn.facades.modelManager;
const response = await modelManager.listModels({
  tag: conn.info.user.identity,
});
const models = response["user-models"];
console.log("models:", models);

// Close the connection to the controller
conn.transport.close();

// Login to each model
for (const modelDetails of models) {
  const model = await connect(
    `${serverURL}/model/${modelDetails.model.uuid}/api`,
    {
      facades: [Client],
      wsclass: WebSocket,
    }
  );
  conn = await model.login(credentials);

  // Get the details of the model
  const client = conn.facades.client;
  console.log("model details:", await client.fullStatus());

  // Close the connection to the model
  conn.transport.close();
}

In the code above, a connection is established to the provided controller API URL where the client declares interest in using the facade ModelManager, and we establish a new connection with each model API to get the full details using the facade Client.

Note: Facades are used to supported different versions of juju, when multiple versions of the same facade are supported by the juju API (like the two client versions in the example), the most recent version supported by the server is made available to the client.

The connect method returns a juju object which is used to log into the controller or model by providing a user/pass credentials or macaroons. See the various examples.

Client API Reference

Visit the full API documentation for detailed information on the Client API.

Examples

We have a number of examples showing how to perform a few common tasks. Those can be found in the examples folder.

Facade API Reference

Detailed Facade documentation is available as part of the full API documentation or you can visit the facade source directly using the following links:

FacadeVersions
ActionPrunerActionPrunerV1.ts
ActionActionV6.tsActionV7.ts
AdminAdminV3.ts
AgentLifeFlagAgentLifeFlagV1.ts
AgentToolsAgentToolsV1.ts
AgentAgentV2.tsAgentV3.ts
AllModelWatcherAllModelWatcherV2.tsAllModelWatcherV3.tsAllModelWatcherV4.ts
AllWatcherAllWatcherV1.tsAllWatcherV2.tsAllWatcherV3.ts
AnnotationsAnnotationsV2.ts
ApplicationOffersApplicationOffersV2.tsApplicationOffersV3.tsApplicationOffersV4.ts
ApplicationScalerApplicationScalerV1.ts
ApplicationApplicationV12.tsApplicationV13.tsApplicationV14.tsApplicationV15.tsApplicationV18.tsApplicationV19.ts
BackupsBackupsV2.tsBackupsV3.ts
BlockBlockV2.ts
BundleBundleV1.tsBundleV4.tsBundleV5.tsBundleV6.ts
CAASAdmissionCAASAdmissionV1.ts
CAASAgentCAASAgentV1.tsCAASAgentV2.ts
CAASApplicationProvisionerCAASApplicationProvisionerV1.ts
CAASApplicationCAASApplicationV1.ts
CAASFirewallerEmbeddedCAASFirewallerEmbeddedV1.ts
CAASFirewallerSidecarCAASFirewallerSidecarV1.ts
CAASFirewallerCAASFirewallerV1.ts
CAASModelConfigManagerCAASModelConfigManagerV1.ts
CAASModelOperatorCAASModelOperatorV1.ts
CAASOperatorProvisionerCAASOperatorProvisionerV1.ts
CAASOperatorUpgraderCAASOperatorUpgraderV1.ts
CAASOperatorCAASOperatorV1.ts
CAASUnitProvisionerCAASUnitProvisionerV1.tsCAASUnitProvisionerV2.ts
CharmDownloaderCharmDownloaderV1.ts
CharmHubCharmHubV1.ts
CharmRevisionUpdaterCharmRevisionUpdaterV2.ts
CharmsCharmsV2.tsCharmsV4.tsCharmsV5.tsCharmsV6.tsCharmsV7.ts
CleanerCleanerV2.ts
ClientClientV2.tsClientV3.tsClientV5.tsClientV6.tsClientV7.ts
CloudCloudV1.tsCloudV2.tsCloudV3.tsCloudV4.tsCloudV5.tsCloudV7.ts
ControllerControllerV11.tsControllerV3.tsControllerV4.tsControllerV5.tsControllerV6.tsControllerV7.tsControllerV8.tsControllerV9.ts
CredentialManagerCredentialManagerV1.ts
CredentialValidatorCredentialValidatorV2.ts
CrossControllerCrossControllerV1.ts
CrossModelRelationsCrossModelRelationsV2.ts
CrossModelSecretsCrossModelSecretsV1.ts
DeployerDeployerV1.ts
DiskManagerDiskManagerV2.ts
EntityWatcherEntityWatcherV2.ts
EnvironUpgraderEnvironUpgraderV1.ts
ExternalControllerUpdaterExternalControllerUpdaterV1.ts
FanConfigurerFanConfigurerV1.ts
FilesystemAttachmentsWatcherFilesystemAttachmentsWatcherV2.ts
FirewallRulesFirewallRulesV1.ts
FirewallerFirewallerV5.tsFirewallerV7.ts
HighAvailabilityHighAvailabilityV2.ts
HostKeyReporterHostKeyReporterV1.ts
ImageManagerImageManagerV2.ts
ImageMetadataManagerImageMetadataManagerV1.ts
ImageMetadataImageMetadataV3.ts
InstanceMutaterInstanceMutaterV2.tsInstanceMutaterV3.ts
InstancePollerInstancePollerV4.ts
KeyManagerKeyManagerV1.ts
KeyUpdaterKeyUpdaterV1.ts
LeadershipServiceLeadershipServiceV2.ts
LifeFlagLifeFlagV1.ts
LogForwardingLogForwardingV1.ts
LoggerLoggerV1.ts
MachineActionsMachineActionsV1.ts
MachineManagerMachineManagerV10.tsMachineManagerV6.tsMachineManagerV7.tsMachineManagerV9.ts
MachineUndertakerMachineUndertakerV1.ts
MachinerMachinerV4.tsMachinerV5.ts
MeterStatusMeterStatusV2.ts
MetricsAdderMetricsAdderV2.ts
MetricsDebugMetricsDebugV2.ts
MetricsManagerMetricsManagerV1.ts
MigrationFlagMigrationFlagV1.ts
MigrationMasterMigrationMasterV2.tsMigrationMasterV3.ts
MigrationMinionMigrationMinionV1.ts
MigrationStatusWatcherMigrationStatusWatcherV1.ts
MigrationTargetMigrationTargetV1.tsMigrationTargetV2.tsMigrationTargetV3.ts
ModelConfigModelConfigV2.tsModelConfigV3.ts
ModelGenerationModelGenerationV4.ts
ModelManagerModelManagerV2.tsModelManagerV3.tsModelManagerV4.tsModelManagerV5.tsModelManagerV8.tsModelManagerV9.ts
ModelSummaryWatcherModelSummaryWatcherV1.ts
ModelUpgraderModelUpgraderV1.ts
NotifyWatcherNotifyWatcherV1.ts
OfferStatusWatcherOfferStatusWatcherV1.ts
PayloadsHookContextPayloadsHookContextV1.ts
PayloadsPayloadsV1.ts
PingerPingerV1.ts
ProvisionerProvisionerV11.ts
ProxyUpdaterProxyUpdaterV2.ts
RaftLeaseRaftLeaseV1.tsRaftLeaseV2.ts
RebootRebootV2.ts
RelationStatusWatcherRelationStatusWatcherV1.ts
RelationUnitsWatcherRelationUnitsWatcherV1.ts
RemoteRelationWatcherRemoteRelationWatcherV1.ts
RemoteRelationsRemoteRelationsV2.ts
ResourcesHookContextResourcesHookContextV1.ts
ResourcesResourcesV1.tsResourcesV2.tsResourcesV3.ts
ResumerResumerV2.ts
RetryStrategyRetryStrategyV1.ts
SecretBackendsManagerSecretBackendsManagerV1.ts
SecretBackendsRotateWatcherSecretBackendsRotateWatcherV1.ts
SecretBackendsSecretBackendsV1.ts
SecretsDrainSecretsDrainV1.ts
SecretsManagerSecretsManagerV1.tsSecretsManagerV2.ts
SecretsRevisionWatcherSecretsRevisionWatcherV1.ts
SecretsRotationWatcherSecretsRotationWatcherV1.ts
6.0.0

2 months ago

5.0.0

3 months ago

4.1.0

4 months ago

4.0.0

10 months ago

3.2.1

1 year ago

3.2.0

1 year ago

3.1.3

1 year ago

3.1.2

1 year ago

3.1.1

1 year ago

3.1.0

1 year ago

3.0.3

1 year ago

3.0.2

1 year ago

3.0.1

1 year ago

3.0.0

1 year ago

2.0.0

1 year ago

2.0.0-beta.8

2 years ago

2.0.0-beta.7

3 years ago

2.0.0-beta.6

3 years ago

2.0.0-beta.5

3 years ago

2.0.0-beta.4

3 years ago

2.0.0-beta.3

3 years ago

2.0.0-beta.2

3 years ago

2.0.0-beta.1

3 years ago

2.0.0-beta.0

3 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago