Skip to content

Commit

Permalink
Fixes #11, Fixes #13, Fixes #15, Fixes #18, Fixes #20
Browse files Browse the repository at this point in the history
  • Loading branch information
craigcarl-oracle committed Mar 14, 2017
1 parent 770baee commit 7d6b3df
Show file tree
Hide file tree
Showing 57 changed files with 1,831 additions and 118 deletions.
11 changes: 11 additions & 0 deletions client/bare_metal_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type BareMetalClient interface {
CreateRouteTable(compartmentID, vcnID string, routeRules []baremetal.RouteRule, opts *baremetal.CreateOptions) (res *baremetal.RouteTable, e error)
CreateSecurityList(compartmentID, vcnID string, egressRules []baremetal.EgressSecurityRule, ingressRules []baremetal.IngressSecurityRule, opts *baremetal.CreateOptions) (res *baremetal.SecurityList, e error)
CreateSubnet(availabilityDomain, cidrBlock, compartmentID, vcnID string, opts *baremetal.CreateSubnetOptions) (sn *baremetal.Subnet, e error)
CreateSwiftPassword(userID, desc string, opts *baremetal.RetryTokenOptions) (res *baremetal.SwiftPassword, e error)
CreateUser(name, desc string, opts *baremetal.RetryTokenOptions) (res *baremetal.User, e error)
CreateVirtualNetwork(cidrBlock, compartmentID string, opts *baremetal.CreateOptions) (vcn *baremetal.VirtualNetwork, e error)
CreateVolume(availabilityDomain, compartmentID string, opts *baremetal.CreateVolumeOptions) (res *baremetal.Volume, e error)
Expand All @@ -46,6 +47,7 @@ type BareMetalClient interface {
DeleteRouteTable(id string, opts *baremetal.IfMatchOptions) (e error)
DeleteSecurityList(id string, opts *baremetal.IfMatchOptions) (e error)
DeleteSubnet(id string, opts *baremetal.IfMatchOptions) error
DeleteSwiftPassword(id, userID string, opts *baremetal.IfMatchOptions) (e error)
DeleteUser(id string, opts *baremetal.IfMatchOptions) (e error)
DeleteUserGroupMembership(id string, opts *baremetal.IfMatchOptions) (e error)
DeleteVirtualNetwork(id string, opts *baremetal.IfMatchOptions) (e error)
Expand Down Expand Up @@ -114,11 +116,13 @@ type BareMetalClient interface {
ListInstances(compartmentID string, opts *baremetal.ListInstancesOptions) (insts *baremetal.ListInstances, e error)
ListInternetGateways(compartmentID, vcnID string, opts *baremetal.ListOptions) (list *baremetal.ListInternetGateways, e error)
ListObjects(namespace baremetal.Namespace, bucket string, opts *baremetal.ListObjectsOptions) (objects *baremetal.ListObjects, e error)
ListPolicies(compartmentID string, opts *baremetal.ListOptions) (resources *baremetal.ListPolicies, e error)
ListRouteTables(compartmentID, vcnID string, opts *baremetal.ListOptions) (res *baremetal.ListRouteTables, e error)
ListSecurityLists(compartmentID, vcnID string, opts *baremetal.ListOptions) (res *baremetal.ListSecurityLists, e error)
ListShapes(compartmentID string, opts *baremetal.ListShapesOptions) (shapes *baremetal.ListShapes, e error)
ListSubnets(compartmentID, vcnID string, opts *baremetal.ListOptions) (subnets *baremetal.ListSubnets, e error)
ListSupportedOperations() (*baremetal.ListSupportedOperations, error)
ListSwiftPasswords(userID string) (resources *baremetal.ListSwiftPasswords, e error)
ListUserGroupMemberships(opts *baremetal.ListMembershipsOptions) (resources *baremetal.ListUserGroupMemberships, e error)
ListUsers(opts *baremetal.ListOptions) (resources *baremetal.ListUsers, e error)
ListVirtualNetworks(compartmentID string, opts *baremetal.ListOptions) (vcns *baremetal.ListVirtualNetworks, e error)
Expand All @@ -136,15 +140,22 @@ type BareMetalClient interface {

UpdateBucket(compartmentID string, name string, namespaceName baremetal.Namespace, opts *baremetal.UpdateBucketOptions) (bckt *baremetal.Bucket, e error)
UpdateCompartment(id string, opts *baremetal.UpdateIdentityOptions) (res *baremetal.Compartment, e error)
UpdateCpe(id string, opts *baremetal.IfMatchDisplayNameOptions) (cpe *baremetal.Cpe, e error)
UpdateDHCPOptions(id string, opts *baremetal.UpdateDHCPDNSOptions) (res *baremetal.DHCPOptions, e error)
UpdateDrg(id string, opts *baremetal.IfMatchDisplayNameOptions) (drg *baremetal.Drg, e error)
UpdateDrgAttachment(id string, opts *baremetal.IfMatchDisplayNameOptions) (drg *baremetal.DrgAttachment, e error)
UpdateGroup(id string, opts *baremetal.UpdateIdentityOptions) (res *baremetal.Group, e error)
UpdateImage(id string, opts *baremetal.UpdateOptions) (res *baremetal.Image, e error)
UpdateInstance(id string, opts *baremetal.UpdateOptions) (inst *baremetal.Instance, e error)
UpdateInternetGateway(id string, opts *baremetal.UpdateGatewayOptions) (gw *baremetal.InternetGateway, e error)
UpdateIPSecConnection(id string, opts *baremetal.IfMatchDisplayNameOptions) (conn *baremetal.IPSecConnection, e error)
UpdatePolicy(id string, opts *baremetal.UpdatePolicyOptions) (res *baremetal.Policy, e error)
UpdateRouteTable(id string, opts *baremetal.UpdateRouteTableOptions) (res *baremetal.RouteTable, e error)
UpdateSecurityList(id string, opts *baremetal.UpdateSecurityListOptions) (res *baremetal.SecurityList, e error)
UpdateSubnet(id string, opts *baremetal.IfMatchDisplayNameOptions) (subnet *baremetal.Subnet, e error)
UpdateSwiftPassword(id, userID string, opts *baremetal.UpdateIdentityOptions) (res *baremetal.SwiftPassword, e error)
UpdateUser(id string, opts *baremetal.UpdateIdentityOptions) (res *baremetal.User, e error)
UpdateVirtualNetwork(id string, opts *baremetal.IfMatchDisplayNameOptions) (vcn *baremetal.VirtualNetwork, e error)
UpdateVolume(id string, opts *baremetal.UpdateOptions) (res *baremetal.Volume, e error)
UpdateVolumeBackup(id string, opts *baremetal.UpdateBackupOptions) (vol *baremetal.VolumeBackup, e error)
UploadAPIKey(userID, key string, opts *baremetal.RetryTokenOptions) (apiKey *baremetal.APIKey, e error)
Expand Down
244 changes: 244 additions & 0 deletions client/mocks/bare_metal_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,29 @@ func (_m *BareMetalClient) CreateSubnet(availabilityDomain string, cidrBlock str
return r0, r1
}

// CreateSwiftPassword provides a mock function with given fields: userID, desc, opts
func (_m *BareMetalClient) CreateSwiftPassword(userID string, desc string, opts *baremetal.RetryTokenOptions) (*baremetal.SwiftPassword, error) {
ret := _m.Called(userID, desc, opts)

var r0 *baremetal.SwiftPassword
if rf, ok := ret.Get(0).(func(string, string, *baremetal.RetryTokenOptions) *baremetal.SwiftPassword); ok {
r0 = rf(userID, desc, opts)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*baremetal.SwiftPassword)
}
}

var r1 error
if rf, ok := ret.Get(1).(func(string, string, *baremetal.RetryTokenOptions) error); ok {
r1 = rf(userID, desc, opts)
} else {
r1 = ret.Error(1)
}

return r0, r1
}

// CreateUser provides a mock function with given fields: name, desc, opts
func (_m *BareMetalClient) CreateUser(name string, desc string, opts *baremetal.RetryTokenOptions) (*baremetal.User, error) {
ret := _m.Called(name, desc, opts)
Expand Down Expand Up @@ -734,6 +757,20 @@ func (_m *BareMetalClient) DeleteSubnet(id string, opts *baremetal.IfMatchOption
return r0
}

// DeleteSwiftPassword provides a mock function with given fields: id, userID, opts
func (_m *BareMetalClient) DeleteSwiftPassword(id string, userID string, opts *baremetal.IfMatchOptions) error {
ret := _m.Called(id, userID, opts)

var r0 error
if rf, ok := ret.Get(0).(func(string, string, *baremetal.IfMatchOptions) error); ok {
r0 = rf(id, userID, opts)
} else {
r0 = ret.Error(0)
}

return r0
}

// DeleteUser provides a mock function with given fields: id, opts
func (_m *BareMetalClient) DeleteUser(id string, opts *baremetal.IfMatchOptions) error {
ret := _m.Called(id, opts)
Expand Down Expand Up @@ -2106,6 +2143,29 @@ func (_m *BareMetalClient) ListObjects(namespace baremetal.Namespace, bucket str
return r0, r1
}

// ListPolicies provides a mock function with given fields: compartmentID, opts
func (_m *BareMetalClient) ListPolicies(compartmentID string, opts *baremetal.ListOptions) (*baremetal.ListPolicies, error) {
ret := _m.Called(compartmentID, opts)

var r0 *baremetal.ListPolicies
if rf, ok := ret.Get(0).(func(string, *baremetal.ListOptions) *baremetal.ListPolicies); ok {
r0 = rf(compartmentID, opts)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*baremetal.ListPolicies)
}
}

var r1 error
if rf, ok := ret.Get(1).(func(string, *baremetal.ListOptions) error); ok {
r1 = rf(compartmentID, opts)
} else {
r1 = ret.Error(1)
}

return r0, r1
}

// ListRouteTables provides a mock function with given fields: compartmentID, vcnID, opts
func (_m *BareMetalClient) ListRouteTables(compartmentID string, vcnID string, opts *baremetal.ListOptions) (*baremetal.ListRouteTables, error) {
ret := _m.Called(compartmentID, vcnID, opts)
Expand Down Expand Up @@ -2221,6 +2281,29 @@ func (_m *BareMetalClient) ListSupportedOperations() (*baremetal.ListSupportedOp
return r0, r1
}

// ListSwiftPasswords provides a mock function with given fields: userID
func (_m *BareMetalClient) ListSwiftPasswords(userID string) (*baremetal.ListSwiftPasswords, error) {
ret := _m.Called(userID)

var r0 *baremetal.ListSwiftPasswords
if rf, ok := ret.Get(0).(func(string) *baremetal.ListSwiftPasswords); ok {
r0 = rf(userID)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*baremetal.ListSwiftPasswords)
}
}

var r1 error
if rf, ok := ret.Get(1).(func(string) error); ok {
r1 = rf(userID)
} else {
r1 = ret.Error(1)
}

return r0, r1
}

// ListUserGroupMemberships provides a mock function with given fields: opts
func (_m *BareMetalClient) ListUserGroupMemberships(opts *baremetal.ListMembershipsOptions) (*baremetal.ListUserGroupMemberships, error) {
ret := _m.Called(opts)
Expand Down Expand Up @@ -2502,6 +2585,29 @@ func (_m *BareMetalClient) UpdateCompartment(id string, opts *baremetal.UpdateId
return r0, r1
}

// UpdateCpe provides a mock function with given fields: id, opts
func (_m *BareMetalClient) UpdateCpe(id string, opts *baremetal.IfMatchDisplayNameOptions) (*baremetal.Cpe, error) {
ret := _m.Called(id, opts)

var r0 *baremetal.Cpe
if rf, ok := ret.Get(0).(func(string, *baremetal.IfMatchDisplayNameOptions) *baremetal.Cpe); ok {
r0 = rf(id, opts)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*baremetal.Cpe)
}
}

var r1 error
if rf, ok := ret.Get(1).(func(string, *baremetal.IfMatchDisplayNameOptions) error); ok {
r1 = rf(id, opts)
} else {
r1 = ret.Error(1)
}

return r0, r1
}

