github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/lts/v2/loggroups/requests.go (about) 1 package loggroups 2 3 import "github.com/huaweicloud/golangsdk" 4 5 // CreateOptsBuilder is used for creating log group parameters. 6 type CreateOptsBuilder interface { 7 ToLogGroupsCreateMap() (map[string]interface{}, error) 8 } 9 10 // CreateOpts is a struct that contains all the parameters. 11 type CreateOpts struct { 12 // Specifies the log group name. 13 LogGroupName string `json:"log_group_name" required:"true"` 14 15 // Specifies the log expiration time. The value is fixed to 7 days. 16 TTL int `json:"ttl_in_days,omitempty"` 17 } 18 19 // ToLogGroupsCreateMap is used for type convert 20 func (ops CreateOpts) ToLogGroupsCreateMap() (map[string]interface{}, error) { 21 return golangsdk.BuildRequestBody(ops, "") 22 } 23 24 // Create a log group with given parameters. 25 func Create(client *golangsdk.ServiceClient, ops CreateOptsBuilder) (r CreateResult) { 26 b, err := ops.ToLogGroupsCreateMap() 27 if err != nil { 28 r.Err = err 29 return 30 } 31 32 _, r.Err = client.Post(createURL(client), b, &r.Body, &golangsdk.RequestOpts{ 33 OkCodes: []int{201}, 34 }) 35 36 return 37 } 38 39 // Delete a log group by id 40 func Delete(client *golangsdk.ServiceClient, id string) (r DeleteResult) { 41 _, r.Err = client.Delete(deleteURL(client, id), nil) 42 return 43 } 44 45 // Get a log group with detailed information by id 46 func Get(client *golangsdk.ServiceClient, id string) (r GetResult) { 47 _, r.Err = client.Get(getURL(client, id), &r.Body, nil) 48 return 49 }