• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

analytics/H19-Nov-2019-

announcementsservice/H19-Nov-2019-

audit/H19-Nov-2019-

autoscaling/H19-Nov-2019-

budget/H19-Nov-2019-

cmd/genver/H19-Nov-2019-

common/H19-Nov-2019-

containerengine/H19-Nov-2019-

core/H19-Nov-2019-

database/H19-Nov-2019-

dns/H19-Nov-2019-

dts/H19-Nov-2019-

email/H19-Nov-2019-

events/H19-Nov-2019-

example/H19-Nov-2019-

filestorage/H19-Nov-2019-

functions/H19-Nov-2019-

healthchecks/H19-Nov-2019-

identity/H19-Nov-2019-

integration/H19-Nov-2019-

keymanagement/H19-Nov-2019-

limits/H19-Nov-2019-

loadbalancer/H19-Nov-2019-

monitoring/H19-Nov-2019-

objectstorage/H19-Nov-2019-

oce/H19-Nov-2019-

oda/H19-Nov-2019-

ons/H19-Nov-2019-

resourcemanager/H19-Nov-2019-

resourcesearch/H19-Nov-2019-

streaming/H19-Nov-2019-

waas/H19-Nov-2019-

workrequests/H19-Nov-2019-

.gitignoreH A D19-Nov-2019126

CHANGELOG.mdH A D19-Nov-201934.4 KiB

CONTRIBUTING.mdH A D19-Nov-2019702

MakefileH A D19-Nov-20192.4 KiB

README.mdH A D19-Nov-20196.8 KiB

oci.goH A D19-Nov-201914.2 KiB

wercker.ymlH A D19-Nov-2019681

README.md

