how to view the cf rest api requests submitted from the bluemix web console? - ibm-cloud

Most of my experience with Bluemix so far has been using the web management console. I would now like to start using the cloud foundry rest API.
I've had a look through the cf rest API documentation for creating a service instance and see this:
{
"space_guid": "bbbeed31-f908-477a-aab9-8cdcd19e1348",
"name": "my-service-instance",
"service_plan_guid": "fe173a83-df28-4891-8d91-46334e04600d",
"parameters": {
"the_service_broker": "wants this object"
},
"tags": [
"accounting",
"mongodb"
]
}
I have no idea what I need to set for the tags or parameters for a Bluemix service. How can I find this out on for each bluemix service?
When I instantiate a service using the Bluemix web console, is it possible to view the rest API requests that are submitted in the background so that I can reverse engineer the API calls??

You won't be able to see the commands sent by the BlueMix console directly, but you could replicate the commands with the Cloud Foundry CLI and set an environment variable of CF_TRACE=true to output all requests to STDOUT. You can also set it as CF_TRACE=/path/to/file.
The UUIDs could be changed. If you're going to use the API, you'll need to look things up by name, find their UUIDs, and then use them in subsequent requests. I've been working on something similar, that really should have been implemented as a Terraform provider: https://github.com/EngineerBetter/cf-converger

Related

Call an API residing in Kubernetes from ADF

I have deployed an API with certain business logic in AKS. The load balancer type is internal. I am able to access this within AKS cluster. on the below address
http:servicename/myapi/
But I want to call this API from an ADF pipeline. How can I do that? What are the configurations I should do to be able to call this API from ADF?
You have to use Web Activity to make Rest API call from Azure DataFactory Pipeline.
An Azure Data Factory may be used to call a custom REST endpoint
through Web Activity. You can send datasets and connected services to
the activity to be consumed and accessed.
Note : By utilizing self-hosted integration runtime, Web Activity may also invoke URLs that are hosted on a private virtual network. The URL endpoint should be visible to the integration runtime.
Please check below documentation to know more about web activity : Web Activity in Azure Datafactory.

Where to find IBM Cloud Function credentials to access it for Watson Assistant

I am searching for the credentials to access my cloud function from Watson assistant. Both are in Dallas region.
I have looked at various docs and blogs, all looks obsolete. I could not find the credentials that could work in Watson Assistant.
Below is one example location where i could not find credentials:
https://developer.ibm.com/recipes/tutorials/connect-watson-assistant-with-wikipedia-api-via-cloud-functions/
Could someone provide me steps or link to find or generate credentials?
More trials added
https://cloud.ibm.com/docs/services/assistant?topic=assistant-dialog-actions
above link provide another link that is supposed to show me credentials but no success
Note: I can see CF-based API key for the namespace in London but not in Dallas on link -- https://cloud.ibm.com/functions/namespace-settings
Namespace
Below is a part of Watson json.
"actions": [
{
"name": "Namespace-Y1N/irs/helloworld",
"type": "cloud_function",
"parameters": {
},
"credentials": "$private.my_creds",
"result_variable": "$my_result"
}
]
Below is the cloud function
Well, the official IBM Watson Assistant docs on creating programmatic calls have that information. Look for <reference_to_credentials>. There are instructions on how to access Cloud Functions and extract the API key. Some of that is not needed if working with web actions.
The official tutorial on how to build a database-driven Slackbot with Watson Assistant also offers a way on integrating those credentials once for multiple dialog nodes. It uses a "credential node" to manage the info on how to access Cloud Function actions.
Note that Cloud Functions have the old Cloud Foundry-based namespaces and the new IAM-based namespaces. You can only see the authentication key for the Cloud Foundry namespaces. It seems that your Dallas namespace is new and IAM-enabled.
As an alternative, use the IBM Cloud CLI, log in to your org / space or namespace and then use this command to obtain the Cloud Function properties including the authentication key:
ibmcloud fn property get --auth
Create a new API key. Select Menu(Top-left), Manage, Access (AIM), IBM Cloud API Keys. Create an IBM Cloud API Key, then make sure that you save it somewhere because you will never see the key again. I hope that will help.
Your namespace "Namespade-Y1N" in Dallas is a IAM-enabled namespace. Server-based actions in dialog node of Watson Assistant does not support IAM based authentication. It can only work with CF based namespaces and CF based Cloud foundry functions. This is restriction of Watson Assistant.

Retrieve logged user information from cloud foundry web application

