This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
orchestrator-swagger-go-client/api_plug.go

321 lines
9.9 KiB
Go
Raw Permalink Normal View History

2024-05-30 16:34:11 +00:00
/*
Anthrove Orchestrator API
This service handles the communication between the manager and the plugs
API version: 0.1-PREVIEW
Contact: support@anthrove.art
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package openapi
import (
"bytes"
"context"
"io/ioutil"
"net/http"
"net/url"
"strings"
)
// PlugApiService PlugApi service
type PlugApiService service
type ApiPlugPlugTypePutRequest struct {
ctx context.Context
ApiService *PlugApiService
plugType string
request *GitDragseItAnthroveOrchestratorPkgModelsOrchestratorTask
}
// aa
func (r ApiPlugPlugTypePutRequest) Request(request GitDragseItAnthroveOrchestratorPkgModelsOrchestratorTask) ApiPlugPlugTypePutRequest {
r.request = &request
return r
}
func (r ApiPlugPlugTypePutRequest) Execute() (*http.Response, error) {
return r.ApiService.PlugPlugTypePutExecute(r)
}
/*
PlugPlugTypePut Initiates a scraping operation for a user with a specific plug type
Initiates a scraping operation for a user with a specific plug type returns the created task IDs.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param plugType supported plug type
@return ApiPlugPlugTypePutRequest
*/
func (a *PlugApiService) PlugPlugTypePut(ctx context.Context, plugType string) ApiPlugPlugTypePutRequest {
return ApiPlugPlugTypePutRequest{
ApiService: a,
ctx: ctx,
plugType: plugType,
}
}
// Execute executes the request
func (a *PlugApiService) PlugPlugTypePutExecute(r ApiPlugPlugTypePutRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodPut
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PlugApiService.PlugPlugTypePut")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/plug/{plug_type}"
localVarPath = strings.Replace(localVarPath, "{"+"plug_type"+"}", url.PathEscape(parameterToString(r.plugType, "")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.request == nil {
return nil, reportError("request is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.request
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}
type ApiPlugPlugTypeTaskIdDeleteRequest struct {
ctx context.Context
ApiService *PlugApiService
plugType string
taskId string
}
func (r ApiPlugPlugTypeTaskIdDeleteRequest) Execute() (*http.Response, error) {
return r.ApiService.PlugPlugTypeTaskIdDeleteExecute(r)
}
/*
PlugPlugTypeTaskIdDelete Stops a scraping operation for a user with a specific plug type
Stops a scraping operation for a user with a specific plug type returns the created task IDs.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param plugType supported plug type
@param taskId id of task
@return ApiPlugPlugTypeTaskIdDeleteRequest
*/
func (a *PlugApiService) PlugPlugTypeTaskIdDelete(ctx context.Context, plugType string, taskId string) ApiPlugPlugTypeTaskIdDeleteRequest {
return ApiPlugPlugTypeTaskIdDeleteRequest{
ApiService: a,
ctx: ctx,
plugType: plugType,
taskId: taskId,
}
}
// Execute executes the request
func (a *PlugApiService) PlugPlugTypeTaskIdDeleteExecute(r ApiPlugPlugTypeTaskIdDeleteRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodDelete
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PlugApiService.PlugPlugTypeTaskIdDelete")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/plug/{plug_type}/{task_id}"
localVarPath = strings.Replace(localVarPath, "{"+"plug_type"+"}", url.PathEscape(parameterToString(r.plugType, "")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"task_id"+"}", url.PathEscape(parameterToString(r.taskId, "")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}
type ApiPlugPlugTypeTaskIdGetRequest struct {
ctx context.Context
ApiService *PlugApiService
plugType string
taskId string
}
func (r ApiPlugPlugTypeTaskIdGetRequest) Execute() (*http.Response, error) {
return r.ApiService.PlugPlugTypeTaskIdGetExecute(r)
}
/*
PlugPlugTypeTaskIdGet Retrieves the status of a specific task type
Retrieves the status of a specific task and returns it.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param plugType supported plug type
@param taskId id of task
@return ApiPlugPlugTypeTaskIdGetRequest
*/
func (a *PlugApiService) PlugPlugTypeTaskIdGet(ctx context.Context, plugType string, taskId string) ApiPlugPlugTypeTaskIdGetRequest {
return ApiPlugPlugTypeTaskIdGetRequest{
ApiService: a,
ctx: ctx,
plugType: plugType,
taskId: taskId,
}
}
// Execute executes the request
func (a *PlugApiService) PlugPlugTypeTaskIdGetExecute(r ApiPlugPlugTypeTaskIdGetRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PlugApiService.PlugPlugTypeTaskIdGet")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/plug/{plug_type}/{task_id}"
localVarPath = strings.Replace(localVarPath, "{"+"plug_type"+"}", url.PathEscape(parameterToString(r.plugType, "")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"task_id"+"}", url.PathEscape(parameterToString(r.taskId, "")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}