REST API Tutorial

Pivotal Cloud Foundry Api Example and Uses

Summary of learning

Pivotal provides a multi-cloud application platform as a service (PaaS). This tutorial help to manage Cloud Application using rest api. Pivotal Cloud Foundry provides rest API to access many resources like organization, space, app status, start app etc.

Pivotal provides a multi-cloud application platform as a service (PaaS). This tutorial help to manage Cloud Application using rest api.

Pivotal Cloud Foundry provides rest API to access many resources like organization, space, app status, start app etc.

You can manage Pivotal cloud foundry resources using the Rest service very easily. You can get more information from official pivotal rest service docs.

What is Cloud Foundry

Cloud Foundry is an open-source cloud computing platform originally developed by VMware. It is now owned by Pivotal Software, which is a joint venture by VMware, EMC, and General Electric. You can get structural information from here.

This rest api example tutorial helps to get Organization list using Pivotal Cloud Foundry API. I am using PHP programming language to access Pivotal Cloud Foundry API. You can use other programming languages as well, as per your need.

Get Organization List Using Cloud Foundry Api

I am using the guzzle rest client to access the organization’s list from cf using rest API. We need the rest API endpoints and cf authentication token to access Pivotal Cloud Foundry API.

How To Create HTTP Client using Guzzle

We will create a client object using like below –

'restapi url', //https://api.domain.com/
    // You can set any number of default request options.
    'timeout'  => 2.0,
	'headers' => ['Authorization' => "Bearer " . $token,'Content-Type' => 'application/json', "Accept" => "application/json"],
    //ssl false
    'verify' => false
]); 

Please change the token string as per your REST API credentials. The parameters are:

  • $token: This variable will contains token string of cf rest api
  • base_uri : The Pivotal Cloud Foundry host api url path
  • headers : This will contains request header parameters
  • timeout : Request timeout in sec.
  • verify : SSL verification false

How to Fetch Organization list using Cloud Foundry API

We have created CF rest client using token and rest API URL. We will use rest client and pass /organizations the endpoint with GET HTTP request. This rest call return organizations list as JSON objects.

<?php
require_once 'vendor/autoload.php';
use GuzzleHttp\Client;
$token = 'cf auth token';

$response = $client--->get('v2/organizations/');
echo $response->getBody()->getContents();
?>

I hope its help you access Cloud Foundry API using Guzzle rest client.

If you have requirements that needs our attentioN

Please feel free to contact us

We would love to hear from you

Share with your network

Facebook
Twitter
LinkedIn
WhatsApp
Email

This tutorial is intended to cover all the essentials steps and insights to understand Pivotal Cloud Foundry Api Example and Uses

Genislab Technologies

Learn further