We developed a web application using SAP Web-IDE Full Stack; we need to retrieve the details of the user logged into application (as defined in SAP Cloud Platform Identity Authentication Administration), for example display name and assigned groups.
We tried the userapi/currentUser API, but it seems to work only on NEO environment, for this reason is working fine while debugging in Web-IDE, but we get a 404 error when deploying the app on Cloud Foundry.
Do we need to add a new destination to make userapi work also on CF? Or is there some kind of similar solution available on Cloud Foundry?
I highly suggest using the SAP S/4HANA Cloud SDK for such tasks. It is an SDK developed to make building applications for SAP Cloud Platform easy, by providing easy to use mechanisms for all the Cloud Platform mechanisms.
Regarding your task at hand, there is a UserAccessor class that you can use like this:
final Optional<User> user = UserAccessor.getCurrentUser();
This works on Neo as well as on Cloud Foundry, i.e. there is a single interface for both platforms, which allows you to develop your app in a platform agnostic way.
If this sounds like it could solve your problem, I recommend checking out this blog post series to get started.
Alternatively, you can also simply add the following dependency to your project to start testing the SDK:
<dependency>
<groupId>com.sap.cloud.s4hana.cloudplatform</groupId>
<artifactId>scp-neo</artifactId>
<version>2.7.0</version>
</dependency>
For Cloud Foundry use scp-cf instead of scp-neo.
Hope this helps!
P.S.: To answer your question also on a technical level, Cloud Foundry uses so-called JWTs for authentication and authorization. You can check whether a JWT is present by looking at the Authorization header of the request. The JWT should hold the information you're looking for.
In SAP Cloud Foundry if you develop a MTA using XSUAA service to manage User Authentication and Admistration, defined for example in the mta.yaml,
...
resources:
- name: uaa_myapp
parameters:
path: ./xs-security.json
service-plan: application
service: xsuaa
type: org.cloudfoundry.managed-service
...
you can use the UAA API published from XSUAA service self to manage user authentication and authorization (e.g.: retrieve user info, groups assigned, password management etc..). also in the case the application is federated with another IDP.
To consume this API for example to retrieve user info you need to:
Determine the XSUAA endpoint bound to your app (SCP Cockpit > XSUAA service detail > take the value url)
Create a destination (xsuaa_api_destination) of type OAuth2TokenExchange bound to your app with url url took before, and fill OAuth2 authentication parameters with the data contained in XSUAA service detail (step 1).
From your app execute the call xsuaa_api_destination/userinfo, for example using an ajax if you are using JS.
You can find other info in Account and Authentication Service of the Cloud Foundry Environment SAP doc.

How to use Swift REST API with Bluemix Object Store?

I want to write a Java program running externally to Bluemix that interacts with the instance of the Bluemix Object Store I have provisioned.
The program will use the Swift REST APIs to interact with the service.
The documentation for how to use the REST API is mainly missing in the service documentation and the OpenStack documentation is not helpful with specifics on how to reach the Bluemix service.
Can someone tell me what headers to set and what URL to use to authenticate with the service, and then what headers to set and what URL to use to further interact with the service ? Where do I find this information for my instance of the service ? It doesn't seem to all be available in the service credentials that are displayed.
Also, do I need to do basic authentication every time a REST call is made, or is there a way to get a token ? Where is that explained ?
The Bluemix Object Storage uses the OpenStack Identity (Keystone) v3 API for authentication. For complete documentation on the REST API, see: http://developer.openstack.org/api-ref-identity-v3.html
Since your application will be developed in Java, I'd suggest you use the openstack4j SDK. For example of using openstack4j with Bluemix object storage service, see: https://developer.ibm.com/recipes/tutorials/connecting-to-ibm-object-storage-for-bluemix-with-java/

Azure REST API - getting identity data

In Amazon cloud API there is the possibility to get identity data, meaning data from the running instance - on which region it is, dns ....
is there the same option in Azure? as I am creating management system in which the server is installed on a virtual machine and I need to know to which region it is related, all this using REST API
In Azure you can use Azure API Management REST API to get all sort of information for Azure:
ex:
Lists all of the resources in a subscription:
https://management.azure.com/subscriptions/{subscription-id}/resources?$top={top}$skiptoken={skiptoken}&$filter={filter}&api-version={api-version}
For the complete documentation look at this page here:
https://msdn.microsoft.com/en-us/library/azure/dn776326.aspx
You can do similar things using Powershell scripts as well.