Examples
The following example obtains the bucket parameter during submission time and uses the default application configuration named cos that contains a property named cos.creds with a value of the IBM COS credentials for authentication. The COS endpoint is also a submission-time parameter but defaults to the public IBM US geo endpoint.
composite Main {
param
expression<rstring> $bucket: getSubmissionTimeValue("os-bucket");
expression<rstring> $endpoint: getSubmissionTimeValue("os-endpoint", "s3.us.cloud-object-storage.appdomain.cloud");
graph
// ObjectStorageScan operator with directory and pattern
stream<rstring name> Scanned = com.teracloud.streams.objectstorage::ObjectStorageScan() {
param
objectStorageURI: com.teracloud.streams.objectstorage.s3::getObjectStorageURI($bucket);
endpoint: $endpoint;
directory: "/sample";
pattern: ".*";
}
// use a ObjectStorageSource operator to process the object names
stream<rstring line> Data = com.teracloud.streams.objectstorage::ObjectStorageSource(Scanned) {
param
objectStorageURI: com.teracloud.streams.objectstorage.s3::getObjectStorageURI($bucket);
endpoint: $endpoint;
}
}
The following example uses the credentials parameter to specify the IBM COS credentials. The objectStorageURI is provided at submission time and be in either "cos://<bucket-name>/" or "s3a://<bucket-name>/" format.
composite Main {
param
expression<rstring> $credentials: getSubmissionTimeValue("os-credentials");
expression<rstring> $objectStorageURI: getSubmissionTimeValue("os-uri");
expression<rstring> $endpoint: getSubmissionTimeValue("os-endpoint", "s3.us.cloud-object-storage.appdomain.cloud");
graph
// ObjectStorageScan operator with directory and pattern
stream<rstring name> Scanned = com.teracloud.streams.objectstorage::ObjectStorageScan() {
param
credentials: $credentials;
objectStorageURI: $objectStorageURI;
endpoint: $endpoint;
directory: "/sample";
pattern: ".*";
}
// use a ObjectStorageSource operator to process the object names
stream<rstring line> Data = com.teracloud.streams.objectstorage::ObjectStorageSource(Scanned) {
param
credentials: $credentials;
objectStorageURI: $objectStorageURI;
endpoint: $endpoint;
}
}