1# Oracle Cloud Infrastructure Golang SDK
2[![wercker status](https://app.wercker.com/status/09bc4818e7b1d70b04285331a9bdbc41/s/master "wercker status")](https://app.wercker.com/project/byKey/09bc4818e7b1d70b04285331a9bdbc41)
3
4This is the Go SDK for Oracle Cloud Infrastructure. This project is open source and maintained by Oracle Corp.
5The home page for the project is [here](https://godoc.org/github.com/oracle/oci-go-sdk/).
6>***WARNING:***: To avoid automatically consuming breaking changes if we have to rev the major version of the Go SDK,
7please consider using the  [Go dependency management tool](https://github.com/golang/dep), or vendoring the SDK.
8This 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.
9
10## Dependencies
11- Install [Go programming language](https://golang.org/dl/).
12- Install [GNU Make](https://www.gnu.org/software/make/), using the package manager or binary distribution tool appropriate for your platform.
13
14
15
16## Installing
17Use the following command to install this SDK:
18
19```
20go get -u github.com/oracle/oci-go-sdk
21```
22Alternatively you can git clone this repo.
23
24## Working with the Go SDK
25To start working with the Go SDK, you import the service package, create a client, and then use that client to make calls.
26
27### Configuring
28Before using the SDK, set up a config file with the required credentials. See [SDK and Tool Configuration](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm) for instructions.
29
30Note that the Go SDK does not support profile inheritance or defining custom values in the configuration file.
31
32Once a config file has been setup, call `common.DefaultConfigProvider()` function as follows:
33
34 ```go
35 // Import necessary packages
36 import (
37	"github.com/oracle/oci-go-sdk/common"
38	"github.com/oracle/oci-go-sdk/identity" // Identity or any other service you wish to make requests to
39)
40
41 //...
42
43configProvider := common.DefaultConfigProvider()
44```
45
46 Or, to configure the SDK programmatically instead, implement the `ConfigurationProvider` interface shown below:
47 ```go
48// ConfigurationProvider wraps information about the account owner
49type ConfigurationProvider interface {
50	KeyProvider
51	TenancyOCID() (string, error)
52	UserOCID() (string, error)
53	KeyFingerprint() (string, error)
54	Region() (string, error)
55}
56```
57Or simply use one of  structs exposed by the `oci-go-sdk` that already implement the above [interface](https://godoc.org/github.com/oracle/oci-go-sdk/common#ConfigurationProvider)
58
59### Making a Request
60To 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.
61
62- *Creating a client*: All packages provide a function to create clients, using the naming convention `New<ServiceName>ClientWithConfigurationProvider`,
63such as `NewVirtualNetworkClientWithConfigurationProvider` or `NewIdentityClientWithConfigurationProvider`. To create a new client,
64pass a struct that conforms to the `ConfigurationProvider` interface, or use the `DefaultConfigProvider()` function in the common package.
65
66For example:
67```go
68config := common.DefaultConfigProvider()
69client, err := identity.NewIdentityClientWithConfigurationProvider(config)
70if err != nil {
71     panic(err)
72}
73```
74
75- *Making calls*: After successfully creating a client, requests can now be made to the service. Generally all functions associated with an operation
76accept [`context.Context`](https://golang.org/pkg/context/) and a struct that wraps all input parameters. The functions then return a response struct
77that contains the desired data, and an error struct that describes the error if an error occurs.
78
79For example:
80```go
81id := "your_group_id"
82response, err := client.GetGroup(context.Background(), identity.GetGroupRequest{GroupId:&id})
83if err != nil {
84	//Something happened
85	panic(err)
86}
87//Process the data in response struct
88fmt.Println("Group's name is:", response.Name)
89```
90
91## Organization of the SDK
92The `oci-go-sdk` contains the following:
93- **Service packages**: All packages except `common` and any other package found inside `cmd`. These packages represent
94the Oracle Cloud Infrastructure services supported by the Go SDK. Each package represents a service.
95These packages include methods to interact with the service, structs that model
96input and output parameters, and a client struct that acts as receiver for the above methods.
97
98- **Common package**: Found in the `common` directory. The common package provides supporting functions and structs used by service packages.
99Includes HTTP request/response (de)serialization, request signing, JSON parsing, pointer to reference and other helper functions. Most of the functions
100in this package are meant to be used by the service packages.
101
102- **cmd**: Internal tools used by the `oci-go-sdk`.
103
104## Examples
105Examples can be found [here](https://github.com/oracle/oci-go-sdk/tree/master/example)
106
107## Documentation
108Full documentation can be found [on the godocs site](https://godoc.org/github.com/oracle/oci-go-sdk/).
109
110## Help
111* The [Issues](https://github.com/oracle/oci-go-sdk/issues) page of this GitHub repository.
112* [Stack Overflow](https://stackoverflow.com/), use the [oracle-cloud-infrastructure](https://stackoverflow.com/questions/tagged/oracle-cloud-infrastructure) and [oci-go-sdk](https://stackoverflow.com/questions/tagged/oci-go-sdk) tags in your post.
113* [Developer Tools](https://community.oracle.com/community/cloud_computing/bare-metal/content?filterID=contentstatus%5Bpublished%5D~category%5Bdeveloper-tools%5D&filterID=contentstatus%5Bpublished%5D~objecttype~objecttype%5Bthread%5D) of the Oracle Cloud forums.
114* [My Oracle Support](https://support.oracle.com).
115
116
117## Contributing
118`oci-go-sdk` is an open source project. See [CONTRIBUTING](/CONTRIBUTING.md) for details.
119
120Oracle gratefully acknowledges the contributions to oci-go-sdk that have been made by the community.
121
122
123## License
124Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
125
126This SDK and sample is dual licensed under the Universal Permissive License 1.0 and the Apache License 2.0.
127
128See [LICENSE](/LICENSE.txt) for more details.
129
130## Changes
131See [CHANGELOG](/CHANGELOG.md).
132
133## Known Issues
134You can find information on any known issues with the SDK here and under the [Issues](https://github.com/oracle/oci-go-sdk/issues) tab of this project's GitHub repository.
135
136## Building and Testing
137### Dev Dependencies
138- Install [Testify](https://github.com/stretchr/testify) with the command:
139```sh
140go get github.com/stretchr/testify
141```
142- Install [go lint](https://github.com/golang/lint) with the command:
143```
144go get -u github.com/golang/lint/golint
145```
146### Build
147Building is provided by the make file at the root of the project. To build the project execute.
148
149```
150make build
151```
152
153To run the tests:
154```
155make test
156```
157