github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/lts/v2/transfers/CreateLogDumpObs.go (about) 1 package transfers 2 3 import ( 4 golangsdk "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/build" 6 "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" 7 ) 8 9 type CreateLogDumpObsOpts struct { 10 // Log group ID. 11 // Value length: 36 characters 12 LogGroupId string `json:"log_group_id" required:"true"` 13 // Indicates IDs of log streams whose logs are to be periodically transferred to OBS. You can specify one or more log streams. 14 // Example value: 15 // 7bb6b1e7-xxxx-4255-87f9-b3dc7fb2xxxx 16 LogStreamIds []string `json:"log_stream_ids" required:"true"` 17 // Indicates the name of an OBS bucket. 18 // Minimum length: 3 characters 19 // Maximum length: 63 characters 20 ObsBucketName string `json:"obs_bucket_name" required:"true"` 21 // Set this parameter to cycle, which indicates that the log transfer is periodic. 22 // Value length: 5 characters 23 Type string `json:"type" required:"true"` 24 // Indicates whether the logs are stored in raw or JSON format. The default value is RAW. 25 // Minimum length: 3 characters 26 // Maximum length: 4 characters 27 StorageFormat string `json:"storage_format" required:"true"` 28 // Indicates whether the log transfer is enabled. The value is true (default) or false. 29 SwitchOn *bool `json:"switch_on,omitempty"` 30 // Indicates the file name prefix of the log files transferred to an OBS bucket. 31 // Minimum length: 0 characters 32 // Maximum length: 64 characters 33 PrefixName string `json:"prefix_name,omitempty"` 34 // Indicates a custom path to store the log files. 35 // Minimum length: 0 characters 36 // Maximum length: 64 characters 37 DirPrefixName string `json:"dir_prefix_name,omitempty"` 38 // Indicates the length of the log transfer interval. 39 // Example values: 1, 2, 3, 5, 6, 12, and 30 40 Period int32 `json:"period" required:"true"` 41 // Indicates the unit of the log transfer interval. 42 // Example values: min and hour 43 // Minimum length: 3 characters 44 // Maximum length: 4 characters 45 // NOTE: 46 // The log transfer interval is specified by the combination of the values of period and period_unit, and must be set to one of the following: 2 min, 5 min, 30 min, 1 hour, 3 hours, 6 hours, and 12 hours. 47 PeriodUnit string `json:"period_unit" required:"true"` 48 } 49 50 func CreateLogDumpObs(client *golangsdk.ServiceClient, opts CreateLogDumpObsOpts) (string, error) { 51 b, err := build.RequestBody(opts, "") 52 if err != nil { 53 return "", err 54 } 55 56 // POST /v2/{project_id}/log-dump/obs 57 raw, err := client.Post(client.ServiceURL("log-dump", "obs"), b, nil, &golangsdk.RequestOpts{ 58 OkCodes: []int{200, 201}, 59 }) 60 if err != nil { 61 return "", err 62 } 63 64 var res struct { 65 ID string `json:"log_dump_obs_id"` 66 } 67 err = extract.Into(raw.Body, &res) 68 return res.ID, err 69 }