All Projects → oracle → ballerina-oci

oracle / ballerina-oci

Licence: other
OCI Module for Ballerina

Programming Languages

Ballerina
12 projects

Projects that are alternatives of or similar to ballerina-oci

terraform-examples
Terraform Examples for Oracle Cloud Infrastructure and Platfrom
Stars: ✭ 34 (+100%)
Mutual labels:  oracle-cloud-infrastructure
oci-flexvolume-driver
A Kubernetes volume driver for Oracle Cloud Infrastructure
Stars: ✭ 19 (+11.76%)
Mutual labels:  oracle-cloud-infrastructure
minectl
minectl 🗺 is a cli for creating Minecraft server on different cloud provider.
Stars: ✭ 85 (+400%)
Mutual labels:  oracle-cloud-infrastructure
oci-cloud-controller-manager
Kubernetes Cloud Controller Manager implementation for Oracle Cloud Infrastucture
Stars: ✭ 101 (+494.12%)
Mutual labels:  oracle-cloud-infrastructure
Valheim-Free-Game-Server-Setup-Using-Oracle-Cloud
Valheim Oracle Cloud Server Setup
Stars: ✭ 24 (+41.18%)
Mutual labels:  oracle-cloud-infrastructure
oci-service-broker
Oracle Cloud Infrastructure Service Broker is an open source implementation of Open service broker API Spec for OCI services. Customers can use this implementation to install Open Service Broker in Oracle Container Engine for Kubernetes or in other Kubernetes clusters.
Stars: ✭ 48 (+182.35%)
Mutual labels:  oracle-cloud-infrastructure
oci-compute-jenkins-plugin
Jenkins Plugin for Oracle Cloud Infrastructure (Compute)
Stars: ✭ 12 (-29.41%)
Mutual labels:  oracle-cloud-infrastructure
terraform-oci-compute-instance
Terraform Module for creating Oracle Cloud Infrastructure compute instances
Stars: ✭ 29 (+70.59%)
Mutual labels:  oracle-cloud-infrastructure
oci-utils
Oracle Cloud Infrastructure utilities
Stars: ✭ 34 (+100%)
Mutual labels:  oracle-cloud-infrastructure
oci-ansible-collection
Oracle Cloud Infrastructure Ansible Collection provides an easy way to provision and manage resources in Oracle Cloud using Ansible.
Stars: ✭ 106 (+523.53%)
Mutual labels:  oracle-cloud-infrastructure

Ballerina Oracle Cloud Infrastructure (OCI) Connector

The Oracle OCI connector allows you to access the Oracle OCI REST APIs through ballerina. This project is open source and maintained by Oracle Corp.

Compatibility

Version
Ballerina Language 1.0.1
Oracle Core Services API 20160918
Oracle Identity and Access Management Service API 20160918
Oracle Object Storage Service API 20160918

Prerequisites

Option 1: Install from Source

Building the source

  1. Clone this repository using the following command:

    $ git clone https://github.com/oracle/ballerina-oci.git
  2. Run below commands from the ballerina-oci root directory. For convenience, the below commands skip tests. However, for any change you make, make sure you run all tests so that the module is not broken.

    $ ballerina build -c --skip-tests --all
    $ ballerina compile --skip-tests
  3. Now that the .balo files are created, add the dependencies for the required .balo files in your Ballerina.toml file. This is required as Core, IAM, Objectstorage modules have not been pushed to the Ballerina Central as of now. Thus, in order to use these in your project, add the below dependencies in your Ballerina.toml file.

[dependencies]
"oracle/core" = { path = "path-to-core.balo", version = "0.1.0"}
"oracle/iam" = { path = "path-to-iam.balo", version = "0.1.0"}
"oracle/objectstorage" = { path = "path-to-objectstorage.balo", version = "0.1.0"}

Option 2: Specify the path for cloned or downloaded .balo files

Clone or download this github repository - ballerina-oci. Specify the path of the ".balo" files (found in the target folder) in the Ballerina.toml as below:

