Skip to content

Commit

Permalink
feat(spec): updated the sdk as per the api spec released on 2024-07-22 (
Browse files Browse the repository at this point in the history
#98)

Signed-off-by: Ujjwal Kumar <[email protected]>
  • Loading branch information
ujjwal-ibm authored Jul 22, 2024
1 parent 093c341 commit cdacdde
Show file tree
Hide file tree
Showing 4 changed files with 518 additions and 17 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/IBM/vpc-go-sdk)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

# IBM Cloud VPC Go SDK Version 0.55.0
# IBM Cloud VPC Go SDK Version 0.56.0
Go client library to interact with the various [IBM Cloud VPC Services APIs](https://cloud.ibm.com/apidocs?category=vpc).

**Note:** Given the current version of all VPC SDKs across supported languages and the current VPC API specification, we retracted the vpc-go-sdk version 1.x to version v0.6.0, which had the same features as v1.0.1.
Consider using v0.55.0 from now on. Refrain from using commands like `go get -u ..` and `go get ..@latest` on go 1.14 and lower as you will not get the latest release.
Consider using v0.56.0 from now on. Refrain from using commands like `go get -u ..` and `go get ..@latest` on go 1.14 and lower as you will not get the latest release.

This SDK uses [Semantic Versioning](https://semver.org), and as such there may be backward-incompatible changes for any new `0.y.z` version.
## Table of Contents
Expand Down Expand Up @@ -64,7 +64,7 @@ Use this command to download and install the VPC Go SDK service to allow your Go
use it:

```
go get github.com/IBM/vpc-go-sdk@v0.55.0
go get github.com/IBM/vpc-go-sdk@v0.56.0
```


Expand All @@ -90,7 +90,7 @@ to your `Gopkg.toml` file. Here is an example:
```
[[constraint]]
name = "github.com/IBM/vpc-go-sdk/"
version = "0.55.0"
version = "0.56.0"
```

Then run `dep ensure`.
Expand Down
2 changes: 1 addition & 1 deletion common/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package common

// Version of the SDK
const Version = "0.55.0"
const Version = "0.56.0"
183 changes: 171 additions & 12 deletions vpcv1/vpc_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
// VpcV1 : The IBM Cloud Virtual Private Cloud (VPC) API can be used to programmatically provision and manage virtual
// server instances, along with subnets, volumes, load balancers, and more.
//
// API Version: 2024-07-17
// API Version: 2024-07-22
type VpcV1 struct {
Service *core.BaseService

Expand All @@ -47,7 +47,7 @@ type VpcV1 struct {
Generation *int64

// The API version, in format `YYYY-MM-DD`. For the API behavior documented here, specify any date between `2024-04-30`
// and `2024-07-17`.
// and `2024-07-22`.
Version *string
}

Expand All @@ -68,7 +68,7 @@ type VpcV1Options struct {
Generation *int64

// The API version, in format `YYYY-MM-DD`. For the API behavior documented here, specify any date between `2024-04-30`
// and `2024-07-10`.
// and `2024-07-22`.
Version *string
}

Expand Down Expand Up @@ -14755,6 +14755,96 @@ func (vpc *VpcV1) GetBareMetalServerInitializationWithContext(ctx context.Contex
return
}

// ReplaceBareMetalServerInitialization : Reinitialize a bare metal server
// This request reinitializes a bare metal server with the specified image and SSH keys. The server must be stopped.
// Upon successful reinitiatilization, the bare metal server will be started automatically.
func (vpc *VpcV1) ReplaceBareMetalServerInitialization(replaceBareMetalServerInitializationOptions *ReplaceBareMetalServerInitializationOptions) (result *BareMetalServerInitialization, response *core.DetailedResponse, err error) {
result, response, err = vpc.ReplaceBareMetalServerInitializationWithContext(context.Background(), replaceBareMetalServerInitializationOptions)
err = core.RepurposeSDKProblem(err, "")
return
}

// ReplaceBareMetalServerInitializationWithContext is an alternate form of the ReplaceBareMetalServerInitialization method which supports a Context parameter
func (vpc *VpcV1) ReplaceBareMetalServerInitializationWithContext(ctx context.Context, replaceBareMetalServerInitializationOptions *ReplaceBareMetalServerInitializationOptions) (result *BareMetalServerInitialization, response *core.DetailedResponse, err error) {
err = core.ValidateNotNil(replaceBareMetalServerInitializationOptions, "replaceBareMetalServerInitializationOptions cannot be nil")
if err != nil {
err = core.SDKErrorf(err, "", "unexpected-nil-param", common.GetComponentInfo())
return
}
err = core.ValidateStruct(replaceBareMetalServerInitializationOptions, "replaceBareMetalServerInitializationOptions")
if err != nil {
err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo())
return
}

pathParamsMap := map[string]string{
"id": *replaceBareMetalServerInitializationOptions.ID,
}

builder := core.NewRequestBuilder(core.PUT)
builder = builder.WithContext(ctx)
builder.EnableGzipCompression = vpc.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{id}/initialization`, pathParamsMap)
if err != nil {
err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo())
return
}

for headerName, headerValue := range replaceBareMetalServerInitializationOptions.Headers {
builder.AddHeader(headerName, headerValue)
}

sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ReplaceBareMetalServerInitialization")
for headerName, headerValue := range sdkHeaders {
builder.AddHeader(headerName, headerValue)
}
builder.AddHeader("Accept", "application/json")
builder.AddHeader("Content-Type", "application/json")

builder.AddQuery("version", fmt.Sprint(*vpc.Version))
builder.AddQuery("generation", fmt.Sprint(*vpc.Generation))

body := make(map[string]interface{})
if replaceBareMetalServerInitializationOptions.Image != nil {
body["image"] = replaceBareMetalServerInitializationOptions.Image
}
if replaceBareMetalServerInitializationOptions.Keys != nil {
body["keys"] = replaceBareMetalServerInitializationOptions.Keys
}
if replaceBareMetalServerInitializationOptions.UserData != nil {
body["user_data"] = replaceBareMetalServerInitializationOptions.UserData
}
_, err = builder.SetBodyContentJSON(body)
if err != nil {
err = core.SDKErrorf(err, "", "set-json-body-error", common.GetComponentInfo())
return
}

request, err := builder.Build()
if err != nil {
err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo())
return
}

var rawResponse map[string]json.RawMessage
response, err = vpc.Service.Request(request, &rawResponse)
if err != nil {
core.EnrichHTTPProblem(err, "replace_bare_metal_server_initialization", getServiceComponentInfo())
err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo())
return
}
if rawResponse != nil {
err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerInitialization)
if err != nil {
err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo())
return
}
response.Result = result
}

return
}

// RestartBareMetalServer : Restart a bare metal server
// This request immediately restarts a bare metal server. For this request to succeed, the server must have a `status`
// of `running`.
Expand Down Expand Up @@ -29977,7 +30067,7 @@ func (vpc *VpcV1) UpdateFlowLogCollectorWithContext(ctx context.Context, updateF
return
}
func getServiceComponentInfo() *core.ProblemComponent {
return core.NewProblemComponent(DefaultServiceName, "today")
return core.NewProblemComponent(DefaultServiceName, "2024-07-09")
}

// AccountReference : AccountReference struct
Expand Down Expand Up @@ -32405,6 +32495,7 @@ type BareMetalServer struct {
// - `failed`: server is failed and not usable (see `status_reasons`)
// - `maintenance`: server is undergoing maintenance (not usable)
// - `pending`: server is being provisioned and not yet usable
// - `reinitializing`: server is reinitializing and not yet usable
// - `restarting`: server is restarting and not yet usable
// - `running`: server is powered on
// - `starting`: server is starting and not yet usable
Expand Down Expand Up @@ -32450,6 +32541,7 @@ const (
// - `failed`: server is failed and not usable (see `status_reasons`)
// - `maintenance`: server is undergoing maintenance (not usable)
// - `pending`: server is being provisioned and not yet usable
// - `reinitializing`: server is reinitializing and not yet usable
// - `restarting`: server is restarting and not yet usable
// - `running`: server is powered on
// - `starting`: server is starting and not yet usable
Expand All @@ -32458,14 +32550,15 @@ const (
// The enumerated values for this property may
// [expand](https://cloud.ibm.com/apidocs/vpc#property-value-expansion) in the future.
const (
BareMetalServerStatusDeletingConst = "deleting"
BareMetalServerStatusFailedConst = "failed"
BareMetalServerStatusMaintenanceConst = "maintenance"
BareMetalServerStatusPendingConst = "pending"
BareMetalServerStatusRestartingConst = "restarting"
BareMetalServerStatusRunningConst = "running"
BareMetalServerStatusStartingConst = "starting"
BareMetalServerStatusStoppedConst = "stopped"
BareMetalServerStatusDeletingConst = "deleting"
BareMetalServerStatusFailedConst = "failed"
BareMetalServerStatusMaintenanceConst = "maintenance"
BareMetalServerStatusPendingConst = "pending"
BareMetalServerStatusReinitializingConst = "reinitializing"
BareMetalServerStatusRestartingConst = "restarting"
BareMetalServerStatusRunningConst = "running"
BareMetalServerStatusStartingConst = "starting"
BareMetalServerStatusStoppedConst = "stopped"
)

// UnmarshalBareMetalServer unmarshals an instance of BareMetalServer from the specified map of raw messages.
Expand Down Expand Up @@ -36358,6 +36451,7 @@ type BareMetalServerStatusReason struct {
// The enumerated values for this property may
// [expand](https://cloud.ibm.com/apidocs/vpc#property-value-expansion) in the future.
const (
BareMetalServerStatusReasonCodeCannotReinitializeConst = "cannot_reinitialize"
BareMetalServerStatusReasonCodeCannotStartConst = "cannot_start"
BareMetalServerStatusReasonCodeCannotStartCapacityConst = "cannot_start_capacity"
BareMetalServerStatusReasonCodeCannotStartComputeConst = "cannot_start_compute"
Expand Down Expand Up @@ -74004,6 +74098,71 @@ func (options *RemoveVPNGatewayConnectionsPeerCIDROptions) SetHeaders(param map[
return options
}

// ReplaceBareMetalServerInitializationOptions : The ReplaceBareMetalServerInitialization options.
type ReplaceBareMetalServerInitializationOptions struct {
// The bare metal server identifier.
ID *string `json:"id" validate:"required,ne="`

// The image to be used when provisioning the bare metal server.
Image ImageIdentityIntf `json:"image" validate:"required"`

// The public SSH keys to install on the bare metal server. Keys will be made available to the bare metal server as
// cloud-init vendor data. For cloud-init enabled images, these keys will also be added as SSH authorized keys for the
// administrative user.
//
// For Windows images, at least one key must be specified, and one will be selected to encrypt the administrator
// password. Keys are optional for other images, but if no keys are specified, the instance will be inaccessible unless
// the specified image provides another means of access.
Keys []KeyIdentityIntf `json:"keys" validate:"required"`

// User data to be made available when initializing the bare metal server.
//
// If unspecified, no user data will be made available.
UserData *string `json:"user_data,omitempty"`

// Allows users to set headers on API requests
Headers map[string]string
}

// NewReplaceBareMetalServerInitializationOptions : Instantiate ReplaceBareMetalServerInitializationOptions
func (*VpcV1) NewReplaceBareMetalServerInitializationOptions(id string, image ImageIdentityIntf, keys []KeyIdentityIntf) *ReplaceBareMetalServerInitializationOptions {
return &ReplaceBareMetalServerInitializationOptions{
ID: core.StringPtr(id),
Image: image,
Keys: keys,
}
}

// SetID : Allow user to set ID
func (_options *ReplaceBareMetalServerInitializationOptions) SetID(id string) *ReplaceBareMetalServerInitializationOptions {
_options.ID = core.StringPtr(id)
return _options
}

// SetImage : Allow user to set Image
func (_options *ReplaceBareMetalServerInitializationOptions) SetImage(image ImageIdentityIntf) *ReplaceBareMetalServerInitializationOptions {
_options.Image = image
return _options
}

// SetKeys : Allow user to set Keys
func (_options *ReplaceBareMetalServerInitializationOptions) SetKeys(keys []KeyIdentityIntf) *ReplaceBareMetalServerInitializationOptions {
_options.Keys = keys
return _options
}

// SetUserData : Allow user to set UserData
func (_options *ReplaceBareMetalServerInitializationOptions) SetUserData(userData string) *ReplaceBareMetalServerInitializationOptions {
_options.UserData = core.StringPtr(userData)
return _options
}

// SetHeaders : Allow user to set Headers
func (options *ReplaceBareMetalServerInitializationOptions) SetHeaders(param map[string]string) *ReplaceBareMetalServerInitializationOptions {
options.Headers = param
return options
}

// ReplaceLoadBalancerPoolMembersOptions : The ReplaceLoadBalancerPoolMembers options.
type ReplaceLoadBalancerPoolMembersOptions struct {
// The load balancer identifier.
Expand Down
Loading

0 comments on commit cdacdde

Please sign in to comment.