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

     1  package policies
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     6  )
     7  
     8  type ListLogsOpts struct {
     9  	// Specifies the AS policy ID.
    10  	ScalingPolicyId string
    11  	// Specifies the ID of an AS policy execution log.
    12  	LogId string `q:"log_id,omitempty"`
    13  	// Specifies the scaling resource type.
    14  	// AS group: SCALING_GROUP
    15  	// Bandwidth: BANDWIDTH
    16  	ScalingResourceType string `q:"scaling_resource_type,omitempty"`
    17  	// Specifies the scaling resource ID.
    18  	ScalingResourceId string `q:"scaling_resource_id,omitempty"`
    19  	// Specifies the AS policy execution type.
    20  	// SCHEDULED: automatically triggered at a specified time point
    21  	// RECURRENCE: automatically triggered at a specified time period
    22  	// ALARM: alarm-triggered
    23  	// MANUAL: manually triggered
    24  	ExecuteType string `q:"execute_type,omitempty"`
    25  	// Specifies the start time that complies with UTC for querying AS policy execution logs.
    26  	// The format of the start time is yyyy-MM-ddThh:mm:ssZ.
    27  	StartTime string `q:"start_time,omitempty"`
    28  	// Specifies the end time that complies with UTC for querying AS policy execution logs.
    29  	// The format of the end time is yyyy-MM-ddThh:mm:ssZ.
    30  	EndTime string `q:"end_time,omitempty"`
    31  	// Specifies the start line number. The default value is 0. The minimum parameter value is 0.
    32  	StartNumber int32 `q:"start_number,omitempty"`
    33  	// Specifies the number of query records. The default value is 20. The value range is 0 to 100.
    34  	Limit int32 `q:"limit,omitempty"`
    35  }
    36  
    37  func ListScalingPolicyExecuteLogs(client *golangsdk.ServiceClient, opts ListLogsOpts) (*ListScalingPolicyExecuteLogsResponse, error) {
    38  	url, err := golangsdk.NewURLBuilder().WithEndpoints("scaling_policy_execute_log", opts.ScalingPolicyId).WithQueryParams(&opts).Build()
    39  	if err != nil {
    40  		return nil, err
    41  	}
    42  
    43  	// GET /autoscaling-api/v1/{project_id}/scaling_policy_execute_log/{scaling_policy_id}
    44  	raw, err := client.Get(client.ServiceURL(url.String()), nil, nil)
    45  	if err != nil {
    46  		return nil, err
    47  	}
    48  
    49  	var res ListScalingPolicyExecuteLogsResponse
    50  	err = extract.IntoStructPtr(raw.Body, &res, "scaling_policy")
    51  	return &res, err
    52  }
    53  
    54  type ListScalingPolicyExecuteLogsResponse struct {
    55  	TotalNumber             int32                         `json:"total_number,omitempty"`
    56  	StartNumber             int32                         `json:"start_number,omitempty"`
    57  	Limit                   int32                         `json:"limit,omitempty"`
    58  	ScalingPolicyExecuteLog []ScalingPolicyExecuteLogList `json:"scaling_policy_execute_log,omitempty"`
    59  }
    60  
    61  type ScalingPolicyExecuteLogList struct {
    62  	// Specifies the AS policy execution status.
    63  	// SUCCESS: The AS policy has been executed.
    64  	// FAIL: Executing the AS policy failed.
    65  	// EXECUTING: The AS policy is being executed.
    66  	Status string `json:"status,omitempty"`
    67  	// Specifies the AS policy execution failure.
    68  	FailedReason string `json:"failed_reason,omitempty"`
    69  	// Specifies the AS policy execution type.
    70  	// SCHEDULED: automatically triggered at a specified time point
    71  	// RECURRENCE: automatically triggered at a specified time period
    72  	// ALARM: alarm-triggered
    73  	// MANUAL: manually triggered
    74  	ExecuteType string `json:"execute_type,omitempty"`
    75  	// Specifies the time when an AS policy was executed. The time format complies with UTC.
    76  	ExecuteTime string `json:"execute_time,omitempty"`
    77  	// Specifies the ID of an AS policy execution log.
    78  	Id string `json:"id,omitempty"`
    79  	// Specifies the project ID.
    80  	TenantId string `json:"tenant_id,omitempty"`
    81  	// Specifies the AS policy ID.
    82  	ScalingPolicyId string `json:"scaling_policy_id,omitempty"`
    83  	// Specifies the scaling resource type.
    84  	// AS group: SCALING_GROUP
    85  	// Bandwidth: BANDWIDTH
    86  	ScalingResourceType string `json:"scaling_resource_type,omitempty"`
    87  	// Specifies the scaling resource ID.
    88  	ScalingResourceId string `json:"scaling_resource_id,omitempty"`
    89  	// Specifies the source value.
    90  	OldValue string `json:"old_value,omitempty"`
    91  	// Specifies the target value.
    92  	DesireValue string `json:"desire_value,omitempty"`
    93  	// Specifies the operation restrictions.
    94  	// If scaling_resource_type is set to BANDWIDTH and operation is not SET, this parameter takes effect and the unit is Mbit/s.
    95  	// In this case:
    96  	// If operation is set to ADD, this parameter indicates the maximum bandwidth allowed.
    97  	// If operation is set to REDUCE, this parameter indicates the minimum bandwidth allowed.
    98  	LimitValue string `json:"limit_value,omitempty"`
    99  	// Specifies the AS policy execution type.
   100  	// ADD: indicates adding instances.
   101  	// REMOVE: indicates reducing instances.
   102  	// SET: indicates setting the number of instances to a specified value.
   103  	Type string `json:"type,omitempty"`
   104  	// Specifies the tasks contained in a scaling action based on an AS policy.
   105  	JobRecords []JobRecords `json:"job_records,omitempty"`
   106  
   107  	MetaData EipMetaData `json:"meta_data,omitempty"`
   108  }
   109  
   110  type JobRecords struct {
   111  	// Specifies the task name.
   112  	JobName string `json:"job_name,omitempty"`
   113  	// Specifies the record type.
   114  	// API: API calling type
   115  	// MEG: message type
   116  	RecordType string `json:"record_type,omitempty"`
   117  	// Specifies the record time.
   118  	RecordTime string `json:"record_time,omitempty"`
   119  	// Specifies the request body. This parameter is valid only if record_type is set to API.
   120  	Request string `json:"request,omitempty"`
   121  	// Specifies the response body. This parameter is valid only if record_type is set to API.
   122  	Response string `json:"response,omitempty"`
   123  	// Specifies the returned code. This parameter is valid only if record_type is set to API.
   124  	Code string `json:"code,omitempty"`
   125  	// Specifies the message. This parameter is valid only if record_type is set to MEG.
   126  	Message string `json:"message,omitempty"`
   127  	// Specifies the execution status of the task.
   128  	// SUCCESS: The task is successfully executed.
   129  	// FAIL: The task failed to be executed.
   130  	JobStatus string `json:"job_status,omitempty"`
   131  }
   132  
   133  type EipMetaData struct {
   134  	// Specifies the bandwidth sharing type in the bandwidth scaling policy.
   135  	MetadataBandwidthShareType string `json:"metadata_bandwidth_share_type,omitempty"`
   136  	// Specifies the EIP ID for the bandwidth in the bandwidth scaling policy.
   137  	MetadataEipId string `json:"metadata_eip_id,omitempty"`
   138  	// Specifies the EIP for the bandwidth in the bandwidth scaling policy.
   139  	MetadataeipAddress string `json:"metadataeip_address,omitempty"`
   140  }