Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

CAPI classes in MID Server script includes

Cloud Provisioning and Governance provides several JavaScript classes that make REST calls to cloud providers. These classes are called from MID Server script includes (for Azure by default) or from Java calls in the system (for AWS by default). If you create custom providers, interfaces, or CAPI APIs (for any cloud provider), you can use MID Server script includes to call the classes.

Note: In CAPI APIs, there are no MID Server script includes (in Method Mappers) that you can customize to call the AWS classes. By default, the CAPI APIs for AWS make Java calls to then call the AWS classes. However, if you create CAPI APIs, you can also create custom script includes to call the classes.

View CAPI classes by navigating to MID Servers > Script Includes in the base system instance interface (not the Cloud Admin Portal). You search for the name of a class in the Go to search box using the Name column:

Image omitted: capi-classes-finding.png
Searching for MID Server script includes

Base classes

These base classes are available by default. They form a basis for the Azure and AWS classes that make the actual REST calls.

  • CloudAPIBase

    CloudAPIBase is a provider-agnostic API that communicates with all types of cloud APIs. It provides functions for basic debugging and logging, and for collecting proxy information on the MID Server. It also defines Headers, Parameters, Endpoints, and this.parameter.

  • AWSCloudAPIBase

    This class is extended from CloudAPIBase and provides functions that call the invoker to make GET, PUT, POST, and DELETE requests. The class provides the option of an executeAction method, which is an AWS implementation of GET, or the invoke method, which provides REST API calls.

  • AzureCloudAPIBase

    This class is extended from CloudAPIBase and provides functions that do these actions:

    • Fetch resource IDs.
    • Fetch endpoint properties.
    • List resources.
    • Call the invoker to make GET, PUT, POST, and DELETE requests.

AzureCloudAPIBase utilizes the _invokeRequest method to make REST API calls to Azure using the standard REST API calls.

Image omitted: capi-cloudapibase.png
CloudAPIBase

Invoker classes

Invoker classes perform the actual REST calls to the cloud provider. If you create a custom CAPI interface and API, you should extend CloudRestAPIInvoker to create your REST calls.

  • CloudRestAPIInvoker

    This class is an abstracted class for making REST API calls. If there are headers and/or parameters to send with a request, classes that implement the invoker must extend this object. They also must provide overrides for getEndpointUrl to return the targeted endpoint, and for getHeaders and getParameters. For example, with Azure REST APIs, authentication requires the passing of a token as a header. The extension implementing it should provide a response from getHeaders that performs the token creation or retrieval and sets it. This base object invokes getHeaders and sends whatever it gets back with the request. This class also provides a getResponse method to handle the response from the cloud provider.

    If you create a custom CAPI API, you should extend CloudRestAPIInvoker to make REST calls to the cloud provider.

  • AmazonWebServicesAPIInvoker

    This class is extended from CloudRestAPIInvoker and provides methods for making REST API calls to the cloud provider.

  • AzureAPIInvoker

    This class is extended from CloudRestAPIInvoker and provides functions that make these REST API calls to Azure Resource Manager:

    • Sets the Service Principal, headers, and parameters for REST calls.
    • Gets the endpoint URL, token (client ID, tenant ID, and secret key), and headers/parameters.
    • Retrieves and decodes the JSON response body from the cloud provider.
    • AzureEAAPIInvoker

    This class returns the token for access to the Azure Enterprise Agreement (EA) REST API.

  • AzureStorageAPIInvoker

    This class makes REST calls for Azure storage. The functions in this class can get the token, response, headers, and parameters.

This graphic illustrates how these base classes are used to extend AWS-specific and Azure-specific classes:

Image omitted: capi-cloudrestapiinvoker.png
CloudRestAPIInvoker

Exceptions

  • RESTAPIException

    This base class handles exceptions that might occur during the REST call. It returns the response code from the cloud provider.

  • AWSAPIException

    This class handles exceptions that might occur during the REST call.

  • AzureAPIException

    This class throws a runtime exception when needed during Azure API invocation.

Image omitted: capi-restapiexception.png
RESTAPIException

