github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/dli/v3/flinkjob/requests.go (about)

     1  package flinkjob
     2  
     3  import (
     4  	"github.com/chnsz/golangsdk"
     5  )
     6  
     7  // StreamGraphOpts is the structure that represents used to generate a static stream graph or simplified stream graph.
     8  type StreamGraphOpts struct {
     9  	// The job ID of the flink job.
    10  	JobId string `json:"-" required:"true"`
    11  	// Stream SQL statement.
    12  	SqlBody string `json:"sql_body" required:"true"`
    13  	// The total number of CUs.
    14  	CuNumber *int `json:"cu_number,omitempty"`
    15  	// The number of CUs of the management unit.
    16  	ManagerCuNumber *int `json:"manager_cu_number,omitempty"`
    17  	// The number of parallel jobs
    18  	ParallelNumber *int `json:"parallel_number,omitempty"`
    19  	// The number of CUs in a taskManager.
    20  	TmCus *int `json:"tm_cus,omitempty"`
    21  	// The number of slots in a taskManager.
    22  	TmSlotNum *int `json:"tm_slot_num,omitempty"`
    23  	// The operator configurations.
    24  	OperatorConfig string `json:"operator_config,omitempty"`
    25  	// Whether to estimate static resources.
    26  	StaticEstimator *bool `json:"static_estimator,omitempty"`
    27  	// Job type. Only flink_opensource_sql_job job is supported.
    28  	JobType string `json:"job_type,omitempty"`
    29  	// Stream graph type. The valid values aer as follows:
    30  	// + simple_graph: Simplified stream graph.
    31  	// + job_graph: Static stream graph.
    32  	GraphType string `json:"graph_type,omitempty"`
    33  	// Traffic or hit ratio of each operator, which is a string in JSON format.
    34  	StaticEstimatorConfig string `json:"static_estimator_config,omitempty"`
    35  	// Flink version. Currently, only 1.10 and 1.12 are supported.
    36  	FlinkVersion string `json:"flink_version,omitempty"`
    37  }
    38  
    39  // CreateFlinkSqlJobGraph is a method to generate a stream graph for a Flink SQL job using given parameters.
    40  func CreateFlinkSqlJobGraph(c *golangsdk.ServiceClient, opts StreamGraphOpts) (*streamGraphResp, error) {
    41  	b, err := golangsdk.BuildRequestBody(opts, "")
    42  	if err != nil {
    43  		return nil, err
    44  	}
    45  
    46  	var r streamGraphResp
    47  	_, err = c.Post(streamGraphURL(c, opts.JobId), b, &r, &golangsdk.RequestOpts{})
    48  	return &r, err
    49  }