Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update swagger client and models to service-broker v1.85.0-ibm #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
Expand Down
59 changes: 43 additions & 16 deletions clients/instance/ibm-pi-datacenters.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,53 @@ func NewIBMPIDatacenterClient(ctx context.Context, sess *ibmpisession.IBMPISessi
}
}
func (f *IBMPIDatacentersClient) Get(datacenterRegion string) (*models.Datacenter, error) {
params := datacenters.NewV1DatacentersGetParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut).WithDatacenterRegion(datacenterRegion)
resp, err := f.session.Power.Datacenters.V1DatacentersGet(params)
if err != nil {
return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf(errors.GetDatacenterOperationFailed, f.cloudInstanceID, err))
}
if resp == nil || resp.Payload == nil {
return nil, fmt.Errorf("failed to Get Datacenter %s", datacenterRegion)
if !f.session.IsOnPrem() {
params := datacenters.NewV1DatacentersGetParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut).WithDatacenterRegion(datacenterRegion)
resp, err := f.session.Power.Datacenters.V1DatacentersGet(params)

if err != nil {
return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf(errors.GetDatacenterOperationFailed, f.cloudInstanceID, err))
}
if resp == nil || resp.Payload == nil {
return nil, fmt.Errorf("failed to Get Datacenter %s", datacenterRegion)
}
return resp.Payload, nil
} else {
params := datacenters.NewV1DatacentersPrivateGetParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut).WithDatacenterRegion(datacenterRegion)
resp, err := f.session.Power.Datacenters.V1DatacentersPrivateGet(params, f.session.AuthInfo(f.cloudInstanceID))

if err != nil {
return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf(errors.GetDatacenterOperationFailed, f.cloudInstanceID, err))
}
if resp == nil || resp.Payload == nil {
return nil, fmt.Errorf("failed to Get Private Datacenter %s", datacenterRegion)
}
return resp.Payload, nil
}
return resp.Payload, nil
}

