//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UNet AllocateShareBandwidth

package unet

import (
	"github.com/ucloud/ucloud-sdk-go/ucloud/request"
	"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)

// AllocateShareBandwidthRequest is request schema for AllocateShareBandwidth action
type AllocateShareBandwidthRequest struct {
	request.CommonBase

	// [公共参数] 地域。 参见 [地域和可用区列表](../summary/regionlist.html)
	// Region *string `required:"true"`

	// [公共参数] 项目ID。不填写为默认项目，子帐号必须填写。
	// ProjectId *string `required:"false"`

	// 共享带宽名字
	Name *string `required:"true"`

	// 付费方式:Year 按年,Month 按月,Dynamic 按时;
	ChargeType *string `required:"true"`

	// 共享带宽值
	ShareBandwidth *int `required:"true"`

	// 购买时长
	Quantity *int `required:"false"`

	// 共享带宽保底值(后付费)
	ShareBandwidthGuarantee *int `required:"false"`
}

// AllocateShareBandwidthResponse is response schema for AllocateShareBandwidth action
type AllocateShareBandwidthResponse struct {
	response.CommonBase

	// 共享带宽资源Id
	ShareBandwidthId string
}

// NewAllocateShareBandwidthRequest will create request of AllocateShareBandwidth action.
func (c *UNetClient) NewAllocateShareBandwidthRequest() *AllocateShareBandwidthRequest {
	req := &AllocateShareBandwidthRequest{}

	// setup request with client config
	c.Client.SetupRequest(req)

	// setup retryable with default retry policy (retry for non-create action and common error)
	req.SetRetryable(false)
	return req
}

// AllocateShareBandwidth - 开通共享带宽
func (c *UNetClient) AllocateShareBandwidth(req *AllocateShareBandwidthRequest) (*AllocateShareBandwidthResponse, error) {
	var err error
	var res AllocateShareBandwidthResponse

	err = c.Client.InvokeAction("AllocateShareBandwidth", req, &res)
	if err != nil {
		return &res, err
	}

	return &res, nil
}
