vania-janet/multiturn-rag-retrieval-data huggingface dataset:
Querying firewall events with GraphQL 

This example uses the GraphQL Analytics API to query for firewall events over a specified time period.

The following API call requests Firewall Events over a one-hour period, and outputs the requested fields. Be sure to replace CIS_DOMAIN_ID with your domain ID and API token, and adjust the datetime_geg and datetime_leq values to meet your needs.



 The API call 

PAYLOAD='{ "query":
"query ListFirewallEvents($zoneTag: string, $filter: FirewallEventsAdaptiveFilter_InputObject) {
viewer {
zones(filter: { zoneTag: $zoneTag }) {
firewallEventsAdaptive(
filter: $filter
limit: 10
orderBy: [datetime_DESC]
) {
action
clientAsn
clientCountryName
clientIP
clientRequestPath
clientRequestQuery
datetime
source
userAgent
}
}
}
}",
"variables": {
"zoneTag": "CIS_DOMAIN_ID",
"filter": {
"datetime_geq": "2020-04-24T11:00:00Z",
"datetime_leq": "2020-04-24T12:00:00Z"
}
}
}'

curl -X POST -H "Content-Type: application/json" -H "Authorization: IBM IAM TOKEN" --data "$(echo $PAYLOAD)" https://api.cis.cloud.ibm.com/v1/<crn>/zones/<zoneid>/graphql
Show more

