github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/rts/v1/stackevents/requests.go (about) 1 package stackevents 2 3 import ( 4 "github.com/huaweicloud/golangsdk" 5 "github.com/huaweicloud/golangsdk/pagination" 6 ) 7 8 // SortDir is a type for specifying in which direction to sort a list of events. 9 type SortDir string 10 11 // SortKey is a type for specifying by which key to sort a list of events. 12 type SortKey string 13 14 // ResourceStatus is a type for specifying by which resource status to filter a 15 // list of events. 16 type ResourceStatus string 17 18 // ResourceAction is a type for specifying by which resource action to filter a 19 // list of events. 20 type ResourceAction string 21 22 var ( 23 // ResourceStatusInProgress is used to filter a List request by the 'IN_PROGRESS' status. 24 ResourceStatusInProgress ResourceStatus = "IN_PROGRESS" 25 // ResourceStatusComplete is used to filter a List request by the 'COMPLETE' status. 26 ResourceStatusComplete ResourceStatus = "COMPLETE" 27 // ResourceStatusFailed is used to filter a List request by the 'FAILED' status. 28 ResourceStatusFailed ResourceStatus = "FAILED" 29 30 // ResourceActionCreate is used to filter a List request by the 'CREATE' action. 31 ResourceActionCreate ResourceAction = "CREATE" 32 // ResourceActionDelete is used to filter a List request by the 'DELETE' action. 33 ResourceActionDelete ResourceAction = "DELETE" 34 // ResourceActionUpdate is used to filter a List request by the 'UPDATE' action. 35 ResourceActionUpdate ResourceAction = "UPDATE" 36 // ResourceActionRollback is used to filter a List request by the 'ROLLBACK' action. 37 ResourceActionRollback ResourceAction = "ROLLBACK" 38 // ResourceActionSuspend is used to filter a List request by the 'SUSPEND' action. 39 ResourceActionSuspend ResourceAction = "SUSPEND" 40 // ResourceActionResume is used to filter a List request by the 'RESUME' action. 41 ResourceActionResume ResourceAction = "RESUME" 42 // ResourceActionAbandon is used to filter a List request by the 'ABANDON' action. 43 ResourceActionAbandon ResourceAction = "ABANDON" 44 45 // SortAsc is used to sort a list of stacks in ascending order. 46 SortAsc SortDir = "asc" 47 // SortDesc is used to sort a list of stacks in descending order. 48 SortDesc SortDir = "desc" 49 50 // SortName is used to sort a list of stacks by name. 51 SortName SortKey = "name" 52 // SortResourceType is used to sort a list of stacks by resource type. 53 SortResourceType SortKey = "resource_type" 54 // SortCreatedAt is used to sort a list of stacks by date created. 55 SortCreatedAt SortKey = "created_at" 56 ) 57 58 // ListOptsBuilder allows extensions to add additional parameters to the 59 // List request. 60 type ListOptsBuilder interface { 61 ToStackEventListQuery() (string, error) 62 } 63 64 // ListOpts allows the filtering and sorting of paginated collections through 65 // the API. Marker and Limit are used for pagination. 66 type ListOpts struct { 67 // The stack resource ID with which to start the listing. 68 Marker string `q:"marker"` 69 // Integer value for the limit of values to return. 70 Limit int `q:"limit"` 71 // Filters the event list by the specified ResourceAction. You can use this 72 // filter multiple times to filter by multiple resource actions: CREATE, DELETE, 73 // UPDATE, ROLLBACK, SUSPEND, RESUME or ADOPT. 74 ResourceActions []ResourceAction `q:"resource_action"` 75 // Filters the event list by the specified resource_status. You can use this 76 // filter multiple times to filter by multiple resource statuses: IN_PROGRESS, 77 // COMPLETE or FAILED. 78 ResourceStatuses []ResourceStatus `q:"resource_status"` 79 // Filters the event list by the specified resource_name. You can use this 80 // filter multiple times to filter by multiple resource names. 81 ResourceNames []string `q:"resource_name"` 82 // Filters the event list by the specified resource_type. You can use this 83 // filter multiple times to filter by multiple resource types: OS::Nova::Server, 84 // OS::Cinder::Volume, and so on. 85 ResourceTypes []string `q:"resource_type"` 86 // Sorts the event list by: resource_type or created_at. 87 SortKey SortKey `q:"sort_keys"` 88 // The sort direction of the event list. Which is asc (ascending) or desc (descending). 89 SortDir SortDir `q:"sort_dir"` 90 } 91 92 // ToStackEventListQuery formats a ListOpts into a query string. 93 func (opts ListOpts) ToStackEventListQuery() (string, error) { 94 q, err := golangsdk.BuildQueryString(opts) 95 return q.String(), err 96 } 97 98 // List makes a request against the API to list resources for the given stack. 99 func List(client *golangsdk.ServiceClient, stackName, stackID string, opts ListOptsBuilder) pagination.Pager { 100 url := listURL(client, stackName, stackID) 101 if opts != nil { 102 query, err := opts.ToStackEventListQuery() 103 if err != nil { 104 return pagination.Pager{Err: err} 105 } 106 url += query 107 } 108 return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { 109 p := EventPage{pagination.MarkerPageBase{PageResult: r}} 110 p.MarkerPageBase.Owner = p 111 return p 112 }) 113 }