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

/*
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"
"net/http"
"net/url"
"strings"
)
// PlugAPIService PlugAPI service
type PlugAPIService service
type ApiPlugPlugTypePutRequest struct {
ctx context.Context
ApiService *PlugAPIService
plugType string
request *ModelsOrchestratorTask
}
// aa
func (r ApiPlugPlugTypePutRequest) Request(request ModelsOrchestratorTask) 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(parameterValueToString(r.plugType, "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 := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.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(parameterValueToString(r.plugType, "plugType")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"task_id"+"}", url.PathEscape(parameterValueToString(r.taskId, "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 := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.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(parameterValueToString(r.plugType, "plugType")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"task_id"+"}", url.PathEscape(parameterValueToString(r.taskId, "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 := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.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
}