// UpdateDHCPOptions provides a mock function with given fields: id, opts
func (_m *BareMetalClient) UpdateDHCPOptions(id string, opts *baremetal.UpdateDHCPDNSOptions) (*baremetal.DHCPOptions, error) {
ret := _m.Called(id, opts)
Expand All @@ -2525,6 +2631,52 @@ func (_m *BareMetalClient) UpdateDHCPOptions(id string, opts *baremetal.UpdateDH
return r0, r1
}

// UpdateDrg provides a mock function with given fields: id, opts
func (_m *BareMetalClient) UpdateDrg(id string, opts *baremetal.IfMatchDisplayNameOptions) (*baremetal.Drg, error) {
ret := _m.Called(id, opts)

var r0 *baremetal.Drg
if rf, ok := ret.Get(0).(func(string, *baremetal.IfMatchDisplayNameOptions) *baremetal.Drg); ok {
r0 = rf(id, opts)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*baremetal.Drg)
}
}

var r1 error
if rf, ok := ret.Get(1).(func(string, *baremetal.IfMatchDisplayNameOptions) error); ok {
r1 = rf(id, opts)
} else {
r1 = ret.Error(1)
}

return r0, r1
}

// UpdateDrgAttachment provides a mock function with given fields: id, opts
func (_m *BareMetalClient) UpdateDrgAttachment(id string, opts *baremetal.IfMatchDisplayNameOptions) (*baremetal.DrgAttachment, error) {
ret := _m.Called(id, opts)

var r0 *baremetal.DrgAttachment
if rf, ok := ret.Get(0).(func(string, *baremetal.IfMatchDisplayNameOptions) *baremetal.DrgAttachment); ok {
r0 = rf(id, opts)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*baremetal.DrgAttachment)
}
}

