@adobe/aio-lib-cloudmanager

Adobe I/O Cloud Manager Library

Usage no npm install needed!

<script type="module">
  import adobeAioLibCloudmanager from 'https://cdn.skypack.dev/@adobe/aio-lib-cloudmanager';
</script>

README

Version Downloads/week Build Status License Codecov Coverage

Adobe I/O Cloud Manager Library

JavaScript SDK wrapping the Adobe Cloud Manager API.

Installing

$ npm install @adobe/aio-lib-cloudmanager

Usage

  1. Initialize the SDK
const sdk = require('@adobe/aio-lib-cloudmanager')

async function sdkTest() {
  //initialize sdk
  const client = await sdk.init('<orgId>', 'x-api-key', '<valid auth token>')
}
  1. Call methods using the initialized SDK
const sdk = require('@adobe/aio-lib-cloudmanager')

async function sdkTest() {
  // initialize sdk
  const client = await sdk.init('<orgId>', 'x-api-key', '<valid auth token>')

  // call methods
  try {
    // get... something
    const result = await client.getSomething({})
    console.log(result)

  } catch (e) {
    console.error(e)
  }
}

Classes

CloudManagerAPI

This class provides methods to call your Cloud Manager APIs. Before calling any method initialize the instance by calling the init method on it with valid values for tenantId, apiKey and accessToken

Functions

getCurrentStep(execution)PipelineExecutionStepState

Find the first non-finished step in a pipeline execution

getWaitingStep(execution)PipelineExecutionStepState

Find the first waiting step in a pipeline execution

init(orgId, apiKey, accessToken, baseUrl)Promise.<CloudManagerAPI>

Returns a Promise that resolves with a new CloudManagerAPI object.

Typedefs

EmbeddedProgram : object

A lightweight representation of a Program

Pipeline : object

A representation of a CI/CD Pipeline

PipelinePhase : object

Describes a phase of a pipeline

PipelineExecution : object

A representation of an execution of a CI/CD Pipeline.

PipelineExecutionStepState : object

Describes the status of a particular pipeline execution step for display purposes

PipelineStepMetrics : object
Metric : object

A representation of a specific metric generated by a CI/CD Pipeline step.

Environment : object

A representation of an Environment known to Cloud Manager.

Variable : object

A named value than can be set on an Environment or Pipeline

LogOptionRepresentation : object
IPAllowedListBinding : object

Describes an IP Allowed List Binding

IPAllowedList : object

Describes an IP Allowed List

ListPipelineOptions : object

Options to the listPipeline function

DownloadedLog : object
PipelineUpdate : object

CloudManagerAPI

This class provides methods to call your Cloud Manager APIs. Before calling any method initialize the instance by calling the init method on it with valid values for tenantId, apiKey and accessToken

Kind: global class

cloudManagerAPI.orgId : string

The organization id

Kind: instance property of CloudManagerAPI

cloudManagerAPI.apiKey : string

The api key from your integration

Kind: instance property of CloudManagerAPI

cloudManagerAPI.accessToken : string

The access token from your integration

Kind: instance property of CloudManagerAPI

cloudManagerAPI.baseUrl : string

The base URL for the API endpoint

Kind: instance property of CloudManagerAPI

cloudManagerAPI.init(orgId, apiKey, accessToken, baseUrl) ⇒ Promise.<CloudManagerAPI>

Initializes a CloudManagerAPI object and returns it.

Kind: instance method of CloudManagerAPI
Returns: Promise.<CloudManagerAPI> - a CloudManagerAPI object

