This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //route handler (Bootstrap.groovy): | |
| post "/oci/upload-part", { req, res -> | |
| req.attribute("org.eclipse.jetty.multipartConfig", new MultipartConfigElement("/tmp")) | |
| HttpRequestWrapper reqRaw = req.raw() | |
| InputStream is = reqRaw.getPart("uploadPart").getInputStream() | |
| def objectName = req.queryParams("objectName") | |
| def partNum = req.queryParams("partNum").toInteger() | |
| def uploadId = req.queryParams("uploadId") | |
| return JsonOutput.toJson( objectService.uploadPart(is, objectName, uploadId, partNum) ) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //route handler (Bootstrap.groovy): | |
| post "/oci/upload-commit", { req, res -> | |
| /* | |
| expects a JSON object in the request body that looks like this: | |
| { | |
| uploadId: "", | |
| objectName: "", | |
| uploads: [ | |
| { | |
| partNum: 1, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # set variables | |
| OCI_FN_TENANCY=<your tenancy name> | |
| OCI_FN_HOME_REGION=us-ashburn-1 | |
| OCI_FN_FN_REGION=us-phoenix-1 | |
| OCI_FN_USER_NAME=faas-user | |
| OCI_FN_GROUP_NAME=faas-group | |
| OCI_FN_COMPARTMENT_NAME=faas-compartment | |
| OCI_FN_POLICY_NAME=faas-demo-policy | |
| OCI_FN_VCN_NAME=faas-demo-vcn | |
| OCI_FN_VCN_CIDR_BLOCK=10.0.0.0/16 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Created compartment faas-compartment with ID ocid1.compartment.oc1..[redacted]na | |
| Created group faas-group with ID ocid1.group.oc1..[redacted]vq | |
| Created user faas-user with ID ocid1.user.oc1..[redacted]va | |
| Created Auth Token. Remember this token, it can not be retrieved in the future: ew[redacted]et | |
| Added user faas-user to group faas-group | |
| Action completed. Waiting until the resource has entered state: ACTIVE | |
| Created policy faas-demo-policy. Use the command: 'oci iam policy get --policy-id ocid1.policy.oc1..[redacted]sa' if you want to view the policy. | |
| Creating VCN. This may take a few seconds... | |
| ServiceError: | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Lists the objects in a bucket. | |
| * @param {ListObjectsRequest} listObjectsRequest An instance of ListObjectsRequest | |
| * @method | |
| */ | |
| listObjects(listObjectsRequest){ | |
| const params = this.Utils.cleanObject( listObjectsRequest.queryParams ); | |
| const qs = this.querystring.stringify( params ); | |
| const url = `${this.serviceBaseUrl}/n/${listObjectsRequest.pathParams.namespaceName}/b/${listObjectsRequest.pathParams.bucketName}/o${qs ? '?' + qs : ''}`; | |
| return this.doRequest(url, 'GET', { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * A class that contains properties necessary to perform ListObjects | |
| * @param {string} namespaceName Minimum: 1 Maximum: The Object Storage namespace used for the request. | |
| * @param {string} bucketName Minimum: 1 Maximum: The name of the bucket. Avoid entering confidential information. Example: my-new-bucket1 | |
| * @param {string} [prefix] The string to use for matching against the start of object names in a list query. | |
| * @param {string} [start] Object names returned by a list query must be greater or equal to this parameter. | |
| * @param {string} [end] Object names returned by a list query must be strictly less than this parameter. | |
| * @param {number} [limit] The maximum number of items to return. | |
| * @param {string} [delimiter] When this parameter is set, only objects whose names do not contain the delimiter character (after an optionally specified prefix) are returned in the objects key of the response body. Scanned objects whose names contain the delimiter have the part of their name up to the first occurre |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Grab(group='io.swagger', module='swagger-parser', version='1.0.34') | |
| @Grab(group='io.swagger', module='swagger-core', version='1.5.18') | |
| import io.swagger.models.Swagger; | |
| import io.swagger.parser.SwaggerParser; | |
| import groovy.json.* | |
| Swagger swagger = new SwaggerParser().read("https://docs.cloud.oracle.com/iaas/api/specs/b22ebbac302e1155839cca403b2458f54c7b4e46.yaml"); | |
| groovy.inspect.swingui.ObjectBrowser.inspect(swagger) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package codes.recursive.barn.automation.service.streaming | |
| import com.oracle.bmc.auth.ConfigFileAuthenticationDetailsProvider | |
| import com.oracle.bmc.streaming.StreamClient | |
| import com.oracle.bmc.streaming.model.PutMessagesDetails | |
| import com.oracle.bmc.streaming.model.PutMessagesDetailsEntry | |
| import com.oracle.bmc.streaming.requests.PutMessagesRequest | |
| import groovy.util.logging.Slf4j | |
| import javax.enterprise.context.ApplicationScoped |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package codes.recursive.barn.automation.service.streaming | |
| import codes.recursive.barn.automation.event.EventEmitter | |
| import codes.recursive.barn.automation.model.BarnEvent | |
| import codes.recursive.barn.automation.service.data.OracleDataService | |
| import com.oracle.bmc.auth.ConfigFileAuthenticationDetailsProvider | |
| import com.oracle.bmc.streaming.StreamClient | |
| import com.oracle.bmc.streaming.model.CreateGroupCursorDetails | |
| import com.oracle.bmc.streaming.model.Message | |
| import com.oracle.bmc.streaming.requests.CreateGroupCursorRequest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ConfigFileAuthenticationDetailsProvider provider = new ConfigFileAuthenticationDetailsProvider('/path/to/.oci/config', 'DEFAULT') | |
| StreamClient client = new StreamClient(provider) | |
| String key = 'Key' | |
| String msg = 'Message' | |
| PutMessagesDetails putMessageDetails = PutMessagesDetails.builder() | |
| .messages([ | |
| PutMessagesDetailsEntry.builder() | |
| .key(key.getBytes(Charset.forName("UTF-8"))) | |
| .value(msg.getBytes(Charset.forName("UTF-8"))) |