Skip to content

Commit 7d6b3df

Browse files
Fixes #11, Fixes #13, Fixes #15, Fixes #18, Fixes #20
1 parent 770baee commit 7d6b3df

File tree

57 files changed

+1831
-118
lines changed

Some content is hidden

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

57 files changed

+1831
-118
lines changed

client/bare_metal_client.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type BareMetalClient interface {
2626
CreateRouteTable(compartmentID, vcnID string, routeRules []baremetal.RouteRule, opts *baremetal.CreateOptions) (res *baremetal.RouteTable, e error)
2727
CreateSecurityList(compartmentID, vcnID string, egressRules []baremetal.EgressSecurityRule, ingressRules []baremetal.IngressSecurityRule, opts *baremetal.CreateOptions) (res *baremetal.SecurityList, e error)
2828
CreateSubnet(availabilityDomain, cidrBlock, compartmentID, vcnID string, opts *baremetal.CreateSubnetOptions) (sn *baremetal.Subnet, e error)
29+
CreateSwiftPassword(userID, desc string, opts *baremetal.RetryTokenOptions) (res *baremetal.SwiftPassword, e error)
2930
CreateUser(name, desc string, opts *baremetal.RetryTokenOptions) (res *baremetal.User, e error)
3031
CreateVirtualNetwork(cidrBlock, compartmentID string, opts *baremetal.CreateOptions) (vcn *baremetal.VirtualNetwork, e error)
3132
CreateVolume(availabilityDomain, compartmentID string, opts *baremetal.CreateVolumeOptions) (res *baremetal.Volume, e error)
@@ -46,6 +47,7 @@ type BareMetalClient interface {
4647
DeleteRouteTable(id string, opts *baremetal.IfMatchOptions) (e error)
4748
DeleteSecurityList(id string, opts *baremetal.IfMatchOptions) (e error)
4849
DeleteSubnet(id string, opts *baremetal.IfMatchOptions) error
50+
DeleteSwiftPassword(id, userID string, opts *baremetal.IfMatchOptions) (e error)
4951
DeleteUser(id string, opts *baremetal.IfMatchOptions) (e error)
5052
DeleteUserGroupMembership(id string, opts *baremetal.IfMatchOptions) (e error)
5153
DeleteVirtualNetwork(id string, opts *baremetal.IfMatchOptions) (e error)
@@ -114,11 +116,13 @@ type BareMetalClient interface {
114116
ListInstances(compartmentID string, opts *baremetal.ListInstancesOptions) (insts *baremetal.ListInstances, e error)
115117
ListInternetGateways(compartmentID, vcnID string, opts *baremetal.ListOptions) (list *baremetal.ListInternetGateways, e error)
116118
ListObjects(namespace baremetal.Namespace, bucket string, opts *baremetal.ListObjectsOptions) (objects *baremetal.ListObjects, e error)
119+
ListPolicies(compartmentID string, opts *baremetal.ListOptions) (resources *baremetal.ListPolicies, e error)
117120
ListRouteTables(compartmentID, vcnID string, opts *baremetal.ListOptions) (res *baremetal.ListRouteTables, e error)
118121
ListSecurityLists(compartmentID, vcnID string, opts *baremetal.ListOptions) (res *baremetal.ListSecurityLists, e error)
119122
ListShapes(compartmentID string, opts *baremetal.ListShapesOptions) (shapes *baremetal.ListShapes, e error)
120123
ListSubnets(compartmentID, vcnID string, opts *baremetal.ListOptions) (subnets *baremetal.ListSubnets, e error)
121124
ListSupportedOperations() (*baremetal.ListSupportedOperations, error)
125+
ListSwiftPasswords(userID string) (resources *baremetal.ListSwiftPasswords, e error)
122126
ListUserGroupMemberships(opts *baremetal.ListMembershipsOptions) (resources *baremetal.ListUserGroupMemberships, e error)
123127
ListUsers(opts *baremetal.ListOptions) (resources *baremetal.ListUsers, e error)
124128
ListVirtualNetworks(compartmentID string, opts *baremetal.ListOptions) (vcns *baremetal.ListVirtualNetworks, e error)
@@ -136,15 +140,22 @@ type BareMetalClient interface {
136140

137141
UpdateBucket(compartmentID string, name string, namespaceName baremetal.Namespace, opts *baremetal.UpdateBucketOptions) (bckt *baremetal.Bucket, e error)
138142
UpdateCompartment(id string, opts *baremetal.UpdateIdentityOptions) (res *baremetal.Compartment, e error)
143+
UpdateCpe(id string, opts *baremetal.IfMatchDisplayNameOptions) (cpe *baremetal.Cpe, e error)
139144
UpdateDHCPOptions(id string, opts *baremetal.UpdateDHCPDNSOptions) (res *baremetal.DHCPOptions, e error)
145+
UpdateDrg(id string, opts *baremetal.IfMatchDisplayNameOptions) (drg *baremetal.Drg, e error)
146+
UpdateDrgAttachment(id string, opts *baremetal.IfMatchDisplayNameOptions) (drg *baremetal.DrgAttachment, e error)
140147
UpdateGroup(id string, opts *baremetal.UpdateIdentityOptions) (res *baremetal.Group, e error)
141148
UpdateImage(id string, opts *baremetal.UpdateOptions) (res *baremetal.Image, e error)
142149
UpdateInstance(id string, opts *baremetal.UpdateOptions) (inst *baremetal.Instance, e error)
143150
UpdateInternetGateway(id string, opts *baremetal.UpdateGatewayOptions) (gw *baremetal.InternetGateway, e error)
151+
UpdateIPSecConnection(id string, opts *baremetal.IfMatchDisplayNameOptions) (conn *baremetal.IPSecConnection, e error)
144152
UpdatePolicy(id string, opts *baremetal.UpdatePolicyOptions) (res *baremetal.Policy, e error)
145153
UpdateRouteTable(id string, opts *baremetal.UpdateRouteTableOptions) (res *baremetal.RouteTable, e error)
146154
UpdateSecurityList(id string, opts *baremetal.UpdateSecurityListOptions) (res *baremetal.SecurityList, e error)
155+
UpdateSubnet(id string, opts *baremetal.IfMatchDisplayNameOptions) (subnet *baremetal.Subnet, e error)
156+
UpdateSwiftPassword(id, userID string, opts *baremetal.UpdateIdentityOptions) (res *baremetal.SwiftPassword, e error)
147157
UpdateUser(id string, opts *baremetal.UpdateIdentityOptions) (res *baremetal.User, e error)
158+
UpdateVirtualNetwork(id string, opts *baremetal.IfMatchDisplayNameOptions) (vcn *baremetal.VirtualNetwork, e error)
148159
UpdateVolume(id string, opts *baremetal.UpdateOptions) (res *baremetal.Volume, e error)
149160
UpdateVolumeBackup(id string, opts *baremetal.UpdateBackupOptions) (vol *baremetal.VolumeBackup, e error)
150161
UploadAPIKey(userID, key string, opts *baremetal.RetryTokenOptions) (apiKey *baremetal.APIKey, e error)

client/mocks/bare_metal_client.go

Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,29 @@ func (_m *BareMetalClient) CreateSubnet(availabilityDomain string, cidrBlock str
423423
return r0, r1
424424
}
425425

426+
// CreateSwiftPassword provides a mock function with given fields: userID, desc, opts
427+
func (_m *BareMetalClient) CreateSwiftPassword(userID string, desc string, opts *baremetal.RetryTokenOptions) (*baremetal.SwiftPassword, error) {
428+
ret := _m.Called(userID, desc, opts)
429+
430+
var r0 *baremetal.SwiftPassword
431+
if rf, ok := ret.Get(0).(func(string, string, *baremetal.RetryTokenOptions) *baremetal.SwiftPassword); ok {
432+
r0 = rf(userID, desc, opts)
433+
} else {
434+
if ret.Get(0) != nil {
435+
r0 = ret.Get(0).(*baremetal.SwiftPassword)
436+
}
437+
}
438+
439+
var r1 error
440+
if rf, ok := ret.Get(1).(func(string, string, *baremetal.RetryTokenOptions) error); ok {
441+
r1 = rf(userID, desc, opts)
442+
} else {
443+
r1 = ret.Error(1)
444+
}
445+
446+
return r0, r1
447+
}
448+
426449
// CreateUser provides a mock function with given fields: name, desc, opts
427450
func (_m *BareMetalClient) CreateUser(name string, desc string, opts *baremetal.RetryTokenOptions) (*baremetal.User, error) {
428451
ret := _m.Called(name, desc, opts)
@@ -734,6 +757,20 @@ func (_m *BareMetalClient) DeleteSubnet(id string, opts *baremetal.IfMatchOption
734757
return r0
735758
}
736759

760+
// DeleteSwiftPassword provides a mock function with given fields: id, userID, opts
761+
func (_m *BareMetalClient) DeleteSwiftPassword(id string, userID string, opts *baremetal.IfMatchOptions) error {
762+
ret := _m.Called(id, userID, opts)
763+
764+
var r0 error
765+
if rf, ok := ret.Get(0).(func(string, string, *baremetal.IfMatchOptions) error); ok {
766+
r0 = rf(id, userID, opts)
767+
} else {
768+
r0 = ret.Error(0)
769+
}
770+
771+
return r0
772+
}
773+
737774
// DeleteUser provides a mock function with given fields: id, opts
738775
func (_m *BareMetalClient) DeleteUser(id string, opts *baremetal.IfMatchOptions) error {
739776
ret := _m.Called(id, opts)
@@ -2106,6 +2143,29 @@ func (_m *BareMetalClient) ListObjects(namespace baremetal.Namespace, bucket str
21062143
return r0, r1
21072144
}
21082145

2146+
// ListPolicies provides a mock function with given fields: compartmentID, opts
2147+
func (_m *BareMetalClient) ListPolicies(compartmentID string, opts *baremetal.ListOptions) (*baremetal.ListPolicies, error) {
2148+
ret := _m.Called(compartmentID, opts)
2149+
2150+
var r0 *baremetal.ListPolicies
2151+
if rf, ok := ret.Get(0).(func(string, *baremetal.ListOptions) *baremetal.ListPolicies); ok {
2152+
r0 = rf(compartmentID, opts)
2153+
} else {
2154+
if ret.Get(0) != nil {
2155+
r0 = ret.Get(0).(*baremetal.ListPolicies)
2156+
}
2157+
}
2158+
2159+
var r1 error
2160+
if rf, ok := ret.Get(1).(func(string, *baremetal.ListOptions) error); ok {
2161+
r1 = rf(compartmentID, opts)
2162+
} else {
2163+
r1 = ret.Error(1)
2164+
}
2165+
2166+
return r0, r1
2167+
}
2168+
21092169
// ListRouteTables provides a mock function with given fields: compartmentID, vcnID, opts
21102170
func (_m *BareMetalClient) ListRouteTables(compartmentID string, vcnID string, opts *baremetal.ListOptions) (*baremetal.ListRouteTables, error) {
21112171
ret := _m.Called(compartmentID, vcnID, opts)
@@ -2221,6 +2281,29 @@ func (_m *BareMetalClient) ListSupportedOperations() (*baremetal.ListSupportedOp
22212281
return r0, r1
22222282
}
22232283

2284+
// ListSwiftPasswords provides a mock function with given fields: userID
2285+
func (_m *BareMetalClient) ListSwiftPasswords(userID string) (*baremetal.ListSwiftPasswords, error) {
2286+
ret := _m.Called(userID)
2287+
2288+
var r0 *baremetal.ListSwiftPasswords
2289+
if rf, ok := ret.Get(0).(func(string) *baremetal.ListSwiftPasswords); ok {
2290+
r0 = rf(userID)
2291+
} else {
2292+
if ret.Get(0) != nil {
2293+
r0 = ret.Get(0).(*baremetal.ListSwiftPasswords)
2294+
}
2295+
}
2296+
2297+
var r1 error
2298+
if rf, ok := ret.Get(1).(func(string) error); ok {
2299+
r1 = rf(userID)
2300+
} else {
2301+
r1 = ret.Error(1)
2302+
}
2303+
2304+
return r0, r1
2305+
}
2306+
22242307
// ListUserGroupMemberships provides a mock function with given fields: opts
22252308
func (_m *BareMetalClient) ListUserGroupMemberships(opts *baremetal.ListMembershipsOptions) (*baremetal.ListUserGroupMemberships, error) {
22262309
ret := _m.Called(opts)
@@ -2502,6 +2585,29 @@ func (_m *BareMetalClient) UpdateCompartment(id string, opts *baremetal.UpdateId
25022585
return r0, r1
25032586
}
25042587

2588+
// UpdateCpe provides a mock function with given fields: id, opts
2589+
func (_m *BareMetalClient) UpdateCpe(id string, opts *baremetal.IfMatchDisplayNameOptions) (*baremetal.Cpe, error) {
2590+
ret := _m.Called(id, opts)
2591+
2592+
var r0 *baremetal.Cpe
2593+
if rf, ok := ret.Get(0).(func(string, *baremetal.IfMatchDisplayNameOptions) *baremetal.Cpe); ok {
2594+
r0 = rf(id, opts)
2595+
} else {
2596+
if ret.Get(0) != nil {
2597+
r0 = ret.Get(0).(*baremetal.Cpe)
2598+
}
2599+
}
2600+
2601+
var r1 error
2602+
if rf, ok := ret.Get(1).(func(string, *baremetal.IfMatchDisplayNameOptions) error); ok {
2603+
r1 = rf(id, opts)
2604+
} else {
2605+
r1 = ret.Error(1)
2606+
}
2607+
2608+
return r0, r1
2609+
}
2610+
25052611
// UpdateDHCPOptions provides a mock function with given fields: id, opts
25062612
func (_m *BareMetalClient) UpdateDHCPOptions(id string, opts *baremetal.UpdateDHCPDNSOptions) (*baremetal.DHCPOptions, error) {
25072613
ret := _m.Called(id, opts)
@@ -2525,6 +2631,52 @@ func (_m *BareMetalClient) UpdateDHCPOptions(id string, opts *baremetal.UpdateDH
25252631
return r0, r1
25262632
}
25272633

2634+
// UpdateDrg provides a mock function with given fields: id, opts
2635+
func (_m *BareMetalClient) UpdateDrg(id string, opts *baremetal.IfMatchDisplayNameOptions) (*baremetal.Drg, error) {
2636+
ret := _m.Called(id, opts)
2637+
2638+
var r0 *baremetal.Drg
2639+
if rf, ok := ret.Get(0).(func(string, *baremetal.IfMatchDisplayNameOptions) *baremetal.Drg); ok {
2640+
r0 = rf(id, opts)
2641+
} else {
2642+
if ret.Get(0) != nil {
2643+
r0 = ret.Get(0).(*baremetal.Drg)
2644+
}
2645+
}
2646+
2647+
var r1 error
2648+
if rf, ok := ret.Get(1).(func(string, *baremetal.IfMatchDisplayNameOptions) error); ok {
2649+
r1 = rf(id, opts)
2650+
} else {
2651+
r1 = ret.Error(1)
2652+
}
2653+
2654+
return r0, r1
2655+
}
2656+
2657+
// UpdateDrgAttachment provides a mock function with given fields: id, opts
2658+
func (_m *BareMetalClient) UpdateDrgAttachment(id string, opts *baremetal.IfMatchDisplayNameOptions) (*baremetal.DrgAttachment, error) {
2659+
ret := _m.Called(id, opts)
2660+
2661+
var r0 *baremetal.DrgAttachment
2662+
if rf, ok := ret.Get(0).(func(string, *baremetal.IfMatchDisplayNameOptions) *baremetal.DrgAttachment); ok {
2663+
r0 = rf(id, opts)
2664+
} else {
2665+
if ret.Get(0) != nil {
2666+
r0 = ret.Get(0).(*baremetal.DrgAttachment)
2667+
}
2668+
}
2669+
2670+
var r1 error
2671+
if rf, ok := ret.Get(1).(func(string, *baremetal.IfMatchDisplayNameOptions) error); ok {
2672+
r1 = rf(id, opts)
2673+
} else {
2674+
r1 = ret.Error(1)
2675+
}
2676+
2677+
return r0, r1
2678+
}
2679+
25282680
// UpdateGroup provides a mock function with given fields: id, opts
25292681
func (_m *BareMetalClient) UpdateGroup(id string, opts *baremetal.UpdateIdentityOptions) (*baremetal.Group, error) {
25302682
ret := _m.Called(id, opts)
@@ -2548,6 +2700,29 @@ func (_m *BareMetalClient) UpdateGroup(id string, opts *baremetal.UpdateIdentity
25482700
return r0, r1
25492701
}
25502702

2703+
// UpdateIPSecConnection provides a mock function with given fields: id, opts
2704+
func (_m *BareMetalClient) UpdateIPSecConnection(id string, opts *baremetal.IfMatchDisplayNameOptions) (*baremetal.IPSecConnection, error) {
2705+
ret := _m.Called(id, opts)
2706+
2707+
var r0 *baremetal.IPSecConnection
2708+
if rf, ok := ret.Get(0).(func(string, *baremetal.IfMatchDisplayNameOptions) *baremetal.IPSecConnection); ok {
2709+
r0 = rf(id, opts)
2710+
} else {
2711+
if ret.Get(0) != nil {
2712+
r0 = ret.Get(0).(*baremetal.IPSecConnection)
2713+
}
2714+
}
2715+
2716+
var r1 error
2717+
if rf, ok := ret.Get(1).(func(string, *baremetal.IfMatchDisplayNameOptions) error); ok {
2718+
r1 = rf(id, opts)
2719+
} else {
2720+
r1 = ret.Error(1)
2721+
}
2722+
2723+
return r0, r1
2724+
}
2725+
25512726
// UpdateImage provides a mock function with given fields: id, opts
25522727
func (_m *BareMetalClient) UpdateImage(id string, opts *baremetal.UpdateOptions) (*baremetal.Image, error) {
25532728
ret := _m.Called(id, opts)
@@ -2686,6 +2861,52 @@ func (_m *BareMetalClient) UpdateSecurityList(id string, opts *baremetal.UpdateS
26862861
return r0, r1
26872862
}
26882863

2864+
// UpdateSubnet provides a mock function with given fields: id, opts
2865+
func (_m *BareMetalClient) UpdateSubnet(id string, opts *baremetal.IfMatchDisplayNameOptions) (*baremetal.Subnet, error) {
2866+
ret := _m.Called(id, opts)
2867+
2868+
var r0 *baremetal.Subnet
2869+
if rf, ok := ret.Get(0).(func(string, *baremetal.IfMatchDisplayNameOptions) *baremetal.Subnet); ok {
2870+
r0 = rf(id, opts)
2871+
} else {
2872+
if ret.Get(0) != nil {
2873+
r0 = ret.Get(0).(*baremetal.Subnet)
2874+
}
2875+
}
2876+
2877+
var r1 error
2878+
if rf, ok := ret.Get(1).(func(string, *baremetal.IfMatchDisplayNameOptions) error); ok {
2879+
r1 = rf(id, opts)
2880+
} else {
2881+
r1 = ret.Error(1)
2882+
}
2883+
2884+
return r0, r1
2885+
}
2886+
2887+
// UpdateSwiftPassword provides a mock function with given fields: id, userID, opts
2888+
func (_m *BareMetalClient) UpdateSwiftPassword(id string, userID string, opts *baremetal.UpdateIdentityOptions) (*baremetal.SwiftPassword, error) {
2889+
ret := _m.Called(id, userID, opts)
2890+
2891+
var r0 *baremetal.SwiftPassword
2892+
if rf, ok := ret.Get(0).(func(string, string, *baremetal.UpdateIdentityOptions) *baremetal.SwiftPassword); ok {
2893+
r0 = rf(id, userID, opts)
2894+
} else {
2895+
if ret.Get(0) != nil {
2896+
r0 = ret.Get(0).(*baremetal.SwiftPassword)
2897+
}
2898+
}
2899+
2900+
var r1 error
2901+
if rf, ok := ret.Get(1).(func(string, string, *baremetal.UpdateIdentityOptions) error); ok {
2902+
r1 = rf(id, userID, opts)
2903+
} else {
2904+
r1 = ret.Error(1)
2905+
}
2906+
2907+
return r0, r1
2908+
}
2909+
26892910
// UpdateUser provides a mock function with given fields: id, opts
26902911
func (_m *BareMetalClient) UpdateUser(id string, opts *baremetal.UpdateIdentityOptions) (*baremetal.User, error) {
26912912
ret := _m.Called(id, opts)
@@ -2709,6 +2930,29 @@ func (_m *BareMetalClient) UpdateUser(id string, opts *baremetal.UpdateIdentityO
27092930
return r0, r1
27102931
}
27112932

2933+
// UpdateVirtualNetwork provides a mock function with given fields: id, opts
2934+
func (_m *BareMetalClient) UpdateVirtualNetwork(id string, opts *baremetal.IfMatchDisplayNameOptions) (*baremetal.VirtualNetwork, error) {
2935+
ret := _m.Called(id, opts)
2936+
2937+
var r0 *baremetal.VirtualNetwork
2938+
if rf, ok := ret.Get(0).(func(string, *baremetal.IfMatchDisplayNameOptions) *baremetal.VirtualNetwork); ok {
2939+
r0 = rf(id, opts)
2940+
} else {
2941+
if ret.Get(0) != nil {
2942+
r0 = ret.Get(0).(*baremetal.VirtualNetwork)
2943+
}
2944+
}
2945+
2946+
var r1 error
2947+
if rf, ok := ret.Get(1).(func(string, *baremetal.IfMatchDisplayNameOptions) error); ok {
2948+
r1 = rf(id, opts)
2949+
} else {
2950+
r1 = ret.Error(1)
2951+
}
2952+
2953+
return r0, r1
2954+
}
2955+
27122956
// UpdateVolume provides a mock function with given fields: id, opts
27132957
func (_m *BareMetalClient) UpdateVolume(id string, opts *baremetal.UpdateOptions) (*baremetal.Volume, error) {
27142958
ret := _m.Called(id, opts)

core/cpe_resource.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ func CpeResource() *schema.Resource {
1212
return &schema.Resource{
1313
Create: createCpe,
1414
Read: readCpe,
15+
Update: updateCpe,
1516
Delete: deleteCpe,
1617
Schema: map[string]*schema.Schema{
1718
"id": {
@@ -26,7 +27,6 @@ func CpeResource() *schema.Resource {
2627
"display_name": {
2728
Type: schema.TypeString,
2829
Optional: true,
29-
ForceNew: true,
3030
Computed: true,
3131
},
3232
"ip_address": {
@@ -59,6 +59,14 @@ func readCpe(d *schema.ResourceData, m interface{}) (e error) {
5959
return crud.ReadResource(sync)
6060
}
6161

62+
func updateCpe(d *schema.ResourceData, m interface{}) (e error) {
63+
client := m.(client.BareMetalClient)
64+
crd := &CpeResourceCrud{}
65+
crd.D = d
66+
crd.Client = client
67+
return crud.UpdateResource(d, crd)
68+
}
69+
6270
func deleteCpe(d *schema.ResourceData, m interface{}) (e error) {
6371
client := m.(client.BareMetalClient)
6472
sync := &CpeResourceCrud{}

0 commit comments

Comments
 (0)