github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/dis/v2/streams/UpdatePartitionCount.go (about)

     1  package streams
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/build"
     6  )
     7  
     8  type UpdatePartitionCountOpts struct {
     9  	// Name of the stream whose partition quantity needs to be changed.
    10  	// Maximum: 64
    11  	StreamName string `json:"stream_name" required:"true"`
    12  	// Number of the target partitions.
    13  	// The value is an integer greater than 0.
    14  	// If the value is greater than the number of current partitions, scaling-up is required.
    15  	// If the value is less than the number of current partitions, scale-down is required.
    16  	// Note: A maximum of five scale-up/down operations can be performed for each stream within one hour.
    17  	// If a scale-up/down operation is successfully performed, you cannot perform one more scale-up/down operation within the next one hour.
    18  	// Minimum: 0
    19  	TargetPartitionCount int `json:"target_partition_count"`
    20  }
    21  
    22  func UpdatePartitionCount(client *golangsdk.ServiceClient, opts UpdatePartitionCountOpts) error {
    23  	body, err := build.RequestBody(opts, "")
    24  	if err != nil {
    25  		return err
    26  	}
    27  
    28  	// PUT /v2/{project_id}/streams/{stream_name}
    29  	_, err = client.Put(client.ServiceURL("streams", opts.StreamName), body, nil, &golangsdk.RequestOpts{
    30  		OkCodes: []int{200},
    31  	})
    32  	return err
    33  }