How to set Cloud foundry API endpoint? - ibm-cloud

I am trying to login to bluemix account through cloud foundry cli using command CF login and I am getting output as 'API endpoints > '
I tried CF API then I got message as 'No API endpoint set . Use 'cf api' to set an endpoint .' what is the API endpoint ?

The API endpoint is the server your CLI program talks to to execute the commands and obtain information. For IBM Bluemix the API endpoints are documented here.
You could do cf api api.eu-de.bluemix.net to set the endpoint for Bluemix in Frankfurt, Germany. Or cf api api.ng.bluemix.net to configure Dallas, USA, as endpoint. See the above linked documentation for the full list of Bluemix Public. Bluemix Dedicated and Bluemix Local have other API endpoints.
You can also set the api endpoint and login using just one command using, e.g. for the Dallas, USA, endpoint:
cf login -a https://api.ng.bluemix.net

Alternatively you can use new API endpoints:
https://api.us-south.cf.cloud.ibm.com
https://api.eu-gb.cf.cloud.ibm.com
https://api.eu-de.cf.cloud.ibm.com
https://api.au-syd.cf.cloud.ibm.com
with:
cf login -a <API_ENDPOINT>
or you can use ibmcloud cli:
ibmcloud login -a 'https://cloud.ibm.com' -r 'us-south'
ibmcloud target --cf-api 'https://api.us-south.cf.cloud.ibm.com'

Related

How can I access IBM Cloud Compose RabbitMQ logs?

Is there a way to get IBM Cloud Compose for RabbitMQ logs using web interface or cli?
There is Syslog-NG for RabbitMQ and it has other cloud logging services namely papertrail and Loggly providing the webinterface along with two IBM Cloud Compose API calls for logs
Get list of available logfiles
GET /2016-07/deployments/:id/logfiles
Get details of a logfile including download link
GET /2016-07/deployments/:id/logfiles/:logfile_id
To make use of the API, you will need a handful of digital assets; a token for your account to access the IBM Cloud API and a foundation endpoint for your queries. Check this link for details on how to get the token, endpoint and example cURL calls

How to generate access token for IBM bluemix federated (corporate) user

I have a federated (corporate) id for IBM bluemix. I want non-browser access to a Bluemix client / API. I am trying to use this POST command (using curl) - POST http://iam.ng.bluemix.net/oidc/token ; but I get following error and message:
"errorCode":"BXNIM0608E"
"errorMessage":"You cannot authenticate with username and password, as you are a federated user"
Then I came across this post: https://developer.ibm.com/devops-services/2016/06/23/whats-federated-authentication-and-how-does-it-affect-me/
As mentioned at beginning of it, I need to use "IBM Bluemix Continuous Delivery" website (IBM Bluemix DevOps) to get the access token.
Can you please let me know where exactly on that website I can get the access token?
Regards,
Amit
It seems you need to follow the instructions for IAM at https://console.ng.bluemix.net/docs/iam/apikeys.html#manapikey
That's where you can generate your API keys. I then found instructions to use the key to login as mentioned in https://console.ng.bluemix.net/docs/cli/reference/cfcommands/index.html#cf_login
bash$ cf login -u apikey -p $API_TOKEN

Accessing Bluemix Account Usage via Platform API

Is there a way to programmatically (via REST api) access the usage of service within a public bluemix account?
Does Public Bluemix exposes API to access the usage history of bluemix account
Updated answer:
You can use the following Bluemix CLI command to retrieve the monthly usage and costs of your account:
bluemix bss account-usage [-d YYYY-MM] [--json]
Prerequisites: Endpoint, Login
Command options:
-d MONTH_DATE (optional)
Display data for month and date specifying by using the YYYY-MM format. If not specified, usage of the current month is shown.
--json (optional)
Display the usage result in JSON format.
Here's an example that show an account usage and cost report in 2016-06:
bluemix bss account-usage -d 2016-06
If you run the command with "export BLUEMIX_TRACE=true”, you can see the API endpoints that are being used.
There are other commands and more information available at the following URL:
https://console.ng.bluemix.net/docs/cli/reference/bluemix_cli/index.html#bluemix_bss_account_usage

What is the difference between api.mybluemix vs api.ng.bluemix?

What is the difference between the two?
I am using cf api https://api.ng.bluemix.net.
Another tutorial on the IBM website uses cf api https://api.mybluemix.net.
Which doesn't seem to be working. Is it outdated and not working or am I using it wrong? On the Bluemix website they only show two CF API endpoints.
api.ng.bluemix.net
api.eu-gb.bluemix.net
https://www.ng.bluemix.net/docs/#overview/overview.html
Cheers
You should be using the api.ng.bluemix.net or api.eu-gb.bluemix.net as these are to two addresses for the two regions that are currently available in Bluemix. When new regions are created then you would use the api endpoint for that new region to log into it.
So if you have apps and services in the eu-gb (UK) region then you would log into api.eu-gb.bluemix.net. If you are using us-south region then you would log into api.ng.bluemix.net
The difference between a mybluemix.net address and a bluemix.net address is that the bluemix.net address is reserved for official IBM Bluemix provided applications such as console.ng.bluemix.net, api.ng.bluemix.net or status.ng.bluemix.net. The mybluemix.net addresses are the user applications that are running on Bluemix, these might or might not be developed by IBM.
I am not sure why are you getting the SSL Cert error.
Will you please try and see if cf login works for you by giving it the endpoint directly ? http://docs.cloudfoundry.org/devguide/installcf/whats-new-v6.html
Example =>
>>cf login -a api.ng.bluemix.net -u xxx#yy.zz -o xxx#yy.zz -s dev
API endpoint: api.ng.bluemix.net
Password>
Authenticating...
OK
Targeted org xxx#yy.zz
Targeted space dev
API endpoint: https://api.ng.bluemix.net (API version: 2.14.0)
User: xxx#yy.zz
Org: xxx#yy.zz
Space: dev

Unable to push my app to bluemix

I developed an app using watson and cloudant. Completed the coding part using eclipse.
Build was successful and I got war file.
When I am trying to push this to bluemix, I am facing problem.
on giving the command
cf api https://api.eu-gb.bluemix.net
or
cf api https://api.ng.bluemix.net
I get the following in response
setting api endpoint to https://api.eu-gb.bluemixnet...
FAILED
Invalide SSL Cert for api.eu-gb.bluemix.net
TIP:Use 'CF api --skip--ssl-validation' to continue with an insecure API endpoint
Please help out, or tell some way to push my application.
I am not sure why are you getting the SSL Cert error.
Will you please try and see if cf login works for you by giving it the endpoint directly ?
http://docs.cloudfoundry.org/devguide/installcf/whats-new-v6.html
-u is the Bluemix user-id and this will prompt you for password. Let me know if this resolves for you or you get the same SSL error
Example =>
>>cf login -a api.ng.bluemix.net -u xxx#yy.zz -o xxx#yy.zz -s dev
API endpoint: api.ng.bluemix.net
Password>
Authenticating...
OK
Targeted org xxx#yy.zz
Targeted space dev
API endpoint: https://api.ng.bluemix.net (API version: 2.14.0)
User: xxx#yy.zz
Org: xxx#yy.zz
Space: dev