vania-janet/multiturn-rag-retrieval-data huggingface dataset:
If the supplied offset is greater than or equal to the total number of resources present, the server MUST return an empty collection, and MUST NOT return an 400- or 500-series response code.

If the value provided for offset is not a non-negative integer, the server SHOULD return a 400 status code and appropriate error response model.





 Limit 

The limit parameter MUST determine how many resources are returned, unless the offset and limit are such that the response is the last page

[5]of resources.

If limit is unspecified, a default limit MUST be used. The default limit MUST be consistent across all requests to the collection. It should be determined for each collection based on a reasonable default request time and payload size. The default limit should be highlighted in the collection's documentation.

A paginated collection MUST impose a maximum value for the limit. The maximum limit MUST be consistent across all requests to the collection.

[6]The maximum limit should be determined for each collection based on reasonable maximums for request time and payload size. [7] The maximum limit should be highlighted in the collection's documentation.

If the value provided for limit is not a positive integer, or if the value provided is greater than the maximum value for the collection, the server SHOULD return a 400 status code and appropriate error response model.





 Additional response fields 

The fields offset and limit MUST be included in the collection response. The values for these fields MUST be integers, and MUST be included whether they were explicitly provided by the user or provided by defaults.

A total_count field SHOULD also be included in the collection response. If present, this field MUST contain an integer representing the total number of resources in the collection (accounting for filtering, but not for paging). If it is expensive or impractical to provide a total_count value, the total_count field MAY be omitted.





 Example offset and limit pagination response 

