diff --git a/cloud/scope/clients.go b/cloud/scope/clients.go deleted file mode 100644 index 6a8ce83c8..000000000 --- a/cloud/scope/clients.go +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright 2021 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package scope - -import ( - "github.com/IBM/go-sdk-core/v5/core" - "github.com/IBM/vpc-go-sdk/vpcv1" -) - -// IBMVPCClients hosts the IBM VPC service. -type IBMVPCClients struct { - VPCService *vpcv1.VpcV1 - // APIKey string - // IAMEndpoint string - // ServiceEndPoint string -} - -func (c *IBMVPCClients) setIBMVPCService(authenticator core.Authenticator, svcEndpoint string) error { - var err error - c.VPCService, err = vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ - Authenticator: authenticator, - URL: svcEndpoint, - }) - - return err -} diff --git a/cloud/scope/cluster.go b/cloud/scope/cluster.go index db4483dd5..837f7d301 100644 --- a/cloud/scope/cluster.go +++ b/cloud/scope/cluster.go @@ -30,12 +30,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" infrav1beta1 "sigs.k8s.io/cluster-api-provider-ibmcloud/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-ibmcloud/pkg/cloud/services/vpc" "sigs.k8s.io/cluster-api-provider-ibmcloud/pkg/record" ) // ClusterScopeParams defines the input parameters used to create a new ClusterScope. type ClusterScopeParams struct { - IBMVPCClients + IBMVPCClient vpc.Vpc Client client.Client Logger logr.Logger Cluster *capiv1beta1.Cluster @@ -48,7 +49,7 @@ type ClusterScope struct { client client.Client patchHelper *patch.Helper - IBMVPCClients + IBMVPCClient vpc.Vpc Cluster *capiv1beta1.Cluster IBMVPCCluster *infrav1beta1.IBMVPCCluster } @@ -71,9 +72,9 @@ func NewClusterScope(params ClusterScopeParams, authenticator core.Authenticator return nil, errors.Wrap(err, "failed to init patch helper") } - vpcErr := params.IBMVPCClients.setIBMVPCService(authenticator, svcEndpoint) - if vpcErr != nil { - return nil, errors.Wrap(vpcErr, "failed to create IBM VPC session") + vpcClient, err := vpc.NewService(svcEndpoint) + if err != nil { + return nil, errors.Wrap(err, "failed to create IBM VPC session") } if params.Logger.V(DEBUGLEVEL).Enabled() { @@ -83,7 +84,7 @@ func NewClusterScope(params ClusterScopeParams, authenticator core.Authenticator return &ClusterScope{ Logger: params.Logger, client: params.Client, - IBMVPCClients: params.IBMVPCClients, + IBMVPCClient: vpcClient, Cluster: params.Cluster, IBMVPCCluster: params.IBMVPCCluster, patchHelper: helper, @@ -105,7 +106,7 @@ func (s *ClusterScope) CreateVPC() (*vpcv1.VPC, error) { ID: &s.IBMVPCCluster.Spec.ResourceGroup, }) options.SetName(s.IBMVPCCluster.Spec.VPC) - vpc, _, err := s.IBMVPCClients.VPCService.CreateVPC(options) + vpc, _, err := s.IBMVPCClient.CreateVPC(options) if err != nil { record.Warnf(s.IBMVPCCluster, "FailedCreateVPC", "Failed vpc creation - %v", err) return nil, err @@ -121,7 +122,7 @@ func (s *ClusterScope) CreateVPC() (*vpcv1.VPC, error) { func (s *ClusterScope) DeleteVPC() error { deleteVpcOptions := &vpcv1.DeleteVPCOptions{} deleteVpcOptions.SetID(s.IBMVPCCluster.Status.VPC.ID) - _, err := s.IBMVPCClients.VPCService.DeleteVPC(deleteVpcOptions) + _, err := s.IBMVPCClient.DeleteVPC(deleteVpcOptions) if err != nil { record.Warnf(s.IBMVPCCluster, "FailedDeleteVPC", "Failed vpc deletion - %v", err) } else { @@ -133,7 +134,7 @@ func (s *ClusterScope) DeleteVPC() error { func (s *ClusterScope) ensureVPCUnique(vpcName string) (*vpcv1.VPC, error) { listVpcsOptions := &vpcv1.ListVpcsOptions{} - vpcs, _, err := s.IBMVPCClients.VPCService.ListVpcs(listVpcsOptions) + vpcs, _, err := s.IBMVPCClient.ListVpcs(listVpcsOptions) if err != nil { return nil, err } @@ -153,7 +154,7 @@ func (s *ClusterScope) updateDefaultSG(sgID string) error { Protocol: core.StringPtr("all"), IPVersion: core.StringPtr("ipv4"), }) - _, _, err := s.IBMVPCClients.VPCService.CreateSecurityGroupRule(options) + _, _, err := s.IBMVPCClient.CreateSecurityGroupRule(options) if err != nil { record.Warnf(s.IBMVPCCluster, "FailedCreateSecurityGroupRule", "Failed security group rule creation - %v", err) } @@ -182,7 +183,7 @@ func (s *ClusterScope) ReserveFIP() (*vpcv1.FloatingIP, error) { }, }) - floatingIP, _, err := s.IBMVPCClients.VPCService.CreateFloatingIP(options) + floatingIP, _, err := s.IBMVPCClient.CreateFloatingIP(options) if err != nil { record.Warnf(s.IBMVPCCluster, "FailedCreateFloatingIP", "Failed floatingIP creation - %v", err) } @@ -190,8 +191,8 @@ func (s *ClusterScope) ReserveFIP() (*vpcv1.FloatingIP, error) { } func (s *ClusterScope) ensureFIPUnique(fipName string) (*vpcv1.FloatingIP, error) { - listFloatingIpsOptions := s.IBMVPCClients.VPCService.NewListFloatingIpsOptions() - floatingIPs, _, err := s.IBMVPCClients.VPCService.ListFloatingIps(listFloatingIpsOptions) + listFloatingIpsOptions := &vpcv1.ListFloatingIpsOptions{} + floatingIPs, _, err := s.IBMVPCClient.ListFloatingIps(listFloatingIpsOptions) if err != nil { return nil, err } @@ -208,7 +209,7 @@ func (s *ClusterScope) DeleteFloatingIP() error { if fipID := *s.IBMVPCCluster.Status.VPCEndpoint.FIPID; fipID != "" { deleteFIPOption := &vpcv1.DeleteFloatingIPOptions{} deleteFIPOption.SetID(fipID) - _, err := s.IBMVPCClients.VPCService.DeleteFloatingIP(deleteFIPOption) + _, err := s.IBMVPCClient.DeleteFloatingIP(deleteFIPOption) if err != nil { record.Warnf(s.IBMVPCCluster, "FailedDeleteFloatingIP", "Failed floatingIP deletion - %v", err) } @@ -247,7 +248,7 @@ func (s *ClusterScope) CreateSubnet() (*vpcv1.Subnet, error) { ID: &s.IBMVPCCluster.Spec.ResourceGroup, }, }) - subnet, _, err := s.IBMVPCClients.VPCService.CreateSubnet(options) + subnet, _, err := s.IBMVPCClient.CreateSubnet(options) if err != nil { record.Warnf(s.IBMVPCCluster, "FailedCreateSubnet", "Failed subnet creation - %v", err) } @@ -269,7 +270,7 @@ func (s *ClusterScope) getSubnetAddrPrefix(vpcID, zone string) (string, error) { options := &vpcv1.ListVPCAddressPrefixesOptions{ VPCID: &vpcID, } - addrCollection, _, err := s.IBMVPCClients.VPCService.ListVPCAddressPrefixes(options) + addrCollection, _, err := s.IBMVPCClient.ListVPCAddressPrefixes(options) if err != nil { return "", err @@ -284,7 +285,7 @@ func (s *ClusterScope) getSubnetAddrPrefix(vpcID, zone string) (string, error) { func (s *ClusterScope) ensureSubnetUnique(subnetName string) (*vpcv1.Subnet, error) { options := &vpcv1.ListSubnetsOptions{} - subnets, _, err := s.IBMVPCClients.VPCService.ListSubnets(options) + subnets, _, err := s.IBMVPCClient.ListSubnets(options) if err != nil { return nil, err @@ -304,7 +305,7 @@ func (s *ClusterScope) DeleteSubnet() error { // get the pgw id for given subnet, so we can delete it later getPGWOptions := &vpcv1.GetSubnetPublicGatewayOptions{} getPGWOptions.SetID(subnetID) - pgw, _, err := s.IBMVPCClients.VPCService.GetSubnetPublicGateway(getPGWOptions) + pgw, _, err := s.IBMVPCClient.GetSubnetPublicGateway(getPGWOptions) if pgw != nil && err == nil { // public gateway found // Unset the public gateway for subnet first err = s.detachPublicGateway(subnetID, *pgw.ID) @@ -316,7 +317,7 @@ func (s *ClusterScope) DeleteSubnet() error { // Delete subnet deleteSubnetOption := &vpcv1.DeleteSubnetOptions{} deleteSubnetOption.SetID(subnetID) - _, err = s.IBMVPCClients.VPCService.DeleteSubnet(deleteSubnetOption) + _, err = s.IBMVPCClient.DeleteSubnet(deleteSubnetOption) if err != nil { record.Warnf(s.IBMVPCCluster, "FailedDeleteSubnet", "Failed subnet deletion - %v", err) return errors.Wrap(err, "Error when deleting subnet ") @@ -335,7 +336,7 @@ func (s *ClusterScope) createPublicGateWay(vpcID string, zoneName string, resour options.SetResourceGroup(&vpcv1.ResourceGroupIdentity{ ID: &resourceGroupID, }) - publicGateway, _, err := s.IBMVPCClients.VPCService.CreatePublicGateway(options) + publicGateway, _, err := s.IBMVPCClient.CreatePublicGateway(options) if err != nil { record.Warnf(s.IBMVPCCluster, "FailedCreatePublicGateway", "Failed publicgateway creation - %v", err) } @@ -348,7 +349,7 @@ func (s *ClusterScope) attachPublicGateWay(subnetID string, pgwID string) (*vpcv options.SetPublicGatewayIdentity(&vpcv1.PublicGatewayIdentity{ ID: &pgwID, }) - publicGateway, _, err := s.IBMVPCClients.VPCService.SetSubnetPublicGateway(options) + publicGateway, _, err := s.IBMVPCClient.SetSubnetPublicGateway(options) if err != nil { record.Warnf(s.IBMVPCCluster, "FailedAttachPublicGateway", "Failed publicgateway attachment - %v", err) } @@ -359,7 +360,7 @@ func (s *ClusterScope) detachPublicGateway(subnetID string, pgwID string) error // Unset the publicgateway first, and then delete it unsetPGWOption := &vpcv1.UnsetSubnetPublicGatewayOptions{} unsetPGWOption.SetID(subnetID) - _, err := s.IBMVPCClients.VPCService.UnsetSubnetPublicGateway(unsetPGWOption) + _, err := s.IBMVPCClient.UnsetSubnetPublicGateway(unsetPGWOption) if err != nil { record.Warnf(s.IBMVPCCluster, "FailedDetachPublicGateway", "Failed publicgateway detachment - %v", err) return errors.Wrap(err, "Error when unsetting publicgateway for subnet "+subnetID) @@ -368,7 +369,7 @@ func (s *ClusterScope) detachPublicGateway(subnetID string, pgwID string) error // Delete the public gateway deletePGWOption := &vpcv1.DeletePublicGatewayOptions{} deletePGWOption.SetID(pgwID) - _, err = s.IBMVPCClients.VPCService.DeletePublicGateway(deletePGWOption) + _, err = s.IBMVPCClient.DeletePublicGateway(deletePGWOption) if err != nil { record.Warnf(s.IBMVPCCluster, "FailedDeletePublicGateway", "Failed publicgateway deletion - %v", err) return errors.Wrap(err, "Error when deleting publicgateway for subnet "+subnetID) diff --git a/cloud/scope/machine.go b/cloud/scope/machine.go index 61fb06c31..78368e631 100644 --- a/cloud/scope/machine.go +++ b/cloud/scope/machine.go @@ -32,12 +32,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" infrav1beta1 "sigs.k8s.io/cluster-api-provider-ibmcloud/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-ibmcloud/pkg/cloud/services/vpc" "sigs.k8s.io/cluster-api-provider-ibmcloud/pkg/record" ) // MachineScopeParams defines the input parameters used to create a new MachineScope. type MachineScopeParams struct { - IBMVPCClients + IBMVPCClient vpc.Vpc Client client.Client Logger logr.Logger Cluster *capiv1beta1.Cluster @@ -52,7 +53,7 @@ type MachineScope struct { client client.Client patchHelper *patch.Helper - IBMVPCClients + IBMVPCClient vpc.Vpc Cluster *capiv1beta1.Cluster Machine *capiv1beta1.Machine IBMVPCCluster *infrav1beta1.IBMVPCCluster @@ -77,9 +78,9 @@ func NewMachineScope(params MachineScopeParams, authenticator core.Authenticator return nil, errors.Wrap(err, "failed to init patch helper") } - vpcErr := params.IBMVPCClients.setIBMVPCService(authenticator, svcEndpoint) - if vpcErr != nil { - return nil, errors.Wrap(vpcErr, "failed to create IBM VPC session") + vpcClient, err := vpc.NewService(svcEndpoint) + if err != nil { + return nil, errors.Wrap(err, "failed to create IBM VPC session") } if params.Logger.V(DEBUGLEVEL).Enabled() { @@ -89,7 +90,7 @@ func NewMachineScope(params MachineScopeParams, authenticator core.Authenticator return &MachineScope{ Logger: params.Logger, client: params.Client, - IBMVPCClients: params.IBMVPCClients, + IBMVPCClient: vpcClient, Cluster: params.Cluster, IBMVPCCluster: params.IBMVPCCluster, patchHelper: helper, @@ -147,7 +148,7 @@ func (m *MachineScope) CreateMachine() (*vpcv1.Instance, error) { } options.SetInstancePrototype(instancePrototype) - instance, response, err := m.IBMVPCClients.VPCService.CreateInstance(options) + instance, response, err := m.IBMVPCClient.CreateInstance(options) if err != nil { record.Warnf(m.IBMVPCMachine, "FailedCreateInstance", "Failed instance creation - %v", err) } else { @@ -161,7 +162,7 @@ func (m *MachineScope) CreateMachine() (*vpcv1.Instance, error) { func (m *MachineScope) DeleteMachine() error { options := &vpcv1.DeleteInstanceOptions{} options.SetID(m.IBMVPCMachine.Status.InstanceID) - _, err := m.IBMVPCClients.VPCService.DeleteInstance(options) + _, err := m.IBMVPCClient.DeleteInstance(options) if err != nil { record.Warnf(m.IBMVPCMachine, "FailedDeleteInstance", "Failed instance deletion - %v", err) } else { @@ -172,7 +173,7 @@ func (m *MachineScope) DeleteMachine() error { func (m *MachineScope) ensureInstanceUnique(instanceName string) (*vpcv1.Instance, error) { options := &vpcv1.ListInstancesOptions{} - instances, _, err := m.IBMVPCClients.VPCService.ListInstances(options) + instances, _, err := m.IBMVPCClient.ListInstances(options) if err != nil { return nil, err @@ -190,7 +191,7 @@ func (m *MachineScope) GetMachine(instanceID string) (*vpcv1.Instance, error) { options := &vpcv1.GetInstanceOptions{} options.SetID(instanceID) - instance, _, err := m.IBMVPCClients.VPCService.GetInstance(options) + instance, _, err := m.IBMVPCClient.GetInstance(options) return instance, err } diff --git a/controllers/ibmvpccluster_controller.go b/controllers/ibmvpccluster_controller.go index f91ae022c..67d18b0ea 100644 --- a/controllers/ibmvpccluster_controller.go +++ b/controllers/ibmvpccluster_controller.go @@ -167,7 +167,7 @@ func (r *IBMVPCClusterReconciler) reconcileDelete(clusterScope *scope.ClusterSco listVSIOpts := &vpcv1.ListInstancesOptions{ VPCID: &clusterScope.IBMVPCCluster.Status.VPC.ID, } - vsis, _, err := clusterScope.VPCService.ListInstances(listVSIOpts) + vsis, _, err := clusterScope.IBMVPCClient.ListInstances(listVSIOpts) if err != nil { return ctrl.Result{}, errors.Wrap(err, "Error when listing VSIs when tried to delete subnet ") } diff --git a/controllers/ibmvpcmachine_controller.go b/controllers/ibmvpcmachine_controller.go index 7919af1ee..8c2869cdf 100644 --- a/controllers/ibmvpcmachine_controller.go +++ b/controllers/ibmvpcmachine_controller.go @@ -176,7 +176,7 @@ func (r *IBMVPCMachineReconciler) reconcileNormal(machineScope *scope.MachineSco options.SetInstanceID(*instance.ID) options.SetNetworkInterfaceID(*instance.PrimaryNetworkInterface.ID) floatingIP, _, err := - machineScope.IBMVPCClients.VPCService.AddInstanceNetworkInterfaceFloatingIP(options) + machineScope.IBMVPCClient.AddInstanceNetworkInterfaceFloatingIP(options) if err != nil { return ctrl.Result{}, errors.Wrapf(err, "failed to bind floating IP to control plane %s/%s", machineScope.IBMVPCMachine.Namespace, machineScope.IBMVPCMachine.Name) } diff --git a/pkg/cloud/services/vpc/doc.go b/pkg/cloud/services/vpc/doc.go new file mode 100644 index 000000000..cd52a1e67 --- /dev/null +++ b/pkg/cloud/services/vpc/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2022 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package vpc implements VPC code. +package vpc diff --git a/pkg/cloud/services/vpc/mock/vpc_generated.go b/pkg/cloud/services/vpc/mock/vpc_generated.go new file mode 100644 index 000000000..4939427cc --- /dev/null +++ b/pkg/cloud/services/vpc/mock/vpc_generated.go @@ -0,0 +1,381 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by MockGen. DO NOT EDIT. +// Source: ./vpc.go + +// Package mock is a generated GoMock package. +package mock + +import ( + reflect "reflect" + + core "github.com/IBM/go-sdk-core/v5/core" + vpcv1 "github.com/IBM/vpc-go-sdk/vpcv1" + gomock "github.com/golang/mock/gomock" +) + +// MockVpc is a mock of Vpc interface. +type MockVpc struct { + ctrl *gomock.Controller + recorder *MockVpcMockRecorder +} + +// MockVpcMockRecorder is the mock recorder for MockVpc. +type MockVpcMockRecorder struct { + mock *MockVpc +} + +// NewMockVpc creates a new mock instance. +func NewMockVpc(ctrl *gomock.Controller) *MockVpc { + mock := &MockVpc{ctrl: ctrl} + mock.recorder = &MockVpcMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockVpc) EXPECT() *MockVpcMockRecorder { + return m.recorder +} + +// AddInstanceNetworkInterfaceFloatingIP mocks base method. +func (m *MockVpc) AddInstanceNetworkInterfaceFloatingIP(options *vpcv1.AddInstanceNetworkInterfaceFloatingIPOptions) (*vpcv1.FloatingIP, *core.DetailedResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AddInstanceNetworkInterfaceFloatingIP", options) + ret0, _ := ret[0].(*vpcv1.FloatingIP) + ret1, _ := ret[1].(*core.DetailedResponse) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// AddInstanceNetworkInterfaceFloatingIP indicates an expected call of AddInstanceNetworkInterfaceFloatingIP. +func (mr *MockVpcMockRecorder) AddInstanceNetworkInterfaceFloatingIP(options interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddInstanceNetworkInterfaceFloatingIP", reflect.TypeOf((*MockVpc)(nil).AddInstanceNetworkInterfaceFloatingIP), options) +} + +// CreateFloatingIP mocks base method. +func (m *MockVpc) CreateFloatingIP(options *vpcv1.CreateFloatingIPOptions) (*vpcv1.FloatingIP, *core.DetailedResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateFloatingIP", options) + ret0, _ := ret[0].(*vpcv1.FloatingIP) + ret1, _ := ret[1].(*core.DetailedResponse) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// CreateFloatingIP indicates an expected call of CreateFloatingIP. +func (mr *MockVpcMockRecorder) CreateFloatingIP(options interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateFloatingIP", reflect.TypeOf((*MockVpc)(nil).CreateFloatingIP), options) +} + +// CreateInstance mocks base method. +func (m *MockVpc) CreateInstance(options *vpcv1.CreateInstanceOptions) (*vpcv1.Instance, *core.DetailedResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateInstance", options) + ret0, _ := ret[0].(*vpcv1.Instance) + ret1, _ := ret[1].(*core.DetailedResponse) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// CreateInstance indicates an expected call of CreateInstance. +func (mr *MockVpcMockRecorder) CreateInstance(options interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateInstance", reflect.TypeOf((*MockVpc)(nil).CreateInstance), options) +} + +// CreatePublicGateway mocks base method. +func (m *MockVpc) CreatePublicGateway(options *vpcv1.CreatePublicGatewayOptions) (*vpcv1.PublicGateway, *core.DetailedResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreatePublicGateway", options) + ret0, _ := ret[0].(*vpcv1.PublicGateway) + ret1, _ := ret[1].(*core.DetailedResponse) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// CreatePublicGateway indicates an expected call of CreatePublicGateway. +func (mr *MockVpcMockRecorder) CreatePublicGateway(options interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreatePublicGateway", reflect.TypeOf((*MockVpc)(nil).CreatePublicGateway), options) +} + +// CreateSecurityGroupRule mocks base method. +func (m *MockVpc) CreateSecurityGroupRule(options *vpcv1.CreateSecurityGroupRuleOptions) (vpcv1.SecurityGroupRuleIntf, *core.DetailedResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateSecurityGroupRule", options) + ret0, _ := ret[0].(vpcv1.SecurityGroupRuleIntf) + ret1, _ := ret[1].(*core.DetailedResponse) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// CreateSecurityGroupRule indicates an expected call of CreateSecurityGroupRule. +func (mr *MockVpcMockRecorder) CreateSecurityGroupRule(options interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateSecurityGroupRule", reflect.TypeOf((*MockVpc)(nil).CreateSecurityGroupRule), options) +} + +// CreateSubnet mocks base method. +func (m *MockVpc) CreateSubnet(options *vpcv1.CreateSubnetOptions) (*vpcv1.Subnet, *core.DetailedResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateSubnet", options) + ret0, _ := ret[0].(*vpcv1.Subnet) + ret1, _ := ret[1].(*core.DetailedResponse) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// CreateSubnet indicates an expected call of CreateSubnet. +func (mr *MockVpcMockRecorder) CreateSubnet(options interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateSubnet", reflect.TypeOf((*MockVpc)(nil).CreateSubnet), options) +} + +// CreateVPC mocks base method. +func (m *MockVpc) CreateVPC(options *vpcv1.CreateVPCOptions) (*vpcv1.VPC, *core.DetailedResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateVPC", options) + ret0, _ := ret[0].(*vpcv1.VPC) + ret1, _ := ret[1].(*core.DetailedResponse) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// CreateVPC indicates an expected call of CreateVPC. +func (mr *MockVpcMockRecorder) CreateVPC(options interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateVPC", reflect.TypeOf((*MockVpc)(nil).CreateVPC), options) +} + +// DeleteFloatingIP mocks base method. +func (m *MockVpc) DeleteFloatingIP(options *vpcv1.DeleteFloatingIPOptions) (*core.DetailedResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteFloatingIP", options) + ret0, _ := ret[0].(*core.DetailedResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// DeleteFloatingIP indicates an expected call of DeleteFloatingIP. +func (mr *MockVpcMockRecorder) DeleteFloatingIP(options interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteFloatingIP", reflect.TypeOf((*MockVpc)(nil).DeleteFloatingIP), options) +} + +// DeleteInstance mocks base method. +func (m *MockVpc) DeleteInstance(options *vpcv1.DeleteInstanceOptions) (*core.DetailedResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteInstance", options) + ret0, _ := ret[0].(*core.DetailedResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// DeleteInstance indicates an expected call of DeleteInstance. +func (mr *MockVpcMockRecorder) DeleteInstance(options interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteInstance", reflect.TypeOf((*MockVpc)(nil).DeleteInstance), options) +} + +// DeletePublicGateway mocks base method. +func (m *MockVpc) DeletePublicGateway(options *vpcv1.DeletePublicGatewayOptions) (*core.DetailedResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeletePublicGateway", options) + ret0, _ := ret[0].(*core.DetailedResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// DeletePublicGateway indicates an expected call of DeletePublicGateway. +func (mr *MockVpcMockRecorder) DeletePublicGateway(options interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeletePublicGateway", reflect.TypeOf((*MockVpc)(nil).DeletePublicGateway), options) +} + +// DeleteSubnet mocks base method. +func (m *MockVpc) DeleteSubnet(options *vpcv1.DeleteSubnetOptions) (*core.DetailedResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteSubnet", options) + ret0, _ := ret[0].(*core.DetailedResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// DeleteSubnet indicates an expected call of DeleteSubnet. +func (mr *MockVpcMockRecorder) DeleteSubnet(options interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteSubnet", reflect.TypeOf((*MockVpc)(nil).DeleteSubnet), options) +} + +// DeleteVPC mocks base method. +func (m *MockVpc) DeleteVPC(options *vpcv1.DeleteVPCOptions) (*core.DetailedResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteVPC", options) + ret0, _ := ret[0].(*core.DetailedResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// DeleteVPC indicates an expected call of DeleteVPC. +func (mr *MockVpcMockRecorder) DeleteVPC(options interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteVPC", reflect.TypeOf((*MockVpc)(nil).DeleteVPC), options) +} + +// GetInstance mocks base method. +func (m *MockVpc) GetInstance(options *vpcv1.GetInstanceOptions) (*vpcv1.Instance, *core.DetailedResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetInstance", options) + ret0, _ := ret[0].(*vpcv1.Instance) + ret1, _ := ret[1].(*core.DetailedResponse) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetInstance indicates an expected call of GetInstance. +func (mr *MockVpcMockRecorder) GetInstance(options interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetInstance", reflect.TypeOf((*MockVpc)(nil).GetInstance), options) +} + +// GetSubnetPublicGateway mocks base method. +func (m *MockVpc) GetSubnetPublicGateway(options *vpcv1.GetSubnetPublicGatewayOptions) (*vpcv1.PublicGateway, *core.DetailedResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetSubnetPublicGateway", options) + ret0, _ := ret[0].(*vpcv1.PublicGateway) + ret1, _ := ret[1].(*core.DetailedResponse) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetSubnetPublicGateway indicates an expected call of GetSubnetPublicGateway. +func (mr *MockVpcMockRecorder) GetSubnetPublicGateway(options interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSubnetPublicGateway", reflect.TypeOf((*MockVpc)(nil).GetSubnetPublicGateway), options) +} + +// ListFloatingIps mocks base method. +func (m *MockVpc) ListFloatingIps(options *vpcv1.ListFloatingIpsOptions) (*vpcv1.FloatingIPCollection, *core.DetailedResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListFloatingIps", options) + ret0, _ := ret[0].(*vpcv1.FloatingIPCollection) + ret1, _ := ret[1].(*core.DetailedResponse) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// ListFloatingIps indicates an expected call of ListFloatingIps. +func (mr *MockVpcMockRecorder) ListFloatingIps(options interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListFloatingIps", reflect.TypeOf((*MockVpc)(nil).ListFloatingIps), options) +} + +// ListInstances mocks base method. +func (m *MockVpc) ListInstances(options *vpcv1.ListInstancesOptions) (*vpcv1.InstanceCollection, *core.DetailedResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListInstances", options) + ret0, _ := ret[0].(*vpcv1.InstanceCollection) + ret1, _ := ret[1].(*core.DetailedResponse) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// ListInstances indicates an expected call of ListInstances. +func (mr *MockVpcMockRecorder) ListInstances(options interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListInstances", reflect.TypeOf((*MockVpc)(nil).ListInstances), options) +} + +// ListSubnets mocks base method. +func (m *MockVpc) ListSubnets(options *vpcv1.ListSubnetsOptions) (*vpcv1.SubnetCollection, *core.DetailedResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListSubnets", options) + ret0, _ := ret[0].(*vpcv1.SubnetCollection) + ret1, _ := ret[1].(*core.DetailedResponse) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// ListSubnets indicates an expected call of ListSubnets. +func (mr *MockVpcMockRecorder) ListSubnets(options interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListSubnets", reflect.TypeOf((*MockVpc)(nil).ListSubnets), options) +} + +// ListVPCAddressPrefixes mocks base method. +func (m *MockVpc) ListVPCAddressPrefixes(options *vpcv1.ListVPCAddressPrefixesOptions) (*vpcv1.AddressPrefixCollection, *core.DetailedResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListVPCAddressPrefixes", options) + ret0, _ := ret[0].(*vpcv1.AddressPrefixCollection) + ret1, _ := ret[1].(*core.DetailedResponse) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// ListVPCAddressPrefixes indicates an expected call of ListVPCAddressPrefixes. +func (mr *MockVpcMockRecorder) ListVPCAddressPrefixes(options interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListVPCAddressPrefixes", reflect.TypeOf((*MockVpc)(nil).ListVPCAddressPrefixes), options) +} + +// ListVpcs mocks base method. +func (m *MockVpc) ListVpcs(options *vpcv1.ListVpcsOptions) (*vpcv1.VPCCollection, *core.DetailedResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListVpcs", options) + ret0, _ := ret[0].(*vpcv1.VPCCollection) + ret1, _ := ret[1].(*core.DetailedResponse) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// ListVpcs indicates an expected call of ListVpcs. +func (mr *MockVpcMockRecorder) ListVpcs(options interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListVpcs", reflect.TypeOf((*MockVpc)(nil).ListVpcs), options) +} + +// SetSubnetPublicGateway mocks base method. +func (m *MockVpc) SetSubnetPublicGateway(options *vpcv1.SetSubnetPublicGatewayOptions) (*vpcv1.PublicGateway, *core.DetailedResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetSubnetPublicGateway", options) + ret0, _ := ret[0].(*vpcv1.PublicGateway) + ret1, _ := ret[1].(*core.DetailedResponse) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// SetSubnetPublicGateway indicates an expected call of SetSubnetPublicGateway. +func (mr *MockVpcMockRecorder) SetSubnetPublicGateway(options interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetSubnetPublicGateway", reflect.TypeOf((*MockVpc)(nil).SetSubnetPublicGateway), options) +} + +// UnsetSubnetPublicGateway mocks base method. +func (m *MockVpc) UnsetSubnetPublicGateway(options *vpcv1.UnsetSubnetPublicGatewayOptions) (*core.DetailedResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UnsetSubnetPublicGateway", options) + ret0, _ := ret[0].(*core.DetailedResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// UnsetSubnetPublicGateway indicates an expected call of UnsetSubnetPublicGateway. +func (mr *MockVpcMockRecorder) UnsetSubnetPublicGateway(options interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnsetSubnetPublicGateway", reflect.TypeOf((*MockVpc)(nil).UnsetSubnetPublicGateway), options) +} diff --git a/pkg/cloud/services/vpc/service.go b/pkg/cloud/services/vpc/service.go new file mode 100644 index 000000000..d63c4ed35 --- /dev/null +++ b/pkg/cloud/services/vpc/service.go @@ -0,0 +1,150 @@ +/* +Copyright 2022 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package vpc + +import ( + "github.com/IBM/go-sdk-core/v5/core" + "github.com/IBM/vpc-go-sdk/vpcv1" + + "sigs.k8s.io/cluster-api-provider-ibmcloud/pkg/cloud/services/authenticator" +) + +// Service holds the VPC Service specific information. +type Service struct { + vpcService *vpcv1.VpcV1 +} + +// CreateInstance created an virtal server instance. +func (s *Service) CreateInstance(options *vpcv1.CreateInstanceOptions) (*vpcv1.Instance, *core.DetailedResponse, error) { + return s.vpcService.CreateInstance(options) +} + +// DeleteInstance deleted a virtal server instance. +func (s *Service) DeleteInstance(options *vpcv1.DeleteInstanceOptions) (*core.DetailedResponse, error) { + return s.vpcService.DeleteInstance(options) +} + +// GetInstance returns the virtal server instance. +func (s *Service) GetInstance(options *vpcv1.GetInstanceOptions) (*vpcv1.Instance, *core.DetailedResponse, error) { + return s.vpcService.GetInstance(options) +} + +// ListInstances returns list of virtual server instances. +func (s *Service) ListInstances(options *vpcv1.ListInstancesOptions) (*vpcv1.InstanceCollection, *core.DetailedResponse, error) { + return s.vpcService.ListInstances(options) +} + +// CreateVPC creates a new VPC. +func (s *Service) CreateVPC(options *vpcv1.CreateVPCOptions) (*vpcv1.VPC, *core.DetailedResponse, error) { + return s.vpcService.CreateVPC(options) +} + +// DeleteVPC deletes a VPC. +func (s *Service) DeleteVPC(options *vpcv1.DeleteVPCOptions) (*core.DetailedResponse, error) { + return s.vpcService.DeleteVPC(options) +} + +// ListVpcs returns list of VPCs in a region. +func (s *Service) ListVpcs(options *vpcv1.ListVpcsOptions) (*vpcv1.VPCCollection, *core.DetailedResponse, error) { + return s.vpcService.ListVpcs(options) +} + +// CreateFloatingIP reserves a floating IP. +func (s *Service) CreateFloatingIP(options *vpcv1.CreateFloatingIPOptions) (*vpcv1.FloatingIP, *core.DetailedResponse, error) { + return s.vpcService.CreateFloatingIP(options) +} + +// DeleteFloatingIP releases a floating IP. +func (s *Service) DeleteFloatingIP(options *vpcv1.DeleteFloatingIPOptions) (*core.DetailedResponse, error) { + return s.vpcService.DeleteFloatingIP(options) +} + +// ListFloatingIps returns list of the floating IPs in a region. +func (s *Service) ListFloatingIps(options *vpcv1.ListFloatingIpsOptions) (*vpcv1.FloatingIPCollection, *core.DetailedResponse, error) { + return s.vpcService.ListFloatingIps(options) +} + +// CreateSubnet creates a subnet. +func (s *Service) CreateSubnet(options *vpcv1.CreateSubnetOptions) (*vpcv1.Subnet, *core.DetailedResponse, error) { + return s.vpcService.CreateSubnet(options) +} + +// DeleteSubnet deletes a subnet. +func (s *Service) DeleteSubnet(options *vpcv1.DeleteSubnetOptions) (*core.DetailedResponse, error) { + return s.vpcService.DeleteSubnet(options) +} + +// ListSubnets returns list of subnets in a region. +func (s *Service) ListSubnets(options *vpcv1.ListSubnetsOptions) (*vpcv1.SubnetCollection, *core.DetailedResponse, error) { + return s.vpcService.ListSubnets(options) +} + +// GetSubnetPublicGateway returns a public gateway attched to the subnet. +func (s *Service) GetSubnetPublicGateway(options *vpcv1.GetSubnetPublicGatewayOptions) (*vpcv1.PublicGateway, *core.DetailedResponse, error) { + return s.vpcService.GetSubnetPublicGateway(options) +} + +// CreatePublicGateway creates a public gateway for the VPC. +func (s *Service) CreatePublicGateway(options *vpcv1.CreatePublicGatewayOptions) (*vpcv1.PublicGateway, *core.DetailedResponse, error) { + return s.vpcService.CreatePublicGateway(options) +} + +// DeletePublicGateway deletes a public gateway. +func (s *Service) DeletePublicGateway(options *vpcv1.DeletePublicGatewayOptions) (*core.DetailedResponse, error) { + return s.vpcService.DeletePublicGateway(options) +} + +// UnsetSubnetPublicGateway detaches a public gateway from the subnet. +func (s *Service) UnsetSubnetPublicGateway(options *vpcv1.UnsetSubnetPublicGatewayOptions) (*core.DetailedResponse, error) { + return s.vpcService.UnsetSubnetPublicGateway(options) +} + +// SetSubnetPublicGateway attaches a public gateway to the subnet. +func (s *Service) SetSubnetPublicGateway(options *vpcv1.SetSubnetPublicGatewayOptions) (*vpcv1.PublicGateway, *core.DetailedResponse, error) { + return s.vpcService.SetSubnetPublicGateway(options) +} + +// ListVPCAddressPrefixes returns list of all address prefixes for a VPC. +func (s *Service) ListVPCAddressPrefixes(options *vpcv1.ListVPCAddressPrefixesOptions) (*vpcv1.AddressPrefixCollection, *core.DetailedResponse, error) { + return s.vpcService.ListVPCAddressPrefixes(options) +} + +// CreateSecurityGroupRule creates a rule for a security group. +func (s *Service) CreateSecurityGroupRule(options *vpcv1.CreateSecurityGroupRuleOptions) (vpcv1.SecurityGroupRuleIntf, *core.DetailedResponse, error) { + return s.vpcService.CreateSecurityGroupRule(options) +} + +// AddInstanceNetworkInterfaceFloatingIP associates a floating IP with a network interface. +func (s *Service) AddInstanceNetworkInterfaceFloatingIP(options *vpcv1.AddInstanceNetworkInterfaceFloatingIPOptions) (*vpcv1.FloatingIP, *core.DetailedResponse, error) { + return s.vpcService.AddInstanceNetworkInterfaceFloatingIP(options) +} + +// NewService returns a new VPC Service. +func NewService(svcEndpoint string) (Vpc, error) { + service := &Service{} + auth, err := authenticator.GetAuthenticator() + if err != nil { + return nil, err + } + + service.vpcService, err = vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + Authenticator: auth, + URL: svcEndpoint, + }) + + return service, err +} diff --git a/pkg/cloud/services/vpc/vpc.go b/pkg/cloud/services/vpc/vpc.go new file mode 100644 index 000000000..ba1534b42 --- /dev/null +++ b/pkg/cloud/services/vpc/vpc.go @@ -0,0 +1,50 @@ +/* +Copyright 2022 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +//go:generate ../../../../hack/tools/bin/mockgen -source=./vpc.go -destination=./mock/vpc_generated.go -package=mock +//go:generate /usr/bin/env bash -c "cat ../../../../hack/boilerplate/boilerplate.generatego.txt ./mock/vpc_generated.go > ./mock/_vpc_generated.go && mv ./mock/_vpc_generated.go ./mock/vpc_generated.go" + +package vpc + +import ( + "github.com/IBM/go-sdk-core/v5/core" + "github.com/IBM/vpc-go-sdk/vpcv1" +) + +// Vpc interface defines methods that a Cluster API IBMCLOUD object should implement. +type Vpc interface { + CreateInstance(options *vpcv1.CreateInstanceOptions) (*vpcv1.Instance, *core.DetailedResponse, error) + DeleteInstance(options *vpcv1.DeleteInstanceOptions) (*core.DetailedResponse, error) + GetInstance(options *vpcv1.GetInstanceOptions) (*vpcv1.Instance, *core.DetailedResponse, error) + ListInstances(options *vpcv1.ListInstancesOptions) (*vpcv1.InstanceCollection, *core.DetailedResponse, error) + CreateVPC(options *vpcv1.CreateVPCOptions) (*vpcv1.VPC, *core.DetailedResponse, error) + DeleteVPC(options *vpcv1.DeleteVPCOptions) (response *core.DetailedResponse, err error) + ListVpcs(options *vpcv1.ListVpcsOptions) (*vpcv1.VPCCollection, *core.DetailedResponse, error) + CreateFloatingIP(options *vpcv1.CreateFloatingIPOptions) (*vpcv1.FloatingIP, *core.DetailedResponse, error) + DeleteFloatingIP(options *vpcv1.DeleteFloatingIPOptions) (*core.DetailedResponse, error) + ListFloatingIps(options *vpcv1.ListFloatingIpsOptions) (*vpcv1.FloatingIPCollection, *core.DetailedResponse, error) + CreateSubnet(options *vpcv1.CreateSubnetOptions) (*vpcv1.Subnet, *core.DetailedResponse, error) + DeleteSubnet(options *vpcv1.DeleteSubnetOptions) (*core.DetailedResponse, error) + ListSubnets(options *vpcv1.ListSubnetsOptions) (*vpcv1.SubnetCollection, *core.DetailedResponse, error) + GetSubnetPublicGateway(options *vpcv1.GetSubnetPublicGatewayOptions) (*vpcv1.PublicGateway, *core.DetailedResponse, error) + SetSubnetPublicGateway(options *vpcv1.SetSubnetPublicGatewayOptions) (*vpcv1.PublicGateway, *core.DetailedResponse, error) + UnsetSubnetPublicGateway(options *vpcv1.UnsetSubnetPublicGatewayOptions) (*core.DetailedResponse, error) + CreatePublicGateway(options *vpcv1.CreatePublicGatewayOptions) (*vpcv1.PublicGateway, *core.DetailedResponse, error) + DeletePublicGateway(options *vpcv1.DeletePublicGatewayOptions) (*core.DetailedResponse, error) + ListVPCAddressPrefixes(options *vpcv1.ListVPCAddressPrefixesOptions) (*vpcv1.AddressPrefixCollection, *core.DetailedResponse, error) + CreateSecurityGroupRule(options *vpcv1.CreateSecurityGroupRuleOptions) (vpcv1.SecurityGroupRuleIntf, *core.DetailedResponse, error) + AddInstanceNetworkInterfaceFloatingIP(options *vpcv1.AddInstanceNetworkInterfaceFloatingIPOptions) (*vpcv1.FloatingIP, *core.DetailedResponse, error) +}