github.com/aiven/aiven-go-client@v1.36.0/flink_application_version.go (about)

     1  package aiven
     2  
     3  type (
     4  	// FlinkApplicationVersionHandler is the client which interacts with the Flink Application Version.
     5  	FlinkApplicationVersionHandler struct {
     6  		client *Client
     7  	}
     8  
     9  	// GenericFlinkApplicationVersionResponse is the generic response for Flink Application Version requests.
    10  	GenericFlinkApplicationVersionResponse struct {
    11  		APIResponse
    12  		GenericFlinkApplicationVersionRequest
    13  	}
    14  
    15  	// DetailedFlinkApplicationVersionResponse is the detailed response for Flink Application Version requests.
    16  	// GET /project/{project}/service/{service_name}/flink/application/{application_id}/version/{application_version_id}
    17  	// POST /project/{project}/service/{service_name}/flink/application/{application_id}/version
    18  	// DELETE /project/{project}/service/{service_name}/flink/application/{application_id}/version/{application_version_id}
    19  	DetailedFlinkApplicationVersionResponse struct {
    20  		GenericFlinkApplicationVersionResponse
    21  
    22  		ID        string `json:"id,omitempty"`
    23  		Version   int    `json:"version"`
    24  		CreatedAt string `json:"created_at"`
    25  		CreatedBy string `json:"created_by"`
    26  	}
    27  
    28  	// ValidateFlinkApplicationVersionStatementError is the error for validating a Flink Application Version.
    29  	ValidateFlinkApplicationVersionStatementError struct {
    30  		Message  string        `json:"message"`
    31  		Position flinkPosition `json:"position"`
    32  	}
    33  
    34  	// ValidateFlinkApplicationVersionResponse is the response for validating a Flink Application Version.
    35  	// POST /project/{project}/service/{service_name}/flink/application/{application_id}/version/validate
    36  	ValidateFlinkApplicationVersionResponse struct {
    37  		GenericFlinkApplicationVersionResponse
    38  
    39  		ValidateFlinkApplicationVersionStatementError
    40  	}
    41  
    42  	// FlinkApplicationVersionRelation is the relation between a Flink Application Version and an Integration.
    43  	FlinkApplicationVersionRelation struct {
    44  		CreateTable   string `json:"create_table,omitempty"`
    45  		IntegrationID string `json:"integration_id,omitempty"`
    46  	}
    47  
    48  	// GenericFlinkApplicationVersionRequest is the generic request for Flink Application Version requests.
    49  	// POST /project/{project}/service/{service_name}/flink/application/{application_id}/version
    50  	// POST /project/{project}/service/{service_name}/flink/application/{application_id}/version/validate
    51  	GenericFlinkApplicationVersionRequest struct {
    52  		Statement string                            `json:"statement,omitempty"`
    53  		Sinks     []FlinkApplicationVersionRelation `json:"sinks,omitempty"`
    54  		Sources   []FlinkApplicationVersionRelation `json:"sources,omitempty"`
    55  	}
    56  )
    57  
    58  // Get is the method to get a Flink Application Version.
    59  func (h *FlinkApplicationVersionHandler) Get(
    60  	project string,
    61  	service string,
    62  	applicationID string,
    63  	applicationVersionID string,
    64  ) (*DetailedFlinkApplicationVersionResponse, error) {
    65  	path := buildPath(
    66  		"project",
    67  		project,
    68  		"service",
    69  		service,
    70  		"flink",
    71  		"application",
    72  		applicationID,
    73  		"version",
    74  		applicationVersionID,
    75  	)
    76  
    77  	bts, err := h.client.doGetRequest(path, nil)
    78  	if err != nil {
    79  		return nil, err
    80  	}
    81  
    82  	var r DetailedFlinkApplicationVersionResponse
    83  	return &r, checkAPIResponse(bts, &r)
    84  }
    85  
    86  // Create is the method to create a Flink Application Version.
    87  func (h *FlinkApplicationVersionHandler) Create(
    88  	project string,
    89  	service string,
    90  	applicationID string,
    91  	req GenericFlinkApplicationVersionRequest,
    92  ) (*DetailedFlinkApplicationVersionResponse, error) {
    93  	path := buildPath("project", project, "service", service, "flink", "application", applicationID, "version")
    94  
    95  	bts, err := h.client.doPostRequest(path, req)
    96  	if err != nil {
    97  		return nil, err
    98  	}
    99  
   100  	var r DetailedFlinkApplicationVersionResponse
   101  	return &r, checkAPIResponse(bts, &r)
   102  }
   103  
   104  // Delete is the method to delete a Flink Application Version.
   105  func (h *FlinkApplicationVersionHandler) Delete(
   106  	project string,
   107  	service string,
   108  	applicationID string,
   109  	applicationVersionID string,
   110  ) (*DetailedFlinkApplicationVersionResponse, error) {
   111  	path := buildPath(
   112  		"project",
   113  		project,
   114  		"service",
   115  		service,
   116  		"flink",
   117  		"application",
   118  		applicationID,
   119  		"version",
   120  		applicationVersionID,
   121  	)
   122  
   123  	bts, err := h.client.doDeleteRequest(path, nil)
   124  	if err != nil {
   125  		return nil, err
   126  	}
   127  
   128  	var r DetailedFlinkApplicationVersionResponse
   129  	return &r, checkAPIResponse(bts, &r)
   130  }
   131  
   132  // Validate is the method to validate a Flink Application Version.
   133  func (h *FlinkApplicationVersionHandler) Validate(
   134  	project string,
   135  	service string,
   136  	applicationID string,
   137  	req GenericFlinkApplicationVersionRequest,
   138  ) (*ValidateFlinkApplicationVersionResponse, error) {
   139  	path := buildPath(
   140  		"project",
   141  		project,
   142  		"service",
   143  		service,
   144  		"flink",
   145  		"application",
   146  		applicationID,
   147  		"version",
   148  		"validate",
   149  	)
   150  
   151  	bts, err := h.client.doPostRequest(path, req)
   152  	if err != nil {
   153  		return nil, err
   154  	}
   155  
   156  	var r ValidateFlinkApplicationVersionResponse
   157  	return &r, checkAPIResponse(bts, &r)
   158  }