github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/autoscaling/v1/groups/update.go (about)

     1  package groups
     2  
     3  import (
     4  	"github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/build"
     6  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     7  )
     8  
     9  type UpdateOpts struct {
    10  	// Specifies the AS group name. The name contains only letters, digits, underscores (_), and hyphens (-), and cannot exceed 64 characters.
    11  	Name string `json:"scaling_group_name,omitempty"`
    12  	// Specifies the expected number of instances.
    13  	// The value ranges from the minimum number of instances to the maximum number of instances.
    14  	DesireInstanceNumber int `json:"desire_instance_number"`
    15  	// Specifies the minimum number of instances.
    16  	MinInstanceNumber int `json:"min_instance_number"`
    17  	// Specifies the maximum number of instances, which is greater than or equal to the minimum number of instances.
    18  	MaxInstanceNumber int `json:"max_instance_number"`
    19  	// Specifies the cooldown period (in seconds). The value ranges from 0 to 86400 and is 300 by default.
    20  	CoolDownTime int `json:"cool_down_time,omitempty"`
    21  	// Specifies the ID of a classic load balancer listener.
    22  	// The system supports the binding of up to six load balancer listeners, the IDs of which are separated using a comma (,).
    23  	// The value of this parameter can be changed only when all the following conditions are met:
    24  	// No scaling actions are triggered in the AS group.
    25  	// The number of instances in the AS group is 0.
    26  	// The AS group is not in service.
    27  	LBListenerID string `json:"lb_listener_id,omitempty"`
    28  	// Specifies information about an enhanced load balancer. The system supports the binding of up to six load balancers.
    29  	// This parameter is in list data structure.
    30  	// This parameter is alternative to lb_listener_id.
    31  	LBaaSListeners []LBaaSListener `json:"lbaas_listeners,omitempty"`
    32  	// Specifies the AZ information. The instances added in a scaling action will be created in a specified AZ.
    33  	// If you do not specify an AZ, the system automatically specifies one.
    34  	// You can change the AZ of an AS group only when no scaling action is being performed in the group.
    35  	AvailableZones []string `json:"available_zones,omitempty"`
    36  	// Specifies network information. The system supports up to five subnets.
    37  	// The first subnet transferred serves as the primary NIC of the ECS by default. This parameter is in data structure.
    38  	// The value of this parameter can be changed only when all the following conditions are met:
    39  	// No scaling actions are triggered in the AS group.
    40  	// The number of instances in the AS group is 0.
    41  	// The AS group is not in service.
    42  	Networks []ID `json:"networks,omitempty"`
    43  	// Specifies the security group. A maximum of one security group can be selected. This parameter is in data structure.
    44  	// If the security group is specified both in the AS configuration and AS group,
    45  	// scaled ECS instances will be added to the security group specified in the AS configuration.
    46  	// If the security group is not specified in either of them, scaled ECS instances will be added to the default security group.
    47  	// For your convenience, you are advised to specify the security group in the AS configuration.
    48  	// The value of this parameter can be changed only when all the following conditions are met:
    49  	// No scaling actions are triggered in the AS group.
    50  	// The number of instances in the AS group is 0.
    51  	// The AS group is not in service.
    52  	SecurityGroup []ID `json:"security_groups"`
    53  	// Specifies the health check method for instances in the AS group. The health check methods include ELB_AUDIT and NOVA_AUDIT.
    54  	// When load balancing is configured for an AS group, the default value is ELB_AUDIT. Otherwise, the default value is NOVA_AUDIT.
    55  	// ELB_AUDIT: indicates the ELB health check, which takes effect in an AS group with a listener.
    56  	// NOVA_AUDIT: indicates the ECS health check, which is the health check method delivered with AS.
    57  	HealthPeriodicAuditMethod string `json:"health_periodic_audit_method,omitempty"`
    58  	// Specifies the health check period for the instances in the AS group. The value can be 1, 5, 15, 60, or 180 in the unit of minutes.
    59  	// If the value is set to 0, health check is performed every 10 seconds.
    60  	HealthPeriodicAuditTime int `json:"health_periodic_audit_time,omitempty"`
    61  	// Specifies the grace period for instance health check. The unit is second and value range is 0-86400. The default value is 600.
    62  	// The health check grace period starts after an instance is added to an AS group and is enabled.
    63  	// The AS group will start checking the instance status only after the grace period ends.
    64  	// This parameter is valid only when the instance health check method of the AS group is ELB_AUDIT.
    65  	HealthPeriodicAuditGrace int `json:"health_periodic_audit_grace_period,omitempty"`
    66  	// Specifies the instance removal policy.
    67  	// OLD_CONFIG_OLD_INSTANCE (default): The earlier-created instances based on the earlier-created AS configurations are removed first.
    68  	// OLD_CONFIG_NEW_INSTANCE: The later-created instances based on the earlier-created AS configurations are removed first.
    69  	// OLD_INSTANCE: The earlier-created instances are removed first.
    70  	// NEW_INSTANCE: The later-created instances are removed first.
    71  	InstanceTerminatePolicy string `json:"instance_terminate_policy,omitempty"`
    72  	// Specifies the notification mode.
    73  	// EMAIL refers to notification by email.
    74  	Notifications []string `json:"notifications,omitempty"`
    75  	// Specifies whether to delete the EIP bound to the ECS when deleting the ECS.
    76  	// If you do not want to delete the EIP, set this parameter to false.
    77  	// Then, the system only unbinds the EIP from the ECS and reserves the EIP.
    78  	// true: deletes the EIP bound to the ECS when deleting the ECS.
    79  	// false: only unbinds the EIP bound to the ECS when deleting the ECS.
    80  	IsDeletePublicip *bool `json:"delete_publicip,omitempty"`
    81  	// Specifies whether to delete the data disks attached to the ECS when deleting the ECS.
    82  	// The value can be true or false. The default value is false.
    83  	// true: deletes the data disks attached to the ECS when deleting the ECS.
    84  	// false: only detaches the data disks attached to the ECS when deleting the ECS.
    85  	IsDeleteVolume *bool `json:"delete_volume,omitempty"`
    86  	// Specifies the AS configuration ID, which can be obtained using the API for querying AS configurations.
    87  	ConfigurationID string `json:"scaling_configuration_id,omitempty"`
    88  	// Specifies the enterprise project ID, which is used to specify the enterprise project to which the AS group belongs.
    89  	// If the value is 0 or left blank, the AS group belongs to the default enterprise project.
    90  	// If the value is a UUID, the AS group belongs to the enterprise project corresponding to the UUID.
    91  	// If an enterprise project is configured for an AS group, ECSs created in this AS group also belong to this enterprise project.
    92  	// Otherwise, the default enterprise project will be used.
    93  	EnterpriseProjectID string `json:"enterprise_project_id,omitempty"`
    94  	// Specifies the priority policy used to select target AZs when adjusting the number of instances in an AS group.
    95  	// EQUILIBRIUM_DISTRIBUTE (default): When adjusting the number of instances,
    96  	// ensure that instances in each AZ in the available_zones list is evenly distributed.
    97  	// If instances cannot be added in the target AZ, select another AZ based on the PICK_FIRST policy.
    98  	// PICK_FIRST: When adjusting the number of instances, target AZs are determined in the order in the available_zones list.
    99  	MultiAZPriorityPolicy string `json:"multi_az_priority_policy,omitempty"`
   100  	// Specifies the description of the AS group. The value can contain 1 to 256 characters.
   101  	Description string `json:"description,omitempty"`
   102  }
   103  
   104  func Update(client *golangsdk.ServiceClient, id string, opts UpdateOpts) (string, error) {
   105  	body, err := build.RequestBody(opts, "")
   106  	if err != nil {
   107  		return "", err
   108  	}
   109  
   110  	raw, err := client.Put(client.ServiceURL("scaling_group", id), body, nil, &golangsdk.RequestOpts{
   111  		OkCodes: []int{200},
   112  	})
   113  	if err != nil {
   114  		return "", err
   115  	}
   116  
   117  	var res struct {
   118  		ID string `json:"scaling_group_id"`
   119  	}
   120  	err = extract.Into(raw.Body, &res)
   121  	return res.ID, err
   122  }