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

     1  package aiven
     2  
     3  type (
     4  	// FlinkApplicationHandler is the client which interacts with the Flink Application.
     5  	FlinkApplicationHandler struct {
     6  		client *Client
     7  	}
     8  
     9  	// GenericFlinkApplicationResponse is the generic response for Flink Application requests.
    10  	// GET https://api.aiven.io/v1/project/{project}/service/{service_name}/flink/application
    11  	GenericFlinkApplicationResponse struct {
    12  		APIResponse
    13  
    14  		ID        string `json:"id"`
    15  		Name      string `json:"name"`
    16  		CreatedAt string `json:"created_at"`
    17  		CreatedBy string `json:"created_by"`
    18  		UpdatedAt string `json:"updated_at"`
    19  		UpdatedBy string `json:"updated_by"`
    20  	}
    21  
    22  	// DetailedFlinkApplicationResponse is the detailed response for Flink Application requests.
    23  	// GET /project/{project}/service/{service_name}/flink/application/{application_id}
    24  	// POST /project/{project}/service/{service_name}/flink/application
    25  	// PUT /project/{project}/service/{service_name}/flink/application/{application_id}
    26  	// DELETE /project/{project}/service/{service_name}/flink/application/{application_id}
    27  	DetailedFlinkApplicationResponse struct {
    28  		GenericFlinkApplicationResponse
    29  
    30  		ApplicationVersions []FlinkApplicationVersion  `json:"application_versions"`
    31  		CurrentDeployment   FlinkApplicationDeployment `json:"current_deployment"`
    32  	}
    33  
    34  	// CreateFlinkApplicationRequest is the request to create a Flink Application.
    35  	// POST /project/{project}/service/{service_name}/flink/application
    36  	CreateFlinkApplicationRequest struct {
    37  		Name               string                   `json:"name"`
    38  		ApplicationVersion *FlinkApplicationVersion `json:"application_version,omitempty"`
    39  	}
    40  
    41  	FlinkApplicationVersionCreateInput struct {
    42  		CreateTable   string `json:"create_table"`
    43  		IntegrationID string `json:"integration_id"`
    44  	}
    45  
    46  	FlinkApplicationVersion struct {
    47  		Sinks     []FlinkApplicationVersionCreateInput `json:"sinks"`
    48  		Sources   []FlinkApplicationVersionCreateInput `json:"sources"`
    49  		Statement string                               `json:"statement"`
    50  	}
    51  
    52  	// UpdateFlinkApplicationRequest is the request to update a Flink Application.
    53  	// PUT /project/{project}/service/{service_name}/flink/application/{application_id}
    54  	UpdateFlinkApplicationRequest struct {
    55  		Name string `json:"name,omitempty"`
    56  	}
    57  
    58  	// FlinkApplicationListResponse is the response for listing Flink Applications.
    59  	// GET /project/{project}/service/{service_name}/flink/application
    60  	FlinkApplicationListResponse struct {
    61  		APIResponse
    62  
    63  		Applications []GenericFlinkApplicationResponse `json:"applications"`
    64  	}
    65  )
    66  
    67  // Get is the method to get a Flink Application.
    68  func (h *FlinkApplicationHandler) Get(
    69  	project string,
    70  	service string,
    71  	applicationID string,
    72  ) (*DetailedFlinkApplicationResponse, error) {
    73  	path := buildPath("project", project, "service", service, "flink", "application", applicationID)
    74  
    75  	bts, err := h.client.doGetRequest(path, nil)
    76  	if err != nil {
    77  		return nil, err
    78  	}
    79  
    80  	var r DetailedFlinkApplicationResponse
    81  
    82  	return &r, checkAPIResponse(bts, &r)
    83  }
    84  
    85  // Create is the method to create a Flink Application.
    86  func (h *FlinkApplicationHandler) Create(
    87  	project string,
    88  	service string,
    89  	req CreateFlinkApplicationRequest,
    90  ) (*DetailedFlinkApplicationResponse, error) {
    91  	path := buildPath("project", project, "service", service, "flink", "application")
    92  
    93  	bts, err := h.client.doPostRequest(path, req)
    94  	if err != nil {
    95  		return nil, err
    96  	}
    97  
    98  	var r DetailedFlinkApplicationResponse
    99  	return &r, checkAPIResponse(bts, &r)
   100  }
   101  
   102  // Update is the method to update a Flink Application.
   103  func (h *FlinkApplicationHandler) Update(
   104  	project string,
   105  	service string,
   106  	applicationID string,
   107  	req UpdateFlinkApplicationRequest,
   108  ) (*DetailedFlinkApplicationResponse, error) {
   109  	path := buildPath("project", project, "service", service, "flink", "application", applicationID)
   110  
   111  	bts, err := h.client.doPutRequest(path, req)
   112  	if err != nil {
   113  		return nil, err
   114  	}
   115  
   116  	var r DetailedFlinkApplicationResponse
   117  	return &r, checkAPIResponse(bts, &r)
   118  }
   119  
   120  // Delete is the method to delete a Flink Application.
   121  func (h *FlinkApplicationHandler) Delete(
   122  	project string,
   123  	service string,
   124  	applicationID string,
   125  ) (*DetailedFlinkApplicationResponse, error) {
   126  	path := buildPath("project", project, "service", service, "flink", "application", applicationID)
   127  
   128  	bts, err := h.client.doDeleteRequest(path, nil)
   129  	if err != nil {
   130  		return nil, err
   131  	}
   132  
   133  	var r DetailedFlinkApplicationResponse
   134  	return &r, checkAPIResponse(bts, &r)
   135  }
   136  
   137  // List is the method to list Flink Applications.
   138  func (h *FlinkApplicationHandler) List(
   139  	project string,
   140  	service string,
   141  ) (*FlinkApplicationListResponse, error) {
   142  	path := buildPath("project", project, "service", service, "flink", "application")
   143  
   144  	bts, err := h.client.doGetRequest(path, nil)
   145  	if err != nil {
   146  		return nil, err
   147  	}
   148  
   149  	var r FlinkApplicationListResponse
   150  	return &r, checkAPIResponse(bts, &r)
   151  }