{
"offset": 100,
"limit": 50,
"total_count": 232,
"first": {
"href": "http://api.example.com/v2/accounts?limit=50"
},
"last": {
if err != nil {
exitErrorf("Unable to delete bucket %q, %v", newBucket, err)
}

// Wait until bucket is deleted before finishing
fmt.Printf("Waiting for bucket %q to be deleted...n", newBucket)

err = client.WaitUntilBucketNotExists(&s3.HeadBucketInput{
Bucket: aws.String(newBucket),
})
if err != nil {
exitErrorf("Error occurred while waiting for bucket to be deleted, %v", newBucket)
}

fmt.Printf("Bucket %q successfully deletedn", newBucket)
}

func exitErrorf(msg string, args ...interface{}) {
fmt.Fprintf(os.Stderr, msg+"n", args...)
os.Exit(1)

'use strict';

// Required libraries
const ibm = require('ibm-cos-sdk');
const fs = require('fs');
const async = require('async');
const uuidv1 = require('uuid/v1');
const crypto = require('crypto');

function logError(e) {
console.log(ERROR: ${e.code} - ${e.message}n);
}

function logDone() {
console.log('DONE!n');
}

function getUUID() {
return uuidv1().toString().replace(/-/g, "");
}

function generateBigRandomFile(fileName, size) {
return new Promise(function(resolve, reject) {
crypto.randomBytes(size, (err, buf) => {
if (err) reject(err);
* Running GET on https://api.softlayer.com/rest/v3.1/SoftLayer_Event_Log/AllObjects.json?resultLimit=0,50 with no body
/
private void allLogs() {
printEventLogs(getAllEvents(false));
}
/
* Pages through all results from the Event_Log. This might take long time.
/
private List<Log> getAllEvents(boolean allEvents) {
List<Log> result=new ArrayList<>();
int limit =50;
int offset =0;
ResultLimit resultLimit =new ResultLimit(offset,limit);
boolean iterateEvents=true;
while(iterateEvents) {
logService.setResultLimit(resultLimit);
List<Log> logs = logService.getAllObjects();
result.addAll(logs);
if (logs.size() < resultLimit.limit) {
iterateEvents = false;
}
offset+=limit;
resultLimit=new ResultLimit(offset,limit);
iterateEvents=iterateEvents&&allEvents;
}
return result;
}
void print(Object object) {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String json;
json = gson.toJson(object);
System.out.println(json);
}
void printEventLogs(List<Log> logs){
for (Log event :logs) {
System.out.println(String.format("%s - %s - %s",
event.getEventName(),
event.getEventCreateDate().getTime(),
event.getUserType()));
}
}
}

import datetime
import SoftLayer
docID := "order00067"

bulkGetDocs := []cloudantv1.BulkGetQueryDocument{
{
ID: &docID,
Rev: core.StringPtr("3-917fa2381192822767f010b95b45325b"),
},
{
ID: &docID,
Rev: core.StringPtr("4-a5be949eeb7296747cc271766e9a498b"),
},
}

postBulkGetOptions := service.NewPostBulkGetOptions(
"orders",
bulkGetDocs,
)
bulkGetResult, response, err := service.PostBulkGet(postBulkGetOptions)
if err != nil {
panic(err)
}

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

const service = CloudantV1.newInstance({});

const docId = 'order00067';

const bulkGetDoc1 = {
id: docId,
rev: '3-917fa2381192822767f010b95b45325b'
};
const bulkGetDoc2 = {
id: docId,
rev: '4-a5be949eeb7296747cc271766e9a498b'
};

const bulkGetDocs = [bulkGetDoc1, bulkGetDoc2];

const postBulkGetParams = {
db: 'orders',
docs: bulkGetDocs,
};

service.postBulkGet(postBulkGetParams)
.then(response => {
console.log(response.result);
});
6. You get an activity ID in response if the parameters passed as part of the request are valid. You should see the plan being applied in the Schematics workspace that you created in the IBM Cloud console. If you don’t get a successful response, the error response contains the errors that you need to resolve. Resolve those errors and run the script until you are able to get a valid response and apply a plan.
7. If you want to check the logs of the action, see [Retrieving action logs with Schematics API](https://cloud.ibm.com/docs/hpc-slurm?topic=hpc-slurm-retrieve-action-logs&interface=api) to retrieve the logs. The response contains the status of the action, and it appears in either a COMPLETED or FAILED state.





 Example Python request 

 Apply a plan using Schematics Python API

import json, logging

from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
from ibm_schematics.schematics_v1 import SchematicsV1

logging.basicConfig()
logging.root.setLevel(logging.NOTSET)
logging.basicConfig(level=logging.NOTSET)

authenticator = IAMAuthenticator('<ibmcloud-api-key>')

schematics_service = SchematicsV1(authenticator = authenticator)

schematics_service.set_service_url('https://us.schematics.cloud.ibm.com')

logging.info("Started Applying Schematic Plan")

workspace_activity_apply_result = schematics_service.apply_workspace_command(
w_id="<workspace id>",
refresh_token="<refresh-token>",
).get_result()

print(json.dumps(workspace_activity_apply_result, indent=2))

logging.info("Completed Applying Schematic Plan")





 Example Python response 

INFO:root:Started Applying Schematic Plan
: Result value

Hello World 100 days





 from_json 

from_json(jsonStr, schema[, options])
: Returns a struct value with the indicated jsonStr and schema.
: Example of an SQL function usage fragment

> SELECT from_json('{"a":1, "b":0.8}', 'a INT, b DOUBLE')
: Result value

{"a":1, "b":0.8}
: Example of an SQL function usage fragment

> SELECT from_json('{"time":"26/08/2015"}', 'time Timestamp', map('timestampFormat', 'dd/MM/yyyy'))
: Result value

{"time":"2015-08-26 00:00:00.0"}





 from_unixtime 

from_unixtime(unix_time, format)
: Returns unix_time in the specified format.
: Example of an SQL function usage fragment

> SELECT from_unixtime(0, 'yyyy-MM-dd HH:mm:ss')
: Result value

1970-01-01 00:00:00





 from_utc_timestamp 

from_utc_timestamp(timestamp, timezone)
: Given a timestamp, such as '2017-07-14 02:40:00.0', this function interprets it as a time in Coordinated Universal Time (UTC), and renders that time as a timestamp in the indicated time zone. For example, 'GMT+1' would yield '2017-07-14 03:40:00.0'.
: Example of an SQL function usage fragment

> SELECT from_utc_timestamp('2016-08-31', 'Asia/Seoul')
: Result value

2016-08-31 09:00:00





 get_json_object 

get_json_object(json_txt, path)
: Extracts a JSON object from path.
: Example of an SQL function usage fragment
* @param Cloud Functions actions accept a single parameter, which must be a JSON object.
* @return The output of this action, which must be a JSON object.
/
const openwhisk = require('openwhisk');
const ow = openwhisk();

function main(params) {
// for demonstration purposes, we keep track of the individual results of each action that we invoke in our
// custom sequence and return it in the last step of the sequence as the overall action result.

// Although the following .then() blocks are run asynchronously, the main() function acts as a closure that
// makes sure that the chained_action_results variable is accessible for all .then() blocks
const chained_action_results = [];

console.log('Building custom sequence, using openwhisk node-js SDK...');
return ow.actions.invoke({
name: 'action-tutorial/cos-access',
blocking: true,
result: true,
params: {}
})
.then((result) => {
console.log('Result from cos-access ' + JSON.stringify(result));

// storing result
chained_action_results.push(result);

console.log('Now invoking db-access...');

return ow.actions.invoke({
name: 'action-tutorial/db-access',
blocking: true,
result: true,
params: {}
});
})
.catch((error) => {
console.log('An error occurred! ' + JSON.stringify(error));
// IMPORTANT! Re-throw the error, to avoid following .then() block to be executed!
throw error;
})
.then((result) => {
-d '{ "name": "My preset", "channels": ["<CHANNEL>"] }'

Where <PRESET_ID> is the presetid value returned when [running the GET method to return all presets.](https://cloud.ibm.com/docs/log-analysis?topic=log-analysis-preset-apipreset-api-get-all)

A response similar to the following is returned:

{"name":"Send by email","channels":[{"integration":"email","immediate":false,"terminal":true,"triggerlimit":1,"triggerinterval":30,"operator":"presence","emails":"AnotherUser@mycompany.com","alertid":"6043b60788"}],"presetid":"291a4100b0"}

If the <PRESET_ID> does not exist, the following is returned:

{"error":"Resource Not Found","code":"NotFound","status":"error"}





 Deleting a preset 

The following sample deletes a preset.

curl --request DELETE https://api.us-south.logging.cloud.ibm.com/v1/config/presetalert/<PRESET_ID> 
-H "Accept: application/json" 
-H "servicekey: <SERVICE_KEY>" 

Where <PRESET_ID> is the presetid value returned when [running the GET method to return all presets.](https://cloud.ibm.com/docs/log-analysis?topic=log-analysis-preset-apipreset-api-get-all)

The following response will be returned when the preset is successfully deleted:

{"deleted":true}

If the <PRESET_ID> does not exist, the following is returned:

{"error":"Resource Not Found","code":"NotFound","status":"error"}
Errors 

In the event that a request cannot be fulfilled, the server MUST return an appropriate 400-series or 500-series status code. More information on when specific status codes should be used can be found in the [Status Codes](https://cloud.ibm.com/docs/api-handbook?topic=api-handbook-status-codes) section. If a 400-series or 500-series status code is returned, the response body MUST be an error container model.

Any 500 or 503 response made in production MUST be logged and treated as a critical failure requiring an emergency fix. There MUST NOT be long-running known causes for 500 or 503 status errors.



 Error container model 

An error response (any response with 400- or 500-series status code) MUST return an error container model. This model MUST contain an errors field, SHOULD contain a trace field, and MAY contain a status_code field, as outlined below:



Error container model

 Field Type Description 

 errors Error Model Array This field MUST contain an array with at least one error model. 
 trace String This field SHOULD contain a lowercase UUID uniquely identifying the request. 
 status_code Integer This field MAY contain the HTTP status code used for the response. Otherwise, it MUST be omitted. 







 Error model 

An error model MUST contain a code and a message field, SHOULD contain a more_info field, and MAY contain a target field, as outlined below:



Error model

 Field Type Description 

 code Enumeration This field MUST contain a snake case string succinctly identifying the problem. This field SHOULD NOT indicate which field, parameter, or header caused the error, as this is better done with an error target model. 
 message String This field MUST contain a plainly-written, developer-oriented explanation of the solution to the problem in complete, well-formed sentences. 
 more_info URL This field SHOULD contain a publicly-accessible URL where information about the error can be read in a web browser. 
 target Error Target Model This field MAY contain an error target model. Otherwise, it MUST be omitted. 



The error model MAY be extended with additional fields to better specify the error. The target field can be considered a standardized example of such an extension.





 Error target model
6. You get an activity ID in response if the parameters passed as part of the request are valid. You should see the plan being applied in the Schematics workspace that you created in the IBM Cloud console. If you don’t get a successful response, the error response contains the errors that you need to resolve. Resolve those errors and run the script until you are able to get a valid response and apply a plan.
7. If you want to check the logs of the action, see [Retrieving action logs with Schematics API](https://cloud.ibm.com/docs/hpc-spectrum-symphony?topic=hpc-spectrum-symphony-retrieve-action-logs) to retrieve the logs. The response contains the status of the action, and it appears in either a COMPLETED or FAILED state.





 Example Python request 

 Apply a plan using Schematics Python API

import json, logging

from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
from ibm_schematics.schematics_v1 import SchematicsV1

logging.basicConfig()
logging.root.setLevel(logging.NOTSET)
logging.basicConfig(level=logging.NOTSET)

authenticator = IAMAuthenticator('<ibmcloud-api-key>')

schematics_service = SchematicsV1(authenticator = authenticator)

schematics_service.set_service_url('https://us.schematics.cloud.ibm.com')

logging.info("Started Applying Schematic Plan")

workspace_activity_apply_result = schematics_service.apply_workspace_command(
    w_id='<workspace id>',
    refresh_token='<refresh-token>'
).get_result()

print(json.dumps(workspace_activity_apply_result, indent=2))

logging.info("Completed Applying Schematic Plan")





 Example Python response 

INFO:root:Started Applying Schematic Plan
System.out.println(response);

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

const service = CloudantV1.newInstance({});

service.postPartitionView({
db: 'products',
ddoc: 'appliances',
keys: ['1000043', '1000044'],
includeDocs: true,
partitionKey: 'small-appliances',
view: 'byApplianceProdId'
}).then(response => {
console.log(response.result);
});

from ibmcloudant.cloudant_v1 import CloudantV1

service = CloudantV1.new_instance()

response = service.post_partition_view(
db='products',
ddoc='appliances',
keys=['1000043', '1000044'],
include_docs=True,
partition_key='small-appliances',
view='byApplianceProdId'
).get_result()

print(response)

postPartitionViewOptions := service.NewPostPartitionViewOptions(
"products",
"small-appliances",
"appliances",
"byApplianceProdId",
)

keys := []interface{}{"1000043", "1000044"}
postPartitionViewOptions.SetKeys(keys)
postPartitionViewOptions.SetIncludeDocs(true)

viewResult, response, err := service.PostPartitionView(postPartitionViewOptions)
if err != nil {
panic(err)
}

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

The previous Go example requires the following import block:

import (
"encoding/json"
AccountSettings accountSettings = response.getResult();

System.out.println(accountSettings);

account_settings = iam_access_groups_service.update_account_settings(
account_id=test_account_id,
public_access_enabled=False
).get_result()

print(json.dumps(account_settings, indent=2))

updateAccountSettingsOptions := iamAccessGroupsService.NewUpdateAccountSettingsOptions(testAccountID)
updateAccountSettingsOptions.SetPublicAccessEnabled(false)
accountSettings, response, err := iamAccessGroupsService.UpdateAccountSettings(updateAccountSettingsOptions)
if err != nil {
panic(err)
}
b, _ := json.MarshalIndent(accountSettings, "", " ")
fmt.Println(string(b))

const params = {
accountId: testAccountId,
publicAccessEnabled: false,
};

iamAccessGroupsService.updateAccountSettings(params)
.then(res => {
console.log(JSON.stringify(res.result, null, 2));
})
.catch(err => {
console.warn(err)
});

For more information, see [Update account settings](https://cloud.ibm.com/apidocs/iam-access-groupsupdate-account-settings).
4. The service checks whether the challenge string is returned in the body of the response to its GET request. If it is, the service allowlists the callback URL and responds to your original POST request with status code 201. The body of the response includes a JSON object with a status field that has the value created and a url field that has the value of your callback URL.

response code: 201 Created
body: {
"status": "created",
"url": "http://{user_callback_path}/results"
}



The service sends only a single GET request to a callback URL during the registration process. The service must receive a reply with response code 200 that includes the challenge string in its body within five seconds. Otherwise, it does not allowlist the URL. Instead, it sends status code 400 in response to the POST /v1/register_callback request. If the callback URL was already successfully allowlisted, the service sends status code 200 in response to the initial POST request.



 Security considerations 

When you successfully use the POST /v1/register_callback method to register a callback URL, the service allowlists the URL to indicate that it is verified for use with callback notifications. If you specify a user secret with the registration call, allowlisting also means that the URL has been validated for added security. Specifying a user secret provides authentication and data integrity for requests that use the callback URL with the asynchronous HTTP interface.

The service uses the user secret to compute an HMAC-SHA1 signature over the payload of every callback notification that it sends to the URL. The service sends the signature via the X-Callback-Signature header with each notification. The client can use the secret to compute its own signature of each notification payload. If its signature matches the value of the X-Callback-Signature header, the client knows that the notification was sent by the service and that its contents have not been altered during transmission. This knowledge guarantees that the client is not the victim of a man-in-middle-attack.

HTTPS is ideal for production applications.
caseVar, response, err := caseManagementService.CreateCase(createCaseOptions)
if err != nil {
panic(err)
}
b, _ := json.MarshalIndent(caseVar, "", " ")
fmt.Println(string(b))

const offeringType = {
group: 'crn_service_name',
key: 'cloud-object-storage',
};

const offeringPayload = {
name: 'Cloud Object Storage',
type: offeringType,
};

const params = {
type: 'technical',
subject: 'Example technical case',
description: 'This is an example case description. This is where the problem would be described.',
offering: offeringPayload,
severity: 4,
};

caseManagementService.createCase(params)
.then(res => {
caseNumber = res.result.number
console.log(JSON.stringify(res.result, null, 2));
})
.catch(err => {
console.warn(err)
});



 Adding a resource to a support case by using the API 

You can programmatically add a resource to a support case by using the API as shown in the following sample request. For more information, see the [Case Management API reference](https://cloud.ibm.com/apidocs/case-managementcasemanagement-createcase).



* Curl
* Java
* Python
* Go
* Node



curl -X PUT '/case-management/v1/cases/{case_number}/resources' -H 'Authorization: TOKEN' -d '{
"crn": "296878",
"note": "This resource does not work"
}'

AddResourceOptions addResourceOptions = new AddResourceOptions.Builder()
.caseNumber(caseNumber)
String value = (String) property.getCurrentValue(entityId, entityAttributes);







 Supported data types 

App Configuration service configures the feature flag and properties in the following data types: Boolean, Numeric, String. The String data type can be of the format of a text string, JSON, or YAML. The SDK processes each format accordingly as shown in Table 1.



 Feature Flag 

Feature feature = appConfiguration.getFeature("json-feature");
feature.getFeatureDataType(); // STRING
feature.getFeatureDataFormat(); // JSON

// Example below (traversing the returned JSONObject)
if (feature != null) {
JSONObject result = (JSONObject) feature.getCurrentValue(entityId, entityAttributes);
result.get("key") // returns the value of the key
}

Feature feature = appConfiguration.getFeature("yaml-feature");
feature.getFeatureDataType(); // STRING
feature.getFeatureDataFormat(); // YAML
feature.getCurrentValue(entityId, entityAttributes); // returns the stringified yaml (check above Table 1)





 Property 

Property property = appConfiguration.getProperty("json-property");
property.getPropertyDataType(); // STRING
property.getPropertyDataFormat(); // JSON

// Example below (traversing the returned JSONObject)
if (property != null) {
JSONObject result = (JSONObject) property.getCurrentValue(entityId, entityAttributes);
result.get("key") // returns the value of the key
}

Property property = appConfiguration.getProperty("yaml-property");
* [ListObjectsV2Result](https://ibm.github.io/ibm-cos-sdk-java/com/ibm/cloud/objectstorage/services/s3/model/ListObjectsV2Result.html)
* [S3ObjectSummary](https://ibm.github.io/ibm-cos-sdk-java/com/ibm/cloud/objectstorage/services/s3/model/S3ObjectSummary.html)



* Methods



* [getObjectSummaries](https://ibm.github.io/ibm-cos-sdk-java/com/ibm/cloud/objectstorage/services/s3/model/ListObjectsV2Result.htmlgetObjectSummaries--)
* [getNextContinuationToken](https://ibm.github.io/ibm-cos-sdk-java/com/ibm/cloud/objectstorage/services/s3/model/ListObjectsV2Result.htmlgetNextContinuationToken--)
* [listObjectsV2](https://ibm.github.io/ibm-cos-sdk-java/com/ibm/cloud/objectstorage/services/s3/AmazonS3.htmllistObjectsV2-com.ibm.cloud.objectstorage.services.s3.model.ListObjectsV2Request-)









 Get file contents of particular item 

public static void getItem(String bucketName, String itemName) {
System.out.printf("Retrieving item from bucket: %s, key: %sn", bucketName, itemName);

S3Object item = _cos.getObject(new GetObjectRequest(bucketName, itemName));

try {
final int bufferSize = 1024;
final char[] buffer = new char[bufferSize];
final StringBuilder out = new StringBuilder();