Reputation: 209
Can I access Cloud Foundry REST API on Bluemix? If yes, how can I access it (cannot find any documentation)?
Upvotes: 1
Views: 1421
Reputation: 11
In order to access CF API you have to get the authentication token. Then add it to each request in the headers.
oauthTokenResponse = requests.post(
f'https://login.ng.bluemix.net/UAALoginServerWAR/oauth/token?grant_type=password&client_id=cf',
data={'username': <your username>, 'password': <your password>, 'client_id': 'cf'},
auth=('cf', '')
)
auth = oauthTokenResponse.json()['token_type'] + ' ' + oauthTokenResponse.json()['access_token']
appsResponse = requests.get(f'{self.api_endpoint}/v2/apps',
headers={'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': auth}
)
apps = json.loads(appsResponse.content)
Upvotes: 0
Reputation: 3233
You can access the Cloud Foundry REST API on Bluemix as you would normally do with CF. In addition to that, if you need it and you are already familiar with cf curl you can take a look at the bluemix curl command. For example if you want to retrieve the information for all organizations of the current account:
bluemix curl /v2/organizations
Please see the Docs for more information.
Upvotes: 3