var r1 error
if rf, ok := ret.Get(1).(func(string, *baremetal.IfMatchDisplayNameOptions) error); ok {
r1 = rf(id, opts)
} else {
r1 = ret.Error(1)
}

return r0, r1
}

// UpdateGroup provides a mock function with given fields: id, opts
func (_m *BareMetalClient) UpdateGroup(id string, opts *baremetal.UpdateIdentityOptions) (*baremetal.Group, error) {
ret := _m.Called(id, opts)
Expand All @@ -2548,6 +2700,29 @@ func (_m *BareMetalClient) UpdateGroup(id string, opts *baremetal.UpdateIdentity
return r0, r1
}

// UpdateIPSecConnection provides a mock function with given fields: id, opts
func (_m *BareMetalClient) UpdateIPSecConnection(id string, opts *baremetal.IfMatchDisplayNameOptions) (*baremetal.IPSecConnection, error) {
ret := _m.Called(id, opts)

var r0 *baremetal.IPSecConnection
if rf, ok := ret.Get(0).(func(string, *baremetal.IfMatchDisplayNameOptions) *baremetal.IPSecConnection); ok {
r0 = rf(id, opts)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*baremetal.IPSecConnection)
}
}

var r1 error
if rf, ok := ret.Get(1).(func(string, *baremetal.IfMatchDisplayNameOptions) error); ok {
r1 = rf(id, opts)
} else {
r1 = ret.Error(1)
}

