From fd1b7d959ec090260e06355ffd1bbace1f565d41 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Mon, 24 Feb 2025 13:16:42 -0600 Subject: [PATCH] Add nsg and nag commands to on-prem for Q3 --- .../instance/ibm-pi-network-address-group.go | 30 -------------- .../instance/ibm-pi-network-security-group.go | 40 ------------------- 2 files changed, 70 deletions(-) diff --git a/clients/instance/ibm-pi-network-address-group.go b/clients/instance/ibm-pi-network-address-group.go index 2a6df77a..2dbd2264 100644 --- a/clients/instance/ibm-pi-network-address-group.go +++ b/clients/instance/ibm-pi-network-address-group.go @@ -24,10 +24,6 @@ func NewIBMPINetworkAddressGroupClient(ctx context.Context, sess *ibmpisession.I // Create a new Network Address Group func (f *IBMPINetworkAddressGroupClient) Create(body *models.NetworkAddressGroupCreate) (*models.NetworkAddressGroup, error) { - // Add check for on-prem location - if f.session.IsOnPrem() { - return nil, fmt.Errorf(helpers.NotOnPremSupported) - } params := network_address_groups.NewV1NetworkAddressGroupsPostParams().WithContext(f.ctx).WithTimeout(helpers.PICreateTimeOut).WithBody(body) postok, postcreated, err := f.session.Power.NetworkAddressGroups.V1NetworkAddressGroupsPost(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { @@ -44,10 +40,6 @@ func (f *IBMPINetworkAddressGroupClient) Create(body *models.NetworkAddressGroup // Get the list of Network Address Groups for a workspace func (f *IBMPINetworkAddressGroupClient) GetAll() (*models.NetworkAddressGroups, error) { - // Add check for on-prem location - if f.session.IsOnPrem() { - return nil, fmt.Errorf(helpers.NotOnPremSupported) - } params := network_address_groups.NewV1NetworkAddressGroupsGetParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut) resp, err := f.session.Power.NetworkAddressGroups.V1NetworkAddressGroupsGet(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { @@ -57,15 +49,10 @@ func (f *IBMPINetworkAddressGroupClient) GetAll() (*models.NetworkAddressGroups, return nil, fmt.Errorf("failed to get network address groups") } return resp.Payload, nil - } // Get the detail of a Network Address Group func (f *IBMPINetworkAddressGroupClient) Get(id string) (*models.NetworkAddressGroup, error) { - // Add check for on-prem location - if f.session.IsOnPrem() { - return nil, fmt.Errorf(helpers.NotOnPremSupported) - } params := network_address_groups.NewV1NetworkAddressGroupsIDGetParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut).WithNetworkAddressGroupID(id) resp, err := f.session.Power.NetworkAddressGroups.V1NetworkAddressGroupsIDGet(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { @@ -80,10 +67,6 @@ func (f *IBMPINetworkAddressGroupClient) Get(id string) (*models.NetworkAddressG // Update a Network Address Group func (f *IBMPINetworkAddressGroupClient) Update(id string, body *models.NetworkAddressGroupUpdate) (*models.NetworkAddressGroup, error) { - // Add check for on-prem location - if f.session.IsOnPrem() { - return nil, fmt.Errorf(helpers.NotOnPremSupported) - } params := network_address_groups.NewV1NetworkAddressGroupsIDPutParams().WithContext(f.ctx).WithTimeout(helpers.PIUpdateTimeOut).WithNetworkAddressGroupID(id).WithBody(body) resp, err := f.session.Power.NetworkAddressGroups.V1NetworkAddressGroupsIDPut(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { @@ -97,10 +80,6 @@ func (f *IBMPINetworkAddressGroupClient) Update(id string, body *models.NetworkA // Delete a Network Address Group from a workspace func (f *IBMPINetworkAddressGroupClient) Delete(id string) error { - // Add check for on-prem location - if f.session.IsOnPrem() { - return fmt.Errorf(helpers.NotOnPremSupported) - } params := network_address_groups.NewV1NetworkAddressGroupsIDDeleteParams().WithContext(f.ctx).WithTimeout(helpers.PIDeleteTimeOut).WithNetworkAddressGroupID(id) _, err := f.session.Power.NetworkAddressGroups.V1NetworkAddressGroupsIDDelete(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { @@ -111,10 +90,6 @@ func (f *IBMPINetworkAddressGroupClient) Delete(id string) error { // Add a member to a Network Address Group func (f *IBMPINetworkAddressGroupClient) AddMember(id string, body *models.NetworkAddressGroupAddMember) (*models.NetworkAddressGroupMember, error) { - // Add check for on-prem location - if f.session.IsOnPrem() { - return nil, fmt.Errorf(helpers.NotOnPremSupported) - } params := network_address_groups.NewV1NetworkAddressGroupsMembersPostParams().WithContext(f.ctx).WithTimeout(helpers.PICreateTimeOut).WithNetworkAddressGroupID(id).WithBody(body) resp, err := f.session.Power.NetworkAddressGroups.V1NetworkAddressGroupsMembersPost(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { @@ -128,15 +103,10 @@ func (f *IBMPINetworkAddressGroupClient) AddMember(id string, body *models.Netwo // Delete the member from a Network Address Group func (f *IBMPINetworkAddressGroupClient) DeleteMember(id, memberId string) error { - // Add check for on-prem location - if f.session.IsOnPrem() { - return fmt.Errorf(helpers.NotOnPremSupported) - } params := network_address_groups.NewV1NetworkAddressGroupsMembersDeleteParams().WithContext(f.ctx).WithTimeout(helpers.PIDeleteTimeOut).WithNetworkAddressGroupID(id).WithNetworkAddressGroupMemberID(memberId) _, err := f.session.Power.NetworkAddressGroups.V1NetworkAddressGroupsMembersDelete(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { return ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to delete member %s from network address group %s: %w", memberId, id, err)) } - return nil } diff --git a/clients/instance/ibm-pi-network-security-group.go b/clients/instance/ibm-pi-network-security-group.go index ba48b5da..d9d4bf52 100644 --- a/clients/instance/ibm-pi-network-security-group.go +++ b/clients/instance/ibm-pi-network-security-group.go @@ -24,10 +24,6 @@ func NewIBMIPINetworkSecurityGroupClient(ctx context.Context, sess *ibmpisession // Get a network security group func (f *IBMPINetworkSecurityGroupClient) Get(id string) (*models.NetworkSecurityGroup, error) { - // Add check for on-prem location - if f.session.IsOnPrem() { - return nil, fmt.Errorf(helpers.NotOnPremSupported) - } params := network_security_groups.NewV1NetworkSecurityGroupsIDGetParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut).WithNetworkSecurityGroupID(id) resp, err := f.session.Power.NetworkSecurityGroups.V1NetworkSecurityGroupsIDGet(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { @@ -41,10 +37,6 @@ func (f *IBMPINetworkSecurityGroupClient) Get(id string) (*models.NetworkSecurit // Get all network security groups func (f *IBMPINetworkSecurityGroupClient) GetAll() (*models.NetworkSecurityGroups, error) { - // Add check for on-prem location - if f.session.IsOnPrem() { - return nil, fmt.Errorf(helpers.NotOnPremSupported) - } params := network_security_groups.NewV1NetworkSecurityGroupsListParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut) resp, err := f.session.Power.NetworkSecurityGroups.V1NetworkSecurityGroupsList(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { @@ -58,10 +50,6 @@ func (f *IBMPINetworkSecurityGroupClient) GetAll() (*models.NetworkSecurityGroup // Create a network security group func (f *IBMPINetworkSecurityGroupClient) Create(body *models.NetworkSecurityGroupCreate) (*models.NetworkSecurityGroup, error) { - // Add check for on-prem location - if f.session.IsOnPrem() { - return nil, fmt.Errorf(helpers.NotOnPremSupported) - } params := network_security_groups.NewV1NetworkSecurityGroupsPostParams().WithContext(f.ctx).WithTimeout(helpers.PICreateTimeOut).WithBody(body) postok, postcreated, err := f.session.Power.NetworkSecurityGroups.V1NetworkSecurityGroupsPost(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { @@ -78,10 +66,6 @@ func (f *IBMPINetworkSecurityGroupClient) Create(body *models.NetworkSecurityGro // Update a network security group func (f *IBMPINetworkSecurityGroupClient) Update(id string, body *models.NetworkSecurityGroupUpdate) (*models.NetworkSecurityGroup, error) { - // Add check for on-prem location - if f.session.IsOnPrem() { - return nil, fmt.Errorf(helpers.NotOnPremSupported) - } params := network_security_groups.NewV1NetworkSecurityGroupsIDPutParams().WithContext(f.ctx).WithTimeout(helpers.PIUpdateTimeOut).WithNetworkSecurityGroupID(id).WithBody(body) resp, err := f.session.Power.NetworkSecurityGroups.V1NetworkSecurityGroupsIDPut(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { @@ -95,10 +79,6 @@ func (f *IBMPINetworkSecurityGroupClient) Update(id string, body *models.Network // Delete a network security group func (f *IBMPINetworkSecurityGroupClient) Delete(id string) error { - // Add check for on-prem location - if f.session.IsOnPrem() { - return fmt.Errorf(helpers.NotOnPremSupported) - } params := network_security_groups.NewV1NetworkSecurityGroupsIDDeleteParams().WithContext(f.ctx).WithTimeout(helpers.PIDeleteTimeOut).WithNetworkSecurityGroupID(id) _, err := f.session.Power.NetworkSecurityGroups.V1NetworkSecurityGroupsIDDelete(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { @@ -109,10 +89,6 @@ func (f *IBMPINetworkSecurityGroupClient) Delete(id string) error { // Add a member to a network security group func (f *IBMPINetworkSecurityGroupClient) AddMember(id string, body *models.NetworkSecurityGroupAddMember) (*models.NetworkSecurityGroupMember, error) { - // Add check for on-prem location - if f.session.IsOnPrem() { - return nil, fmt.Errorf(helpers.NotOnPremSupported) - } params := network_security_groups.NewV1NetworkSecurityGroupsMembersPostParams().WithContext(f.ctx).WithTimeout(helpers.PICreateTimeOut).WithNetworkSecurityGroupID(id).WithBody(body) resp, err := f.session.Power.NetworkSecurityGroups.V1NetworkSecurityGroupsMembersPost(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { @@ -126,10 +102,6 @@ func (f *IBMPINetworkSecurityGroupClient) AddMember(id string, body *models.Netw // Deleta a member from a network securti group func (f *IBMPINetworkSecurityGroupClient) DeleteMember(id, memberId string) error { - // Add check for on-prem location - if f.session.IsOnPrem() { - return fmt.Errorf(helpers.NotOnPremSupported) - } params := network_security_groups.NewV1NetworkSecurityGroupsMembersDeleteParams().WithContext(f.ctx).WithTimeout(helpers.PIDeleteTimeOut).WithNetworkSecurityGroupID(id).WithNetworkSecurityGroupMemberID(memberId) _, err := f.session.Power.NetworkSecurityGroups.V1NetworkSecurityGroupsMembersDelete(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { @@ -140,10 +112,6 @@ func (f *IBMPINetworkSecurityGroupClient) DeleteMember(id, memberId string) erro // Add a rule to a network security group func (f *IBMPINetworkSecurityGroupClient) AddRule(id string, body *models.NetworkSecurityGroupAddRule) (*models.NetworkSecurityGroupRule, error) { - // Add check for on-prem location - if f.session.IsOnPrem() { - return nil, fmt.Errorf(helpers.NotOnPremSupported) - } params := network_security_groups.NewV1NetworkSecurityGroupsRulesPostParams().WithContext(f.ctx).WithTimeout(helpers.PICreateTimeOut).WithNetworkSecurityGroupID(id).WithBody(body) resp, err := f.session.Power.NetworkSecurityGroups.V1NetworkSecurityGroupsRulesPost(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { @@ -157,10 +125,6 @@ func (f *IBMPINetworkSecurityGroupClient) AddRule(id string, body *models.Networ // Delete a rule from a network security group func (f *IBMPINetworkSecurityGroupClient) DeleteRule(id, ruleId string) error { - // Add check for on-prem location - if f.session.IsOnPrem() { - return fmt.Errorf(helpers.NotOnPremSupported) - } params := network_security_groups.NewV1NetworkSecurityGroupsRulesDeleteParams().WithContext(f.ctx).WithTimeout(helpers.PIDeleteTimeOut).WithNetworkSecurityGroupID(id).WithNetworkSecurityGroupRuleID(ruleId) _, err := f.session.Power.NetworkSecurityGroups.V1NetworkSecurityGroupsRulesDelete(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil { @@ -171,10 +135,6 @@ func (f *IBMPINetworkSecurityGroupClient) DeleteRule(id, ruleId string) error { // Action on a network security group func (f *IBMPINetworkSecurityGroupClient) Action(body *models.NetworkSecurityGroupsAction) error { - // Add check for on-prem location - if f.session.IsOnPrem() { - return fmt.Errorf(helpers.NotOnPremSupported) - } params := network_security_groups.NewV1NetworkSecurityGroupsActionPostParams().WithContext(f.ctx).WithTimeout(helpers.PICreateTimeOut).WithBody(body) _, _, err := f.session.Power.NetworkSecurityGroups.V1NetworkSecurityGroupsActionPost(params, f.session.AuthInfo(f.cloudInstanceID)) if err != nil {