数据工坊 DWR-自定义函数开发规范:结构体示例(GO语言)

时间:2024-01-04 09:39:58

结构体示例(GO语言)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package main

type CreateTranscodeDynamicSourceBody struct {
	Transcodes []*CreateTranscodeTaskBody `json:"transcodes"`
}

type CreateTranscodeTaskBody struct {
	//源文件存储地址。
	Input *FileAddr `json:"input,omitempty"`
	//转码后的视频文件存储地址。
	Output *FileAddr `json:"output"`
	//转码模板ID,数组
	TransTemplateID []int `json:"trans_template_id,omitempty"`
	//支持图片水印和文字水印,最多支持20个。
	Watermarks []*Watermark `json:"watermarks,omitempty"`
	//任务优先级。
	Priority string `json:"priority,omitempty"`
	//输出文件名称,每一路转码输出对应一个名称,需要与转码模板ID数组的顺序对应。
	OutputFilenames []string `json:"output_filenames,omitempty"`
}
type Watermark struct {
	Input          *FileAddr       `json:"input,omitempty"`
	TemplateID     int             `json:"template_id,omitempty"`
	TextContext    string          `json:"text_context,omitempty"`
	ImageWatermark *ImageWatermark `json:"image_watermark,omitempty"`
	TextWatermark  *TextWatermark  `json:"text_watermark,omitempty"`
}
type TextWatermark struct {
	Dx               string `json:"dx,omitempty"`
	Dy               string `json:"dy,omitempty"`
	ReferPos         string `json:"referpos,omitempty"`
	TimelineStart    string `json:"timeline_start,omitempty"`
	TimelineDuration string `json:"timeline_duration,omitempty"`
	FontName         string `json:"font_name,omitempty"`
	FontSize         string `json:"font_size,omitempty"`
	FontColor        string `json:"font_color,omitempty"`
	Base             string `json:"base,omitempty"`
}
type ImageWatermark struct {
	Dx               string `json:"dx,omitempty"`
	Dy               string `json:"dy,omitempty"`
	ReferPos         string `json:"referpos,omitempty"`
	TimelineStart    string `json:"timeline_start,omitempty"`
	TimelineDuration string `json:"timeline_duration,omitempty"`
	ImageProcess     string `json:"image_process,omitempty"`
	Width            string `json:"width,omitempty"`
	Height           string `json:"height,omitempty"`
	Base             string `json:"base,omitempty"`
}

type CreateThumbnailDynamicSourceBody struct {
	Thumbnails []*ThumbnailCreateTaskBody `json:"thumbnails"`
}

//FileAddr 文件路径结构定义
type FileAddr struct {
	Location   string `json:"location"`
	BucketName string `json:"bucket"`
	Object     string `json:"object"`
}

type ThumbnailCreateTaskBody struct {
	//源文件地址。
	Input *FileAddr `json:"input"`
	//输出地址。
	Output *FileAddr `json:"output"`
	//是否压缩抽帧图片生成tar包。
	Tar int `json:"tar,omitempty"`
	//是否同步处理,同步处理是指不下载全部文件,快速定位到截图位置进行截图。
	Mode int `json:"sync,omitempty"`
	//截图参数
	ThumbnailParam *ThumbnailParam `json:"thumbnail_para"`
}

type ThumbnailParam struct {
	Type           string  `json:"type"`
	Time           int64   `json:"time,omitempty"`
	StartTime      int64   `json:"start_time,omitempty"`
	Duration       int64   `json:"duration,omitempty"`
	Dots           []int64 `json:"dots,omitempty"`
	Format         int64   `json:"format,omitempty"`
	AspectRatio    int64   `json:"aspect_ratio,omitempty"`
	Width          int64   `json:"width,omitempty"`
	Height         int64   `json:"height,omitempty"`
	MaxLength      int64   `json:"max_length,omitempty"`
	OutputFileName string  `json:"output_filename,omitempty"`
}

type OBSMessages struct {
	Records []OBSRecord `json:"Records"`
}

// OBSRecord OBS消息格式
type OBSRecord struct {
	EventVersion      string            `json:"eventVersion"`
	EventSource       string            `json:"eventSource"`
	EventRegion       string            `json:"eventRegion"`
	EventTime         string            `json:"eventTime"`
	EventName         string            `json:"eventName"`
	UserIdentity      UserIdentity      `json:"userIdentity"`
	RequestParameters RequestParameters `json:"requestParameters"`
	ResponseElements  ResponseElements  `json:"responseElements"`
	Obs               *OBSInfo          `json:"obs"`
}

// UserIdentity 用户id
type UserIdentity struct {
	ID string `json:"ID,omitempty"`
}

//RequestParameters 原始请求参数
type RequestParameters struct {
	SourceIPAddress string `json:"sourceIPAddress,omitempty"`
}

//ResponseElements 响应参数
type ResponseElements struct {
	OBSRequestID string `json:"x-obs-request-id"`
	OBSID2       string `json:"x-obs-id-2"`
}

//OBSInfo OBS信息
type OBSInfo struct {
	Version         string     `json:"Version"`
	ConfigurationID string     `json:"configurationId"`
	Bucket          BucketInfo `json:"bucket"`
	Object          ObjectInfo `json:"object"`
}

//BucketInfo 桶信息
type BucketInfo struct {
	Name          string       `json:"name"`
	OwnerIdentity UserIdentity `json:"ownerIdentity"`
	Bucket        string       `json:"bucket"`
}

//ObjectInfo 对象信息
type ObjectInfo struct {
	Key       string `json:"key"`
	Tag       string `json:"eTag"`
	Size      uint64 `json:"size"`
	VersionID string `json:"versionId"`
	Sequencer string `json:"sequencer"`
}

type Payload struct {
	ExecutionName string `json:"execution_name"`
	GraphName     string `json:"graph_name"`
	OBSMessages
	DynamicSource interface{}            `json:"dynamic_source"`
	Inputs        map[string]interface{} `json:"inputs"`
}
support.huaweicloud.com/usermanual-dwr/dwr_03_0008.html