Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
github.com/oracle/oci-go-sdk/v40
This is the Go SDK for Oracle Cloud Infrastructure. This project is open source and maintained by Oracle Corp. The home page for the project is here.
WARNING:: To avoid automatically consuming breaking changes if we have to rev the major version of the Go SDK, please consider using the Go dependency management tool, or vendoring the SDK. This will allow you to pin to a specific version of the Go SDK in your project, letting you control how and when you move to the next major version.
Are you a Developer using the OCI SDK? If so, please fill out our survey to help us make the OCI SDK better for you. Click here for the survey page.
OCI Go SDK supports both go get
and Go Modules installing.
If you want to install the SDK under $GOPATH, you can use go get
to retrieve the SDK:
go get -u github.com/oracle/oci-go-sdk
Alternatively, you can also clone the repo from Github.
If you are using Go modules, you can install the latest or specific version(v25.0.0+) when adding the following in the go.mod file:
require github.com/oracle/oci-go-sdk/{major-version} {version}
One example is:
require github.com/oracle/oci-go-sdk/v38 v38.0.0
Run go mod tidy
In your project, you also need to add/update the major-version to make sure go build
works
import "github.com/oracle/oci-go-sdk/v38/common"
To start working with the Go SDK, you import the service package, create a client, and then use that client to make calls.
Before using the SDK, set up a config file with the required credentials. See SDK and Tool Configuration for instructions.
Note that the Go SDK does not support profile inheritance or defining custom values in the configuration file.
Once a config file has been setup, call common.DefaultConfigProvider()
function as follows:
// Import necessary packages
import (
"github.com/oracle/oci-go-sdk/common"
"github.com/oracle/oci-go-sdk/identity" // Identity or any other service you wish to make requests to
)
//...
configProvider := common.DefaultConfigProvider()
Or, to configure the SDK programmatically instead, implement the ConfigurationProvider
interface shown below:
// ConfigurationProvider wraps information about the account owner
type ConfigurationProvider interface {
KeyProvider
TenancyOCID() (string, error)
UserOCID() (string, error)
KeyFingerprint() (string, error)
Region() (string, error)
// AuthType() is used for specify the needed auth type, like UserPrincipal, InstancePrincipal, etc. AuthConfig is used for getting auth related paras in config file.
AuthType() (AuthConfig, error)
}
Or simply use one of structs exposed by the oci-go-sdk
that already implement the above interface
To make a request to an Oracle Cloud Infrastructure service, create a client for the service and then use the client to call a function from the service.
New<ServiceName>ClientWithConfigurationProvider
,
such as NewVirtualNetworkClientWithConfigurationProvider
or NewIdentityClientWithConfigurationProvider
. To create a new client,
pass a struct that conforms to the ConfigurationProvider
interface, or use the DefaultConfigProvider()
function in the common package.For example:
config := common.DefaultConfigProvider()
client, err := identity.NewIdentityClientWithConfigurationProvider(config)
if err != nil {
panic(err)
}
context.Context
and a struct that wraps all input parameters. The functions then return a response struct
that contains the desired data, and an error struct that describes the error if an error occurs.For example:
id := "your_group_id"
response, err := client.GetGroup(context.Background(), identity.GetGroupRequest{GroupId:&id})
if err != nil {
//Something happened
panic(err)
}
//Process the data in response struct
fmt.Println("Group's name is:", response.Name)
The oci-go-sdk
contains the following:
Service packages: All packages except common
and any other package found inside cmd
. These packages represent
the Oracle Cloud Infrastructure services supported by the Go SDK. Each package represents a service.
These packages include methods to interact with the service, structs that model
input and output parameters, and a client struct that acts as receiver for the above methods.
Common package: Found in the common
directory. The common package provides supporting functions and structs used by service packages.
Includes HTTP request/response (de)serialization, request signing, JSON parsing, pointer to reference and other helper functions. Most of the functions
in this package are meant to be used by the service packages.
cmd: Internal tools used by the oci-go-sdk
.
Examples can be found here
Full documentation can be found on the godocs site.
oci-go-sdk
is an open source project. See CONTRIBUTING for details.
Oracle gratefully acknowledges the contributions to oci-go-sdk that have been made by the community.
Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
See LICENSE for more details.
See CHANGELOG.
You can find information on any known issues with the SDK here and under the Issues tab of this project's GitHub repository.
go get github.com/stretchr/testify
go get -u github.com/golang/lint/golint
Building is provided by the make file at the root of the project. To build the project execute.
make build
To run the tests:
make test
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.