Skip to content

Commit

Permalink
feat(zones): added partial zone setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Arpit Srivastava authored and Arpit Srivastava committed Jul 14, 2022
1 parent 60d9ee1 commit 3e8aff6
Show file tree
Hide file tree
Showing 4 changed files with 748 additions and 230 deletions.
154 changes: 103 additions & 51 deletions zonesv1/zones_v1.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corp. 2020.
* (C) Copyright IBM Corp. 2022.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,7 +15,7 @@
*/

/*
* IBM OpenAPI SDK Code Generator Version: 3.20.0-debb9f29-20201203-202043
* IBM OpenAPI SDK Code Generator Version: 3.52.0-8345f809-20220627-220000
*/

// Package zonesv1 : Operations and models for the ZonesV1 service
Expand All @@ -35,7 +35,7 @@ import (

// ZonesV1 : CIS Zones
//
// Version: 1.0.1
// API Version: 1.0.1
type ZonesV1 struct {
Service *core.BaseService

Expand Down Expand Up @@ -223,11 +223,13 @@ func (zones *ZonesV1) ListZonesWithContext(ctx context.Context, listZonesOptions
if err != nil {
return
}
err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalListZonesResp)
if err != nil {
return
if rawResponse != nil {
err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalListZonesResp)
if err != nil {
return
}
response.Result = result
}
response.Result = result

return
}
Expand Down Expand Up @@ -272,6 +274,9 @@ func (zones *ZonesV1) CreateZoneWithContext(ctx context.Context, createZoneOptio
if createZoneOptions.Name != nil {
body["name"] = createZoneOptions.Name
}
if createZoneOptions.Type != nil {
body["type"] = createZoneOptions.Type
}
_, err = builder.SetBodyContentJSON(body)
if err != nil {
return
Expand All @@ -287,11 +292,13 @@ func (zones *ZonesV1) CreateZoneWithContext(ctx context.Context, createZoneOptio
if err != nil {
return
}
err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalZoneResp)
if err != nil {
return
if rawResponse != nil {
err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalZoneResp)
if err != nil {
return
}
response.Result = result
}
response.Result = result

return
}
Expand Down Expand Up @@ -346,11 +353,13 @@ func (zones *ZonesV1) DeleteZoneWithContext(ctx context.Context, deleteZoneOptio
if err != nil {
return
}
err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalDeleteZoneResp)
if err != nil {
return
if rawResponse != nil {
err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalDeleteZoneResp)
if err != nil {
return
}
response.Result = result
}
response.Result = result

return
}
Expand Down Expand Up @@ -405,11 +414,13 @@ func (zones *ZonesV1) GetZoneWithContext(ctx context.Context, getZoneOptions *Ge
if err != nil {
return
}
err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalZoneResp)
if err != nil {
return
if rawResponse != nil {
err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalZoneResp)
if err != nil {
return
}
response.Result = result
}
response.Result = result

return
}
Expand Down Expand Up @@ -474,11 +485,13 @@ func (zones *ZonesV1) UpdateZoneWithContext(ctx context.Context, updateZoneOptio
if err != nil {
return
}
err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalZoneResp)
if err != nil {
return
if rawResponse != nil {
err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalZoneResp)
if err != nil {
return
}
response.Result = result
}
response.Result = result

return
}
Expand Down Expand Up @@ -533,11 +546,13 @@ func (zones *ZonesV1) ZoneActivationCheckWithContext(ctx context.Context, zoneAc
if err != nil {
return
}
err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalZoneActivationcheckResp)
if err != nil {
return
if rawResponse != nil {
err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalZoneActivationcheckResp)
if err != nil {
return
}
response.Result = result
}
response.Result = result

return
}
Expand All @@ -547,19 +562,35 @@ type CreateZoneOptions struct {
// name.
Name *string `json:"name,omitempty"`

// zone type.
Type *string `json:"type,omitempty"`

// Allows users to set headers on API requests
Headers map[string]string
}

// Constants associated with the CreateZoneOptions.Type property.
// zone type.
const (
CreateZoneOptions_Type_Full = "full"
CreateZoneOptions_Type_Partial = "partial"
)

// NewCreateZoneOptions : Instantiate CreateZoneOptions
func (*ZonesV1) NewCreateZoneOptions() *CreateZoneOptions {
return &CreateZoneOptions{}
}

