github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/cts/v2/traces/List.go (about) 1 package traces 2 3 import ( 4 golangsdk "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" 6 ) 7 8 type ListTracesOpts struct { 9 // Status of a trace. The value can be normal, warning, or incident. 10 TraceStatus string `q:"trace_status,omitempty"` 11 // Number of traces returned to the trace list. The default value is 50 and the maximum value is 200. 12 Limit string `q:"limit,omitempty"` 13 // UTC timestamp of the start time of the query time range. The value is in milliseconds and contains 13 digits. 14 // Traces generated on the specified timestamp are not returned. The parameters from and to should be used together. 15 From string `q:"from,omitempty"` 16 // This parameter is used to query traces generated earlier than its specified value. The value can be that of marker in Table 2-34. 17 // next can be used with from and to. 18 // Traces generated in the overlap of the two time ranges specified respectively by next and by from and to will be returned. 19 Next string `q:"next,omitempty"` 20 // UTC timestamp of the end time of the query time range. The value is in milliseconds and contains 13 digits. 21 // Traces generated on the specified timestamp are not returned. The parameters to and from should be used together. 22 To string `q:"to,omitempty"` 23 // Type of service whose traces are to be queried. 24 // The value must be the acronym of a cloud service that has been connected with CTS. 25 // It is a word composed of uppercase letters. 26 // For cloud services that can be connected with CTS, 27 // see section "Supported Services and Operations" in the Cloud Trace Service User Guide. 28 ServiceType string `q:"service_type,omitempty"` 29 // Name of the user whose traces are to be queried. 30 // NOTE The username is case-sensitive. 31 User string `q:"user,omitempty"` 32 // ID of a cloud resource whose traces are to be queried. 33 ResourceId string `q:"resource_id,omitempty"` 34 // Name of a resource whose traces are to be queried. 35 // NOTE The resource name is case-sensitive. 36 ResourceName string `q:"resource_name,omitempty"` 37 // Type of resource whose traces are to be queried. The value can contain 1 to 64 characters, including letters, 38 // digits, hyphens (-), underscores (_), and periods (.). It must start with a letter. 39 // For cloud services that can be connected with CTS, see section "Supported Services and Operations" in the Cloud Trace Service User Guide. 40 ResourceType string `q:"resource_type,omitempty"` 41 // Trace ID. 42 // If this parameter is specified, other query criteria will not take effect. 43 TraceId string `q:"trace_id,omitempty"` 44 // Trace name. It indicates the operation recorded by this trace. 45 // NOTE The trace name is case-sensitive. 46 TraceName string `q:"trace_name,omitempty"` 47 } 48 49 func List(client *golangsdk.ServiceClient, trackerName string, opts ListTracesOpts) (*ListTracesResponse, error) { 50 url, err := golangsdk.NewURLBuilder().WithEndpoints(trackerName, "trace").WithQueryParams(&opts).Build() 51 if err != nil { 52 return nil, err 53 } 54 55 // GET /v2.0/{project_id}/{tracker_name}/trace 56 raw, err := client.Get(client.ServiceURL(url.String()), nil, nil) 57 if err != nil { 58 return nil, err 59 } 60 61 var res ListTracesResponse 62 err = extract.Into(raw.Body, &res) 63 return &res, err 64 } 65 66 type ListTracesResponse struct { 67 Traces []Traces `json:"traces,omitempty"` 68 MetaData MetaData `json:"meta_data,omitempty"` 69 } 70 71 type Traces struct { 72 // ID of a cloud resource on which the recorded operation was performed. 73 ResourceId string `json:"resource_id,omitempty"` 74 // Name of a trace. The value can contain 1 to 64 characters, 75 // including letters, digits, hyphens (-), underscores (_), and periods (.). It must start with a letter. 76 TraceName string `json:"trace_name,omitempty"` 77 // Trace status. The value can be normal, warning, or incident. 78 TraceStatus string `json:"trace_status,omitempty"` 79 // Trace source. The value can be ApiCall, ConsoleAction, or SystemAction. 80 TraceType string `json:"trace_type,omitempty"` 81 // Request of an operation on resources. 82 Request string `json:"request,omitempty"` 83 // Response to a user request, that is, the returned information for an operation on resources. 84 Response string `json:"response,omitempty"` 85 // HTTP status code returned by the associated API. 86 Code string `json:"code,omitempty"` 87 // Version of the API. 88 ApiVersion string `json:"api_version,omitempty"` 89 // Remarks added by other cloud services to a trace. 90 Message string `json:"message,omitempty"` 91 // Timestamp when an operation was recorded by CTS. 92 RecordTime int64 `json:"record_time,omitempty"` 93 // Trace ID. The value is the UUID generated by the system. 94 TraceId string `json:"trace_id,omitempty"` 95 // Timestamp when a trace was generated. 96 Time int64 `json:"time,omitempty"` 97 // Information of the user who performed the operation that triggered the trace. 98 User UserInfo `json:"user,omitempty"` 99 // Type of service whose traces are to be queried. 100 // The value must be the acronym of a cloud service that has been connected with CTS. 101 // It is a word composed of uppercase letters. 102 ServiceType string `json:"service_type,omitempty"` 103 // Type of resource whose traces are to be queried. The value can contain 1 to 64 characters, 104 // including letters, digits, hyphens (-), underscores (_), and periods (.). It must start with a letter. 105 ResourceType string `json:"resource_type,omitempty"` 106 // IP address of the tenant who performed the operation that triggered the trace. 107 SourceIp string `json:"source_ip,omitempty"` 108 // Name of a resource on which the recorded operation was performed. 109 ResourceName string `json:"resource_name,omitempty"` 110 // Request ID. 111 RequestId string `json:"request_id,omitempty"` 112 // Additional information required for fault locating after a request error. 113 LocationInfo string `json:"location_info,omitempty"` 114 // Endpoint in the details page URL of the cloud resource on which the recorded operation was performed. 115 Endpoint string `json:"endpoint,omitempty"` 116 // Details page URL (excluding the endpoint) of the cloud resource on which the recorded operation was performed. 117 ResourceUrl string `json:"resource_url,omitempty"` 118 } 119 120 type UserInfo struct { 121 Id string `json:"id,omitempty"` 122 Name string `json:"name,omitempty"` 123 Domain BaseUser `json:"domain,omitempty"` 124 } 125 126 type BaseUser struct { 127 Id string `json:"id,omitempty"` 128 Name string `json:"name,omitempty"` 129 } 130 131 type MetaData struct { 132 // Number of returned traces. 133 Count int `json:"count,omitempty"` 134 // ID of the last trace in the returned trace list. The value of this parameter can be used as the next value. 135 // If the value of marker is null, all traces have been returned. 136 Marker string `json:"marker,omitempty"` 137 }