Skip to content

Commit ad5c34e

Browse files
authored
Merge pull request #29 in SDK/oci-go-sdk from merge_to_github2018-04-05-04-46-59 to github (#104)
Release V1.2.0
1 parent 37d08a7 commit ad5c34e

File tree

89 files changed

+2627
-43
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+2627
-43
lines changed

CHANGELOG.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ 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+
## 1.2.0 - 2018-04-05
8+
### Added
9+
- Support for Email Delivery Service. Example can be found on [Github](https://github.com/oracle/oci-go-sdk/tree/master/example/example_email_test.go)
10+
- Support for paravirtualized volume attachments in Core Services
11+
- Support for remote VCN peering across regions
12+
- Support for variable size boot volumes in Core Services
13+
- Support for SMTP credentials in the Identity Service
14+
- Support for tagging Bucket resources in the Object Storage Service
715

816
## 1.1.0 - 2018-03-27
917
### Added
@@ -23,4 +31,4 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
2331
- Support for Database service
2432
- Support for IAM service
2533
- Support for Load Balancing service
26-
- Suport for Object Storage service
34+
- Support for Object Storage service

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
DOC_SERVER_URL=https:\/\/docs.us-phoenix-1.oraclecloud.com
22

3-
GEN_TARGETS = identity core objectstorage loadbalancer database audit dns filestorage
3+
GEN_TARGETS = identity core objectstorage loadbalancer database audit dns filestorage email
44
NON_GEN_TARGETS = common common/auth
55
TARGETS = $(NON_GEN_TARGETS) $(GEN_TARGETS)
66

common/auth/configuration.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (p instancePrincipalConfigurationProvider) KeyID() (string, error) {
4242
}
4343

4444
func (p instancePrincipalConfigurationProvider) TenancyOCID() (string, error) {
45-
return "", nil
45+
return p.keyProvider.TenancyOCID()
4646
}
4747

4848
func (p instancePrincipalConfigurationProvider) UserOCID() (string, error) {

common/auth/instance_principal_key_provider.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const (
2727
type instancePrincipalKeyProvider struct {
2828
regionForFederationClient common.Region
2929
federationClient federationClient
30+
tenancyID string
3031
}
3132

3233
// newInstancePrincipalKeyProvider creates and returns an instancePrincipalKeyProvider instance based on
@@ -61,7 +62,7 @@ func newInstancePrincipalKeyProvider() (provider *instancePrincipalKeyProvider,
6162
federationClient := newX509FederationClient(
6263
region, tenancyID, leafCertificateRetriever, intermediateCertificateRetrievers)
6364

64-
provider = &instancePrincipalKeyProvider{regionForFederationClient: region, federationClient: federationClient}
65+
provider = &instancePrincipalKeyProvider{regionForFederationClient: region, federationClient: federationClient, tenancyID: tenancyID}
6566
return
6667
}
6768

@@ -93,3 +94,8 @@ func (p *instancePrincipalKeyProvider) KeyID() (string, error) {
9394
}
9495
return fmt.Sprintf("ST$%s", securityToken), nil
9596
}
97+
98+
99+
func (p *instancePrincipalKeyProvider) TenancyOCID() (string, error) {
100+
return p.tenancyID, nil
101+
}

common/http.go

+25-2
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,34 @@ func addToQuery(request *http.Request, value reflect.Value, field reflect.Struct
269269

270270
//if not mandatory and nil. Omit
271271
if !mandatory && isNil(value) {
272-
Debugf("Query parameter value is not mandatory and is nil pointer in field: %s. Skipping header", field.Name)
272+
Debugf("Query parameter value is not mandatory and is nil pointer in field: %s. Skipping query", field.Name)
273273
return
274274
}
275275

276-
if queryParameterValue, e = toStringValue(value, field); e != nil {
276+
encoding := strings.ToLower(field.Tag.Get("collectionFormat"))
277+
switch encoding {
278+
case "csv":
279+
if value.Kind() != reflect.Slice && value.Kind() != reflect.Array {
280+
e = fmt.Errorf("query paramater is tagged as csv yet its type is neither an Array nor a Slice: %s", field.Name)
281+
break
282+
}
283+
284+
numOfElements := value.Len()
285+
stringValues := make([]string, numOfElements)
286+
for i := 0; i < numOfElements; i++ {
287+
stringValues[i], e = toStringValue(value.Index(i), field)
288+
if e != nil {
289+
break
290+
}
291+
}
292+
queryParameterValue = strings.Join(stringValues, ",")
293+
case "":
294+
queryParameterValue, e = toStringValue(value, field)
295+
default:
296+
e = fmt.Errorf("encoding of type %s is not supported for query param: %s", encoding, field.Name)
297+
}
298+
299+
if e != nil {
277300
return
278301
}
279302

common/http_test.go

+42-6
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ type TestupdateUserDetails struct {
2828
}
2929

3030
type listCompartmentsRequest struct {
31-
CompartmentID string `mandatory:"true" contributesTo:"query" name:"compartmentId"`
32-
Page string `mandatory:"false" contributesTo:"query" name:"page"`
33-
Limit int32 `mandatory:"false" contributesTo:"query" name:"limit"`
31+
CompartmentID string `mandatory:"true" contributesTo:"query" name:"compartmentId"`
32+
Page string `mandatory:"false" contributesTo:"query" name:"page"`
33+
Limit int32 `mandatory:"false" contributesTo:"query" name:"limit"`
34+
Fields []string `mandatory:"true" contributesTo:"query" name:"fields" collectionFormat:"csv"`
3435
}
3536

3637
type updateUserRequest struct {
@@ -69,13 +70,15 @@ func TestHttpMarshallerInvalidStruct(t *testing.T) {
6970
}
7071

7172
func TestHttpRequestMarshallerQuery(t *testing.T) {
72-
s := listCompartmentsRequest{CompartmentID: "ocid1", Page: "p", Limit: 23}
73+
s := listCompartmentsRequest{CompartmentID: "ocid1", Page: "p", Limit: 23, Fields: []string{"one", "two", "three"}}
7374
request := MakeDefaultHTTPRequest(http.MethodPost, "/")
74-
HTTPRequestMarshaller(s, &request)
75+
e := HTTPRequestMarshaller(s, &request)
7576
query := request.URL.Query()
77+
assert.NoError(t, e)
7678
assert.True(t, query.Get("compartmentId") == "ocid1")
7779
assert.True(t, query.Get("page") == "p")
7880
assert.True(t, query.Get("limit") == "23")
81+
assert.True(t, query.Get("fields") == "one,two,three")
7982
}
8083

8184
func TestMakeDefault(t *testing.T) {
@@ -169,15 +172,19 @@ func TestHttpMarshallerEmptyPath(t *testing.T) {
169172

170173
func TestHttpMarshalerAll(t *testing.T) {
171174
desc := "theDescription"
175+
type inc string
176+
includes := []inc{inc("One"), inc("Two")}
177+
172178
s := struct {
173179
ID string `contributesTo:"path"`
174180
Name string `contributesTo:"query" name:"name"`
175181
When *SDKTime `contributesTo:"query" name:"when"`
176182
Income float32 `contributesTo:"query" name:"income"`
183+
Include []inc `contributesTo:"query" name:"includes" collectionFormat:"csv"`
177184
Male bool `contributesTo:"header" name:"male"`
178185
Details TestupdateUserDetails `contributesTo:"body"`
179186
}{
180-
"101", "tapir", now(), 3.23, true, TestupdateUserDetails{Description: desc},
187+
"101", "tapir", now(), 3.23, includes, true, TestupdateUserDetails{Description: desc},
181188
}
182189
request := MakeDefaultHTTPRequest(http.MethodPost, "/")
183190
e := HTTPRequestMarshaller(s, &request)
@@ -190,6 +197,7 @@ func TestHttpMarshalerAll(t *testing.T) {
190197
assert.True(t, request.URL.Query().Get("name") == s.Name)
191198
assert.True(t, request.URL.Query().Get("income") == strconv.FormatFloat(float64(s.Income), 'f', 6, 32))
192199
assert.True(t, request.URL.Query().Get("when") == when)
200+
assert.True(t, request.URL.Query().Get("includes") == "One,Two")
193201
assert.Contains(t, content, "description")
194202
assert.Equal(t, request.Header.Get("Content-Type"), "application/json")
195203
if val, ok := content["description"]; !ok || val != desc {
@@ -678,6 +686,34 @@ func TestEmptyQueryParam(t *testing.T) {
678686
assert.NotContains(t, r.URL.RawQuery, "meta")
679687
}
680688

689+
type responseWithWrongCsvType struct {
690+
Meta string `contributesTo:"query" omitEmpty:"true" name:"meta"`
691+
QParam string `contributesTo:"query" omitEmpty:"false" name:"qp"`
692+
QParam2 string `contributesTo:"query" name:"qp2"`
693+
QParam3 map[string]string `contributesTo:"query" name:"qp2" collectionFormat:"csv"`
694+
}
695+
696+
func TestWrongTypeQueryParamEncodingWrongType(t *testing.T) {
697+
m := make(map[string]string)
698+
m["one"] = "one"
699+
s := responseWithWrongCsvType{QParam3: m}
700+
_, err := MakeDefaultHTTPRequestWithTaggedStruct("GET", "/", s)
701+
assert.Error(t, err)
702+
}
703+
704+
type responseUnsupportedQueryEncoding struct {
705+
Meta string `contributesTo:"query" omitEmpty:"true" name:"meta"`
706+
QParam string `contributesTo:"query" omitEmpty:"false" name:"qp"`
707+
QParam2 string `contributesTo:"query" name:"qp2"`
708+
QParam3 []string `contributesTo:"query" name:"qp2" collectionFormat:"xml"`
709+
}
710+
711+
func TestWrongTypeQueryParamWrongEncoding(t *testing.T) {
712+
s := responseUnsupportedQueryEncoding{QParam3: []string{"one ", "two"}}
713+
_, err := MakeDefaultHTTPRequestWithTaggedStruct("GET", "/", s)
714+
assert.Error(t, err)
715+
}
716+
681717
func TestOmitFieldsInJson_SimpleStruct(t *testing.T) {
682718
type Nested struct {
683719
N *string `mandatory:"false" json:"n"`

common/version.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
2+
// Code generated. DO NOT EDIT.
3+
4+
// Core Services API
5+
//
6+
// APIs for Networking Service, Compute Service, and Block Volume Service.
7+
//
8+
9+
package core
10+
11+
import (
12+
"encoding/json"
13+
"github.com/oracle/oci-go-sdk/common"
14+
)
15+
16+
// AttachParavirtualizedVolumeDetails The representation of AttachParavirtualizedVolumeDetails
17+
type AttachParavirtualizedVolumeDetails struct {
18+
19+
// The OCID of the instance.
20+
InstanceId *string `mandatory:"true" json:"instanceId"`
21+
22+
// The OCID of the volume.
23+
VolumeId *string `mandatory:"true" json:"volumeId"`
24+
25+
// A user-friendly name. Does not have to be unique, and it cannot be changed. Avoid entering confidential information.
26+
DisplayName *string `mandatory:"false" json:"displayName"`
27+
28+
// Whether the attachment was created in read-only mode.
29+
IsReadOnly *bool `mandatory:"false" json:"isReadOnly"`
30+
}
31+
32+
//GetDisplayName returns DisplayName
33+
func (m AttachParavirtualizedVolumeDetails) GetDisplayName() *string {
34+
return m.DisplayName
35+
}
36+
37+
//GetInstanceId returns InstanceId
38+
func (m AttachParavirtualizedVolumeDetails) GetInstanceId() *string {
39+
return m.InstanceId
40+
}
41+
42+
//GetIsReadOnly returns IsReadOnly
43+
func (m AttachParavirtualizedVolumeDetails) GetIsReadOnly() *bool {
44+
return m.IsReadOnly
45+
}
46+
47+
//GetVolumeId returns VolumeId
48+
func (m AttachParavirtualizedVolumeDetails) GetVolumeId() *string {
49+
return m.VolumeId
50+
}
51+
52+
func (m AttachParavirtualizedVolumeDetails) String() string {
53+
return common.PointerString(m)
54+
}
55+
56+
// MarshalJSON marshals to json representation
57+
func (m AttachParavirtualizedVolumeDetails) MarshalJSON() (buff []byte, e error) {
58+
type MarshalTypeAttachParavirtualizedVolumeDetails AttachParavirtualizedVolumeDetails
59+
s := struct {
60+
DiscriminatorParam string `json:"type"`
61+
MarshalTypeAttachParavirtualizedVolumeDetails
62+
}{
63+
"paravirtualized",
64+
(MarshalTypeAttachParavirtualizedVolumeDetails)(m),
65+
}
66+
67+
return json.Marshal(&s)
68+
}

core/attach_volume_details.go

+4
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ func (m *attachvolumedetails) UnmarshalPolymorphicJSON(data []byte) (interface{}
6666
mm := AttachIScsiVolumeDetails{}
6767
err = json.Unmarshal(data, &mm)
6868
return mm, err
69+
case "paravirtualized":
70+
mm := AttachParavirtualizedVolumeDetails{}
71+
err = json.Unmarshal(data, &mm)
72+
return mm, err
6973
default:
7074
return m, nil
7175
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
2+
// Code generated. DO NOT EDIT.
3+
4+
// Core Services API
5+
//
6+
// APIs for Networking Service, Compute Service, and Block Volume Service.
7+
//
8+
9+
package core
10+
11+
import (
12+
"github.com/oracle/oci-go-sdk/common"
13+
)
14+
15+
// ConnectRemotePeeringConnectionsDetails Information about the other remote peering connection (RPC).
16+
type ConnectRemotePeeringConnectionsDetails struct {
17+
18+
// The OCID of the RPC you want to peer with.
19+
PeerId *string `mandatory:"true" json:"peerId"`
20+
21+
// The name of the region that contains the RPC you want to peer with.
22+
// Example: `us-ashburn-1`
23+
PeerRegionName *string `mandatory:"true" json:"peerRegionName"`
24+
}
25+
26+
func (m ConnectRemotePeeringConnectionsDetails) String() string {
27+
return common.PointerString(m)
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
2+
// Code generated. DO NOT EDIT.
3+
4+
package core
5+
6+
import (
7+
"github.com/oracle/oci-go-sdk/common"
8+
"net/http"
9+
)
10+
11+
// ConnectRemotePeeringConnectionsRequest wrapper for the ConnectRemotePeeringConnections operation
12+
type ConnectRemotePeeringConnectionsRequest struct {
13+
14+
// The OCID of the remote peering connection (RPC).
15+
RemotePeeringConnectionId *string `mandatory:"true" contributesTo:"path" name:"remotePeeringConnectionId"`
16+
17+
// Details to connect peering connection with peering connection from remote region
18+
ConnectRemotePeeringConnectionsDetails `contributesTo:"body"`
19+
}
20+
21+
func (request ConnectRemotePeeringConnectionsRequest) String() string {
22+
return common.PointerString(request)
23+
}
24+
25+
// ConnectRemotePeeringConnectionsResponse wrapper for the ConnectRemotePeeringConnections operation
26+
type ConnectRemotePeeringConnectionsResponse struct {
27+
28+
// The underlying http response
29+
RawResponse *http.Response
30+
31+
// Unique Oracle-assigned identifier for the request. If you need to contact Oracle about
32+
// a particular request, please provide the request ID.
33+
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
34+
}
35+
36+
func (response ConnectRemotePeeringConnectionsResponse) String() string {
37+
return common.PointerString(response)
38+
}

core/core_compute_client.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,8 @@ func (m *listvolumeattachment) UnmarshalPolymorphicJSON(data []byte) (interface{
737737

738738
// ListVolumeAttachments Lists the volume attachments in the specified compartment. You can filter the
739739
// list by specifying an instance OCID, volume OCID, or both.
740-
// Currently, the only supported volume attachment type is IScsiVolumeAttachment.
740+
// Currently, the only supported volume attachment type are IScsiVolumeAttachment and
741+
// ParavirtualizedVolumeAttachment.
741742
func (client ComputeClient) ListVolumeAttachments(ctx context.Context, request ListVolumeAttachmentsRequest) (response ListVolumeAttachmentsResponse, err error) {
742743
httpRequest, err := common.MakeDefaultHTTPRequestWithTaggedStruct(http.MethodGet, "/volumeAttachments/", request)
743744
if err != nil {

0 commit comments

Comments
 (0)