How to connect an OCI function to OCI NoSQL with Go

31 Views Asked by At

I am trying to use the Go SDKs that OCI provides:

  1. OCI SDK for Go
  2. Oracle NoSQL Database Go SDK

I am trying to connect using a config file in the same folder that looks like this:

[DEFAULT]
tenancy=ocid1.tenancy.oc1..abcdefg
user=ocid1.user.oc1..abcdefg
fingerprint=00:00:00:00:00.....
key_file="./oci.pem"
region=eu-frankfurt-1
package main

import (
    "context"
    "encoding/json"
    "io"
    "net/http"

    fdk "github.com/fnproject/fdk-go"
)

func main() {
    fdk.Handle(fdk.HandlerFunc(fnHandler))
}

func fnHandler(ctx context.Context, in io.Reader, out io.Writer) {
    fnctx, ok := fdk.GetContext(ctx).(fdk.HTTPContext)
    if !ok {
        fdk.WriteStatus(out, http.StatusBadRequest)
        io.WriteString(out, `{"error":"Invalid Request"}`)
        return
    }

    /** Oracle NoSQL and Object Storage Connection */

    /**
     *
     *
     *
     *
     *
     *
     *
     */

    response := struct {
        URL     string            `json:"url"`
        Header  http.Header       `json:"header"`
        Config  map[string]string `json:"config"`
        Message bool              `json:"ok"`
    }{
        URL:     fnctx.RequestURL(),
        Header:  fnctx.Header(),
        Config:  fnctx.Config(),
        Message: ok,
    }

    fdk.WriteStatus(out, http.StatusCreated)
    json.NewEncoder(out).Encode(&response)
}

I followed their tutorials and their examples in GiHub.

0

There are 0 best solutions below