Skip to content

Commit c4639e5

Browse files
authored
Release v2.2.0
Squashed commit of the following: commit 840f35432a5d72bda5c45469a2b03bb8dc782b9b Author: Jason Yin <[email protected]> Date: Wed Aug 8 22:13:25 2018 +0000 Releasing v2.2.0
1 parent b98b8fe commit c4639e5

9 files changed

+112
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ 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+
## 2.2.0 - 2018-07-26
8+
### Added
9+
- Support for fault domains in the Compute service
10+
- A sample showing how to use Search service from the SDK is available on [Github](https://github.com/oracle/oci-go-sdk/tree/master/example/example_resourcesearch_test.go)
11+
712
## 2.1.0 - 2018-07-26
813
### Added
914
- Support for the OCI Search service

common/http.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"io/ioutil"
1111
"net/http"
1212
"net/url"
13-
"path"
1413
"reflect"
1514
"regexp"
1615
"strconv"
@@ -366,8 +365,7 @@ func addToPath(request *http.Request, value reflect.Value, field reflect.StructF
366365
if !templatedPathRegex.MatchString(currentURLPath) {
367366
Debugln("Marshaling request to path by appending field:", field.Name)
368367
allPath := []string{currentURLPath, additionalURLPathPart}
369-
newPath := strings.Join(allPath, "/")
370-
request.URL.Path = path.Clean(newPath)
368+
request.URL.Path = strings.Join(allPath, "/")
371369
} else {
372370
var fieldName string
373371
if fieldName = field.Tag.Get("name"); fieldName == "" {
@@ -376,7 +374,7 @@ func addToPath(request *http.Request, value reflect.Value, field reflect.StructF
376374
}
377375
urlTemplate := currentURLPath
378376
Debugln("Marshaling to path from field:", field.Name, "in template:", urlTemplate)
379-
request.URL.Path = path.Clean(strings.Replace(urlTemplate, "{"+fieldName+"}", additionalURLPathPart, -1))
377+
request.URL.Path = strings.Replace(urlTemplate, "{"+fieldName+"}", additionalURLPathPart, -1)
380378
}
381379
return
382380
}

common/http_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ func TestHttpMarshalerAll(t *testing.T) {
207207
body, _ := ioutil.ReadAll(request.Body)
208208
json.Unmarshal(body, &content)
209209
when := s.When.Format(time.RFC3339)
210-
assert.True(t, request.URL.Path == "/101")
210+
assert.True(t, request.URL.Path == "//101")
211211
assert.True(t, request.URL.Query().Get("name") == s.Name)
212212
assert.True(t, request.URL.Query().Get("income") == strconv.FormatFloat(float64(s.Income), 'f', 6, 32))
213213
assert.True(t, request.URL.Query().Get("when") == when)

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.

core/create_boot_volume_details.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ type CreateBootVolumeDetails struct {
2727
// This is a mandatory field for a boot volume.
2828
SourceDetails BootVolumeSourceDetails `mandatory:"true" json:"sourceDetails"`
2929

30+
// If provided, specifies the ID of the boot volume backup policy to assign to the newly
31+
// created boot volume. If omitted, no policy will be assigned.
32+
BackupPolicyId *string `mandatory:"false" json:"backupPolicyId"`
33+
3034
// Defined tags for this resource. Each key is predefined and scoped to a namespace.
3135
// For more information, see Resource Tags (https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm).
3236
// Example: `{"Operations": {"CostCenter": "42"}}`
@@ -53,6 +57,7 @@ func (m CreateBootVolumeDetails) String() string {
5357
// UnmarshalJSON unmarshals from json
5458
func (m *CreateBootVolumeDetails) UnmarshalJSON(data []byte) (e error) {
5559
model := struct {
60+
BackupPolicyId *string `json:"backupPolicyId"`
5661
DefinedTags map[string]map[string]interface{} `json:"definedTags"`
5762
DisplayName *string `json:"displayName"`
5863
FreeformTags map[string]string `json:"freeformTags"`
@@ -66,6 +71,7 @@ func (m *CreateBootVolumeDetails) UnmarshalJSON(data []byte) (e error) {
6671
if e != nil {
6772
return
6873
}
74+
m.BackupPolicyId = model.BackupPolicyId
6975
m.DefinedTags = model.DefinedTags
7076
m.DisplayName = model.DisplayName
7177
m.FreeformTags = model.FreeformTags

core/instance.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ type Instance struct {
6262
// They are distinguished from 'metadata' fields in that these can be nested JSON objects (whereas 'metadata' fields are string/string maps only).
6363
ExtendedMetadata map[string]interface{} `mandatory:"false" json:"extendedMetadata"`
6464

65+
// The name of the Fault Domain the instance is running in.
66+
// A Fault Domain is a logical grouping of hardware and infrastructure within an Availability Domain that can become
67+
// unavailable in its entirety either due to hardware failure such as Top-of-rack (TOR) switch failure or due to
68+
// planned software maintenance such as security updates that reboot your instances.
69+
// Example: `FAULT-DOMAIN-1`
70+
FaultDomain *string `mandatory:"false" json:"faultDomain"`
71+
6572
// Free-form tags for this resource. Each tag is a simple key-value pair with no
6673
// predefined name, type, or namespace. For more information, see
6774
// Resource Tags (https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm).
@@ -116,6 +123,7 @@ func (m *Instance) UnmarshalJSON(data []byte) (e error) {
116123
DefinedTags map[string]map[string]interface{} `json:"definedTags"`
117124
DisplayName *string `json:"displayName"`
118125
ExtendedMetadata map[string]interface{} `json:"extendedMetadata"`
126+
FaultDomain *string `json:"faultDomain"`
119127
FreeformTags map[string]string `json:"freeformTags"`
120128
ImageId *string `json:"imageId"`
121129
IpxeScript *string `json:"ipxeScript"`
@@ -139,6 +147,7 @@ func (m *Instance) UnmarshalJSON(data []byte) (e error) {
139147
m.DefinedTags = model.DefinedTags
140148
m.DisplayName = model.DisplayName
141149
m.ExtendedMetadata = model.ExtendedMetadata
150+
m.FaultDomain = model.FaultDomain
142151
m.FreeformTags = model.FreeformTags
143152
m.ImageId = model.ImageId
144153
m.IpxeScript = model.IpxeScript

core/launch_instance_details.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ type LaunchInstanceDetails struct {
4747
// They are distinguished from 'metadata' fields in that these can be nested JSON objects (whereas 'metadata' fields are string/string maps only).
4848
ExtendedMetadata map[string]interface{} `mandatory:"false" json:"extendedMetadata"`
4949

50+
// The name of the Fault Domain in which to launch an instance.
51+
// To get a list of Fault Domains, use the ListFaultDomains
52+
// operation in the Identity and Access Management Service API.
53+
// Example: `FAULT-DOMAIN-1`
54+
FaultDomain *string `mandatory:"false" json:"faultDomain"`
55+
5056
// Free-form tags for this resource. Each tag is a simple key-value pair with no
5157
// predefined name, type, or namespace. For more information, see
5258
// Resource Tags (https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm).
@@ -149,6 +155,7 @@ func (m *LaunchInstanceDetails) UnmarshalJSON(data []byte) (e error) {
149155
DefinedTags map[string]map[string]interface{} `json:"definedTags"`
150156
DisplayName *string `json:"displayName"`
151157
ExtendedMetadata map[string]interface{} `json:"extendedMetadata"`
158+
FaultDomain *string `json:"faultDomain"`
152159
FreeformTags map[string]string `json:"freeformTags"`
153160
HostnameLabel *string `json:"hostnameLabel"`
154161
ImageId *string `json:"imageId"`
@@ -169,6 +176,7 @@ func (m *LaunchInstanceDetails) UnmarshalJSON(data []byte) (e error) {
169176
m.DefinedTags = model.DefinedTags
170177
m.DisplayName = model.DisplayName
171178
m.ExtendedMetadata = model.ExtendedMetadata
179+
m.FaultDomain = model.FaultDomain
172180
m.FreeformTags = model.FreeformTags
173181
m.HostnameLabel = model.HostnameLabel
174182
m.ImageId = model.ImageId

example/example_objectstorage_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func ExampleObjectStorage_UploadFile() {
4444
defer file.Close()
4545
helpers.FatalIfError(e)
4646

47-
e = putObject(ctx, c, namespace, bname, filename, int(filesize), file, nil)
47+
e = putObject(ctx, c, namespace, bname, filename, filesize, file, nil)
4848
helpers.FatalIfError(e)
4949
defer deleteObject(ctx, c, namespace, bname, filename)
5050

@@ -64,7 +64,7 @@ func getNamespace(ctx context.Context, c objectstorage.ObjectStorageClient) stri
6464
return *r.Value
6565
}
6666

67-
func putObject(ctx context.Context, c objectstorage.ObjectStorageClient, namespace, bucketname, objectname string, contentLen int, content io.ReadCloser, metadata map[string]string) error {
67+
func putObject(ctx context.Context, c objectstorage.ObjectStorageClient, namespace, bucketname, objectname string, contentLen int64, content io.ReadCloser, metadata map[string]string) error {
6868
request := objectstorage.PutObjectRequest{
6969
NamespaceName: &namespace,
7070
BucketName: &bucketname,
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
2+
// Code generated. DO NOT EDIT.
3+
4+
// Example for Resource Search Service
5+
//
6+
// Search for resources across your cloud infrastructure
7+
8+
package example
9+
10+
import (
11+
"context"
12+
"fmt"
13+
"log"
14+
15+
"github.com/oracle/oci-go-sdk/common"
16+
"github.com/oracle/oci-go-sdk/example/helpers"
17+
"github.com/oracle/oci-go-sdk/resourcesearch"
18+
)
19+
20+
func Example_ResourceSearch() {
21+
client, err := resourcesearch.NewResourceSearchClientWithConfigurationProvider(common.DefaultConfigProvider())
22+
ctx := context.Background()
23+
helpers.FatalIfError(err)
24+
25+
// list resource types
26+
listReq := resourcesearch.ListResourceTypesRequest{}
27+
listResp, err := client.ListResourceTypes(ctx, listReq)
28+
fmt.Println("list resource types")
29+
30+
for _, element := range listResp.Items {
31+
log.Printf("Resource: %s", *element.Name)
32+
}
33+
34+
// get group type details
35+
getReq := resourcesearch.GetResourceTypeRequest{
36+
Name: common.String("Group"),
37+
}
38+
getResp, err := client.GetResourceType(context.Background(), getReq)
39+
helpers.FatalIfError(err)
40+
fmt.Println("get group type details")
41+
log.Printf("Resource type: %s", getResp.ResourceType)
42+
43+
// search resource by freetext
44+
searchReq := resourcesearch.SearchResourcesRequest{
45+
SearchDetails: resourcesearch.FreeTextSearchDetails{
46+
Text: common.String("displayname"),
47+
},
48+
}
49+
50+
freeSearchResp, err := client.SearchResources(context.Background(), searchReq)
51+
helpers.FatalIfError(err)
52+
fmt.Println("search resource by freetext")
53+
54+
for _, element := range freeSearchResp.Items {
55+
log.Printf("Resource: %s", element)
56+
}
57+
58+
searchReq.SearchDetails = resourcesearch.StructuredSearchDetails{
59+
MatchingContextType: resourcesearch.SearchDetailsMatchingContextTypeHighlights,
60+
Query: common.String("query all resources"),
61+
}
62+
63+
structureSearchResp, err := client.SearchResources(context.Background(), searchReq)
64+
helpers.FatalIfError(err)
65+
66+
// search resource by structured query
67+
fmt.Println("search resource by structured query")
68+
69+
for _, element := range structureSearchResp.Items {
70+
log.Printf("Resource: %s", element)
71+
}
72+
73+
// Output:
74+
// list resource types
75+
// get group type details
76+
// search resource by freetext
77+
// search resource by structured query
78+
}

0 commit comments

Comments
 (0)