Param Type Description
orgId string the organization id
apiKey string the API key for your integration
accessToken string the access token for your integration
baseUrl string the base URL to access the API (defaults to https://cloudmanager.adobe.io)

cloudManagerAPI.listPrograms() ⇒ Promise.<Array.<EmbeddedProgram>>

Obtain a list of programs for the target organization.

Kind: instance method of CloudManagerAPI
Returns: Promise.<Array.<EmbeddedProgram>> - an array of Programs

cloudManagerAPI.listPipelines(programId, options) ⇒ Promise.<Array.<Pipeline>>

Obtain a list of pipelines for the target program.

Kind: instance method of CloudManagerAPI
Returns: Promise.<Array.<Pipeline>> - an array of Pipelines

Param Type Description
programId string the program id
options ListPipelineOptions options

cloudManagerAPI.createExecution(programId, pipelineId) ⇒ Promise.<PipelineExecution>

Create a new execution for a pipeline, returning the execution.

Kind: instance method of CloudManagerAPI
Returns: Promise.<PipelineExecution> - the new execution

Param Type Description
programId string the program id
pipelineId string the pipeline id

cloudManagerAPI.startExecution(programId, pipelineId) ⇒ Promise.<string>

Deprecated

Start an execution for a pipeline, returning the url of the new execution

Kind: instance method of CloudManagerAPI
Returns: Promise.<string> - the execution url

Param Type Description
programId string the program id
pipelineId string the pipeline id

cloudManagerAPI.getCurrentExecution(programId, pipelineId) ⇒ Promise.<PipelineExecution>

Get the current execution for a pipeline

Kind: instance method of CloudManagerAPI
Returns: Promise.<PipelineExecution> - the execution

Param Type Description
programId string the program id
pipelineId string the pipeline id

cloudManagerAPI.listExecutions(programId, pipelineId, limit) ⇒ Promise.<Array.<PipelineExecution>>

List the most recent executions for a pipeline

Kind: instance method of CloudManagerAPI
Returns: Promise.<Array.<PipelineExecution>> - the list of executions

Param Type Default Description
programId string the program id
pipelineId string the pipeline id
limit number 20 the maximum number of executions to return (defaults to 20)

cloudManagerAPI.getExecution(programId, pipelineId, executionId) ⇒ Promise.<PipelineExecution>

Get an execution for a pipeline

Kind: instance method of CloudManagerAPI
Returns: Promise.<PipelineExecution> - the execution

Param Type Description
programId string the program id
pipelineId string the pipeline id
executionId string the execution id

cloudManagerAPI.getQualityGateResults(programId, pipelineId, executionId, action) ⇒ Promise.<PipelineStepMetrics>

Get the quality gate results for a pipeline step

Kind: instance method of CloudManagerAPI
Returns: Promise.<PipelineStepMetrics> - the execution

Param Type Description
programId string the program id
pipelineId string the pipeline id
executionId string the execution id
action string the action name

cloudManagerAPI.cancelCurrentExecution(programId, pipelineId) ⇒ Promise.<object>

Cancel current execution

Kind: instance method of CloudManagerAPI
Returns: Promise.<object> - a truthy value

Param Type Description
programId string the program id
pipelineId string the pipeline id

cloudManagerAPI.advanceCurrentExecution(programId, pipelineId) ⇒ Promise.<object>

Advance current execution

Kind: instance method of CloudManagerAPI
Returns: Promise.<object> - a truthy value

Param Type Description
programId string the program id
pipelineId string the pipeline id

cloudManagerAPI.listEnvironments(programId) ⇒ Promise.<Array.<Environment>>

List environments for a program

Kind: instance method of CloudManagerAPI
Returns: Promise.<Array.<Environment>> - a list of environments

Param Type Description
programId string the program id

cloudManagerAPI.getExecutionStepLog(programId, pipelineId, executionId, action, logFile, outputStream) ⇒ Promise.<object>

Write step log to an output stream.

Kind: instance method of CloudManagerAPI
Returns: Promise.<object> - a truthy value

Param Type Description
programId string the program id
pipelineId string the pipeline id
executionId string the execution id
action string the action
logFile string the log file to select a non-default value
outputStream object the output stream to write to

cloudManagerAPI.tailExecutionStepLog(programId, pipelineId, action, logFile, outputStream) ⇒ Promise.<PipelineExecutionStepState>

Tail step log to an output stream.

Kind: instance method of CloudManagerAPI
Returns: Promise.<PipelineExecutionStepState> - the completed step state

Param Type Description
programId string the program id
pipelineId string the pipeline id
action string the action
logFile string the log file to select a non-default value
outputStream object the output stream to write to

cloudManagerAPI.listAvailableLogOptions(programId, environmentId) ⇒ Promise.<Array.<LogOptionRepresentation>>

List the log options available for an environment

Kind: instance method of CloudManagerAPI
Returns: Promise.<Array.<LogOptionRepresentation>> - the log options for the environment

Param Type Description
programId string the program id
environmentId string the environment id

cloudManagerAPI.downloadLogs(programId, environmentId, service, name, days, outputDirectory) ⇒ Promise.<Array.<DownloadedLog>>

Download log files from the environment to a specified directory.

Kind: instance method of CloudManagerAPI
Returns: Promise.<Array.<DownloadedLog>> - the list of downloaded logs

Param Type Description
programId string the program id
environmentId string the environment id
service string the service specification
name string the log name
days number the number of days
outputDirectory string the output directory

cloudManagerAPI.deletePipeline(programId, pipelineId) ⇒ Promise.<object>

Delete a pipeline

Kind: instance method of CloudManagerAPI
Returns: Promise.<object> - a truthy object

Param Type Description
programId string the program id
pipelineId string the pipeline id

cloudManagerAPI.updatePipeline(programId, pipelineId, changes) ⇒ Promise.<Pipeline>

Update a pipeline

Kind: instance method of CloudManagerAPI
Returns: Promise.<Pipeline> - the new pipeline definition

Param Type Description
programId string the program id
pipelineId string the pipeline id
changes PipelineUpdate the changes

cloudManagerAPI.getDeveloperConsoleUrl(programId, environmentId) ⇒ Promise.<string>

Get the link to the developer console

Kind: instance method of CloudManagerAPI
Returns: Promise.<string> - the console url

Param Type Description
programId string the program id
environmentId string the environment id

cloudManagerAPI.getEnvironmentVariables(programId, environmentId) ⇒ Promise.<Array.<Variable>>

Get the list of variables for an environment

Kind: instance method of CloudManagerAPI
Returns: Promise.<Array.<Variable>> - the variables

Param Type Description
programId string the program id
environmentId string the environment id

cloudManagerAPI.setEnvironmentVariables(programId, environmentId, variables) ⇒ Promise.<object>

Set the variables for an environment

Kind: instance method of CloudManagerAPI
Returns: Promise.<object> - a truthy value

Param Type Description
programId string the program id
environmentId string the environment id
variables Array.<Variable> the variables

cloudManagerAPI.getPipelineVariables(programId, pipelineId) ⇒ Promise.<Array.<Variable>>

Get the list of variables for a pipeline

Kind: instance method of CloudManagerAPI
Returns: Promise.<Array.<Variable>> - the variables

Param Type Description
programId string the program id
pipelineId string the pipeline id

cloudManagerAPI.setPipelineVariables(programId, pipelineId, variables) ⇒ Promise.<object>

Set the variables for a pipeline

Kind: instance method of CloudManagerAPI
Returns: Promise.<object> - a truthy value

Param Type Description
programId string the program id
pipelineId string the pipeline id
variables Array.<Variable> the variables

cloudManagerAPI.deleteProgram(programId) ⇒ Promise.<object>

Delete a program

Kind: instance method of CloudManagerAPI
Returns: Promise.<object> - a truthy value

Param Type Description
programId string the program id

cloudManagerAPI.deleteEnvironment(programId, environmentId) ⇒ Promise.<object>

Delete an environment

Kind: instance method of CloudManagerAPI
Returns: Promise.<object> - a truthy value

Param Type Description
programId string the program id
environmentId string the environment id

cloudManagerAPI.listIpAllowlists(programId) ⇒ Promise.<IPAllowedList>

List the program's defined IP Allow Lists

Kind: instance method of CloudManagerAPI
Returns: Promise.<IPAllowedList> - - the IP Allow Lists

Param Type Description
programId string the program id

cloudManagerAPI.createIpAllowlist(programId, name, cidrBlocks) ⇒ Promise.<IPAllowedList>

Create IP Allow List

Kind: instance method of CloudManagerAPI
Returns: Promise.<IPAllowedList> - a truthy value

Param Type Description
programId string the program id
name string the name
cidrBlocks Array.<string> the CIDR blocks

cloudManagerAPI.updateIpAllowlist(programId, ipAllowlistId, cidrBlocks) ⇒ Promise.<object>

Update the CIDR blocks of an IP Allow List

Kind: instance method of CloudManagerAPI
Returns: Promise.<object> - a truthy value

Param Type Description
programId string the program id
ipAllowlistId string the allow list id
cidrBlocks Array.<string> the replacement CIDR blocks

cloudManagerAPI.deleteIpAllowlist(programId, ipAllowlistId) ⇒ Promise.<object>

Update the CIDR blocks of an IP Allow List

Kind: instance method of CloudManagerAPI
Returns: Promise.<object> - a truthy value

Param Type Description
programId string the program id
ipAllowlistId string the allow list id

cloudManagerAPI.addIpAllowlistBinding(programId, ipAllowlistId, environmentId, service) ⇒ Promise.<object>

Bind an IP Allow List to an environment

Kind: instance method of CloudManagerAPI
Returns: Promise.<object> - a truthy value

Param Type Description
programId string the program id
ipAllowlistId string the allow list id
environmentId string the environment id
service string the service name

cloudManagerAPI.removeIpAllowlistBinding(programId, ipAllowlistId, environmentId, service) ⇒ Promise.<object>

Unbind an IP Allow List from an environment

Kind: instance method of CloudManagerAPI
Returns: Promise.<object> - a truthy value

Param Type Description
programId string the program id
ipAllowlistId string the allow list id
environmentId string the environment id
service string the service name

cloudManagerAPI.getCommerceCommandExecution(programId, environmentId, executionId) ⇒ Promise.<object>

Get status for an existing Commerce execution

Kind: instance method of CloudManagerAPI
Returns: Promise.<object> - a truthy value of the commerce execution

Param Type Description
programId string the program id
environmentId string the environment id
executionId string the execution id

cloudManagerAPI.postCommerceCommandExecution(programId, environmentId, options) ⇒ Promise.<object>

Make a Post to Commerce API

Kind: instance method of CloudManagerAPI
Returns: Promise.<object> - a truthy value

Param Type Description
programId string the program id
environmentId string the environment id
options object options

getCurrentStep(execution) ⇒ PipelineExecutionStepState

Find the first non-finished step in a pipeline execution

Kind: global function
Returns: PipelineExecutionStepState - the step state or a falsy object if all steps are finished

Param Type Description
execution PipelineExecution the execution

getWaitingStep(execution) ⇒ PipelineExecutionStepState

Find the first waiting step in a pipeline execution

Kind: global function
Returns: PipelineExecutionStepState - the step state or a falsy object if no step is waiting

Param Type Description
execution PipelineExecution the execution

init(orgId, apiKey, accessToken, baseUrl) ⇒ Promise.<CloudManagerAPI>

Returns a Promise that resolves with a new CloudManagerAPI object.

Kind: global function
Returns: Promise.<CloudManagerAPI> - a Promise with a CloudManagerAPI object

Param Type Description
orgId string the organization id
apiKey string the API key for your integration
accessToken string the access token for your integration
baseUrl string the base URL to access the API (defaults to https://cloudmanager.adobe.io)

EmbeddedProgram : object

A lightweight representation of a Program

Kind: global typedef
Properties

Name Type Description
id string Identifier of the program. Unique within the space.
name string Name of the program
enabled boolean Whether this Program has been enabled for Cloud Manager usage
tenantId string Tenant Id

Pipeline : object

A representation of a CI/CD Pipeline

Kind: global typedef
Properties

Name Type Description
id string Identifier of the pipeline. Unique within the program.
programId string Identifier of the program. Unique within the space.
name string Name of the pipeline
trigger string How should the execution be triggered. ON_COMMIT: each time one or more commits are pushed and the Pipeline is idle then a execution is triggered. MANUAL: triggerd through UI or API.
status string Pipeline status
createdAt string Create date
updatedAt string Update date
lastStartedAt string Last pipeline execution start
lastFinishedAt string Last pipeline execution end
phases Array.<PipelinePhase> Pipeline phases in execution order

PipelinePhase : object

Describes a phase of a pipeline

Kind: global typedef
Properties

Name Type Description
name string Name of the phase
type string Type of the phase
repositoryId string Identifier of the source repository. The code from this repository will be build at the start of this phase. Mandatory if type=BUILD
branch string Name of the tracked branch or a fully qualified git tag (e.g. refs/tags/v1). Assumed to be master if missing.
environmentId string Identifier of the target environment. Mandatory if type=DEPLOY

PipelineExecution : object

A representation of an execution of a CI/CD Pipeline.

Kind: global typedef
Properties

Name Type Description
id string Pipeline execution identifier
programId string Identifier of the program. Unique within the space.
pipelineId string Identifier of the pipeline. Unique within the space.
artifactsVersion string Version of the artifacts generated during this execution
user string AdobeID who started the pipeline. Empty for auto triggered builds
status string Status of the execution
trigger string How the execution was triggered.
createdAt string Start time
updatedAt string Date of last status change
finishedAt string Date the execution reached a final state

PipelineExecutionStepState : object

Describes the status of a particular pipeline execution step for display purposes

Kind: global typedef
Properties

Name Type Description
id string
stepId string
phaseId string
action string Name of the action
repository string Target repository
branch string Target branch
environment string Target environment
environmentId string Target environment id
environmentType string Target environment type
startedAt string Start time
finishedAt string Date the execution reached a final state
details object Information about step result
status string Action status

PipelineStepMetrics : object

Kind: global typedef
Properties

Name Type Description
metrics Array.<Metric> metrics

Metric : object

A representation of a specific metric generated by a CI/CD Pipeline step.

Kind: global typedef
Properties

Name Type Description
id string KPI result identifier
severity string Severity of the metric
passed boolean Whether metric is considered passed
override boolean Whether user override the failed metric
actualValue string Expected value for the metric
expectedValue string Expected value for the metric
comparator string Comparator used for the metric
kpi string KPI identifier

Environment : object

A representation of an Environment known to Cloud Manager.

Kind: global typedef
Properties

Name Type Description
id string id
programId string Identifier of the program. Unique within the space.
name string Name of the environment
description string Description of the environment
type string Type of the environment
availableLogOptions Array.<LogOptionRepresentation> List of logs available in the environment

Variable : object

A named value than can be set on an Environment or Pipeline

Kind: global typedef
Properties

Name Type Description
name string Name of the variable. Of a-z, A-Z, _ and 0-9 Cannot begin with a number.
value string Value of the variable. Read-Write for non-secrets, write-only for secrets. The length of secretString values must be less than 500 characters. An empty value causes a variable to be deleted.
type string Type of the variable. Default string if missing. secretString variables are encrypted at rest. The type of a variable be changed after creation; the variable must be deleted and recreated.
service string Service of the variable. When not provided, the variable applies to all services. Currently the values 'author', 'publish', and 'preview' are supported. Note - this value is case-sensitive.
status string Status of the variable

LogOptionRepresentation : object

Kind: global typedef
Properties

Name Type Description
service string Name of the service in environment. Example: author
name string Name of the log for service in environment. Example: aemerror

IPAllowedListBinding : object

Describes an IP Allowed List Binding

Kind: global typedef
Properties

Name Type Description
id string Identifier of the IP Allowed List Binding to an Environment
tier string Tier of the environment.
status string Status of the binding.
programId string Identifier of the program.
ipAllowListId string Identifier of the IP allow list.
environmentId string Identifier of the environment.

IPAllowedList : object

Describes an IP Allowed List

Kind: global typedef
Properties

Name Type Description
id string Identifier of the IP Allowed List
name string Name of the IP Allowed List
ipCidrSet Array.<string> IP CIDR Set
programId string Identifier of the program.
bindings Array.<IPAllowedListBinding> IP Allowlist bindings

ListPipelineOptions : object

Options to the listPipeline function

Kind: global typedef
Properties

Name Type Description
busy boolean if true, only busy pipelines will be returned

DownloadedLog : object

Kind: global typedef
Properties

Name Type Description
path string the path where the log was stored
url string the url of the log that was downloaded

PipelineUpdate : object

Kind: global typedef
Properties

Name Type Description
branch string the new branch
repositoryId string the new repository id

Debug Logs

LOG_LEVEL=debug <your_call_here>

Prepend the LOG_LEVEL environment variable and debug value to the call that invokes your function, on the command line. This should output a lot of debug data for your SDK calls.

Contributing

Contributions are welcome! Read the Contributing Guide for more information.

Licensing

This project is licensed under the Apache V2 License. See LICENSE for more information.