The results are returned in JSON, so piping the output to jq makes them easier to read. For example:
[Review operations table](https://cloud.ibm.com/docs-content/v1/content/ca9232b3702768f24bb897f48f10778fcda28718/watson-assistant/images/extension-review-operations.png)

For each operation, a row in the table shows the following information:



* Operation: A description of the operation, which is derived from either the summary (if present) or description in the OpenAPI file.
* Method: The HTTP method used to send the API request for the operation.
* Resource: The path to the resource the operation acts upon.



To see more information about an operation, click the ![label](https://cloud.ibm.com/docs-content/v1/content/ca9232b3702768f24bb897f48f10778fcda28718/watson-assistant/images/twistie.png) icon next to its row in the table. The following details are shown:



* Request parameters: The list of input parameters defined for the operation, along with the type of each parameter and whether the parameter is required or optional.
* Response properties: The properties of the response body that are mapped to variables the assistant can access.



6. Click Finish.
7. Click Close to return to the Integrations page.



The extension is now connected to your assistant and available for use by actions in the draft environment.



 OAuth 2.0 authentication 

If you are configuring OAuth 2.0 authentication, the information you must provide depends upon the grant type.

For more information about OAuth 2.0, see [OAuth 2.0](https://oauth.net/2/).

To complete the OAuth authentication setup, follow these steps:



1. If you haven't already, register your application with the external API you want to access. Copy the client ID and client secret that is provided by the external API.
2. In the Grant type field, select the grant type that you want to use.
[federated-query-notices](https://cloud.ibm.com/apidocs/discoveryfederated-query-notices) Action username, password, iam_access_token, iam_apikey, iam_url, headers, headers[X-Watson-Learning-Opt-Out], url, environment_id, collection_ids, filter, query, natural_language_query, aggregation, count, return_fields, offset, sort, highlight, deduplicate_field, similar, similar_document_ids, similar_fields Query multiple collection system notices. 
 [query](https://cloud.ibm.com/apidocs/discoveryquery) Action username, password, iam_access_token, iam_apikey, iam_url, headers, headers[X-Watson-Learning-Opt-Out], url, environment_id, collection_id, filter, query, natural_language_query, passages, aggregation, count, return_fields, offset, sort, highlight, passages_fields, passages_count, passages_characters, deduplicate, deduplicate_field, similar, similar_document_ids, similar_fields Query your collection. 
 [query-entities](https://cloud.ibm.com/apidocs/discoveryquery-entities) Action username, password, iam_access_token, iam_apikey, iam_url, headers, headers[X-Watson-Learning-Opt-Out], url, environment_id, collection_id, feature, entity, context, count, evidence_count Query a Knowledge Graph entity.
OpenAPI does not itself specify valid encoding for query parameters with boolean schemas, which makes the preceding guidance crucial.



Schema guidance for booleans in requests

 Constraint Recommended value Description 

 type boolean type MUST be boolean. 











 Integer 

The integer type provides for whole number values between -2^53 + 1 (-9,007,199,254,740,991) and 2^53 - 1 (9,007,199,254,740,991)

[5].



 Response format 

In a response body, an integer field SHOULD have documented minimum and maximum values. For the sake of backward-compatible future expansions, documented constraints MAY be more permissive (allowing for a greater range of values) for responses than for requests.

An integer value MUST be returned as a JSON number and MUST NOT have a decimal point or use scientific notation.



Schema guidance for integers in responses

 Constraint Recommended value Description 

 type integer type MUST be string. 
 format int32 or int64 format MUST be int32 or int64. 
 minimum ≥-2147483648 for int32 or ≥-9007199254740991 for int64 minimum value SHOULD be present. 
 maximum ≤2147483647 for int32 or ≤9007199254740991 for int64 maximum value SHOULD be present. 







 Request formats 

In a request body, an integer field MUST have documented minimum and maximum values.

Minimum and maximum constraints MUST be checked prior to any other processing of an integer included in a request. Failure to match constraints MUST cause the entire request to fail with a 400 status code and appropriate error response model.



 Request bodies 



* Any JSON number value which evaluates to an integer within the service providing an API MUST be considered a valid integer, but MAY be rejected by other validation rules.
* The null JSON keyword MAY be accepted in a JSON merge patch request body if the field is optional in the resource state and MUST NOT be accepted otherwise.
* Any other value MUST be rejected with a 400 status code and appropriate error response model.







 Query parameters
For example, to read a version of an object foo with a version ID of L4kqtJlcpXroDVBH40Nr8X8gdRQBpUMLUo, the request might look like the following:

=======

curl -X "GET" "https://$BUCKET.s3.$REGION.cloud-object-storage.appdomain.cloud/foo?versionId=L4kqtJlcpXroDVBH40Nr8X8gdRQBpUMLUo" -H 'Authorization: bearer $TOKEN'

Deleting that object is done in the same manner.

=======

curl -X "DELETE" "https://$BUCKET.s3.$REGION.cloud-object-storage.appdomain.cloud/foo?versionId=L4kqtJlcpXroDVBH40Nr8X8gdRQBpUMLUo" -H 'Authorization: bearer $TOKEN'

For requests that already make use of a query parameter, the versionId parameter can be added to the end.

=======

curl -X "GET" "https://$BUCKET.s3.$REGION.cloud-object-storage.appdomain.cloud/foo?tagging&versionId=L4kqtJlcpXroDVBH40Nr8X8gdRQBpUMLUo" -H 'Authorization: bearer $TOKEN'

Server-side copying of object versions is supported, but uses a slightly different syntax. The query parameter is not added to the URL itself, but instead is appended to the x-amz-copy-source header. This is the same syntax as creating a part for a multipart part from a source object.

=======

curl -X "PUT" "https://$BUCKET.s3.$REGION.cloud-object-storage.appdomain.cloud/<new-object-key>"
-H "Authorization: bearer $TOKEN"
New completion notification : A message was added that displays an alert when documents are finished processing.





 9 October 2017 

New unique count metric in the API : A new aggregation metric unique_count is available in the API. It returns a count of the unique instances of the specified field in a collection. See [unique_count](https://cloud.ibm.com/docs/discovery?topic=discovery-query-aggregationsunique_count) for more information.

New support for Histogram and Timeslice in Visual Query Builder : Histogram and Timeslice aggregations are now supported in the Visual Query Builder. You also have the option to turn on anomaly detection for Timeslice queries.

New enrichment options in Data schema explorer : The Data schema explorer displays sample queries for the enrichment chosen. It also now has a Show more values link that displays additional example values for that enrichment.

New navigation menu in data and query screens : A hamburger menu is added to make it faster to navigate the Manage data, View data schema, and Build queries screens.



 3 October 2017 

New document segmentation : Document segmentation is now available. See [Splitting documents with document segmentation](https://cloud.ibm.com/docs/discovery?topic=discovery-configservicedoc-segmentation).





 29 September 2017 

New Germany location now available : Discovery launched in the Germany location 29 September 2017. To comply with EU data regulations, AlchemyLanguage enrichments are not supported in this location.

Known issue in query fields : Known issue: Query fields cannot contain whitespaces. When writing a query in Discovery, if any query field contains whitespace (for example, body.additional reading), you receive a 400: Invalid query syntax error. [Resolved](https://cloud.ibm.com/docs/discovery?topic=discovery-release-notes8nov17)





 25 September 2017 

New Premium pricing plan : A Premium pricing plan is now available. For more information, see [Discovery pricing plans](https://cloud.ibm.com/docs/discovery?topic=discovery-discovery-pricing-plans).
For example, GET {url}/v1/environments/{environment_id}/collections/{collection_id}/query?q=.

The API returns the results. The matching_results field specifies the total number of results. The results object returns the matching documents. Each document is returned as a separate JSON object. It returns a maximum of 10 documents by default.

{
"matching_results": 34,
"session_token": "nnn",
"results": [
{"{result objects}":"{maximum of 10 by default}"}
]
}
2. You can use the count and offset parameters to page through the query results and save all of the documents.

For example, to get 100 documents at a time, you can set the count to 100 and offset to 0 and submit the query.

GET {url}/v1/environments/{environment_id}/collections/{collection_id}/query?q=&count=100&offset=0

Next, you can again set the count to 100, but this time set the offset to 100 to get the next 100 documents.

GET {url}/v1/environments/{environment_id}/collections/{collection_id}/query?q=&count=100&offset=100

Repeat this process, incrementing the offset by 100 until you retrieve all of the documents.
3. Prepare the exported documents to be ingested into v2.

Each resulting JSON file that you get from Discovery v1 contains data that is extracted from the original document, such as text, html, and other fields. If custom metadata was associated with the document when it was uploaded to v1, it is also present in the JSON file. In addition, the file contains several fields that were generated by the v1 analysis. Retain only a subset of this data as part of the document that you add to Discovery v2.

The following tips can help you decide which fields to keep:



* Include the text field or any other field with textual content that you want to be able to enrich or search in Discovery v2.
where {api_key} is the value of your API key. The response looks like the following example:

{"access_token":"[_access-token-value_]","refresh_token":"not_supported","token_type":"Bearer","expires_in":3600,"expiration":1615370557,"scope":"ibm openid"}

Now you can use the IAM access token in your API calls; for example:

curl https://{api_host}/api/orgs 
-H "Accept: application/json" 
-H "Content-Type: application/json" 
-H "Authorization: Bearer _access-token-value_"

{
"total_results": 2,
"results": [
{
"type": "org",
"org_type": "provider",
...
}
]
}
See [Supported languages](https://cloud.ibm.com/docs/assistant?topic=assistant-language-support) for details.





 29 January 2018 

Watson Assistant REST API now supports new request parameters
: 

* Use the append parameter when updating a workspace to indicate whether the new workspace data should be added to the existing data, rather than replacing it. For more information, see [Update workspace](https://cloud.ibm.com/apidocs/assistant/assistant-v1?curl=update-workspace).
* Use the nodes_visited_details parameter when sending a message to indicate whether the response should include additional diagnostic information about the nodes that were visited during processing of the message. For more information, see [Send message](https://cloud.ibm.com/apidocs/assistant/assistant-v1?curl=message).







 23 January 2018 

Unable to retrieve list of workspaces
: If you see this or similar error messages when working in the tooling, it might mean that your session has expired. Log out by choosing Log out from the User information icon, and then log back in.





 8 December 2017 

Log data access across instances (Premium users only)
: If you are a Watson Assistant Premium user, your premium instances can optionally be configured to allow access to log data from workspaces across your different premium instances.

Copy nodes
: You can now duplicate a node to make a copy of it and its children. This feature is helpful if you build a node with useful logic that you want to reuse elsewhere in your dialog. See [Copying a dialog node](https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-tasksdialog-tasks-copy-node) for more information.

Capture groups in pattern entities
: You can identify groups in the regular expression pattern that you define for an entity. Identifying groups is useful if you want to be able to refer to a subsection of the pattern later. For example, your entity might have a regex pattern that captures US phone numbers.
[Get a service key](https://cloud.ibm.com/docs/log-analysis?topic=log-analysis-service_keys).





 Step 2. Identify the data to pass through the export parameters 

To verify that the query that you use in the export returns the set of logs that you are looking for, define the search query through the logging web UI. Refine the query until you can only see the logs that you want to export. Then, map the data to the query parameters.

Notice that when you copy the query from the logging web UI, you must replace every space with %20.





 Step 3. Export the logs 

Run the following cURL command to export logs:

curl "ENDPOINT/v1/export?QUERY_PARAMETERS" -u SERVICE_KEY:

Where



* ENDPOINT represents the entry point to the service. Each region has a different URL. [Learn more](https://cloud.ibm.com/docs/log-analysis?topic=log-analysis-endpoints).
* QUERY_PARAMETERS are parameters that define the filtering criteria that is applied to the export request.
* SERVICE_KEY is the service key that you created in the previous step.









 Samples 

For example, to write log lines into the terminal, you can run the following command:

curl "https://api.us-south.logging.cloud.ibm.com/v1/export?to=$(date +%s)000&from=$(($(date +%s)-86400))000<=vels=info" -u e08c0c759663491880b0d61712346789:

To send an email with the link to download the log lines specified on the export, you can run the following command:
GET /apiary?list-type=2&max-keys=1&continuation-token=1dPe45g5uuxjyASPegLq80sQsZKL5OB2by4Iz_7YGR5NjiOENBPZXqvKJN6_PgKGVzZYTlws7qqdWaMklzb8HX2iDxxl72ane3rUFQrvNMeIih49MZ4APUjrAuYI83KxSMmfKHGZyKallFkD5N6PwKg HTTP/1.1
Authorization: 'AWS4-HMAC-SHA256 Credential={access-key}/{date}/{region}/s3/aws4_request,SignedHeaders=host;x-amz-date;,Signature={signature}'
x-amz-date: {timestamp}
Content-Type: text/plain
Host: s3.us.cloud-object-storage.appdomain.cloud

Example response (Truncated Response, continuation-token parameter)

HTTP/1.1 200 OK
Date: Wed, 24 Aug 2016 17:36:24 GMT
X-Clv-Request-Id: 9f39ff2e-55d1-461b-a6f1-2d0b75138861
Accept-Ranges: bytes
Server: Cleversafe/3.13.3.57
X-Clv-S3-Version: 2.5
x-amz-request-id: 9f39ff2e-55d1-461b-a6f1-2d0b75138861
Content-Type: application/xml
Content-Length: 604

<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Name>apiary</Name>
<Prefix/>
For example, when your webpage is first loaded, it calls the GET /todolist endpoint. The GET /todolist endpoint uses the postFind method to query the database for all documents (by using the index created after the todo database), and then orders the notes by timestamp, and returns them to the front end for display.

Filtering by tag uses the same postFind method, but by using the second index, you create and delete notes by using the postDocument and deleteDocument methods.







 Summary 

IBM Cloudant allows rapid development of web applications, as its HTTP API is modeled by the [Node.js SDK](https://www.npmjs.com/package/@ibm-cloud/cloudant) and is easy to integrate with your own code. You create an IBM Cloudant database and add JSON documents that model your own data. Remember to create secondary indexes to help service your query access patterns so that query performance remains quick as your data volume grows.

If you don't fancy writing JavaScript, we have SDKs for [Java™, Python, and Go](https://cloud.ibm.com/apidocs/cloudant), plus our [HTTP API](https://cloud.ibm.com/apidocs/cloudant). Don't forget. The [IBM Cloudant Dashboard](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-connectingibm-cloudant-dashboard) is a great way to explore your databases, create and modify documents, and refine your index and querying skills.

You can find more best practice guidance in our [blog](https://blog.cloudant.com/2019/11/21/Best-and-Worst-Practices.html) and [documentation](https://cloud.ibm.com/docs/services/Cloudant/getting-started.html). For a video guide to IBM Cloudant and its capabilities, see the course in our [learning center](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-learning-center).
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 

[Secure your API using OAuth 2.0](https://cloud.ibm.com/docs/apiconnect/tutorials?topic=apiconnect-tut_secure_oauth_2).

Create > Manage > Secure > Socialize > Analyze
* [Forming your API request](https://cloud.ibm.com/docs/blockchain?topic=blockchain-ibp-v2-apisibp-v2-apis-form-api-request)
* [Limitations](https://cloud.ibm.com/docs/blockchain?topic=blockchain-ibp-v2-apisibp-v2-apis-limitations)
* [Building a network by using APIs](https://cloud.ibm.com/docs/blockchain?topic=blockchain-ibp-v2-apisibp-v2-apis-build-with-apis)



* [Creating a node within a specific zone](https://cloud.ibm.com/docs/blockchain?topic=blockchain-ibp-v2-apisibp-v2-apis-zone)



* [Creating a node with a custom configuration](https://cloud.ibm.com/docs/blockchain?topic=blockchain-ibp-v2-apisibp-v2-apis-custom)



* [Example: Creating a custom Certificate Authority](https://cloud.ibm.com/docs/blockchain?topic=blockchain-ibp-v2-apisexample-creating-a-custom-certificate-authority)
* [Create a high availability CA](https://cloud.ibm.com/docs/blockchain?topic=blockchain-ibp-v2-apiscreate-a-high-availability-ca)
* [Deploy a node that uses an HSM](https://cloud.ibm.com/docs/blockchain?topic=blockchain-ibp-v2-apisdeploy-a-node-that-uses-an-hsm)



* [Import a network by using APIs](https://cloud.ibm.com/docs/blockchain?topic=blockchain-ibp-v2-apisibp-v2-apis-import-with-apis)
'Content-Type: application/json'
'X-Watson-Metadata: customer_id=abc'
--data
'{"input":{"text":"hello"}}'
'{url}/v2/assistants/{assistant_id}/sessions/{session_id}/message?version=2019-02-28'

where {url} is the appropriate URL for your instance. For more details, see [Service endpoint](https://cloud.ibm.com/apidocs/assistant-data-v2service-endpoint).

The customer_id string cannot include the semicolon (;) or equal sign (=) characters. You are responsible for ensuring that each customer ID property is unique across your customers.

You can pass multiple customer ID values with semicolon-separated customer_id={value} pairs. For example: 'X-Watson-Metadata: customer_id=abc;customer_id=xyz'

If you add a search skill to an assistant, user input that is submitted to the assistant is passed to the Discovery service as a search query. If the Watson Assistant integration provides a customer ID, then the resulting /message API request includes the customer ID in the header, and the ID is passed through to the Discovery /query API request. To delete any query data that is associated with a specific customer, you must send a separate delete request directly to the Discovery service instance that is linked your the assistant. See the appropriate documentation for the version of the API that is used by your Discovery service instance:



* v1: [Information security](https://cloud.ibm.com/docs/discovery?topic=discovery-information-security)
* v2: [Information security](https://cloud.ibm.com/docs/discovery-data?topic=discovery-data-information-security)







 Querying user data 

Use the v1 /logs method filter parameter to search an application log for specific user data. For example, to search for data specific to a customer_id that matches my_best_customer, the query might be:

curl -X GET -u "apikey:3Df...
The query parameter is not added to the URL itself, but instead is appended to the x-amz-copy-source header. This is the same syntax as creating a part for a multipart part from a source object.

=======

curl -X "PUT" "https://$BUCKET.s3.$REGION.cloud-object-storage.appdomain.cloud/<new-object-key>"
-H "Authorization: bearer $TOKEN"
-H "x-amz-copy-source: /<source-bucket>/<object-key>?versionId=L4kqtJlcpXroDVBH40Nr8X8gdRQBpUMLUo"







 CLI examples 

You can use the IBM Cloud CLI with the cos plug-in to enable versioning on a bucket.

cos bucket-versioning-put --bucket $BUCKET --versioning-configuration file://vers.json

In this case, vers.json is a simple document:

{
"Status": "Enabled"
}





 SDK examples 

The following examples make use of the IBM COS SDKs for Python and Node.js, although the implementation of object versioning should be fully compatible with any S3-compatible library or tool that allows for the setting of custom endpoints. Using third-party tools requires HMAC credentials in order to calculate AWS V4 signatures. For more information on HMAC credentials, [see the documentation](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-uhc-hmac-credentials-main).



 Python 

Enabling versioning using the IBM COS SDK for Python can be done using either the [high-level resource](https://ibm.github.io/ibm-cos-sdk-python/reference/services/s3.htmlservice-resource) or [low-level client](https://ibm.github.io/ibm-cos-sdk-python/reference/services/s3.htmlclient) syntax.

Using a resource: