vania-janet/multiturn-rag-retrieval-data huggingface dataset:
[Create an Event Streams instance](https://cloud.ibm.com/docs/EventStreams?topic=EventStreams-getting_started).



* From the pricing plans, select an Enterprise Plan.
* If necessary, set up an [Authorization in IAM](https://cloud.ibm.com/iam/authorizations) for Event Streams to target a KMS provider such as Key Protect, and refresh the page.
* For the Service Endpoint, select an option with a Private network.



2. Wait a few minutes for your Event Streams instance to provision.
3. In your Event Streams instance, [create a topic](https://cloud.ibm.com/docs/EventStreams?topic=EventStreams-getting_startedgetting_started_steps), such as kafka-java-console-sample-topic.
4. Create a service key for credentials to your Event Streams instance on the private cloud service endpoint.



* <name>: Enter a name for the service key.
* <event_streams_instance>: Replace with the name of your Event Streams instance.



ibmcloud resource service-key-create <name> Writer --instance-name <event_streams_instance> --service-endpoint private
5. In the output of the previous command, get the details that you need to make a REST call.



* api_key
* kafka_http_url



Example output:

api_key: 123465123456123465123465123465123465
kafka_http_url: https://mh-<id>.private.us-south.messagehub.appdomain.cloud
6. From the [Monitoring dashboard](https://cloud.ibm.com/observe/monitoring), click Open dashboard for the Monitoring instance that you want to use.
7. Click Get Started > Configure a notification channel > Configure Notification Channel. The Settings page opens.
8. Click + Add Notification Channel and select the Webhook option.
9.
You can test the web action by using one of the following methods.



* Testing the web action by using a cURL command.

curl https://<apihost>/api/v1/web/<namespace_ID>/demo/hello.json?name=Jane -X GET -H "X-Require-Whisk-Auth: <my-secret>"
* Testing the web action by using a wget command.

wget https://<apihost>/api/v1/web/<namespace_ID>/demo/hello.json?name=Jane -X GET -H "X-Require-Whisk-Auth: <my-secret>"



Example output

{
"body": "<html><body><h3>Hello, Jane!</h3></body></html>"
}





 Testing a secure web action with custom value of X-Require-Whisk-Auth 

To secure your web action with a custom value, update your hello web action with your own require-whisk-auth value. Then, try testing your web action by specifying the X-Require-Whisk-Auth value during invocation.



1. Set a require-whisk-auth value where <my-secret> is your case-sensitive authentication token.

ibmcloud fn action update demo/hello /<filepath>/hello.js --web true --annotation require-whisk-auth <mysecret>
2. Test the web action and include your <my-secret> value. You can test the web action by using one of the following methods.



* Testing the web action by using a cURL command.

curl https://<apihost>/api/v1/web/<namespace_ID>/demo/hello.json?name=Jane -X GET -H "X-Require-Whisk-Auth: <my-secret>"
* Testing the action by using a wget command.
In API Connect, Products provide a way to group APIs that are intended for a particular use. Products are published to a Catalog.
3. In the Assemble tab, click the play icon to test your API proxy's target invocation.
4. In the test panel, select the get /current operation.

a. zipcode is a required parameter for this operation, so enter a valid US zip code (for example, 10504).

![test-invoke-params.png](https://cloud.ibm.com/docs-content/v1/content/78bb71851d95d7580503eb9ba10cf3ae31490ade/apiconnect/tutorials/images/test-invoke-params.png)

b. Click Invoke.

If you run into a CORS error, follow the instructions in the error message. Click the link in the error to add the exception to your browser, and then hit the "invoke" button again.

![test-invoke-new.png](https://cloud.ibm.com/docs-content/v1/content/78bb71851d95d7580503eb9ba10cf3ae31490ade/apiconnect/tutorials/images/test-invoke-new.png)



--------------------





 Conclusion 

In this tutorial, you learned how an existing REST service can be invoked through an API pass-through proxy. You started by checking the availability of the sample service through the web browser. Then, you created a new OpenAPI spec in API Connect, and linked it to the sample service to be invoked. You packaged your API into a product, published the product to catalog, and tested the proxy.

--------------------







 Next step
* [Deploying the Get HTTP Resource template from the CLI](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-templatesget-http-resource-template-cli)
* [Invoking the Get HTTP Resource action](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-templatesget-http-resource-template-invoke)



* [Deploying the Hello World template](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-templateshello-world-template)



* [Deploying the Hello World template from the console](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-templateshello-world-template-ui)
* [Deploying the Hello World template from the CLI](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-templateshello-world-template-cli)
* [Testing the Hello World action](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-templateshello-world-template-test)



* [Deploying the IBM® Event Streams for IBM Cloud® template](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-templatesmessagehub-events-template)



* [Deploying the Event Streams template from the console](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-templatesmessagehub-events-template-ui)
* [Deploying the Event Streams Events template from the CLI](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-templatesmessagehub-events-template-cli)



* [Deploying the Periodic Slack Reminder template](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-templatesslack-reminder-template)
* For the [asynchronous HTTP interface](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-async), use the POST /v1/recognitions method. The specified custom model is used for that request.

IBM Cloud

curl -X POST -u "apikey:{apikey}" --header "Content-Type: audio/flac" --data-binary @audio-file.flac "{url}/v1/recognitions?acoustic_customization_id={customization_id}"

IBM Cloud Pak for Data

curl -X POST --header "Authorization: Bearer {token}" --header "Content-Type: audio/flac" --data-binary @audio-file.flac "{url}/v1/recognitions?acoustic_customization_id={customization_id}"



You can omit the language model from the request if the custom model is based on the default model, en-US_BroadbandModel. Otherwise, you must use the model parameter to specify the base model, as shown for the WebSocket example. A custom model can be used only with the base model for which it is created.





 Troubleshooting the use of custom acoustic models 

If you apply a custom acoustic model to speech recognition but find that the quality of speech recognition does not improve, check for the following possible problems:



* Make sure that you are correctly passing the customization ID to the recognition request as shown in the previous examples.
* Make sure that the status of the custom model is available, meaning that it is fully trained and ready to use. For more information, see [Listing custom acoustic models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageAcousticModelslistModels-acoustic).
Regardless of whether you choose to use the high-Level Fabric contract APIs, or the low-Level Fabric SDK APIs, both require network access to the following components:



* The CA for your organization. (You should never need to access the CA for another organization).
* All organizations peers (where all organizations are the organizations that are required for endorsing transactions).
* All ordering service nodes for all channels that you are transacting on.



You must ensure that the hostnames of these components are resolvable by DNS lookup (or /etc/hosts if you cannot correctly configure DNS). You must also ensure that all of the network ports for these components are accessible to the systems that are running your applications that are using the Hyperledger Fabric SDKs. The hostname and port for each node are visible in the console. Open the CA, peer, or ordering node tile and then click the Info and usage tab. The API URL field contains the hostname and port for the node.





 Application compatibility 

For your planning purposes, the following SDK and smart contract compatibility matrices have been tested and validated.



 SDKs 

Click the Java SDK or Node SDK tab for details.

Java SDK

Node SDK



Table 1. Java SDK

 Version Peer Fabric image Java 

 [Java SDK Version 2.2](https://github.com/hyperledger/fabric-gateway-java/tree/release-2.2) 2.2 Java 8 <br> <br>Java 11 
 [Java SDK Version 1.4](https://github.com/hyperledger/fabric-gateway-java/tree/release-2.2) 1.4 Java 8 <br> <br>Java 11 







 Smart contracts 

Click the Java Smart contract or Node Smart contract tab for details.

Java Smart contract

Node Smart contract



Table 2. Java Smart contract

 Contract API Peer Fabric image Java runtime
![test_api_keys_3.png](https://cloud.ibm.com/docs-content/v1/content/78bb71851d95d7580503eb9ba10cf3ae31490ade/apiconnect/tutorials/images/test_api_keys_3.png)







 Call your API using the Client ID and Client Secret 

The security settings can also be tested using the Explore tool. The Explore tool explicitly calls the proxy endpoint, and passes the Client ID and Client Secret keys as header values.



1. Click Explore. ![explore_1.png](https://cloud.ibm.com/docs-content/v1/content/78bb71851d95d7580503eb9ba10cf3ae31490ade/apiconnect/tutorials/images/explore_1.png)
2. Click the GET /current operation from the list.
3. Click Call operation to run the test.
![4.png](https://cloud.ibm.com/docs-content/v1/content/78bb71851d95d7580503eb9ba10cf3ae31490ade/apiconnect/tutorials/images/4.png)



--------------------



 Conclusion 

In this tutorial, you learned how to set the identification mechanism of your API, test changes made to your API, and call your API using the Client ID and Client secret.

--------------------







 Next step 

Start to socialize your API by [setting up and configuring a developer portal](https://cloud.ibm.com/docs/apiconnect?topic=apiconnect-tut_config_dev_portal).

Create > Manage > Secure > Socialize > Analyze
4. Paste the URL that you copied from the Cloud Functions UI.
5. From the list of HTTP verbs, select POST.
6. Click Add.



After you create your destination, copy your destination ID. You use this value to prepare your Functions code in a later step.





 Create a subscription with webhook signing 

Next, create a new Event Notifications subscription with webhook signing enabled.

With webhook signing, you verify that the notification payload is sent by Event Notifications and not by a third party. For more information, check out the [Event Notifications documentation](https://cloud.ibm.com/docs/event-notifications?topic=event-notifications-en-destinations-webhooken-webhook-sign).



1. [Create a subscription with signing enabled](https://cloud.ibm.com/docs/event-notifications?topic=event-notifications-en-create-en-subscription) between your existing Secrets Manager topic and your new Cloud Functions destination.



1. In the Event Notifications UI, click Subscriptions > Create.
2. Provide a name for your subscription. For example, Slack.
3. Select the Secrets Manager topic that you created in part 1.
4. Select the destination that you created in the previous step.
5. In the Security section, select the Signing enabled option.
6. Click Create.



Now you're all set to securely deliver notifications to your webhook URL. Continue to the next step.









 Step 3: Prepare your sample code 

Now you can prepare the sample code for your Cloud Functions action.



1. Copy the following JavaScript code and update the placeholder values.

const axios = require('axios');
const jwtVerify = require('jsonwebtoken').verify;

// Generate an IAM token
async function getIAMToken() {
const options = {
url: 'https://iam.cloud.ibm.com/identity/token',
[Get credentials using the IBM Cloud CLI](https://cloud.ibm.com/docs/EventStreams?topic=EventStreams-connectingconnect_enterprise_external_cli) and make note of the api key and broker URL values.







 Step 3. Configure the connection in Log Analysis to Event Streams 

Complete the following steps to configure the connection in Log Analysis to Event Streams:



1. [Launch the Log Analysis web UI](https://cloud.ibm.com/docs/services/log-analysis?topic=log-analysis-launch).
2. Click the Settings icon ![Configuration icon](https://cloud.ibm.com/docs-content/v1/content/f61dbc5d84bf0c89e477a05cab04c72f429e1b7a/log-analysis/images/admin.png). Then select Streaming > Configuration.
3. Select kafka as the streaming type. Then, enter the following information:



1. In the Username field, enter the value token.
2. In the Password field, enter the API key that is associated with the service credential that you want to use to authenticate Log Analysis with Event Streams.
3. In the Bootstrap Server URL section, enter the kafka_brokers_sasl values that are listed in the service credential.

You must enter each URL as individual entries. If you need to add additional URLs, click Add another URL to add each additional URL.
4. Enter the name of a topic.
5. Click Save.
6. A message will be displayed indicating that sample lines are sent that can be used to verify your connection.

!
Open Drafts, select APIs, and click Add > OAuth 2.0 Provider API.
![oauth_provider_1.png](https://cloud.ibm.com/docs-content/v1/content/78bb71851d95d7580503eb9ba10cf3ae31490ade/apiconnect/tutorials/images/oauth_provider_1.png) b. Title it "OAuth Endpoint API". The name and base path should be populated automatically.
c. Select Create API.
d. In the newly created OAuth Endpoint API, navigate to the OAuth 2 panel (or scroll down to it), and select "Confidential" as the Client Type.
e. Under Scopes, rename scope1 to view_current. Delete scope2 and scope3.
![oauth_provider_type_scope.png](https://cloud.ibm.com/docs-content/v1/content/78bb71851d95d7580503eb9ba10cf3ae31490ade/apiconnect/tutorials/images/oauth_provider_type_scope.png)

f. Under Grants, deselect Implicit, Password, and Access Code. Leave Application selected.
![oauth_provider_grants.png](https://cloud.ibm.com/docs-content/v1/content/78bb71851d95d7580503eb9ba10cf3ae31490ade/apiconnect/tutorials/images/oauth_provider_grants.png)

g. Save your API.
2. Update the security definition of your Weather Provider API to include OAuth.
a. Switch over to your Weather Provider API. (Go back to APIs and then select Weather Provider API.)
Create the api client
client = SoftLayer.Client()
listener_service = client['Network_LBaaS_Listener']

_mask = "mask[listeners]"

try:
response = listener_service.updateLoadBalancerProtocols(uuid, protocolConfigurations, mask=mask)
pprint(response)
except SoftLayer.SoftLayerAPIError as e:
print("Unable to add protocols: %s, %s" % (e.faultCode, e.faultString))
Show more





 Update a protocol 

import SoftLayer
from pprint import pprint

 Your load balancer UUID
uuid = 'set me'

 New protocols to add
protocolConfigurations = [
{
"listenerUuid": "69fad83a-e850-4b72-a4d3-af94d5bf5437",
"serverTimeout": 60,
"clientTimeout": 60
},
{
"listenerUuid": "e4b8cfd0-1e27-4d3e-a8ed-595b198cd683",
"frontendPort": 1450,
"maxConn": 1002,
"serverTimeout": 80,
"clientTimeout": 80
}
]

 Create the api client
client = SoftLayer.Client()
listener_service = client['Network_LBaaS_Listener']

_mask = "mask[listeners]"

try:
response = listener_service.updateLoadBalancerProtocols(uuid, protocolConfigurations, mask=mask)
pprint(response)
except SoftLayer.SoftLayerAPIError as e:
print("Unable to add protocols: %s, %s" % (e.faultCode, e.faultString))
Show more







 Canceling a load balancer 

import SoftLayer

 Your load balancer UUID
uuid = 'set me'
2. Use your private key to sign a JSON Web Token (JWT). You will pass the token with the messages that are sent from your website as proof of their origin.

The JWT payload must specify values for the following claims:



* iss: Represents the issuer of the JWT. This value is a case-sensitive string.
* sub: Represents the principal that is the subject of the JWT. This value must either be scoped to be locally unique in the context of the issuer or be globally unique. The value you specify for sub is used as the user_id. The syntax of the value must meet the requirements for header fields as defined in [RFC 7230](https://tools.ietf.org/html/rfc7230section-3.2).
* exp: Represents the expiration time on or after which the JWT cannot be accepted for processing. Many libraries set this value for you automatically. Set a short-lived exp claim with whatever library you use.



For more information about JSON Web Tokens, see the [RFC7519](https://tools.ietf.org/html/rfc7519) and [OpenID Connect 1.0](https://openid.net/specs/openid-connect-core-1_0.html) specifications.

Most programming languages offer JWT libraries that you can use to generate a token. The following NodeJS code sample illustrates how to generate a JWT token.

// Sample NodeJS code on your server.
const jwt = require('jsonwebtoken');

/
* Returns a signed JWT generated by RS256 algorithm.
/
function mockLogin() {
const payload = {
/
* Even if this is an unauthenticated user, add a userID in the sub claim that can be used
* for billing purposes.
* This ID will help us keep track "unique users". For unauthenticated users, drop a
* cookie in the browser so you can make sure the user is counted uniquely across visits.
/
* [Creating a web action](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-actions_webactions_web_example)



* [Web action JSON properties](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-actions_webweb_action_properties)
* [Performing an HTTP redirect by using a web action](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-actions_webhttp_redirect)
* [Setting cookies by using a web action](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-actions_webmultiple_cookie)
* [Returning an image by using a web action](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-actions_webreturn_image)
* [Returning JSON by using a web action](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-actions_webreturn_json)
* [HTTP context](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-actions_webactions_web_context)
* [HTTPS Endpoint support](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-actions_webactions_web_endpoint)
* [Altering the response content of web action](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-actions_webaction_web_alter_response)



* [Securing web actions](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-actions_webactions_web_secure)
2. In the URL field, add the URL for the external application to which you want to send HTTP POST request callouts.

For example, to call a Cloud Functions web action, specify the URL for the public web action. For example:

https://us-south.functions.cloud.ibm.com/api/v1/web/my_org_dev/default/Hello%20World.json

If the external application that you call returns a response, it must be able to send back a response in JSON format.

Notice the request URL in this example ends in .json. By specifying this extension, you take advantage of a feature of web actions that lets you specify the desired content type of the response. Specifying this extension type ensures that, if the web actions can return responses in more than one format, a JSON response will be returned. See [Extra features](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-actions_webactions_web_extra) for more details.
3. You do not need to add any headers.

Cloud Functions web actions do not need to be authenticated, so you do not need to define an Authorization header.

Your webhook details are saved automatically.
4. From the skill menu, click Dialog.
5. Click to open the dialog node from which you want to call the web action, and then click Customize.
6. Scroll down to the Webhooks section, and switch the toggle to On, and then click Apply.
7. Add any data that you want to pass to the external application as key and value pairs in the Parameters section.

For example, if you call the Hello World Cloud Functions web action, you might want to add the following information to pass in the message parameter that is accepted by that application:



Parameter example

 Key Value 

 message hello 



When calling a Cloud Functions web action, you cannot pass parameters with the same key as parameters that are defined as part of the web action.
The [SwaggerHub](https://swagger.io/tools/swaggerhub/) website offers an [OpenAPI 3.0 Tutorial](https://support.smartbear.com/swaggerhub/docs/tutorials/openapi-3-tutorial.html), and [tools](https://swagger.io/tools/) to help you develop and validate your OpenAPI document. You can use the online [Swagger editor](https://editor.swagger.io/) to convert your OpenAPI document to the correct format and OpenAPI version.

The OpenAPI document must satisfy the following requirements and restrictions:



* The document must conform to the OpenAPI 3.0 specification. If you have an OpenAPI (or Swagger) document that uses an earlier version of the specification, you can use the online [Swagger editor](https://editor.swagger.io/) to convert it to OpenAPI 3.0.
* The document must be in JSON format (YAML is not supported). If you have a YAML document, you can use the online [Swagger editor](https://editor.swagger.io/) to convert it to JSON.
* Each operation must have a clear and concise summary. The summary text is used in the UI to describe the operations that are available from an action, so it should be short and meaningful to someone who is building an assistant.
* [Relative URLs](https://swagger.io/docs/specification/api-host-and-base-path/relative-urls) are currently not supported.
* Only Basic, Bearer, OAuth 2.0, and API key authentication are supported.
* For OAuth 2.0 authentication, only the Password, Client Credentials, and Authorization Code grant types are supported.
* Schemas that are defined by using anyOf, oneOf, and allOf are currently not supported.



In addition, any call to the external API must complete within 30 seconds.





 Building the custom extension 

To build a custom extension based on the API definition, follow these steps:



1.
Add a new API spec and invoke an existing REST service using the Developer Toolkit 

Duration: 15 mins
Skill level: Beginner



 Objective 

This tutorial helps you get started quickly with IBM® API Connect for IBM Cloud® V5 by illustrating how you can bring your existing API under management control. You'll start by creating a new OpenAPI spec, and then create a pass-through API proxy for an existing REST service.





 Prerequisite 

Before you begin, you need to [set up your API Connect Instance](https://cloud.ibm.com/docs/apiconnect/tutorials?topic=apiconnect-tut_prereq_set_up_apic_instance) and [install the API Connect toolkit](https://cloud.ibm.com/docs/apiconnect/tutorials?topic=apiconnect-tut_prereq_install_toolkit).

--------------------





 Explore the sample app and test the target endpoints 

A sample weather provider app was created for this tutorial.



1. To explore the app, go to [http://gettingstartedweatherapp.mybluemix.net/](http://gettingstartedweatherapp.mybluemix.net/).
2. Enter a valid 5-digit US zip code to get the current weather and today's forecast.
![explore-weatherapp-1.png](https://cloud.ibm.com/docs-content/v1/content/78bb71851d95d7580503eb9ba10cf3ae31490ade/apiconnect/tutorials/images/explore-weatherapp-1.png)
3. The sample weather app was built with APIs that provide the weather data. The endpoint to get the current weather data is https:// myweatherprovider .mybluemix.net/current?zipcode={zipcode}.