// SetName : Allow user to set Name
func (options *CreateZoneOptions) SetName(name string) *CreateZoneOptions {
options.Name = core.StringPtr(name)
return options
func (_options *CreateZoneOptions) SetName(name string) *CreateZoneOptions {
_options.Name = core.StringPtr(name)
return _options
}

// SetType : Allow user to set Type
func (_options *CreateZoneOptions) SetType(typeVar string) *CreateZoneOptions {
_options.Type = core.StringPtr(typeVar)
return _options
}

// SetHeaders : Allow user to set Headers
Expand All @@ -585,9 +616,9 @@ func (*ZonesV1) NewDeleteZoneOptions(zoneIdentifier string) *DeleteZoneOptions {
}

// SetZoneIdentifier : Allow user to set ZoneIdentifier
func (options *DeleteZoneOptions) SetZoneIdentifier(zoneIdentifier string) *DeleteZoneOptions {
options.ZoneIdentifier = core.StringPtr(zoneIdentifier)
return options
func (_options *DeleteZoneOptions) SetZoneIdentifier(zoneIdentifier string) *DeleteZoneOptions {
_options.ZoneIdentifier = core.StringPtr(zoneIdentifier)
return _options
}

// SetHeaders : Allow user to set Headers
Expand Down Expand Up @@ -630,9 +661,9 @@ func (*ZonesV1) NewGetZoneOptions(zoneIdentifier string) *GetZoneOptions {
}

// SetZoneIdentifier : Allow user to set ZoneIdentifier
func (options *GetZoneOptions) SetZoneIdentifier(zoneIdentifier string) *GetZoneOptions {
options.ZoneIdentifier = core.StringPtr(zoneIdentifier)
return options
func (_options *GetZoneOptions) SetZoneIdentifier(zoneIdentifier string) *GetZoneOptions {
_options.ZoneIdentifier = core.StringPtr(zoneIdentifier)
return _options
}

// SetHeaders : Allow user to set Headers
Expand All @@ -659,15 +690,15 @@ func (*ZonesV1) NewListZonesOptions() *ListZonesOptions {
}

// SetPage : Allow user to set Page
func (options *ListZonesOptions) SetPage(page int64) *ListZonesOptions {
options.Page = core.Int64Ptr(page)
return options
func (_options *ListZonesOptions) SetPage(page int64) *ListZonesOptions {
_options.Page = core.Int64Ptr(page)
return _options
}

// SetPerPage : Allow user to set PerPage
func (options *ListZonesOptions) SetPerPage(perPage int64) *ListZonesOptions {
options.PerPage = core.Int64Ptr(perPage)
return options
func (_options *ListZonesOptions) SetPerPage(perPage int64) *ListZonesOptions {
_options.PerPage = core.Int64Ptr(perPage)
return _options
}

// SetHeaders : Allow user to set Headers
Expand Down Expand Up @@ -696,15 +727,15 @@ func (*ZonesV1) NewUpdateZoneOptions(zoneIdentifier string) *UpdateZoneOptions {
}

// SetZoneIdentifier : Allow user to set ZoneIdentifier
func (options *UpdateZoneOptions) SetZoneIdentifier(zoneIdentifier string) *UpdateZoneOptions {
options.ZoneIdentifier = core.StringPtr(zoneIdentifier)
return options
func (_options *UpdateZoneOptions) SetZoneIdentifier(zoneIdentifier string) *UpdateZoneOptions {
_options.ZoneIdentifier = core.StringPtr(zoneIdentifier)
return _options
}

// SetPaused : Allow user to set Paused
func (options *UpdateZoneOptions) SetPaused(paused bool) *UpdateZoneOptions {
options.Paused = core.BoolPtr(paused)
return options
func (_options *UpdateZoneOptions) SetPaused(paused bool) *UpdateZoneOptions {
_options.Paused = core.BoolPtr(paused)
return _options
}

// SetHeaders : Allow user to set Headers
Expand All @@ -730,9 +761,9 @@ func (*ZonesV1) NewZoneActivationCheckOptions(zoneIdentifier string) *ZoneActiva
}

// SetZoneIdentifier : Allow user to set ZoneIdentifier
func (options *ZoneActivationCheckOptions) SetZoneIdentifier(zoneIdentifier string) *ZoneActivationCheckOptions {
options.ZoneIdentifier = core.StringPtr(zoneIdentifier)
return options
func (_options *ZoneActivationCheckOptions) SetZoneIdentifier(zoneIdentifier string) *ZoneActivationCheckOptions {
_options.ZoneIdentifier = core.StringPtr(zoneIdentifier)
return _options
}

// SetHeaders : Allow user to set Headers
Expand Down Expand Up @@ -948,6 +979,15 @@ type ZoneDetails struct {

// name servers.
NameServers []string `json:"name_servers,omitempty"`

// zone type.
Type *string `json:"type,omitempty"`

// verification key.
VerificationKey *string `json:"verification_key,omitempty"`

// canme suffix.
CnameSuffix *string `json:"cname_suffix,omitempty"`
}

// UnmarshalZoneDetails unmarshals an instance of ZoneDetails from the specified map of raw messages.
Expand Down Expand Up @@ -993,6 +1033,18 @@ func UnmarshalZoneDetails(m map[string]json.RawMessage, result interface{}) (err
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "type", &obj.Type)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "verification_key", &obj.VerificationKey)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "cname_suffix", &obj.CnameSuffix)
if err != nil {
return
}
reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj))
return
}
Expand Down
48 changes: 47 additions & 1 deletion zonesv1/zones_v1_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ const configFile = "../cis.env"
var configLoaded bool = true

func shouldSkipTest() {
Skip("Skipping Tests")
if !configLoaded {
Skip("External configuration is not available, skipping...")
}
}

var _ = Describe(`zonesv1_test`, func() {
defer GinkgoRecover()
if _, err := os.Stat(configFile); err != nil {
configLoaded = false
}
Expand Down Expand Up @@ -171,6 +171,52 @@ var _ = Describe(`zonesv1_test`, func() {
Expect(*listResult.Success).Should(BeTrue())

})
It(`partial zones create/update/delete/activation check test`, func() {
shouldSkipTest()
// create partial zone
zoneName := fmt.Sprintf("uuid-%s.ibm.com", guuid.New().String())
zoneType := CreateZoneOptions_Type_Partial
createOpt := service.NewCreateZoneOptions()
createOpt.SetName(zoneName)
createOpt.SetType(zoneType)

createResult, createResp, createErr := service.CreateZone(createOpt)
Expect(createErr).To(BeNil())
Expect(createResp).ToNot(BeNil())
Expect(createResult).ToNot(BeNil())
Expect(*createResult.Success).Should(BeTrue())

// update partial zone
updateOpt := service.NewUpdateZoneOptions(*createResult.Result.ID)
updateOpt.SetPaused(true)
updateResult, updateResp, updateErr := service.UpdateZone(updateOpt)
Expect(updateErr).To(BeNil())
Expect(updateResp).ToNot(BeNil())
Expect(updateResult).ToNot(BeNil())
Expect(*updateResult.Success).Should(BeTrue())

// activation partial check
checkOpt := service.NewZoneActivationCheckOptions(*createResult.Result.ID)
checkResult, checkResp, checkErr := service.ZoneActivationCheck(checkOpt)
Expect(checkErr).To(BeNil())
Expect(checkResp).ToNot(BeNil())
Expect(checkResult).ToNot(BeNil())
Expect(*checkResult.Success).Should(BeTrue())

getOpt := service.NewGetZoneOptions(*createResult.Result.ID)
getResult, getResp, getErr := service.GetZone(getOpt)
Expect(getErr).To(BeNil())
Expect(getResp).ToNot(BeNil())
Expect(getResult).ToNot(BeNil())
Expect(*getResult.Success).Should(BeTrue())

deleteOpt := service.NewDeleteZoneOptions(*createResult.Result.ID)
deleteResult, deleteResp, deleteErr := service.DeleteZone(deleteOpt)
Expect(deleteErr).To(BeNil())
Expect(deleteResp).ToNot(BeNil())
Expect(deleteResult).ToNot(BeNil())
Expect(*deleteResult.Success).Should(BeTrue())
})
})
})
})
5 changes: 3 additions & 2 deletions zonesv1/zones_v1_suite_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corp. 2020.
* (C) Copyright IBM Corp. 2022.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,9 +17,10 @@
package zonesv1_test

import (
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)

func TestZonesV1(t *testing.T) {
Expand Down
Loading

0 comments on commit 3e8aff6

Please sign in to comment.