func (f *IBMPIDatacentersClient) GetAll() (*models.Datacenters, error) {
params := datacenters.NewV1DatacentersGetallParams().WithContext(f.ctx).WithTimeout(helpers.PICreateTimeOut)
resp, err := f.session.Power.Datacenters.V1DatacentersGetall(params)
if !f.session.IsOnPrem() {
params := datacenters.NewV1DatacentersGetallParams().WithContext(f.ctx).WithTimeout(helpers.PICreateTimeOut)
resp, err := f.session.Power.Datacenters.V1DatacentersGetall(params)

if err != nil {
return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to Get all Datacenters: %w", err))
}
if resp == nil || resp.Payload == nil {
return nil, fmt.Errorf("failed to Get all Datacenters")
if err != nil {
return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to Get all Datacenters: %w", err))
}
if resp == nil || resp.Payload == nil {
return nil, fmt.Errorf("failed to Get all Datacenters")
}
return resp.Payload, nil
} else {
params := datacenters.NewV1DatacentersPrivateGetallParams().WithContext(f.ctx).WithTimeout(helpers.PICreateTimeOut)
resp, err := f.session.Power.Datacenters.V1DatacentersPrivateGetall(params, f.session.AuthInfo(f.cloudInstanceID))

if err != nil {
return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to Get all Datacenters: %w", err))
}
if resp == nil || resp.Payload == nil {
return nil, fmt.Errorf("failed to Get all private Datacenters")
}
return resp.Payload, nil
}
return resp.Payload, nil
}
6 changes: 0 additions & 6 deletions clients/instance/ibm-pi-dr-location.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ func NewIBMPIDisasterRecoveryLocationClient(ctx context.Context, sess *ibmpisess

// Get the disaster recovery site details for the current location
func (f *IBMPIDisasterRecoveryLocationClient) Get() (*models.DisasterRecoveryLocation, error) {
if f.session.IsOnPrem() {
return nil, fmt.Errorf("operation not supported in satellite location, check documentation")
}
params := p_cloud_disaster_recovery.NewPcloudLocationsDisasterrecoveryGetParams().
WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut).
WithCloudInstanceID(f.cloudInstanceID)
Expand All @@ -43,9 +40,6 @@ func (f *IBMPIDisasterRecoveryLocationClient) Get() (*models.DisasterRecoveryLoc

// Get all disaster recovery locations supported by Power Virtual Server
func (f *IBMPIDisasterRecoveryLocationClient) GetAll() (*models.DisasterRecoveryLocations, error) {
if f.session.IsOnPrem() {
return nil, fmt.Errorf("operation not supported in satellite location, check documentation")
}
params := p_cloud_disaster_recovery.NewPcloudLocationsDisasterrecoveryGetallParams().
WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut)
resp, err := f.session.Power.PCloudDisasterRecovery.PcloudLocationsDisasterrecoveryGetall(params, f.session.AuthInfo(f.cloudInstanceID))
Expand Down
4 changes: 4 additions & 0 deletions clients/instance/ibm-pi-host-groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ func (f *IBMPIHostGroupsClient) GetHosts() (models.HostList, error) {
if f.session.IsOnPrem() {
return nil, fmt.Errorf("operation not supported in satellite location, check documentation")
}
hostReference := true
params := host_groups.NewV1HostsGetParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut)
params.HostReference = &hostReference
resp, err := f.session.Power.HostGroups.V1HostsGet(params, f.session.AuthInfo(f.cloudInstanceID))
if err != nil {
return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to get hosts for %s: %w", f.cloudInstanceID, err))
Expand Down Expand Up @@ -146,7 +148,9 @@ func (f *IBMPIHostGroupsClient) GetHost(id string) (*models.Host, error) {
if f.session.IsOnPrem() {
return nil, fmt.Errorf("operation not supported in satellite location, check documentation")
}
hostReference := true
params := host_groups.NewV1HostsIDGetParams().WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut).WithHostID(id)
params.HostReference = &hostReference
resp, err := f.session.Power.HostGroups.V1HostsIDGet(params, f.session.AuthInfo(f.cloudInstanceID))
if err != nil {
return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to get host %s for %s: %w", id, f.cloudInstanceID, err))
Expand Down
16 changes: 14 additions & 2 deletions clients/instance/ibm-pi-instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func (f *IBMPIInstanceClient) GetAll() (*models.PVMInstances, error) {
// Create an Instance
func (f *IBMPIInstanceClient) Create(body *models.PVMInstanceCreate) (*models.PVMInstanceList, error) {
// Check for satellite differences in this endpoint
if f.session.IsOnPrem() && body.DeploymentTarget != nil {
return nil, fmt.Errorf("deployment target parameter is not supported in satellite location, check documentation")
if f.session.IsOnPrem() && (body.DeploymentTarget != nil || body.DeploymentType != "") {
return nil, fmt.Errorf("deployment target and deployment type parameters are not supported in satellite location, check documentation")
}
params := p_cloud_p_vm_instances.NewPcloudPvminstancesPostParams().
WithContext(f.ctx).WithTimeout(helpers.PICreateTimeOut).
Expand Down Expand Up @@ -89,6 +89,18 @@ func (f *IBMPIInstanceClient) Delete(id string) error {
return nil
}

// Delete an Instance with body
func (f *IBMPIInstanceClient) DeleteWithBody(id string, body *models.PVMInstanceDelete) error {
params := p_cloud_p_vm_instances.NewPcloudPvminstancesDeleteParams().
WithContext(f.ctx).WithTimeout(helpers.PIDeleteTimeOut).
WithCloudInstanceID(f.cloudInstanceID).WithPvmInstanceID(id).WithBody(body)
_, err := f.session.Power.PCloudpVMInstances.PcloudPvminstancesDelete(params, f.session.AuthInfo(f.cloudInstanceID))
if err != nil {
return fmt.Errorf("failed to Delete PVM Instance %s :%w", id, err)
}
return nil
}

// Update an Instance
func (f *IBMPIInstanceClient) Update(id string, body *models.PVMInstanceUpdate) (*models.PVMInstanceUpdateResponse, error) {
// Check for satellite differences in this endpoint
Expand Down
40 changes: 40 additions & 0 deletions clients/instance/ibm-pi-network-peers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package instance

import (
"context"
"fmt"

"github.com/IBM-Cloud/power-go-client/helpers"
"github.com/IBM-Cloud/power-go-client/ibmpisession"
"github.com/IBM-Cloud/power-go-client/power/client/network_peers"
"github.com/IBM-Cloud/power-go-client/power/models"
)

// IBMPINetworkPeerClient
type IBMPINetworkPeerClient struct {
IBMPIClient
}

// NewIBMPINetworkPeerClient
func NewIBMPINetworkPeerClient(ctx context.Context, sess *ibmpisession.IBMPISession, cloudInstanceID string) *IBMPINetworkPeerClient {
return &IBMPINetworkPeerClient{
*NewIBMPIClient(ctx, sess, cloudInstanceID),
}
}

// Get network peers
func (f *IBMPINetworkPeerClient) GetNetworkPeers() (*models.NetworkPeers, error) {
if !f.session.IsOnPrem() {
return nil, fmt.Errorf("not supported in off-prem location")
}
params := network_peers.NewV1NetworkPeersListParams().WithContext(f.ctx).
WithTimeout(helpers.PIGetTimeOut)
resp, err := f.session.Power.NetworkPeers.V1NetworkPeersList(params, f.session.AuthInfo(f.cloudInstanceID))
if err != nil {
return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to Get Network Peers for cloud instance %s with error %w", f.cloudInstanceID, err))
}
if resp == nil || resp.Payload == nil {
return nil, fmt.Errorf("failed to Get Network Peers for cloud instance %s", f.cloudInstanceID)
}
return resp.Payload, nil
}
18 changes: 0 additions & 18 deletions clients/instance/ibm-pi-spp-placement-groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ func NewIBMPISPPPlacementGroupClient(ctx context.Context, sess *ibmpisession.IBM

// Get a PI SPP Placement Group
func (f *IBMPISPPPlacementGroupClient) Get(id string) (*models.SPPPlacementGroup, error) {
if f.session.IsOnPrem() {
return nil, fmt.Errorf("operation not supported in satellite location, check documentation")
}
params := p_cloud_s_p_p_placement_groups.NewPcloudSppplacementgroupsGetParams().
WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut).
WithCloudInstanceID(f.cloudInstanceID).WithSppPlacementGroupID(id)
Expand All @@ -44,9 +41,6 @@ func (f *IBMPISPPPlacementGroupClient) Get(id string) (*models.SPPPlacementGroup

// Get All SPP Placement Groups
func (f *IBMPISPPPlacementGroupClient) GetAll() (*models.SPPPlacementGroups, error) {
if f.session.IsOnPrem() {
return nil, fmt.Errorf("operation not supported in satellite location, check documentation")
}
params := p_cloud_s_p_p_placement_groups.NewPcloudSppplacementgroupsGetallParams().
WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut).
WithCloudInstanceID(f.cloudInstanceID)
Expand All @@ -62,9 +56,6 @@ func (f *IBMPISPPPlacementGroupClient) GetAll() (*models.SPPPlacementGroups, err

// Create a SPP Placement Group
func (f *IBMPISPPPlacementGroupClient) Create(body *models.SPPPlacementGroupCreate) (*models.SPPPlacementGroup, error) {
if f.session.IsOnPrem() {
return nil, fmt.Errorf("operation not supported in satellite location, check documentation")
}
params := p_cloud_s_p_p_placement_groups.NewPcloudSppplacementgroupsPostParams().
WithContext(f.ctx).WithTimeout(helpers.PICreateTimeOut).
WithCloudInstanceID(f.cloudInstanceID).WithBody(body)
Expand All @@ -80,9 +71,6 @@ func (f *IBMPISPPPlacementGroupClient) Create(body *models.SPPPlacementGroupCrea

// Delete a SPP Placement Group
func (f *IBMPISPPPlacementGroupClient) Delete(id string) error {
if f.session.IsOnPrem() {
return fmt.Errorf("operation not supported in satellite location, check documentation")
}
params := p_cloud_s_p_p_placement_groups.NewPcloudSppplacementgroupsDeleteParams().
WithContext(f.ctx).WithTimeout(helpers.PIDeleteTimeOut).
WithCloudInstanceID(f.cloudInstanceID).WithSppPlacementGroupID(id)
Expand All @@ -95,9 +83,6 @@ func (f *IBMPISPPPlacementGroupClient) Delete(id string) error {

// Add an Instance to a SPP Placement Group
func (f *IBMPISPPPlacementGroupClient) AddMember(id string, sppID string) (*models.SPPPlacementGroup, error) {
if f.session.IsOnPrem() {
return nil, fmt.Errorf("operation not supported in satellite location, check documentation")
}
params := p_cloud_s_p_p_placement_groups.NewPcloudSppplacementgroupsMembersPostParams().
WithContext(f.ctx).WithTimeout(helpers.PICreateTimeOut).
WithCloudInstanceID(f.cloudInstanceID).WithSppPlacementGroupID(id).
Expand All @@ -114,9 +99,6 @@ func (f *IBMPISPPPlacementGroupClient) AddMember(id string, sppID string) (*mode

// Remove an Instance to a SPP Placement Group
func (f *IBMPISPPPlacementGroupClient) DeleteMember(id string, sppID string) (*models.SPPPlacementGroup, error) {
if f.session.IsOnPrem() {
return nil, fmt.Errorf("operation not supported in satellite location, check documentation")
}
params := p_cloud_s_p_p_placement_groups.NewPcloudSppplacementgroupsMembersDeleteParams().
WithContext(f.ctx).WithTimeout(helpers.PIDeleteTimeOut).
WithCloudInstanceID(f.cloudInstanceID).WithSppPlacementGroupID(id).
Expand Down
124 changes: 124 additions & 0 deletions clients/instance/ibm-pi-virtual-serial-number.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package instance

import (
"context"
"fmt"

"github.com/IBM-Cloud/power-go-client/helpers"
"github.com/IBM-Cloud/power-go-client/ibmpisession"
"github.com/IBM-Cloud/power-go-client/power/client/p_cloud_virtual_serial_number"
"github.com/IBM-Cloud/power-go-client/power/models"
)

// IBMPIVSNClient

type IBMPIVSNClient struct {
IBMPIClient
}

// NewIBMPIVSNClient
func NewIBMPIVSNClient(ctx context.Context, sess *ibmpisession.IBMPISession, cloudInstanceID string) *IBMPIVSNClient {
return &IBMPIVSNClient{
*NewIBMPIClient(ctx, sess, cloudInstanceID),
}
}

// Get Virtual Serial Number
func (f *IBMPIVSNClient) Get(id string) (*models.VirtualSerialNumber, error) {
params := p_cloud_virtual_serial_number.NewPcloudVirtualserialnumberGetParams().
WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut).WithVirtualSerialNumber(id)
resp, err := f.session.Power.PCloudVirtualSerialNumber.PcloudVirtualserialnumberGet(params, f.session.AuthInfo(f.cloudInstanceID))
if err != nil {
return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to get virtual serial number %s :%w", id, err))
}
if resp == nil || resp.Payload == nil {
return nil, fmt.Errorf("failed to get virtual serial number %s", id)
}
return resp.Payload, nil
}

// Get All Virtual Serial Numbers
func (f *IBMPIVSNClient) GetAll(pvmInstanceID *string) (models.VirtualSerialNumberList, error) {
params := p_cloud_virtual_serial_number.NewPcloudVirtualserialnumberGetallParams().
WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut)
if pvmInstanceID != nil {
params.SetPvmInstanceID(pvmInstanceID)
}
resp, err := f.session.Power.PCloudVirtualSerialNumber.PcloudVirtualserialnumberGetall(params, f.session.AuthInfo(f.cloudInstanceID))
if err != nil {
return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to get all virtual serial numbers in %s :%w", f.cloudInstanceID, err))
}
if resp == nil || resp.Payload == nil {
return nil, fmt.Errorf("failed to get all virtual serial numbers in %s", f.cloudInstanceID)
}
return resp.Payload, nil
}

// Update Virtual Serial Nunber
func (f *IBMPIVSNClient) Update(id string, body *models.UpdateVirtualSerialNumber) (*models.GetServerVirtualSerialNumber, error) {
params := p_cloud_virtual_serial_number.NewPcloudVirtualserialnumberPutParams().
WithContext(f.ctx).WithTimeout(helpers.PIUpdateTimeOut).WithVirtualSerialNumber(id).
WithBody(body)
resp, err := f.session.Power.PCloudVirtualSerialNumber.PcloudVirtualserialnumberPut(params, f.session.AuthInfo(f.cloudInstanceID))
if err != nil {
return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to update virtual serial number %s :%w", id, err))
}
if resp == nil || resp.Payload == nil {
return nil, fmt.Errorf("failed to Update virtual serial number %s", id)
}
return resp.Payload, nil
}

// Delete Virtual Serial Number
func (f *IBMPIVSNClient) Delete(id string) error {
params := p_cloud_virtual_serial_number.NewPcloudVirtualserialnumberDeleteParams().
WithContext(f.ctx).WithTimeout(helpers.PIDeleteTimeOut).
WithVirtualSerialNumber(id)
_, err := f.session.Power.PCloudVirtualSerialNumber.PcloudVirtualserialnumberDelete(params, f.session.AuthInfo(f.cloudInstanceID))
if err != nil {
return ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to delete virtual serial number %s :%w", id, err))
}
return nil
}

// PVM Instance Delete VSN
func (f *IBMPIVSNClient) PVMInstanceDeleteVSN(pvmInstanceID string, body *models.DeleteServerVirtualSerialNumber) error {
params := p_cloud_virtual_serial_number.NewPcloudPvminstancesVirtualserialnumberDeleteParams().
WithContext(f.ctx).WithTimeout(helpers.PIDeleteTimeOut).WithCloudInstanceID(f.cloudInstanceID).WithPvmInstanceID(pvmInstanceID).
WithBody(body)
_, err := f.session.Power.PCloudVirtualSerialNumber.PcloudPvminstancesVirtualserialnumberDelete(params, f.session.AuthInfo(f.cloudInstanceID))
if err != nil {
return ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to delete virtual serial number for pvm instance %s :%w", pvmInstanceID, err))
}
return nil
}

// PVM Instance Update VSN
func (f *IBMPIVSNClient) PVMInstanceUpdateVSN(pvmInstanceID string, body *models.UpdateServerVirtualSerialNumber) (*models.VirtualSerialNumber, error) {
params := p_cloud_virtual_serial_number.NewPcloudPvminstancesVirtualserialnumberPutParams().
WithContext(f.ctx).WithTimeout(helpers.PICreateTimeOut).WithCloudInstanceID(f.cloudInstanceID).
WithPvmInstanceID(pvmInstanceID).WithBody(body)
resp, err := f.session.Power.PCloudVirtualSerialNumber.PcloudPvminstancesVirtualserialnumberPut(params, f.session.AuthInfo(f.cloudInstanceID))
if err != nil {
return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to update virtual serial number for pvm instance %s :%w", pvmInstanceID, err))
}
if resp == nil || resp.Payload == nil {
return nil, fmt.Errorf("failed to update virtual serial number for pvm instance %s", pvmInstanceID)
}
return resp.Payload, nil
}

// PVM Attach VSN
func (f *IBMPIVSNClient) PVMInstanceAttachVSN(pvmInstanceID string, body *models.AddServerVirtualSerialNumber) (*models.VirtualSerialNumber, error) {
params := p_cloud_virtual_serial_number.NewPcloudPvminstancesVirtualserialnumberPostParams().
WithContext(f.ctx).WithTimeout(helpers.PICreateTimeOut).WithCloudInstanceID(f.cloudInstanceID).
WithPvmInstanceID(pvmInstanceID).WithBody(body)
resp, err := f.session.Power.PCloudVirtualSerialNumber.PcloudPvminstancesVirtualserialnumberPost(params, f.session.AuthInfo(f.cloudInstanceID))
if err != nil {
return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to attach virtual serial number for pvm instance %s :%w", pvmInstanceID, err))
}
if resp == nil || resp.Payload == nil {
return nil, fmt.Errorf("failed to attach virtual serial number for pvm instance %s", pvmInstanceID)
}
return resp.Payload, nil
}
Loading
Loading