Skip to content

Commit f55375e

Browse files
authored
GO SDK 5.5.0 Release
GO SDK 5.5.0 Release
2 parents 83aa58c + 4fed74a commit f55375e

31 files changed

+1636
-37
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66

7+
## 5.5.0 - 2019-05-07
8+
### Added
9+
- Support for the Tokyo (NRT) region
10+
11+
- Support UploadManager for uploading large objects. Sample is available on [Github](https://github.com/oracle/oci-go-sdk/tree/master/example/example_objectstorage_test.go)
12+
713
## 5.4.0 - 2019-04-16
814
### Added
915
- Support for tagging dynamic groups in the Identity service

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
DOC_SERVER_URL=https:\/\/docs.cloud.oracle.com
22

33
GEN_TARGETS = identity core objectstorage loadbalancer database audit dns filestorage email containerengine resourcesearch keymanagement announcementsservice healthchecks waas autoscaling streaming ons monitoring resourcemanager budget ##SPECNAME##
4-
NON_GEN_TARGETS = common common/auth
4+
NON_GEN_TARGETS = common common/auth objectstorage/transfer
55
TARGETS = $(NON_GEN_TARGETS) $(GEN_TARGETS)
66

7-
TARGETS_WITH_TESTS = common common/auth
7+
TARGETS_WITH_TESTS = common common/auth objectstorage/transfer
88
TARGETS_BUILD = $(patsubst %,build-%, $(TARGETS))
99
TARGETS_CLEAN = $(patsubst %,clean-%, $(GEN_TARGETS))
1010
TARGETS_LINT = $(patsubst %,lint-%, $(TARGETS))
@@ -13,6 +13,8 @@ TARGETS_RELEASE= $(patsubst %,release-%, $(TARGETS))
1313
GOLINT=$(GOPATH)/bin/golint
1414
LINT_FLAGS=-min_confidence 0.9 -set_exit_status
1515

16+
# directories under gen targets which contains hand writen code
17+
EXCLUDED_CLEAN_DIRECTORIES = objectstorage/transfer*
1618

1719
.PHONY: $(TARGETS_BUILD) $(TARGET_TEST)
1820

@@ -43,13 +45,13 @@ $(TARGETS_TEST): test-%:%
4345

4446
$(TARGETS_CLEAN): clean-%:%
4547
@echo "cleaning $<"
46-
@-rm -rf $<
48+
@-find $< -not -path "$<" | grep -vZ ${EXCLUDED_CLEAN_DIRECTORIES} | xargs rm -rf
4749

4850
# clean all generated code under GEN_TARGETS folder
4951
clean-generate:
5052
for target in ${GEN_TARGETS}; do \
5153
echo "cleaning $$target"; \
52-
rm -rf $$target; \
54+
find $$target -not -path "$$target" | grep -vZ ${EXCLUDED_CLEAN_DIRECTORIES} | xargs rm -rf; \
5355
done
5456

5557
pre-doc:

common/common.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ const (
2424
RegionFRA Region = "eu-frankfurt-1"
2525
//RegionLHR region LHR
2626
RegionLHR Region = "uk-london-1"
27+
//RegionAPTokyo1 region for tokyo
28+
RegionAPTokyo1 Region = "ap-tokyo-1"
2729

2830
//RegionUSLangley1 region for langley
2931
RegionUSLangley1 Region = "us-langley-1"
@@ -50,10 +52,10 @@ var regionRealm = map[Region]string{
5052
RegionFRA: "oc1",
5153
RegionLHR: "oc1",
5254
RegionCAToronto1: "oc1",
55+
RegionAPTokyo1: "oc1",
5356

54-
RegionUSLangley1: "oc2",
55-
RegionUSLuke1: "oc2",
56-
57+
RegionUSLangley1: "oc2",
58+
RegionUSLuke1: "oc2",
5759
RegionUSGovAshburn1: "oc3",
5860
RegionUSGovChicago1: "oc3",
5961
RegionUSGovPhoenix1: "oc3",
@@ -108,6 +110,8 @@ func StringToRegion(stringRegion string) (r Region) {
108110
r = RegionFRA
109111
case "lhr", "uk-london-1":
110112
r = RegionLHR
113+
case "ap-tokyo-1":
114+
r = RegionAPTokyo1
111115
case "us-langley-1":
112116
r = RegionUSLangley1
113117
case "us-luke-1":

common/version.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/example_objectstorage_test.go

Lines changed: 107 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,15 @@ package example
77

88
import (
99
"context"
10-
"crypto/sha256"
1110
"fmt"
1211
"io"
13-
"io/ioutil"
14-
"math/rand"
1512
"os"
1613
"path"
17-
"time"
1814

1915
"github.com/oracle/oci-go-sdk/common"
2016
"github.com/oracle/oci-go-sdk/example/helpers"
2117
"github.com/oracle/oci-go-sdk/objectstorage"
18+
"github.com/oracle/oci-go-sdk/objectstorage/transfer"
2219
)
2320

2421
// ExampleObjectStorage_UploadFile shows how to create a bucket and upload a file
@@ -34,7 +31,7 @@ func ExampleObjectStorage_UploadFile() {
3431
defer deleteBucket(ctx, c, namespace, bname)
3532

3633
contentlen := 1024 * 1000
37-
filepath, filesize := writeTempFileOfSize(int64(contentlen))
34+
filepath, filesize := helpers.WriteTempFileOfSize(int64(contentlen))
3835
filename := path.Base(filepath)
3936
defer func() {
4037
os.Remove(filename)
@@ -56,6 +53,111 @@ func ExampleObjectStorage_UploadFile() {
5653
// delete bucket
5754
}
5855

56+
func ExampleObjectStorage_UploadManager_UploadFile() {
57+
c, clerr := objectstorage.NewObjectStorageClientWithConfigurationProvider(common.DefaultConfigProvider())
58+
helpers.FatalIfError(clerr)
59+
60+
ctx := context.Background()
61+
bname := "bname"
62+
namespace := getNamespace(ctx, c)
63+
64+
createBucket(ctx, c, namespace, bname)
65+
defer deleteBucket(ctx, c, namespace, bname)
66+
67+
contentlen := 1024 * 1000 * 300 // 300MB
68+
filepath, _ := helpers.WriteTempFileOfSize(int64(contentlen))
69+
filename := path.Base(filepath)
70+
defer os.Remove(filename)
71+
72+
uploadManager := transfer.NewUploadManager()
73+
objectName := "sampleFileUploadObj"
74+
75+
req := transfer.UploadFileRequest{
76+
UploadRequest: transfer.UploadRequest{
77+
NamespaceName: common.String(namespace),
78+
BucketName: common.String(bname),
79+
ObjectName: common.String(objectName),
80+
//PartSize: common.Int(10000000),
81+
},
82+
FilePath: filepath,
83+
}
84+
85+
// if you want to overwrite default value, you can do it
86+
// as: transfer.UploadRequest.AllowMultipartUploads = common.Bool(false) // default is true
87+
// or: transfer.UploadRequest.AllowParrallelUploads = common.Bool(false) // default is true
88+
resp, err := uploadManager.UploadFile(ctx, req)
89+
90+
if err != nil && resp.IsResumable() {
91+
resp, err = uploadManager.ResumeUploadFile(ctx, *resp.MultipartUploadResponse.UploadID)
92+
if err != nil {
93+
fmt.Println(resp)
94+
}
95+
}
96+
97+
defer deleteObject(ctx, c, namespace, bname, objectName)
98+
fmt.Println("file uploaded")
99+
100+
// Output:
101+
// get namespace
102+
// create bucket
103+
// file uploaded
104+
// delete object
105+
// delete bucket
106+
}
107+
108+
func ExampleObjectStorage_UploadManager_Stream() {
109+
c, clerr := objectstorage.NewObjectStorageClientWithConfigurationProvider(common.DefaultConfigProvider())
110+
helpers.FatalIfError(clerr)
111+
112+
ctx := context.Background()
113+
bname := "bname"
114+
namespace := getNamespace(ctx, c)
115+
116+
createBucket(ctx, c, namespace, bname)
117+
defer deleteBucket(ctx, c, namespace, bname)
118+
119+
contentlen := 1024 * 1000 * 130 // 130MB
120+
filepath, _ := helpers.WriteTempFileOfSize(int64(contentlen))
121+
filename := path.Base(filepath)
122+
defer func() {
123+
os.Remove(filename)
124+
}()
125+
126+
uploadManager := transfer.NewUploadManager()
127+
objectName := "sampleStreamUploadObj"
128+
129+
file, _ := os.Open(filepath)
130+
defer file.Close()
131+
132+
req := transfer.UploadStreamRequest{
133+
UploadRequest: transfer.UploadRequest{
134+
NamespaceName: common.String(namespace),
135+
BucketName: common.String(bname),
136+
ObjectName: common.String(objectName),
137+
},
138+
StreamReader: file, // any struct implements the io.Reader interface
139+
}
140+
141+
// if you want to overwrite default value, you can do it
142+
// as: transfer.UploadRequest.AllowMultipartUploads = common.Bool(false) // default is true
143+
// or: transfer.UploadRequest.AllowParrallelUploads = common.Bool(false) // default is true
144+
_, err := uploadManager.UploadStream(context.Background(), req)
145+
146+
if err != nil {
147+
fmt.Println(err)
148+
}
149+
150+
defer deleteObject(ctx, c, namespace, bname, objectName)
151+
fmt.Println("stream uploaded")
152+
153+
// Output:
154+
// get namespace
155+
// create bucket
156+
// stream uploaded
157+
// delete object
158+
// delete bucket
159+
}
160+
59161
func getNamespace(ctx context.Context, c objectstorage.ObjectStorageClient) string {
60162
request := objectstorage.GetNamespaceRequest{}
61163
r, err := c.GetNamespace(ctx, request)
@@ -115,15 +217,3 @@ func deleteBucket(ctx context.Context, c objectstorage.ObjectStorageClient, name
115217
fmt.Println("delete bucket")
116218
return
117219
}
118-
119-
func writeTempFileOfSize(filesize int64) (fileName string, fileSize int64) {
120-
hash := sha256.New()
121-
f, _ := ioutil.TempFile("", "OCIGOSDKSampleFile")
122-
ra := rand.New(rand.NewSource(time.Now().UnixNano()))
123-
defer f.Close()
124-
writer := io.MultiWriter(f, hash)
125-
written, _ := io.CopyN(writer, ra, filesize)
126-
fileName = f.Name()
127-
fileSize = written
128-
return
129-
}

example/example_resourcemanager_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,4 @@ func deleteStack(ctx context.Context, stackID string, client resourcemanager.Res
115115
helpers.FatalIfError(err)
116116

117117
fmt.Println("delete stack completed")
118-
}
118+
}

example/example_retry_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func ExampleRetry() {
3838
}
3939

4040
nextDuration := func(r common.OCIOperationResponse) time.Duration {
41-
// you might want wait longer for next retry when your previouse one failed
41+
// you might want wait longer for next retry when your previous one failed
4242
// this function will return the duration as:
4343
// 1s, 2s, 4s, 8s, 16s, 32s, 64s etc...
4444
return time.Duration(math.Pow(float64(2), float64(r.AttemptNumber-1))) * time.Second

example/helpers/helper.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
package helpers
77

88
import (
9+
"crypto/sha256"
910
"fmt"
11+
"io"
12+
"io/ioutil"
1013
"log"
1114
"math"
1215
"math/rand"
@@ -151,3 +154,16 @@ func GetRandomString(n int) string {
151154
}
152155
return string(b)
153156
}
157+
158+
// WriteTempFileOfSize output random content to a file
159+
func WriteTempFileOfSize(filesize int64) (fileName string, fileSize int64) {
160+
hash := sha256.New()
161+
f, _ := ioutil.TempFile("", "OCIGOSDKSampleFile")
162+
ra := rand.New(rand.NewSource(time.Now().UnixNano()))
163+
defer f.Close()
164+
writer := io.MultiWriter(f, hash)
165+
written, _ := io.CopyN(writer, ra, filesize)
166+
fileName = f.Name()
167+
fileSize = written
168+
return
169+
}

loadbalancer/add_http_request_header_rule.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
)
1616

1717
// AddHttpRequestHeaderRule An object that represents the action of adding a header to a request.
18-
// This rule applies only to HTTP or HTTP2 listeners.
18+
// This rule applies only to HTTP listeners.
1919
// **NOTES:**
2020
// * If a matching header already exists in the request, the system removes all of its occurrences, and then adds the
2121
// new header.

loadbalancer/add_http_response_header_rule.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
)
1616

1717
// AddHttpResponseHeaderRule An object that represents the action of adding a header to a response.
18-
// This rule applies only to HTTP or HTTP2 listeners.
18+
// This rule applies only to HTTP listeners.
1919
// **NOTES:**
2020
// * If a matching header already exists in the response, the system removes all of its occurrences, and then adds the
2121
// new header.

0 commit comments

Comments
 (0)