github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/dis/v2/dump/CreateOBSDumpTask.go (about)

     1  package dump
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/build"
     6  )
     7  
     8  type CreateOBSDumpTaskOpts struct {
     9  	// Name of the stream.
    10  	// Maximum: 60
    11  	StreamName string
    12  	// Dump destination.
    13  	// Possible values:
    14  	// - OBS: Data is dumped to OBS.
    15  	// Default: NOWHERE
    16  	// Enumeration values:
    17  	// OBS
    18  	DestinationType string `json:"destination_type"`
    19  	// Parameter list of OBS to which data in the DIS stream will be dumped.
    20  	OBSDestinationDescriptor OBSDestinationDescriptorOpts `json:"obs_destination_descriptor,omitempty"`
    21  }
    22  
    23  func CreateOBSDumpTask(client *golangsdk.ServiceClient, opts CreateOBSDumpTaskOpts) error {
    24  	b, err := build.RequestBody(opts, "")
    25  	if err != nil {
    26  		return err
    27  	}
    28  
    29  	// POST /v2/{project_id}/streams/{stream_name}/transfer-tasks
    30  	_, err = client.Post(client.ServiceURL("streams", opts.StreamName, "transfer-tasks"), b, nil, &golangsdk.RequestOpts{
    31  		OkCodes: []int{201},
    32  	})
    33  	return err
    34  }
    35  
    36  type OBSDestinationDescriptorOpts struct {
    37  	// Name of the dump task.
    38  	// The task name consists of letters, digits, hyphens (-), and underscores (_).
    39  	// It must be a string of 1 to 64 characters.
    40  	TaskName string `json:"task_name"`
    41  	// Name of the agency created on IAM.
    42  	// DIS uses an agency to access your specified resources.
    43  	// The parameters for creating an agency are as follows:
    44  	// - Agency Type: Cloud service
    45  	// - Cloud Service: DIS
    46  	// - Validity Period: unlimited
    47  	// - Scope: Global service,
    48  	//	 Project: OBS. Select the Tenant Administrator role for the global service project.
    49  	// If agencies have been created, you can obtain available agencies from the agency list by using the "Listing Agencies " API.
    50  	// This parameter cannot be left blank and the parameter value cannot exceed 64 characters.
    51  	// If there are dump tasks on the console, the system displays a message indicating that an agency will be automatically created.
    52  	// The name of the automatically created agency is dis_admin_agency.
    53  	// Maximum: 6
    54  	AgencyName string `json:"agency_name"`
    55  	// User-defined interval at which data is imported from the current DIS stream into OBS.
    56  	// If no data is pushed to the DIS stream during the current interval, no dump file package will be generated.
    57  	// Value range: 30-900
    58  	// Default value: 300
    59  	// Unit: second
    60  	// Minimum: 30
    61  	// Maximum: 900
    62  	// Default: 300
    63  	DeliverTimeInterval *int `json:"deliver_time_interval"`
    64  	// Offset.
    65  	// LATEST: Maximum offset indicating that the latest data will be extracted.
    66  	// TRIM_HORIZON: Minimum offset indicating that the earliest data will be extracted.
    67  	// Default value: LATEST
    68  	// Default: LATEST
    69  	// Enumeration values:
    70  	// LATEST
    71  	// TRIM_HORIZON
    72  	ConsumerStrategy string `json:"consumer_strategy,omitempty"`
    73  	// Directory to store files that will be dumped to OBS.
    74  	// Different directory levels are separated by slashes (/) and cannot start with slashes.
    75  	// The value can contain a maximum of 50 characters, including letters, digits, underscores (_), and slashes (/).
    76  	// This parameter is left empty by default.
    77  	// Maximum: 50
    78  	FilePrefix string `json:"file_prefix,omitempty"`
    79  	// Directory structure of the object file written into OBS.
    80  	// The directory structure is in the format of yyyy/MM/dd/HH/mm (time at which the dump task was created).
    81  	// - N/A: Leave this parameter empty, indicating that the date and time directory is not used.
    82  	// - yyyy: year
    83  	// - yyyy/MM: year/month
    84  	// - yyyy/MM/dd: year/month/day
    85  	// - yyyy/MM/dd/HH: year/month/day/hour
    86  	// - yyyy/MM/dd/HH/mm: year/month/day/hour/minute
    87  	// Example: in 2017/11/10/14/49, the directory structure is 2017 > 11 > 10 > 14 > 49. 2017 indicates the outermost folder.
    88  	// Default value: empty.
    89  	// Note:
    90  	// After data is successfully dumped, the directory structure is obs_bucket_path/file_prefix/partition_format.
    91  	// Enumeration values:
    92  	// yyyy
    93  	// yyyy/MM
    94  	// yyyy/MM/dd
    95  	// yyyy/MM/dd/HH
    96  	// yyyy/MM/dd/HH/mm
    97  	PartitionFormat string `json:"partition_format,omitempty"`
    98  	// Name of the OBS bucket used to store data from the DIS stream.
    99  	OBSBucketPath string `json:"obs_bucket_path,omitempty"`
   100  	// Dump file format.
   101  	// Possible values:
   102  	// - Text (default)
   103  	// - Parquet
   104  	// - CarbonData
   105  	// Note:
   106  	// You can select Parquet or CarbonData only when Source Data Type is set to JSON an Dump Destination is set to OBS.
   107  	// Default: text
   108  	// Enumeration values:
   109  	// text
   110  	// parquet
   111  	// carbon
   112  	DestinationFileType string `json:"destination_file_type,omitempty"`
   113  	// Dump time directory generated based on the timestamp of the source data and the configured partition_format.
   114  	// Directory structure of the object file written into OBS.
   115  	// The directory structure is in the format of yyyy/MM/dd/HH/mm.
   116  	ProcessingSchema ProcessingSchema `json:"processing_schema,omitempty"`
   117  	// Delimiter for the dump file which is used to separate the user data that is written into the dump file
   118  	// Value range:
   119  	// - Comma (,), which is the default value
   120  	// - Semicolon (;)
   121  	// - Vertical bar (|)
   122  	// - Newline character (\n)
   123  	// Default: \n
   124  	RecordDelimiter string `json:"record_delimiter,omitempty"`
   125  }
   126  
   127  type ProcessingSchema struct {
   128  	// Attribute name of the source data timestamp.
   129  	TimestampName string `json:"timestamp_name"`
   130  	// Type of the source data timestamp.
   131  	// - String
   132  	// - Timestamp: 13-bit timestamp of the long type
   133  	TimestampType string `json:"timestamp_type"`
   134  	// OBS directory generated based on the timestamp format.
   135  	// This parameter is mandatory when the timestamp type of the source data is String.
   136  	// Value range:
   137  	// - yyyy/MM/dd HH:mm:ss
   138  	// - MM/dd/yyyy HH:mm:ss
   139  	// - dd/MM/yyyy HH:mm:ss
   140  	// - yyyy-MM-dd HH:mm:ss
   141  	// - MM-dd-yyyy HH:mm:ss
   142  	// - dd-MM-yyyy HH:mm:ss
   143  	// Enumeration values:
   144  	// yyyy/MM/dd HH:mm:ss
   145  	// MM/dd/yyyy HH:mm:ss
   146  	// dd/MM/yyyy HH:mm:ss
   147  	// yyyy-MM-dd HH:mm:ss
   148  	// MM-dd-yyyy HH:mm:ss
   149  	// dd-MM-yyyy HH:mm:ss
   150  	TimestampFormat string `json:"timestamp_format,omitempty"`
   151  }