Skip to content

Commit

Permalink
feat(2022-05-31): updated the sdk as per the 2022-05-31 api version (#52
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ujjwal-ibm authored Jun 3, 2022
1 parent cf9e879 commit f545b65
Show file tree
Hide file tree
Showing 9 changed files with 1,336 additions and 857 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/IBM/vpc-go-sdk)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

# IBM Cloud VPC Go SDK Version 0.19.0
# IBM Cloud VPC Go SDK Version 0.20.0
Go client library to interact with the various [IBM Cloud VPC Services APIs](https://cloud.ibm.com/apidocs?category=vpc).

**Note:** Given the current version of all VPC SDKs across supported languages and the current VPC API specification, we retracted the vpc-go-sdk version 1.x to version v0.6.0, which had the same features as v1.0.1.
Consider using v0.19.0 from now on. Refrain from using commands like `go get -u ..` and `go get ..@latest` on go 1.14 and lower as you will not get the latest release.
Consider using v0.20.0 from now on. Refrain from using commands like `go get -u ..` and `go get ..@latest` on go 1.14 and lower as you will not get the latest release.

This SDK uses [Semantic Versioning](https://semver.org), and as such there may be backward-incompatible changes for any new `0.y.z` version.
## Table of Contents
Expand Down Expand Up @@ -64,7 +64,7 @@ Use this command to download and install the VPC Go SDK service to allow your Go
use it:

```
go get github.com/IBM/vpc-go-sdk@v0.19.0
go get github.com/IBM/vpc-go-sdk@v0.20.0
```


Expand All @@ -90,7 +90,7 @@ to your `Gopkg.toml` file. Here is an example:
```
[[constraint]]
name = "github.com/IBM/vpc-go-sdk/"
version = "0.19.0"
version = "0.20.0"
```

Then run `dep ensure`.
Expand Down
2 changes: 1 addition & 1 deletion common/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package common

// Version of the SDK
const Version = "0.19.0"
const Version = "0.20.0"
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/IBM/vpc-go-sdk
go 1.16

require (
github.com/IBM/go-sdk-core/v5 v5.9.2
github.com/IBM/go-sdk-core/v5 v5.9.5
github.com/go-openapi/strfmt v0.21.1
github.com/onsi/ginkgo v1.14.2
github.com/onsi/gomega v1.10.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/IBM/go-sdk-core/v5 v5.9.2 h1:QKB5JwhlZfRvFHqcOwMeu/Dis/Q7qCBxrQLhx04onMc=
github.com/IBM/go-sdk-core/v5 v5.9.2/go.mod h1:YlOwV9LeuclmT/qi/LAK2AsobbAP42veV0j68/rlZsE=
github.com/IBM/go-sdk-core/v5 v5.9.5 h1:+uMyHpOyBlFFd/I0PB+7JqqXOPY2DzRR0tbBjTc4d/g=
github.com/IBM/go-sdk-core/v5 v5.9.5/go.mod h1:YlOwV9LeuclmT/qi/LAK2AsobbAP42veV0j68/rlZsE=
github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef h1:46PFijGLmAjMPwCCCo7Jf0W6f9slllCkkv7vyc1yOSg=
github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
Expand Down
1,391 changes: 902 additions & 489 deletions vpcv1/vpc_v1.go

Large diffs are not rendered by default.

54 changes: 34 additions & 20 deletions vpcv1/vpc_v1_examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ var (
volumeAttachmentID string
reservedIPID string
reservedIPID2 string
ifMatchVolume string
ifMatchSnapshot string
instanceTemplateID string
instanceGroupID string
instanceGroupManagerID string
Expand Down Expand Up @@ -1251,17 +1253,20 @@ var _ = Describe(`VpcV1 Examples Tests`, func() {
Expect(err).To(BeNil())
Expect(response.StatusCode).To(Equal(200))
Expect(volume).ToNot(BeNil())

ifMatchVolume = response.GetHeaders()["Etag"][0]
})
It(`UpdateVolume request example`, func() {
fmt.Println("\nUpdateVolume() result:")
name := getName("vol")
userTags := []string{"usertag-vol-1"}
// begin-update_volume

options := &vpcv1.UpdateVolumeOptions{}
options.SetID(volumeID)
options.SetIfMatch(ifMatchVolume)
volumePatchModel := &vpcv1.VolumePatch{
Name: &name,
Name: &name,
UserTags: userTags,
}
volumePatch, asPatchErr := volumePatchModel.AsPatch()
if asPatchErr != nil {
Expand Down Expand Up @@ -2672,27 +2677,32 @@ var _ = Describe(`VpcV1 Examples Tests`, func() {
})
It(`CreateSnapshot request example`, func() {
fmt.Println("\nCreateSnapshot() result:")
name := getName("snapshotOne")
secondSnap := &vpcv1.CreateSnapshotOptions{
Name: &name,
SourceVolume: &vpcv1.VolumeIdentityByID{
ID: &volumeID,
},
name := getName("snapshotone")
volumeIdentityModel := &vpcv1.VolumeIdentityByID{
ID: &volumeID,
}
_, _, err := vpcService.CreateSnapshot(secondSnap)
secondSnap := &vpcv1.SnapshotPrototypeSnapshotBySourceVolume{
Name: &name,
SourceVolume: volumeIdentityModel,
}
secondCreateSnapshotOptions := vpcService.NewCreateSnapshotOptions(
secondSnap,
)
_, _, err := vpcService.CreateSnapshot(secondCreateSnapshotOptions)
if err != nil {
panic(err)
}
Expect(err).To(BeNil())
name = getName("snapshotTwo")
name = getName("snapshottwo")
// begin-create_snapshot
options := &vpcv1.CreateSnapshotOptions{
Name: &name,
SourceVolume: &vpcv1.VolumeIdentityByID{
ID: &volumeID,
},
options := &vpcv1.SnapshotPrototypeSnapshotBySourceVolume{
Name: &name,
SourceVolume: volumeIdentityModel,
}
snapshot, response, err := vpcService.CreateSnapshot(options)
createSnapshotOptions := vpcService.NewCreateSnapshotOptions(
options,
)
snapshot, response, err := vpcService.CreateSnapshot(createSnapshotOptions)

// end-create_snapshot
if err != nil {
Expand All @@ -2719,15 +2729,17 @@ var _ = Describe(`VpcV1 Examples Tests`, func() {
Expect(err).To(BeNil())
Expect(response.StatusCode).To(Equal(200))
Expect(snapshot).ToNot(BeNil())

ifMatchSnapshot = response.GetHeaders()["Etag"][0]
})
It(`UpdateSnapshot request example`, func() {
fmt.Println("\nUpdateSnapshot() result:")
name := getName("snapshot")
userTags := []string{"usertag-snap-1"}
// begin-update_snapshot

snapshotPatchModel := &vpcv1.SnapshotPatch{
Name: &name,
Name: &name,
UserTags: userTags,
}
snapshotPatchModelAsPatch, asPatchErr := snapshotPatchModel.AsPatch()
if asPatchErr != nil {
Expand All @@ -2736,6 +2748,7 @@ var _ = Describe(`VpcV1 Examples Tests`, func() {
updateSnapshotOptions := &vpcv1.UpdateSnapshotOptions{
ID: &snapshotID,
SnapshotPatch: snapshotPatchModelAsPatch,
IfMatch: &ifMatchSnapshot,
}
snapshot, response, err := vpcService.UpdateSnapshot(updateSnapshotOptions)

Expand Down Expand Up @@ -3813,7 +3826,6 @@ var _ = Describe(`VpcV1 Examples Tests`, func() {
// begin-list_bare_metal_servers

listBareMetalServersOptions := &vpcv1.ListBareMetalServersOptions{}
listBareMetalServersOptions.SetSort("name")

bareMetalServerCollection, response, err := vpcService.ListBareMetalServers(listBareMetalServersOptions)
if err != nil {
Expand Down Expand Up @@ -5541,6 +5553,7 @@ var _ = Describe(`VpcV1 Examples Tests`, func() {

options := &vpcv1.DeleteVolumeOptions{}
options.SetID(volumeID)
options.SetIfMatch(ifMatchVolume)
response, err := vpcService.DeleteVolume(options)

// end-delete_volume
Expand Down Expand Up @@ -5734,7 +5747,8 @@ var _ = Describe(`VpcV1 Examples Tests`, func() {
It(`DeleteSnapshot request example`, func() {
// begin-delete_snapshot
options := &vpcv1.DeleteSnapshotOptions{
ID: &snapshotID,
ID: &snapshotID,
IfMatch: &ifMatchSnapshot,
}
response, err := vpcService.DeleteSnapshot(options)

Expand Down
40 changes: 12 additions & 28 deletions vpcv1/vpc_v1_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ var (
createdFlowLogID *string
createdVolAttachmentID *string
createdVolumeID *string
ifMatchVolume string
createdVpcAddressPrefixID *string
createdSubnetReservedIP *string
createdVpcID *string
Expand Down Expand Up @@ -418,8 +419,9 @@ func TestVPCResources(t *testing.T) {
})

t.Run("Get Volume", func(t *testing.T) {
res, _, err := GetVolume(vpcService, *createdVolumeID)
res, response, err := GetVolume(vpcService, *createdVolumeID)
ValidateResponse(t, res, err, GET, detailed, increment)
ifMatchVolume = response.GetHeaders()["Etag"][0]
})

t.Run("Get Image", func(t *testing.T) {
Expand Down Expand Up @@ -625,7 +627,8 @@ func TestVPCResources(t *testing.T) {

t.Run("Update Volume", func(t *testing.T) {
name := getName("vol-2")
res, _, err := UpdateVolume(vpcService, *createdVolumeID, name)
userTags := []string{"volume-usertag"}
res, _, err := UpdateVolume(vpcService, userTags, *createdVolumeID, name, ifMatchVolume)
ValidateResponse(t, res, err, PATCH, detailed, increment)
})
})
Expand Down Expand Up @@ -795,7 +798,6 @@ func TestVPCSecurityGroups(t *testing.T) {
t.Error(err)
}
var defaultVpcID = res.Instances[0].VPC.ID
var defaultVnicID = res.Instances[0].PrimaryNetworkInterface.ID

reslb, _, err := ListLoadBalancers(vpcService)
if err != nil {
Expand All @@ -813,11 +815,6 @@ func TestVPCSecurityGroups(t *testing.T) {
sgID = res.SecurityGroups[0].ID
})

t.Run("List Security Group Network Interfaces", func(t *testing.T) {
res, _, err := ListSecurityGroupNetworkInterfaces(vpcService, *sgID)
ValidateListResponse(t, res, err, GET, detailed, increment)
})

t.Run("List Security Group Rules", func(t *testing.T) {
res, _, err := ListSecurityGroupRules(vpcService, *sgID)
ValidateListResponse(t, res, err, GET, detailed, increment)
Expand All @@ -842,12 +839,6 @@ func TestVPCSecurityGroups(t *testing.T) {
createdSgTargetID = sgtarget.ID
})

t.Run("Create Security Group Network Interface", func(t *testing.T) {
res, _, err := CreateSecurityGroupNetworkInterfaceBinding(vpcService, *createdSgID, *defaultVnicID)
ValidateResponse(t, res, err, POST, detailed, increment)
createdSgVnicID = res.ID
})

t.Run("Create Security Group Rule", func(t *testing.T) {
res, _, err := CreateSecurityGroupRule(vpcService, *createdSgID)
sgRule, _ := res.(*vpcv1.SecurityGroupRuleSecurityGroupRuleProtocolAll)
Expand All @@ -865,11 +856,6 @@ func TestVPCSecurityGroups(t *testing.T) {
ValidateResponse(t, res, err, GET, detailed, increment)
})

t.Run("Get Security Group Network Interface", func(t *testing.T) {
res, _, err := GetSecurityGroupNetworkInterface(vpcService, *createdSgID, *defaultVnicID)
ValidateResponse(t, res, err, GET, detailed, increment)
})

t.Run("Get Security Group Rules", func(t *testing.T) {
res, _, err := GetSecurityGroupRule(vpcService, *createdSgID, *createdSgRuleID)
ValidateResponse(t, res, err, GET, detailed, increment)
Expand All @@ -886,11 +872,6 @@ func TestVPCSecurityGroups(t *testing.T) {
ValidateResponse(t, res, err, PATCH, detailed, increment)
})

t.Run("Delete Security Group Network Interface", func(t *testing.T) {
res, err := DeleteSecurityGroupNetworkInterfaceBinding(vpcService, *createdSgID, *defaultVnicID)
ValidateDeleteResponse(t, res, err, DELETE, res.StatusCode, detailed, increment)
})

t.Run("Delete Security Group Rule", func(t *testing.T) {
res, err := DeleteSecurityGroupRule(vpcService, *createdSgID, *createdSgRuleID)
ValidateDeleteResponse(t, res, err, DELETE, res.StatusCode, detailed, increment)
Expand Down Expand Up @@ -1772,6 +1753,8 @@ func TestVPCRoutingTables(t *testing.T) {
func TestVPCSnapshots(t *testing.T) {
vpcService := createVpcService(t)
var snapshotID string
userTags := []string{"snapshot-usertag"}
var ifMatch string
if *defaultVpcID == "" {
res, _, err := ListInstances(vpcService)
if err != nil {
Expand All @@ -1797,18 +1780,19 @@ func TestVPCSnapshots(t *testing.T) {
})

t.Run("Get Snapshot", func(t *testing.T) {
res, _, err := GetSnapshot(vpcService, snapshotID)
res, response, err := GetSnapshot(vpcService, snapshotID)
ValidateResponse(t, res, err, GET, detailed, increment)
ifMatch = response.GetHeaders()["Etag"][0]
})

t.Run("Update Snapshot", func(t *testing.T) {
name := "gsdk-snap-" + timestamp
res, _, err := UpdateSnapshot(vpcService, snapshotID, name)
res, _, err := UpdateSnapshot(vpcService, userTags, snapshotID, name, ifMatch)
ValidateResponse(t, res, err, PATCH, detailed, increment)
})

t.Run("Delete Snapshot", func(t *testing.T) {
res, err := DeleteSnapshot(vpcService, snapshotID)
res, err := DeleteSnapshot(vpcService, snapshotID, ifMatch)
ValidateDeleteResponse(t, res, err, DELETE, res.StatusCode, detailed, increment)
})

Expand Down Expand Up @@ -1980,7 +1964,7 @@ func TestVPCTeardown(t *testing.T) {
})

t.Run("Delete Volume", func(t *testing.T) {
res, err := DeleteVolume(vpcService, *createdVolumeID)
res, err := DeleteVolume(vpcService, *createdVolumeID, ifMatchVolume)
ValidateDeleteResponse(t, res, err, DELETE, res.StatusCode, detailed, increment)
})

Expand Down
Loading

0 comments on commit f545b65

Please sign in to comment.