[dependencies]
"oracle/core" = { path = "path-to-core.balo", version = "0.1.0"}
"oracle/iam" = { path = "path-to-iam.balo", version = "0.1.0"}
"oracle/objectstorage" = { path = "path-to-objectstorage.balo", version = "0.1.0"}

Running Tests

If you want to run the tests from the ballerina-oci modules, follow the below steps.

  1. Create or update ballerina.conf file in your project with following configurations and provide appropriate values. Below is an example.

    HOST_CORE = "iaas.us-ashburn-1.oraclecloud.com" (region of the tenancy in which you are working)
    TENANCY_ID = "<TENANCY OCID>"
    AUTHUSER_ID = "<USER OCID>"
    KEYFINGERPRINT = "<FINGERPRINT ADDED TO THE ABOVE USER>"
    PATHTOKEY = "<PATH TO OCI KEY IN .P12 format>"
    KEYSTOREPASSWORD = "<KEYSTORE PASSWORD>"
    KEYALIAS = "<KEY ALIAS>"
    KEYPASSWORD = "<KEY PASSWORD>"
    

    You will also have to change the variables in each of the test.bal in each module.

  2. Navigate to the ballerina-oci directory.

  3. Run tests :

    $ ballerina test --all

The following sections provide you with information on how to use the Ballerina Oracle OCI connector.

Working with Oracle OCI Connector

1] Create PEM key with password

openssl genrsa -out ~/.oci/oci_api_key.pem -aes128 2048

2] Add the public key to your account and get the key fingerprint which will be required in configuration. Refer the Oracle documentation

3] Convert PEM to PKCS12 format

openssl pkcs12 -export -nocerts -inkey ~/.oci/<KEY_NAME>.pem -in ~/.oci/<KEY_NAME>.pem -out ~/.oci/<KEY_NAME_P12>.p12 -name "<KEY_ALIAS>"

This converts the PEM to PKSC12 with the alias/name. It will prompt for the PEM password. It will prompt for a keystore password.

4] After adding the dependency as mentioned above in the Ballerina.toml file and also adding the details in ballerina.conf file, import the oracle/core module into the Ballerina project.

Sample
import ballerina/io;
import ballerina/config;
import oracle/core;

string host = config:getAsString("HOST_CORE");
string tenancyId = config:getAsString("TENANCY_ID"); 
string authUserId= config:getAsString("AUTHUSER_ID"); 
string keyFingerprint = config:getAsString("KEYFINGERPRINT"); 
string pathToKey = config:getAsString("PATHTOKEY"); 
string keyStorePassword = config:getAsString("KEYSTOREPASSWORD"); 
string keyAlias = config:getAsString("KEYALIAS"); 
string keyPassword = config:getAsString("KEYPASSWORD"); 

# OCI Client endpoint
core: OciConfiguration ociConfig = {
    host: host,
    tenancyId: tenancyId,
    authUserId: authUserId,
    keyFingerprint: keyFingerprint,
    pathToKey: pathToKey,
    keyStorePassword: keyStorePassword,
    keyAlias: keyAlias,
    keyPassword: keyPassword
};
   
core:Client ociClient = new(ociConfig);

public function main() {
    var instanceResponse = ociClient->getInstance(<Instance OCID>);
    io:println("Instance display name: ", instanceResponse.displayName);
}

Similarly, you can use the oracle/iam and oracle/objectstorage module.

Help

Contributing

ballerina-oci is an open source project. See CONTRIBUTING for details. We welcome contributions from the community. Check the issue tracker for open issues that interest you. We look forward to receiving your contributions.

Oracle gratefully acknowledges the contributions to ballerina-oci that have been made by the community.

License

Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.

This Connector and sample is licensed under Apache License 2.0.

See LICENSE for more details.

Changes

See CHANGELOG.

Known Issues

You can find information on any known issues with the module here and under the Issues tab of this project's GitHub repository.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].