return r0, r1
}

// UpdateImage provides a mock function with given fields: id, opts
func (_m *BareMetalClient) UpdateImage(id string, opts *baremetal.UpdateOptions) (*baremetal.Image, error) {
ret := _m.Called(id, opts)
Expand Down Expand Up @@ -2686,6 +2861,52 @@ func (_m *BareMetalClient) UpdateSecurityList(id string, opts *baremetal.UpdateS
return r0, r1
}

// UpdateSubnet provides a mock function with given fields: id, opts
func (_m *BareMetalClient) UpdateSubnet(id string, opts *baremetal.IfMatchDisplayNameOptions) (*baremetal.Subnet, error) {
ret := _m.Called(id, opts)

var r0 *baremetal.Subnet
if rf, ok := ret.Get(0).(func(string, *baremetal.IfMatchDisplayNameOptions) *baremetal.Subnet); ok {
r0 = rf(id, opts)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*baremetal.Subnet)
}
}

var r1 error
if rf, ok := ret.Get(1).(func(string, *baremetal.IfMatchDisplayNameOptions) error); ok {
r1 = rf(id, opts)
} else {
r1 = ret.Error(1)
}

return r0, r1
}

// UpdateSwiftPassword provides a mock function with given fields: id, userID, opts
func (_m *BareMetalClient) UpdateSwiftPassword(id string, userID string, opts *baremetal.UpdateIdentityOptions) (*baremetal.SwiftPassword, error) {
ret := _m.Called(id, userID, opts)

var r0 *baremetal.SwiftPassword
if rf, ok := ret.Get(0).(func(string, string, *baremetal.UpdateIdentityOptions) *baremetal.SwiftPassword); ok {
r0 = rf(id, userID, opts)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*baremetal.SwiftPassword)
}
}