Classes for credentials

  • CloudRESTRequestSigningUtil

    This class uses overrides that are specified in CAPI API Config Overrides. The AmazonWebServicesRequestSigner class extends this class. For Azure, many signers are built into the MID Server script includes for Method Mappers in Azure CAPI APIs.

  • AmazonWebServicesRequestSigner

    This class sets up a secure session for the REST API call by taking information about a request, and creating a signature v4-signed string for the request. This class is extended from CloudRESTRequestSigningUtil.

Other Azure classes

ClassDescription
AzureAlertRuleClass to create and delete Azure alert rules.
AzureAuthorizationPolicyClass to assign tag policies.
AzureComputeAvailabilitySetClass to fetch Azure availability sets. Refer to: https://docs.microsoft.com/en-us/rest/api/compute/availabilitysets
AzureComputeHardwareClass to fetch Azure sizes. Refer to: https://docs.microsoft.com/en-us/rest/api/compute/virtualmachinesizes
AzureComputeImageClass to handle Azure API calls against image. Refer to: https://docs.microsoft.com/en-us/rest/api/manageddisks/images/images-rest-api
AzureComputeVirtualMachineClass to handle Azure API calls against virtual machines. Refer to: https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines VM Size and Capacities: https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-sizes https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-linux-sizes Cloud-Init supported Versions: https://docs.microsoft.com/en-us/azure/virtual-machines/linux/using-cloud-init
AzureDeploymentClass to handle Azure ARM template deployment.
AzureDeploymentOperationClass to handle Azure ARM template deployment operation.
AzureImagesClass to handle Azure Images.
AzureLoadBalancerClass to handle Azure API calls against load balancers. Refer to: https://msdn.microsoft.com/en-us/library/azure/mt163651.aspx
AzureLocalNetworkGatewaysClass to create and retrieve local network gateways.
AzureNetworkNICClass to handle Azure API calls against network interface cards. Refer to: https://msdn.microsoft.com/en-us/library/azure/mt163579.aspx
AzureNetworkPublicIPClass to handle Azure API calls against public IP addresses. Refer to: https://msdn.microsoft.com/en-us/library/azure/mt163638.aspx
AzureNetworkRouterClass to handle Azure API calls against route table. Refer to: https://docs.microsoft.com/en-us/rest/api/network/route-tables
AzureNetworkSecurityGroupClass to handle Azure API calls against network interface cards. Refer to: https://msdn.microsoft.com/en-us/library/azure/mt163579.aspx
AzureNetworkVirtualNetworkClass to handle Azure API calls against virtual networks.
AzureProviderClass to get Azure provider details, such as the provider URL and version.
AzureRegionClass to fetch Azure regions.
AzureResourceDeals with the object referenced by ObjectID in the parameters. It also fetches the API version. This class is Intended mostly to get unsupported types or delete resources.
AzureResourceGroupManagerClass to handle Azure ARM resource groups.
AzureResponseUtilClass to translate Azure API response to DTO object.
AzureStorageAccountClass to handle Azure API calls against storage account. Refer to: //https://msdn.microsoft.com/en-us/library/azure/mt163638.aspx
AzureStorageBlobClass to create and manipulate storage containers and blobs.
AzureStorageManagedDiskClass to handle Azure API calls against managed disk. Refer to: https://docs.microsoft.com/en-us/rest/api/manageddisks/disks/disks-create-or-update
AzureSubscriptionClass to fetch Azure subscriptions.
AzureVirtualNetworkGatewaysClass to create and manipulate virtual network gateways.
AzureCloudEAAPIBaseBase object for Azure EA API handlers. Azure EA APIs have a base URL of https://consumption.azure.com and require the enrollment number in the path. This class handles marshalling of the EnrollmentNumber and EnrollmentToken parameters.

Other AWS classes

ClassDescription
AmazonImagesClass to handle Amazon machine images. http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html
AmazonResponseProcessorUtilClass to handle AWS REST API response.
AWSAutoScalingGroupsClass to handle AWS API calls to create and manipulate Auto Scaling Groups.
AWSCloudFormationHandler for AWS CloudFormation API calls.
AWSEC2Handler for AWS EC2 API calls.
AWSKeyValuePairClass to import and manipulate key pairs.
AWSLaunchConfigurationsHelper class.
AWSS3Handler for AWS S3 API calls.
AWSTopicsClass with AWS topics.

Parent Topic:Cloud Provisioning and Governance