github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/fgs/v2/util/ListStats.go (about)

     1  package util
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     6  )
     7  
     8  type ListStatsOpts struct {
     9  	Filter string `q:"filter" required:"true"`
    10  	Period string `q:"period"`
    11  	Option string `q:"option"`
    12  	Limit  string `q:"limit"`
    13  	Marker string `q:"marker"`
    14  }
    15  
    16  func ListStats(client *golangsdk.ServiceClient, opts ListStatsOpts) (*ListStatsResponse, error) {
    17  	url, err := golangsdk.NewURLBuilder().WithEndpoints("fgs", "functions", "statistics").WithQueryParams(&opts).Build()
    18  	if err != nil {
    19  		return nil, err
    20  	}
    21  
    22  	raw, err := client.Get(client.ServiceURL(url.String()), nil, nil)
    23  	if err != nil {
    24  		return nil, err
    25  	}
    26  
    27  	var res ListStatsResponse
    28  	err = extract.Into(raw.Body, &res)
    29  	return &res, err
    30  }
    31  
    32  type ListStatsResponse struct {
    33  	Count      []MonthUsed `json:"count"`
    34  	Gbs        []MonthUsed `json:"gbs"`
    35  	GpuGbs     []MonthUsed `json:"gpu_gbs"`
    36  	Statistics *StatResp   `json:"monitor_data"`
    37  }
    38  
    39  type MonthUsed struct {
    40  	Date  string  `json:"date"`
    41  	Value float64 `json:"value"`
    42  }
    43  
    44  type StatResp struct {
    45  	Count               []SlaReport `json:"count"`
    46  	Duration            []SlaReport `json:"duration"`
    47  	FailCount           []SlaReport `json:"fail_count"`
    48  	MaxDuration         []SlaReport `json:"max_duration"`
    49  	MinDuration         []SlaReport `json:"min_duration"`
    50  	RejectCount         []SlaReport `json:"reject_count"`
    51  	FuncErrorCount      []SlaReport `json:"function_error_count"`
    52  	SysErrorCount       []SlaReport `json:"system_error_count"`
    53  	ReservedInstanceNum []SlaReport `json:"reserved_instance_num"`
    54  	ConcurrencyNum      []SlaReport `json:"concurrency_num"`
    55  }
    56  
    57  type SlaReport struct {
    58  	TimeStamp int     `json:"timestamp"`
    59  	Value     float64 `json:"value"`
    60  }