var r1 error
if rf, ok := ret.Get(1).(func(string, string, *baremetal.UpdateIdentityOptions) error); ok {
r1 = rf(id, userID, opts)
} else {
r1 = ret.Error(1)
}

return r0, r1
}

// UpdateUser provides a mock function with given fields: id, opts
func (_m *BareMetalClient) UpdateUser(id string, opts *baremetal.UpdateIdentityOptions) (*baremetal.User, error) {
ret := _m.Called(id, opts)
Expand All @@ -2709,6 +2930,29 @@ func (_m *BareMetalClient) UpdateUser(id string, opts *baremetal.UpdateIdentityO
return r0, r1
}

// UpdateVirtualNetwork provides a mock function with given fields: id, opts
func (_m *BareMetalClient) UpdateVirtualNetwork(id string, opts *baremetal.IfMatchDisplayNameOptions) (*baremetal.VirtualNetwork, error) {
ret := _m.Called(id, opts)

var r0 *baremetal.VirtualNetwork
if rf, ok := ret.Get(0).(func(string, *baremetal.IfMatchDisplayNameOptions) *baremetal.VirtualNetwork); ok {
r0 = rf(id, opts)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*baremetal.VirtualNetwork)
}
}

var r1 error
if rf, ok := ret.Get(1).(func(string, *baremetal.IfMatchDisplayNameOptions) error); ok {
r1 = rf(id, opts)
} else {
r1 = ret.Error(1)
}

return r0, r1
}

// UpdateVolume provides a mock function with given fields: id, opts
func (_m *BareMetalClient) UpdateVolume(id string, opts *baremetal.UpdateOptions) (*baremetal.Volume, error) {
ret := _m.Called(id, opts)
Expand Down
10 changes: 9 additions & 1 deletion core/cpe_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ func CpeResource() *schema.Resource {
return &schema.Resource{
Create: createCpe,
Read: readCpe,
Update: updateCpe,
Delete: deleteCpe,
Schema: map[string]*schema.Schema{
"id": {
Expand All @@ -26,7 +27,6 @@ func CpeResource() *schema.Resource {
"display_name": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Computed: true,
},
"ip_address": {
Expand Down Expand Up @@ -59,6 +59,14 @@ func readCpe(d *schema.ResourceData, m interface{}) (e error) {
return crud.ReadResource(sync)
}

func updateCpe(d *schema.ResourceData, m interface{}) (e error) {
client := m.(client.BareMetalClient)
crd := &CpeResourceCrud{}
crd.D = d
crd.Client = client
return crud.UpdateResource(d, crd)
}

func deleteCpe(d *schema.ResourceData, m interface{}) (e error) {
client := m.(client.BareMetalClient)
sync := &CpeResourceCrud{}
Expand Down
Loading

0 comments on commit 7d6b3df

Please sign in to comment.