Skip to content

Commit 4fed74a

Browse files
committed
release 5.5.0
2 parents 83aa58c + 37b16bc commit 4fed74a

31 files changed

+1636
-37
lines changed

CHANGELOG.md

+6
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

+6-4
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

+7-3
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

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/example_objectstorage_test.go

+107-17
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

+1-1
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

+1-1
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

+16
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

+1-1
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

+1-1
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.

loadbalancer/extend_http_request_header_value_rule.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/oracle/oci-go-sdk/common"
1515
)
1616

17-
// ExtendHttpRequestHeaderValueRule An object that represents the action of modifying a request header value. This rule applies only to HTTP or HTTP2 listeners.
17+
// ExtendHttpRequestHeaderValueRule An object that represents the action of modifying a request header value. This rule applies only to HTTP listeners.
1818
// This rule adds a prefix, a suffix, or both to the header value.
1919
// **NOTES:**
2020
// * This rule requires a value for a prefix, suffix, or both.

loadbalancer/extend_http_response_header_value_rule.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/oracle/oci-go-sdk/common"
1515
)
1616

17-
// ExtendHttpResponseHeaderValueRule An object that represents the action of modifying a response header value. This rule applies only to HTTP or HTTP2 listeners.
17+
// ExtendHttpResponseHeaderValueRule An object that represents the action of modifying a response header value. This rule applies only to HTTP listeners.
1818
// This rule adds a prefix, a suffix, or both to the header value.
1919
// **NOTES:**
2020
// * This rule requires a value for a prefix, suffix, or both.

loadbalancer/health_check_result.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type HealthCheckResult struct {
2020
SubnetId *string `mandatory:"true" json:"subnetId"`
2121

2222
// The IP address of the health check status report provider. This identifier helps you differentiate same-subnet
23-
// (private) load balancers that report health check status.
23+
// load balancers that report health check status.
2424
// Example: `10.0.0.7`
2525
SourceIpAddress *string `mandatory:"true" json:"sourceIpAddress"`
2626

loadbalancer/loadbalancer_client.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,8 @@ func (client LoadBalancerClient) createPathRouteSet(ctx context.Context, request
410410
return response, err
411411
}
412412

413-
// CreateRuleSet Creates a new rule set associated with the specified load balancer.
413+
// CreateRuleSet Creates a new rule set associated with the specified load balancer. For more information, see
414+
// Managing Rule Sets (https://docs.cloud.oracle.com/Content/Balance/Tasks/managingrulesets.htm).
414415
func (client LoadBalancerClient) CreateRuleSet(ctx context.Context, request CreateRuleSetRequest) (response CreateRuleSetResponse, err error) {
415416
var ociResponse common.OCIResponse
416417
policy := common.NoRetryPolicy()

loadbalancer/remove_http_request_header_rule.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/oracle/oci-go-sdk/common"
1515
)
1616

17-
// RemoveHttpRequestHeaderRule An object that represents the action of removing a header from a request. This rule applies only to HTTP or HTTP2 listeners.
17+
// RemoveHttpRequestHeaderRule An object that represents the action of removing a header from a request. This rule applies only to HTTP listeners.
1818
// If the same header appears more than once in the request, the load balancer removes all occurances of the specified header.
1919
// **NOTE:** The system does not distinquish between underscore and dash characters in headers. That is, it treats
2020
// `example_header_name` and `example-header-name` as identical. Oracle recommends that you do not rely on underscore

loadbalancer/remove_http_response_header_rule.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/oracle/oci-go-sdk/common"
1515
)
1616

17-
// RemoveHttpResponseHeaderRule An object that represents the action of removing a header from a response. This rule applies only to HTTP or HTTP2 listeners.
17+
// RemoveHttpResponseHeaderRule An object that represents the action of removing a header from a response. This rule applies only to HTTP listeners.
1818
// If the same header appears more than once in the response, the load balancer removes all occurances of the specified header.
1919
// **NOTE:** The system does not distinquish between underscore and dash characters in headers. That is, it treats
2020
// `example_header_name` and `example-header-name` as identical. Oracle recommends that you do not rely on underscore

loadbalancer/rule_set.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import (
1515
)
1616

1717
// RuleSet A named set of rules associated with a load balancer. Rules are objects that represent actions to apply to a listener,
18-
// such as adding, altering, or removing HTTP headers.
18+
// such as adding, altering, or removing HTTP headers. For more information, see
19+
// Managing Rule Sets (https://docs.cloud.oracle.com/Content/Balance/Tasks/managingrulesets.htm).
1920
type RuleSet struct {
2021

2122
// The name for this set of rules. It must be unique and it cannot be changed. Avoid entering

0 commit comments

Comments
 (0)