AppOps API

This Prodly AppOps application programming interface (API) replaces the original, deprecated API.

Overview 

This topic describes the Prodly AppOps application programming interface (API). The API helps integrate continuous delivery and release management systems to automatically perform AppOps deployments. For example, use API requests to deploy a data set or deployment plan.

The AppOps API is a RESTful API that allows you to integrate AppOps deployments into a larger continuous integration process. AppOps API requests use the Force.com REST API to invoke AppOps actions. AppOps also supports global Apex services for internal Salesforce automation.

These API services are available:

  • Apex REST Services
  • Global Apex Services

Apex REST Services 

Prodly AppOps REST services provide AppOps consumers and integrated systems outside of Salesforce the ability to invoke deployments and perform other actions through REST-based API requests exposed by the AppOps Salesforce package in your Prodly AppOps control environment.

These APIs mimic and act as proxy for the the core AppOps services REST API as documented in Swagger. They just add the API key header when invoking the AppOps API.

/apexrest/PDRI/v1/instances/{instanceId}/checkin

/apexrest/PDRI/v1/instances/{instanceId}/checkout

/apexrest/PDRI/v1/instances/{instanceId}/deploy

/apexrest/PDRI/v1/instances

/apexrest/PDRI/v1/jobs

Usage 

The Apex REST service allows you to invoke many AppOps supported actions from applications external to Salesforce, such as a continuous delivery or release management system. For example:

  • You are running CircleCI and after deploying updated code to a QA sandbox, you need to automatically deploy the updated data to the sandbox for end-to-end testing.
  • You have a custom built solution coordinating CPQ deployments that performs automated steps to promote product catalog changes between development, QA, and UAT sandboxes.

Namespace 

PDRI

The REST Endpoints 

These APIs mimic and act as proxy for the core AppOps services REST API as documented in Swagger.

  • /apexrest/PDRI/v1/instances/{instanceId}/checkin – saves data from a Salesforce environment to a version control system (VCS) repository branch.
  • /apexrest/PDRI/v1/instances/{instanceId}/checkout – deploys data from a VCS repository branch to a Salesforce environment.
  • /apexrest/PDRI/v1/instances/{instanceId}/deploy – deploys data from one Salesforce environment to another Salesforce environment.
  • /apexrest/PDRI/v1/instances – authorizes a Salesforce environment for use by the APIs.
  • /apexrest/PDRI/v1/jobs – retrieves the history of deployments.

Refer to our Swagger page for details. Related Salesforce Documentation.

Global Apex Services  

Usage 

AppOpsGlobalServices class that provides a global Apex which allows you to deploy metadata, deployment plans, and data sets.

Namespace 

PDRI

Service Methods

Provides wrappers to deploy data and metadata, and also to list managed instances.

The AppOpsGlobalServices class provides these methods:





global with sharing class AppOpsGlobalService {
  global static AppOpsWebServices.Jobs deploy(AppOpsWebServices.DeploymentServiceRequestV1 deploymentServiceRequest, 
    String destinationManagedInstanceId);

  global static List<AppOpsWebServices.Jobs> deploy(AppOpsWebServices.DeploymentServiceRequestV1 deploymentServiceRequest, 
    List<String> destinationManagedInstanceIds);
    
  global static AppOpsWebServices.Jobs deploy(String deploymentName,
    String deploymentNotes,
    String sourceOrgId,
    String destinationOrgId,
    String dataSetId,
    String deploymentPlanId);
    
  global static List<AppOpsWebServices.Jobs> deploy(String deploymentName,
    String deploymentNotes,
    String sourceOrgId,
    List<String> destinationOrgIds,
    String dataSetId,
    String deploymentPlanId);
  
  global static AppOpsWebServices.ManagedInstances listInstances();
}

Sample Code

Example code which lists all environments in AppOps in order to find the source and destination environments based on org IDs. It then kicks off a deployment of a data set.

//Retrieve managed instances
PDRI.AppOpsWebServices.ManagedInstances managedInstances = 
    PDRI.AppOpsGlobalService.listInstances();

//Find environment ID by org ID
Id sourceOrgId = '00D4x000001989NEAQ', 
    destinationOrgId = '00D020000008kmIEAQ';

PDRI.AppOpsWebServices.ManagedInstance sourceInstance,
    destinationInstance;

for( PDRI.AppOpsWebServices.ManagedInstance instance : managedInstances.instances ) {
    if( instance.platformInstanceId == sourceOrgId ) {
        sourceInstance = instance;
    } else if( instance.platformInstanceId == destinationOrgId ) {
        destinationInstance = instance;
    }
}

//Deploy data set from control to a sandbox
Id dataSetId = 'a054x00000685c3AAA';

PDRI.AppOpsWebServices.DeploymentServiceRequestV1 deploymentServiceRequest = 
    new PDRI.AppOpsWebServices.DeploymentServiceRequestV1();

deploymentServiceRequest.deploymentName = 'My Deployment Name';
deploymentServiceRequest.deploymentNotes = 'Just a test deployment';
deploymentServiceRequest.source = 
    new PDRI.AppOpsWebServices.DeploymentSource( sourceInstance.Id );
deploymentServiceRequest.data =
    new List<PDRI.AppOpsWebServices.DataDeploymentRequest> 
	{ new PDRI.AppOpsWebServices.DataDeploymentRequest(dataSetId) };
deploymentServiceRequest.metadata =
    new PDRI.AppOpsWebServices.MetadataDeploymentRequest();

String destinationManagedInstanceId = destinationInstance.id;

PDRI.AppOpsGlobalService.deploy(deploymentServiceRequest, destinationManagedInstanceId);

Example code which kicks off a deployment of a deployment plan to multiple destinations identified by org ID’s.

String deploymentPlanId = 'a054x0000068OSUAA2';
String sourceOrgId = '00D4x000001989NEAQ';
List<String> destinationOrgIds = 
  new List<String>{'00D010000008qhjEAA','00D4C000000104dUAA'};

PDRI.AppOpsGlobalService.deploy('My Deployment Name', 'Just a test deployment', 
  sourceOrgId,
  destinationOrgIds,
  null,
  deploymentPlanId);