vania-janet/multiturn-rag-retrieval-data huggingface dataset:
To create a new attachment at the same time as creating a new document, include the attachment as an [inline](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-how-to-use-attachmentsinline) component of the JSON content.

To create a new attachment on an existing document, or to update an attachment on a document, make a PUT request with the document's most recent _rev to https://$ACCOUNT.cloudant.com/$DATABASE/$DOCUMENT_ID/$ATTACHMENT. The attachment's [content type](https://en.wikipedia.org/wiki/Internet_media_typeList_of_common_media_types) must be specified by using the Content-Type header. The $ATTACHMENT value is the name by which the attachment is associated with the document.

You can create more than one attachment for a document by ensuring that the $ATTACHMENT value for each attachment is unique within the document.

See the following example for creating or updating an attachment by using HTTP:

PUT /$DATABASE/$DOCUMENT_ID/$ATTACHMENT?rev=$REV HTTP/1.1
Content-Type: $$ATTACHMENT_MIME_TYPE

See the following example for creating or updating an attachment:



* Curl
* Java
* Python
* Go
* Node



curl -H "Authorization: Bearer $API_BEARER_TOKEN" -X PUT "$SERVICE_URL/products/small-appliances:100001/product_details.txt" -H "Content-Type: text/plain" --data 'This appliance includes...'

import com.ibm.cloud.cloudant.v1.Cloudant;
import com.ibm.cloud.cloudant.v1.model.DocumentResult;
import com.ibm.cloud.cloudant.v1.model.PutAttachmentOptions;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;

Cloudant service = Cloudant.newInstance();

String detailedDescription = "This appliance includes..."
One of: JSON.
* --interactive, -i:
* -q, --quiet: Suppress verbose output.



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







 ibmcloud is instance-create-from-template 

Create a virtual server instance from instance template.

ibmcloud is instance-create-from-template --template TEMPLATE [--name Name] [--profile PROFILE] [--zone ZONE] [--vpc VPC] [--image IMAGE | --catalog-offering CATALOG_OFFERING | --catalog-offering-version CATALOG_OFFERING_VERSION] [--total-volume-bandwidth TOTAL_VOLUME_BANDWIDTH] [--boot-volume BOOT_VOLUME_JSON | @BOOT_VOLUME_JSON_FILE] [--volume-attach VOLUME_ATTACH_JSON | @VOLUME_ATTACH_JSON_FILE] [--keys KEYS] [--dedicated-host DEDICATED_HOST | --dedicated-host-group DEDICATED_HOST_GROUP | --placement-group PLACEMENT_GROUP] [--user-data DATA] [(--subnet SUBNET --rip RIP | (--address ADDRESS --auto-delete true | false --ip-name IP_NAME)] --sgs SGS] --allow-ip-spoofing false | true]) | --primary-network-interface PRIMARY_NETWORK_INTERFACE_JSON | @PRIMARY_NETWORK_INTERFACE_JSON_FILE] [--network-interface NETWORK_INTERFACE_JSON | @NETWORK_INTERFACE_JSON_FILE] [--default-trusted-profile DEFAULT_TRUSTED_PROFILE --default-trusted-profile-auto-link true,false]] [--metadata-service, --ms true | false --metadata-service-protocol, --msp http | https | --metadata-service-response-hop-limit, --msrhl METADATA_SERVICE_RESPONSE_HOP_LIMIT,MSRHL]] [--host-failure-policy restart | stop] [--resource-group-id RESOURCE_GROUP_ID | --resource-group-name RESOURCE_GROUP_NAME] [--output JSON] [-q, --quiet]
In this tutorial, you will create a serverless web application using a bucket in Object Storage and implementing the application backend using IBM Cloud Code Engine and IBM Cloudant as JSON document database.

Code Engine Cloudant

+1

Object Storage



* 1 hour
* 2023-06-16



