• Connect to the Juju controller or model at the given URL and the authenticate using the given credentials.

    Returns

    This promise will be rejected if there is an error connecting, or resolved with a new {conn, logout} object. Note that the promise will not be resolved or rejected if a callback is provided.

    Parameters

    • url: string

      The WebSocket URL of the Juju controller or model.

    • options: ConnectOptions

      Connections options, including:

      • facades (default=[]): the list of facade classes to include in the API connection object. Those classes are usually auto-generated and can be found in the facades directory of the project. When multiple versions of the same facade are included, the most recent version supported by the server is made available as part of the connection object;
      • debug (default=false): when enabled, all API messages are logged at debug level;
      • wsclass (default=W3C browser native WebSocket): the WebSocket class to use for opening the connection and sending/receiving messages. Server side, require('websocket').w3cwebsocket can be used safely, as it implements the W3C browser native WebSocket API;
      • bakery (default: null): the bakery client to use when macaroon discharges are required, in the case an external user is used to connect to Juju; see https://www.npmjs.com/package/macaroon-bakery;
      • closeCallback: a callback to be called with the exit code when the connection is closed.
    • Optional credentials: Credentials

      An object with the user and password fields for userpass authentication or the macaroons field for bakery authentication. If an empty object is provided a full bakery discharge will be attempted for logging in with macaroons. Any necessary third party discharges are performed using the bakery instance provided in the options (see below).

    • clientVersion: string = CLIENT_VERSION

    Returns Promise<{
        conn?: Connection;
        logout: typeof logout;
    }>

Generated using TypeDoc