github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/dli/v3/queues/requests.go (about) 1 package queues 2 3 import ( 4 "github.com/chnsz/golangsdk" 5 "github.com/chnsz/golangsdk/pagination" 6 ) 7 8 // ListQueuePropertyOpts is the structure that used to query the list of the queue properties. 9 type ListQueuePropertyOpts struct { 10 // The queue name. 11 QueueName string `json:"-" required:"true"` 12 // The offset number. 13 Offset int `q:"offset"` 14 // Number of records to be queried. 15 Limit int `q:"limit"` 16 } 17 18 // ListQueueProperty is the method that used to query list of the queue properties using given parameters. 19 func ListQueueProperty(c *golangsdk.ServiceClient, opts ListQueuePropertyOpts) ([]PropertyResp, error) { 20 url := propertyURL(c, opts.QueueName) 21 query, err := golangsdk.BuildQueryString(opts) 22 if err != nil { 23 return nil, err 24 } 25 26 url += query.String() 27 pager := pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page { 28 p := QueuePropertyPage{pagination.OffsetPageBase{PageResult: r}} 29 return p 30 }) 31 32 pages, err := pager.AllPages() 33 if err != nil { 34 return nil, err 35 } 36 return ExtractProperties(pages) 37 } 38 39 // Property is the structure that used to update the property of the queue. 40 type Property struct { 41 // Maximum number of Spark drivers can be started on this queue. 42 MaxInstance int `json:"computeEngine.maxInstance,omitempty"` 43 // Maximum number of tasks can be concurrently executed by a Spark driver. 44 MaxConcurrent int `json:"job.maxConcurrent,omitempty"` 45 // Maximum number of Spark drivers can be pre-started on this queue. 46 MaxPrefetchInstance *int `json:"computeEngine.maxPrefetchInstance,omitempty"` 47 // The cidr of the queue. 48 Cidr string `json:"network.cidrInVpc,omitempty"` 49 } 50 51 // UpdateQueueProperty is the method that used to update property of the queue using given parameters. 52 func UpdateQueueProperty(c *golangsdk.ServiceClient, queueName string, opts Property) (*QueuePropertyResp, error) { 53 b, err := golangsdk.BuildRequestBody(opts, "properties") 54 if err != nil { 55 return nil, err 56 } 57 var r QueuePropertyResp 58 _, err = c.Put(propertyURL(c, queueName), b, &r, &golangsdk.RequestOpts{}) 59 return &r, err 60 } 61 62 // DeleteQueueProperties is the method that used to delete properties of the queue. 63 func DeleteQueueProperties(c *golangsdk.ServiceClient, queueName string, opts []string) (*QueuePropertyResp, error) { 64 var r QueuePropertyResp 65 _, err := c.DeleteWithResponse(propertyURL(c, queueName), &r, &golangsdk.RequestOpts{ 66 JSONBody: map[string]interface{}{ 67 "keys": opts, 68 }, 69 }) 70 return &r, err 71 }