[Best practices for organizing users, teams, applications](https://cloud.ibm.com/docs/solution-tutorials?topic=solution-tutorials-users-teams-applications)Best practices for organizing users, teams, applications

This tutorial gives an overview of the concepts available in IBM Cloud for identity and access management and how they can be implemented to support the multiple development stages of an application.

Red Hat OpenShift on IBM Cloud Log Analysis

+3

Monitoring,Kubernetes service,Cloudant



* 1 hour
* 2023-06-14



[Serverless web app and eventing for data retrieval and analytics](https://cloud.ibm.com/docs/solution-tutorials?topic=solution-tutorials-serverless-github-traffic-analytics)Serverless web app and eventing for data retrieval and analytics

In this tutorial, you create an application to automatically collect GitHub traffic statistics for repositories and provide the foundation for traffic analytics. GitHub only provides access to the traffic data for the last 14 days. If you want to analyze statistics over a longer period of time, you need to download and store that data yourself. In this tutorial, you deploy a serverless app in a IBM Cloud Code Engine project. The app manages the metadata for GitHub repositories and provides access to the statistics for data analytics. The traffic data is collected from GitHub either on-demand in the app or when triggered by Code Engine events, e.g., daily. The app discussed in this tutorial implements a multi-tenant-ready solution with the initial set of features supporting a single-tenant mode.

Code Engine Db2 on Cloud

+1

App ID



* 1 hour
* 2023-06-16
* [Cookie authentication](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-work-with-your-accountcookie-authentication)





 IAM authentication 

You can perform the following tasks with IAM:



* Centrally manage access management across IBM Cloud.
* Allow a user or service to access many different resources by using the same set of credentials (for example, same username and password or IAM API key).
* IAM API keys can be granted access to account management functions, like creating new databases.



For more information, see [Managing access](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-managing-access-for-cloudant) or an overview of [IAM](https://cloud.ibm.com/docs/account?topic=account-iamoverview).





 Authentication 

Authentication means proving who you are. You prove your identity by supplying your user credentials for verification.

Basic authentication is similar to showing an ID at a door to be checked every time that you want to enter. Cookie authentication is similar to having a key to the door so that you can let yourself in whenever you want. Within IBM Cloudant, the key is a cookie that is named AuthSession.

When you create or use performance-critical IBM Cloudant applications, cookie authentication has more benefits when compared with Basic authentication. We encourage you to use cookie authentication whenever possible.



 Basic authentication 

To use Basic authentication, pass your credentials as part of every request. You pass your credentials by adding an Authorization header to the request.

The header includes the authentication scheme (Basic), followed by the [BASE64](https://en.wikipedia.org/wiki/Base64) encoding of a string created by concatenating:



* Your username
* The : character
* Your password



In practice, many application libraries that are used for creating HTTP requests can do this encoding for you.

For more information, see [Security scheme](https://cloud.ibm.com/apidocs/cloudantsecurity-scheme) on basic authentication.







 Authorization
const service = CloudantV1.newInstance({});

let selector: CloudantV1.Selector = {
'$text': 'Pacino',
'year': 2010
};

service.postExplain({
db: 'movies',
selector: selector
}).then(response => {
console.log(response.result);
});

from ibmcloudant.cloudant_v1 import CloudantV1

service = CloudantV1.new_instance()

response = service.post_find(
db='movies',
selector={'$text': 'Pacino', 'year': 2010}
).get_result()

print(response)

postExplainOptions := service.NewPostExplainOptions(
"movies",
map[string]interface{}{
"$text": "Pacino",
"year": 2010,
},
)

explainResult, _, err := service.PostExplain(postExplainOptions)
if err != nil {
panic(err)
}

b, _ := json.MarshalIndent(explainResult, "", " ")
fmt.Println(string(b))

The previous Go example requires the following import block:

import (
"encoding/json"
"fmt"
"github.com/IBM/cloudant-go-sdk/cloudantv1"
)

See the following example response that shows which index was used to answer a query:

{
"dbname": "$ACCOUNT/movies",
"index": {
"ddoc": "_design/32372935e14bed00cc6db4fc9efca0f1537d34a8",
"name": "32372935e14bed00cc6db4fc9efca0f1537d34a8",
A prerequisite for the code is that you initialize the S3 client object for IBM Cloud Object Storage by following the instructions in [IBM Cloud Object Storage - S3 API Intro](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-compatibility-api).

/
Backup directly from Cloudant to an S3 bucket via a stream.
@param {string} couchHost - URL of database root
@param {string} couchDatabase - backup source database
@param {object} s3Client - S3 client object
@param {string} s3Bucket - Destination S3 bucket (must exist)
@param {string} s3Key - Destination object's key (shouldn't exist)
@param {boolean} shallow - Whether to use couchbackup's shallow mode
@returns {Promise}
/
function backupToS3(sourceUrl, s3Client, s3Bucket, s3Key, shallow) {
return new Promise((resolve, reject) => {
debug('Setting up S3 upload to ${s3Bucket}/${s3Key}');

// A pass through stream that has couchbackup's output
// written to it and it then read by the S3 upload client.
// It has a 10 MB internal buffer.
const streamToUpload = new stream.PassThrough({highWaterMark: 10485760});

// Set up S3 upload.
const params = {
Bucket: s3Bucket,
Key: s3Key,
Body: streamToUpload
};
s3Client.upload(params, function(err, data) {
debug('S3 upload done');
if (err) {
debug(err);
reject(new Error('S3 upload failed'));
return;
}
debug('S3 upload succeeded');
For more information, see [Managing key rings](https://cloud.ibm.com/docs/hs-crypto?topic=hs-crypto-managing-key-rings). 
 key_material Optional. The new base64 encoded key material that you want to store and manage in the service. This value is required if you initially imported the key material when you added the key to the service.<br><br>To rotate a key that was initially generated by Hyper Protect Crypto Services, omit the payload attribute and pass an empty request entity-body. To rotate an imported key, provide a key material that meets the following requirements:<br><br><br><br> * The key must be 128, 192, or 256 bits.<br> * The bytes of data, for example 32 bytes for 256 bits, must be encoded by using base64 encoding.<br><br><br> 



A successful rotation request returns an HTTP 204 No Content response, which indicates that your root key was replaced by new key material.
4. Optional: Verify that the key was rotated by running the following call to browse the keys in your Hyper Protect Crypto Services service instance.

curl -X GET 
https://api.<region>.hs-crypto.cloud.ibm.com:<port>/api/v2/keys 
-H 'accept: application/vnd.ibm.collection+json' 
-H 'authorization: Bearer <IAM_token>' 
-H 'bluemix-instance: <instance_ID>' 

Review the lastRotateDate value in the response entity-body to inspect the date and time that your key was last rotated.

{
"metadata": {
"collectionType": "application/vnd.ibm.kms.key+json",
"collectionTotal": 1
},
"resources": [
{
"type": "application/vnd.ibm.kms.key+json",
"id": "02fd6835-6001-4482-a892-13bd2085f75d",
They can also be created [programmatically](https://cloud.ibm.com/apidocs/cloudantintroduction) by using the IBM Cloudant API.

For security purposes, the IBM Cloudant team recommends that you use IAM API keys or IBM Cloudant legacy authentication [API keys](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-work-with-your-accountapi-keys) rather than account-level credentials for replication jobs. For more information, see [Managing access](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-managing-access-for-cloudant) or legacy [authentication](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-work-with-your-accountauthentication), and [authorization](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-work-with-your-accountauthorization) documentation.





 Two-way replication 

Data can be copied in both directions in a process that is known as two-way replication or synchronization. You enable this synchronization by setting up two separate replication processes, one taking the data from A to B, the other taking data from B to A. Both replication processes work independently, with data moved seamlessly in both directions.

Zoom

![The graphic shows database a and b. Database a has four documents, one is crossed off. Database b has one document. After replicating database a to database b, database b has five documents, one is crossed off. After replicating database b to database a, database a also has five documents, one is crossed off.](https://cloud.ibm.com/docs-content/v1/content/522c6f62358b063f921283400a601c3f9bc66f08/Cloudant/images/replication_guide_6.svg)

Figure 5. Two-way replication





 Discussion about continuous replication
.build();

IndexDefinition index = new IndexDefinition.Builder()
.addFields(indexField)
.build();

PostIndexOptions indexOptions = new PostIndexOptions.Builder()
.db("readings")
.index(index)
.name("timestamped-readings")
.type("json")
.partitioned(true)
.build();

IndexResult response =
service.postIndex(indexOptions).execute()
.getResult();

System.out.println(response);

const { CloudantV1 } = require('@ibm-cloud/cloudant');

const service = CloudantV1.newInstance({});

const indexField = {
ts: 'asc'
}

const index = {
fields: [indexField]
}

service.postIndex({
db: 'readings',
name: 'timestamped-readings',
index: index,
type: 'json',
partitioned: true
}).then(response => {
console.log(response.result);
});

from ibmcloudant.cloudant_v1 import CloudantV1, IndexDefinition, IndexField

service = CloudantV1.new_instance()

index_field = IndexField(ts='asc')

index = IndexDefinition(
fields=[index_field]
)

response = service.post_index(
db='readings',
name='timestamped-readings',
index=index,
type='json',
partitioned=True
).get_result()

print(response)

var indexField cloudantv1.IndexField
indexField.SetProperty("ts", core.StringPtr("asc"))
For more information about the fields included in the service credentials, see the [IAM guide](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-managing-access-for-cloudant).

The fields for the basic command format that is used in this exercise are described in the following table.



Table 5. Basic command format

 Field Description 

 NAME Arbitrary name that you give the service credentials. 
 ROLE_NAME This field currently allows the Manager role only. 
 SERVICE_INSTANCE_NAME The name that you give to your IBM Cloudant instance. 
 service-endpoints An optional parameter to populate the URL field in the Service Credentials with an internal endpoint to connect to the service over the IBM Cloud internal network. Omit this parameter to populate the URL with an external endpoint that is publicly accessible. Applies only to Standard plan instances deployed on Dedicated Hardware environments that support internal endpoints. If the environment doesn't support internal endpoints, the result is a 400 error. 



The basic command format to retrieve the credentials for a service instance within IBM Cloud is shown in the following example.

ibmcloud resource service-key-create NAME ROLE_NAME --instance-name SERVICE_INSTANCE_NAME [-p '{"service-endpoints":"internal"}]

The fields for the basic command format are described in the previous table.



1. Create credentials for the cs20170517a instance of an IBM Cloudant service, and name the credentials creds_for_cs20170517a.

ibmcloud resource service-key-create creds_for_cs20170517a Manager --instance-name cs20170517a
2. After you receive the request to create credentials for the service instance, review the IBM Cloud response that includes a message similar to the following (abbreviated) example with your credentials.

Creating service key in resource group default of account John Does's Account as john.doe@email.com...
OK
This value is optional. The default value is false.

--no-wait, --nw
: Create the IBM Cloud Object Storage event subscription and do not wait for the subscription to be ready. If you specify the --no-wait option, the subscription create begins and does not wait. Use the subscription cos get command to check the subscription status. This value is optional. The default value is false.

--output, -o
: Specifies the format of the command output. Valid values are json, yaml, jsonpath=JSONPATH_EXPRESSION, and jsonpath-as-json=JSONPATH_EXPRESSION. Use jsonpath to specify the path to an element of the JSON output. This value is optional.

--path
: The path within the destination application where events are forwarded; for example, /events. The default path is the root URL of the destination application. This option can only be specified if destination-type is app. This value is optional.

--prefix, -p
: Prefix of the IBM Cloud Object Storage object. This value is optional.

--quiet, -q
: Specify this option to reduce the output of the command. This value is optional. The default value is false.

--suffix, -s
: Suffix of the IBM Cloud Object Storage object. Consider the file type of your file when specifying the suffix. This value is optional.

--wait, -w
: Create the IBM Cloud Object Storage event subscription and wait for the subscription to be ready. If you specify the --wait option, the subscription create waits for a maximum time in seconds, as set by the --wait-timeout option, for the subscription to become ready. If the subscription is not ready within the specified --wait-timeout period, the IBM Cloud Object Storage event subscription create fails. This value is optional. The default value is true.

--wait-timeout, --wto
: The length of time in seconds to wait for the IBM Cloud Object Storage event subscription to be ready.
Currently only JSON file format is supported. 
 --json or -j Deprecated Prints the output in the JSON format. 



Example

ibmcloud schematics output --id myworkspace3_2-31cf7130-d0c4-4d





 ibmcloud schematics plan 

Scan the Terraform template in your source repository and compare this template against the IBM Cloud resources that are already deployed. The command-line output shows the IBM Cloud resources that must be added, modified, [persisted](https://cloud.ibm.com/docs/schematics?topic=schematics-general-faqpersist-file), or removed to achieve the state that is described in your configuration file. IBM Cloud Schematics supports 50 API requests per minute, per host, and per customer. The host can be us-east, us-south, eu-gb, or eu-de region. You need to wait before calling the command again.

Your workspace must be in an Inactive, Active, Failed, or Stopped state to perform a Schematics plan action.

During the creation of the Terraform execution plan, you cannot make any changes to your workspace.

Syntax

ibmcloud schematics plan --id WORKSPACE_ID [--output OUTPUT] [--json]

Command options



Schematics output flags

 Flag Required / Optional Description 

 --id or -i Required The unique identifier of the workspace that points to the Terraform template in your source repository that you want to scan. To find the ID of a workspace, run ibmcloud schematics workspace list command. 
 --var-file or -vf Optional Path to variables definition file that are ending with .tfvars or .json. This flag can be used multiple times. 
 --json or -j Deprecated Prints the output in the JSON format. Use --output JSON instead. 
 --output or -o Optional Returns the command-line output in JSON format. Currently only JSON file format is supported. 



Example
putReplicationDocumentOptions := service.NewPutReplicationDocumentOptions(
"repldoc-example",
replicationDoc,
)

documentResult, response, err := service.PutReplicationDocument(putReplicationDocumentOptions)
if err != nil {
panic(err)
}

b, _ := json.MarshalIndent(documentResult, "", " ")
fmt.Println(string(b))

The previous Go example requires the following import block:

import (
"encoding/json"
"fmt"
"github.com/IBM/cloudant-go-sdk/cloudantv1"
"github.com/IBM/go-sdk-core/core"
)

All Go examples require the service object to be initialized. For more information, see the API documentation's [Authentication section](https://cloud.ibm.com/apidocs/cloudant?code=goauthentication-with-external-configuration) for examples.

See the following example of a JSON document that defines a filtered replication:

{
"_id": "weekly_backup",
"source": "https://$USERNAME:$PASSWORD@$SOURCE_SERVICE_DOMAIN/source",
"target": "https://$USERNAME:$PASSWORD@$TARGET_SERVICE_DOMAIN/target",
"filter": "mydesigndoc/myfilter",
"query_params": {
"foo": "bar",
"baz": 5
}
}







 Changes feed 

IBM Cloudant publishes the adds, edits, and deletes affecting a database through a single HTTP feed from the [_changes endpoint](https://cloud.ibm.com/apidocs/cloudantpostchanges-databases). This feed can be used by your application to trigger events. You can access the feed by using HTTP or curl, as shown in the examples.
[In-region automatic data redundancy](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-disaster-recovery-and-backupin-region-automatic-data-redundancy) provides applications with high availability access to data. [Cross-region redundancy for disaster recovery](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-disaster-recovery-and-backupcross-region-redundancy-for-disaster-recovery) provides applications with a means of recovering from a disaster. However, both of these capabilities focus on maintaining access only to the current copy of your data.

People and applications can make mistakes and change data in unintended ways. The applications themselves can implement some protection, but sometimes undesirable changes get through. It's useful to be able to restore data from a previous point in time. Database backups support this requirement.

In addition to protecting your data with high availability and disaster recovery features, consider dumping your database data to a separate location at periodic, regular intervals. Ensure you check and test the backups for confidence that they're complete and correct.

IBM Cloudant supports tools that help you dump the JSON content in databases to a file, and later restore databases from those files.

Specifically, IBM Cloudant supports tools that help you perform the following tasks:



* Backup complete databases to a file that is suitable for further processing and off-site storage.
* Restore complete databases from a previous state that is contained in your backup file.



The tools that are supported by IBM Cloudant have the following limitations:



* _security settings aren't backed up by the tools.
* Attachments aren't backed up by the tools.
* Backups aren't precisely accurate "point-in-time" snapshots. The reason is that the documents in the database are retrieved in batches, but other applications might be updating documents at the same time. Therefore, the data in the database can change between the times when the first and last batches are read.
* Index definitions held design documents are backed up, but when data is restored the indexes must be rebuilt.
It is only required to specify the unique resource by name inside this VPC.
* --output: Specify output format, only JSON is supported. One of: JSON.
* -q, --quiet: Suppress verbose output.



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







 ibmcloud is load-balancer-pool-create 

Create a load balancer pool.

ibmcloud is load-balancer-pool-create POOL_NAME LOAD_BALANCER ALGORITHM PROTOCOL HEALTH_DELAY HEALTH_RETRIES HEALTH_TIMEOUT HEALTH_TYPE (--members MEMBERS_JSON | @MEMBERS_JSON_FILE) [--vpc VPC] [--health-monitor-url URL] [--health-monitor-port PORT] [--session-persistence-type source_ip | http_cookie | app_cookie --session-persistence-cookie-name SESSION_PERSISTENCE_COOKIE_NAME]] [--proxy-protocol disabled | v1 | v2] [--output JSON] [-q, --quiet]



 Command examples 



* ibmcloud is load-balancer-pool-create my-pool 72251a2e-d6c5-42b4-97b0-b5f8e8d1f479 round_robin http 20 2 5 http
* ibmcloud is load-balancer-pool-create my-pool my-lb round_robin http 20 2 5 http
* ibmcloud is load-balancer-pool-create my-pool my-lb round_robin http 20 2 5 http --vpc my-vpc
* ibmcloud is load-balancer-pool-create my-pool 72251a2e-d6c5-42b4-97b0-b5f8e8d1f479 round_robin http 20 2 5 http --health-monitor-url / --health-monitor-port 4001