migration from old git (no git history)
This commit is contained in:
commit
e8949a6d49
24
.gitignore
vendored
Normal file
24
.gitignore
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||||
|
*.o
|
||||||
|
*.a
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Folders
|
||||||
|
_obj
|
||||||
|
_test
|
||||||
|
|
||||||
|
# Architecture specific extensions/prefixes
|
||||||
|
*.[568vq]
|
||||||
|
[568vq].out
|
||||||
|
|
||||||
|
*.cgo1.go
|
||||||
|
*.cgo2.c
|
||||||
|
_cgo_defun.c
|
||||||
|
_cgo_gotypes.go
|
||||||
|
_cgo_export.*
|
||||||
|
|
||||||
|
_testmain.go
|
||||||
|
|
||||||
|
*.exe
|
||||||
|
*.test
|
||||||
|
*.prof
|
8
.idea/.gitignore
vendored
Normal file
8
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/orchestrator-swagger-go-client.iml" filepath="$PROJECT_DIR$/.idea/orchestrator-swagger-go-client.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
9
.idea/orchestrator-swagger-go-client.iml
Normal file
9
.idea/orchestrator-swagger-go-client.iml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="Go" enabled="true" />
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
25
.idea/runConfigurations/Generate_Code.xml
Normal file
25
.idea/runConfigurations/Generate_Code.xml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="Generate Code" type="SwaggerCodegen" editBeforeRun="true" show_console_on_std_err="false" show_console_on_std_out="false">
|
||||||
|
<option name="allowRunningInParallel" value="false" />
|
||||||
|
<option name="customTemplatesPath" value="" />
|
||||||
|
<option name="envs">
|
||||||
|
<map />
|
||||||
|
</option>
|
||||||
|
<option name="generateToPath" value="C:\Users\SoXX\GolandProjects\anthrove\orchestrator-swagger-go-client" />
|
||||||
|
<option name="generationParameters">
|
||||||
|
<list />
|
||||||
|
</option>
|
||||||
|
<option name="generatorType" value="OPENAPI_GENERATOR_V6" />
|
||||||
|
<option name="jdkPath" value="C:\Users\SoXX\AppData\Local\Programs\GoLand\jbr\bin\java.exe" />
|
||||||
|
<option name="language" value="go" />
|
||||||
|
<option name="passParentEnvs" value="true" />
|
||||||
|
<option name="programParameters" />
|
||||||
|
<option name="projectPathOnTarget" />
|
||||||
|
<option name="selectedOptions">
|
||||||
|
<list />
|
||||||
|
</option>
|
||||||
|
<option name="specificationPath" value="C:\Users\SoXX\GolandProjects\anthrove\orchestrator\docs\swagger.yaml" />
|
||||||
|
<option name="workingDirectory" value="C:\Users\SoXX\GolandProjects\anthrove\orchestrator\docs" />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
</component>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
23
.openapi-generator-ignore
Normal file
23
.openapi-generator-ignore
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# OpenAPI Generator Ignore
|
||||||
|
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||||
|
|
||||||
|
# Use this file to prevent files from being overwritten by the generator.
|
||||||
|
# The patterns follow closely to .gitignore or .dockerignore.
|
||||||
|
|
||||||
|
# As an example, the C# client generator defines ApiClient.cs.
|
||||||
|
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||||
|
#ApiClient.cs
|
||||||
|
|
||||||
|
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||||
|
#foo/*/qux
|
||||||
|
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||||
|
#foo/**/qux
|
||||||
|
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can also negate patterns with an exclamation (!).
|
||||||
|
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||||
|
#docs/*.md
|
||||||
|
# Then explicitly reverse the ignore rule for a single file:
|
||||||
|
#!docs/README.md
|
24
.openapi-generator/FILES
Normal file
24
.openapi-generator/FILES
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
.gitignore
|
||||||
|
.openapi-generator-ignore
|
||||||
|
.travis.yml
|
||||||
|
README.md
|
||||||
|
api/openapi.yaml
|
||||||
|
api_plug.go
|
||||||
|
api_user.go
|
||||||
|
client.go
|
||||||
|
configuration.go
|
||||||
|
docs/ModelsOrchestratorTask.md
|
||||||
|
docs/ModelsPlugTask.md
|
||||||
|
docs/ModelsPlugTaskState.md
|
||||||
|
docs/PlugAPI.md
|
||||||
|
docs/UserAPI.md
|
||||||
|
git_push.sh
|
||||||
|
go.mod
|
||||||
|
go.sum
|
||||||
|
model_models_orchestrator_task.go
|
||||||
|
model_models_plug_task.go
|
||||||
|
model_models_plug_task_state.go
|
||||||
|
response.go
|
||||||
|
test/api_plug_test.go
|
||||||
|
test/api_user_test.go
|
||||||
|
utils.go
|
1
.openapi-generator/VERSION
Normal file
1
.openapi-generator/VERSION
Normal file
@ -0,0 +1 @@
|
|||||||
|
7.2.0
|
8
.travis.yml
Normal file
8
.travis.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
language: go
|
||||||
|
|
||||||
|
install:
|
||||||
|
- go get -d -v .
|
||||||
|
|
||||||
|
script:
|
||||||
|
- go build -v ./
|
||||||
|
|
118
README.md
Normal file
118
README.md
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
# Go API client for openapi
|
||||||
|
|
||||||
|
This service handles the communication between the manager and the plugs
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client.
|
||||||
|
|
||||||
|
- API version: 0.1-PREVIEW
|
||||||
|
- Package version: 1.0.0
|
||||||
|
- Build package: org.openapitools.codegen.languages.GoClientCodegen
|
||||||
|
For more information, please visit [http://anthrove.art/support](http://anthrove.art/support)
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Install the following dependencies:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
go get github.com/stretchr/testify/assert
|
||||||
|
go get golang.org/x/net/context
|
||||||
|
```
|
||||||
|
|
||||||
|
Put the package under your project folder and add the following in import:
|
||||||
|
|
||||||
|
```go
|
||||||
|
import openapi "git.dragse.it/anthrove/orchestrator-swagger-go-client"
|
||||||
|
```
|
||||||
|
|
||||||
|
To use a proxy, set the environment variable `HTTP_PROXY`:
|
||||||
|
|
||||||
|
```go
|
||||||
|
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuration of Server URL
|
||||||
|
|
||||||
|
Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification.
|
||||||
|
|
||||||
|
### Select Server Configuration
|
||||||
|
|
||||||
|
For using other server than the one defined on index 0 set context value `openapi.ContextServerIndex` of type `int`.
|
||||||
|
|
||||||
|
```go
|
||||||
|
ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Templated Server URL
|
||||||
|
|
||||||
|
Templated server URL is formatted using default variables from configuration or from context value `openapi.ContextServerVariables` of type `map[string]string`.
|
||||||
|
|
||||||
|
```go
|
||||||
|
ctx := context.WithValue(context.Background(), openapi.ContextServerVariables, map[string]string{
|
||||||
|
"basePath": "v2",
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
Note, enum values are always validated and all unused variables are silently ignored.
|
||||||
|
|
||||||
|
### URLs Configuration per Operation
|
||||||
|
|
||||||
|
Each operation can use different server URL defined using `OperationServers` map in the `Configuration`.
|
||||||
|
An operation is uniquely identified by `"{classname}Service.{nickname}"` string.
|
||||||
|
Similar rules for overriding default operation server index and variables applies by using `openapi.ContextOperationServerIndices` and `openapi.ContextOperationServerVariables` context maps.
|
||||||
|
|
||||||
|
```go
|
||||||
|
ctx := context.WithValue(context.Background(), openapi.ContextOperationServerIndices, map[string]int{
|
||||||
|
"{classname}Service.{nickname}": 2,
|
||||||
|
})
|
||||||
|
ctx = context.WithValue(context.Background(), openapi.ContextOperationServerVariables, map[string]map[string]string{
|
||||||
|
"{classname}Service.{nickname}": {
|
||||||
|
"port": "8443",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
## Documentation for API Endpoints
|
||||||
|
|
||||||
|
All URIs are relative to */api/v1*
|
||||||
|
|
||||||
|
Class | Method | HTTP request | Description
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
*PlugAPI* | [**PlugPlugTypePut**](docs/PlugAPI.md#plugplugtypeput) | **Put** /plug/{plug_type} | Initiates a scraping operation for a user with a specific plug type
|
||||||
|
*PlugAPI* | [**PlugPlugTypeTaskIdDelete**](docs/PlugAPI.md#plugplugtypetaskiddelete) | **Delete** /plug/{plug_type}/{task_id} | Stops a scraping operation for a user with a specific plug type
|
||||||
|
*PlugAPI* | [**PlugPlugTypeTaskIdGet**](docs/PlugAPI.md#plugplugtypetaskidget) | **Get** /plug/{plug_type}/{task_id} | Retrieves the status of a specific task type
|
||||||
|
*UserAPI* | [**UserUserIdPut**](docs/UserAPI.md#useruseridput) | **Put** /user/{user_id} | Initiates a scraping operation for the entire user
|
||||||
|
|
||||||
|
|
||||||
|
## Documentation For Models
|
||||||
|
|
||||||
|
- [ModelsOrchestratorTask](docs/ModelsOrchestratorTask.md)
|
||||||
|
- [ModelsPlugTask](docs/ModelsPlugTask.md)
|
||||||
|
- [ModelsPlugTaskState](docs/ModelsPlugTaskState.md)
|
||||||
|
|
||||||
|
|
||||||
|
## Documentation For Authorization
|
||||||
|
|
||||||
|
Endpoints do not require authorization.
|
||||||
|
|
||||||
|
|
||||||
|
## Documentation for Utility Methods
|
||||||
|
|
||||||
|
Due to the fact that model structure members are all pointers, this package contains
|
||||||
|
a number of utility functions to easily obtain pointers to values of basic types.
|
||||||
|
Each of these functions takes a value of the given basic type and returns a pointer to it:
|
||||||
|
|
||||||
|
* `PtrBool`
|
||||||
|
* `PtrInt`
|
||||||
|
* `PtrInt32`
|
||||||
|
* `PtrInt64`
|
||||||
|
* `PtrFloat`
|
||||||
|
* `PtrFloat32`
|
||||||
|
* `PtrFloat64`
|
||||||
|
* `PtrString`
|
||||||
|
* `PtrTime`
|
||||||
|
|
||||||
|
## Author
|
||||||
|
|
||||||
|
support@anthrove.art
|
||||||
|
|
166
api/openapi.yaml
Normal file
166
api/openapi.yaml
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
openapi: 3.0.1
|
||||||
|
info:
|
||||||
|
contact:
|
||||||
|
email: support@anthrove.art
|
||||||
|
name: API Support
|
||||||
|
url: http://anthrove.art/support
|
||||||
|
description: This service handles the communication between the manager and the
|
||||||
|
plugs
|
||||||
|
title: Anthrove Orchestrator API
|
||||||
|
version: 0.1-PREVIEW
|
||||||
|
servers:
|
||||||
|
- url: /api/v1
|
||||||
|
paths:
|
||||||
|
/plug/{plug_type}:
|
||||||
|
put:
|
||||||
|
description: Initiates a scraping operation for a user with a specific plug
|
||||||
|
type returns the created task IDs.
|
||||||
|
parameters:
|
||||||
|
- description: supported plug type
|
||||||
|
in: path
|
||||||
|
name: plug_type
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/models.OrchestratorTask'
|
||||||
|
description: aa
|
||||||
|
required: true
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
content: {}
|
||||||
|
description: OK
|
||||||
|
"404":
|
||||||
|
content: {}
|
||||||
|
description: Not Found
|
||||||
|
"500":
|
||||||
|
content: {}
|
||||||
|
description: Internal Server Error
|
||||||
|
summary: Initiates a scraping operation for a user with a specific plug type
|
||||||
|
tags:
|
||||||
|
- Plug
|
||||||
|
x-codegen-request-body-name: request
|
||||||
|
/plug/{plug_type}/{task_id}:
|
||||||
|
delete:
|
||||||
|
description: Stops a scraping operation for a user with a specific plug type
|
||||||
|
returns the created task IDs.
|
||||||
|
parameters:
|
||||||
|
- description: supported plug type
|
||||||
|
in: path
|
||||||
|
name: plug_type
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
- description: id of task
|
||||||
|
in: path
|
||||||
|
name: task_id
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
content: {}
|
||||||
|
description: OK
|
||||||
|
"404":
|
||||||
|
content: {}
|
||||||
|
description: Not Found
|
||||||
|
"500":
|
||||||
|
content: {}
|
||||||
|
description: Internal Server Error
|
||||||
|
summary: Stops a scraping operation for a user with a specific plug type
|
||||||
|
tags:
|
||||||
|
- Plug
|
||||||
|
get:
|
||||||
|
description: Retrieves the status of a specific task and returns it.
|
||||||
|
parameters:
|
||||||
|
- description: supported plug type
|
||||||
|
in: path
|
||||||
|
name: plug_type
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
- description: id of task
|
||||||
|
in: path
|
||||||
|
name: task_id
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
content: {}
|
||||||
|
description: OK
|
||||||
|
"404":
|
||||||
|
content: {}
|
||||||
|
description: Not Found
|
||||||
|
"500":
|
||||||
|
content: {}
|
||||||
|
description: Internal Server Error
|
||||||
|
summary: Retrieves the status of a specific task type
|
||||||
|
tags:
|
||||||
|
- Plug
|
||||||
|
/user/{user_id}:
|
||||||
|
put:
|
||||||
|
description: Initiates a scraping operation for the entire user and returns
|
||||||
|
the created task IDs.
|
||||||
|
parameters:
|
||||||
|
- description: Anthrove UserID
|
||||||
|
in: path
|
||||||
|
name: user_id
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
content: {}
|
||||||
|
description: OK
|
||||||
|
"404":
|
||||||
|
content: {}
|
||||||
|
description: Not Found
|
||||||
|
"500":
|
||||||
|
content: {}
|
||||||
|
description: Internal Server Error
|
||||||
|
summary: Initiates a scraping operation for the entire user
|
||||||
|
tags:
|
||||||
|
- User
|
||||||
|
components:
|
||||||
|
schemas:
|
||||||
|
models.OrchestratorTask:
|
||||||
|
properties:
|
||||||
|
anthrove_user_id:
|
||||||
|
type: string
|
||||||
|
deep_scrape:
|
||||||
|
type: boolean
|
||||||
|
plug_task:
|
||||||
|
$ref: '#/components/schemas/models.PlugTask'
|
||||||
|
required:
|
||||||
|
- anthrove_user_id
|
||||||
|
- deep_scrape
|
||||||
|
- plug_task
|
||||||
|
type: object
|
||||||
|
models.PlugTask:
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
task_state:
|
||||||
|
$ref: '#/components/schemas/models.PlugTaskState'
|
||||||
|
user_id:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- user_id
|
||||||
|
type: object
|
||||||
|
models.PlugTaskState:
|
||||||
|
enum:
|
||||||
|
- UNKNOWN
|
||||||
|
- STARTED
|
||||||
|
- RUNNING
|
||||||
|
- STOPPED
|
||||||
|
type: string
|
||||||
|
x-enum-varnames:
|
||||||
|
- PlugTaskStateUnknown
|
||||||
|
- PlugTaskStateStarted
|
||||||
|
- PlugTaskStateRunning
|
||||||
|
- PlugTaskStateStopped
|
||||||
|
x-original-swagger-version: "2.0"
|
320
api_plug.go
Normal file
320
api_plug.go
Normal file
@ -0,0 +1,320 @@
|
|||||||
|
/*
|
||||||
|
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
|
||||||
|
}
|
116
api_user.go
Normal file
116
api_user.go
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserAPIService UserAPI service
|
||||||
|
type UserAPIService service
|
||||||
|
|
||||||
|
type ApiUserUserIdPutRequest struct {
|
||||||
|
ctx context.Context
|
||||||
|
ApiService *UserAPIService
|
||||||
|
userId string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r ApiUserUserIdPutRequest) Execute() (*http.Response, error) {
|
||||||
|
return r.ApiService.UserUserIdPutExecute(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
UserUserIdPut Initiates a scraping operation for the entire user
|
||||||
|
|
||||||
|
Initiates a scraping operation for the entire user and returns the created task IDs.
|
||||||
|
|
||||||
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||||
|
@param userId Anthrove UserID
|
||||||
|
@return ApiUserUserIdPutRequest
|
||||||
|
*/
|
||||||
|
func (a *UserAPIService) UserUserIdPut(ctx context.Context, userId string) ApiUserUserIdPutRequest {
|
||||||
|
return ApiUserUserIdPutRequest{
|
||||||
|
ApiService: a,
|
||||||
|
ctx: ctx,
|
||||||
|
userId: userId,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute executes the request
|
||||||
|
func (a *UserAPIService) UserUserIdPutExecute(r ApiUserUserIdPutRequest) (*http.Response, error) {
|
||||||
|
var (
|
||||||
|
localVarHTTPMethod = http.MethodPut
|
||||||
|
localVarPostBody interface{}
|
||||||
|
formFiles []formFile
|
||||||
|
)
|
||||||
|
|
||||||
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "UserAPIService.UserUserIdPut")
|
||||||
|
if err != nil {
|
||||||
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
||||||
|
}
|
||||||
|
|
||||||
|
localVarPath := localBasePath + "/user/{user_id}"
|
||||||
|
localVarPath = strings.Replace(localVarPath, "{"+"user_id"+"}", url.PathEscape(parameterValueToString(r.userId, "userId")), -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
|
||||||
|
}
|
663
client.go
Normal file
663
client.go
Normal file
@ -0,0 +1,663 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
"encoding/json"
|
||||||
|
"encoding/xml"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"log"
|
||||||
|
"mime/multipart"
|
||||||
|
"net/http"
|
||||||
|
"net/http/httputil"
|
||||||
|
"net/url"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"reflect"
|
||||||
|
"regexp"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
"unicode/utf8"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
JsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?json)`)
|
||||||
|
XmlCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?xml)`)
|
||||||
|
queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`)
|
||||||
|
queryDescape = strings.NewReplacer("%5B", "[", "%5D", "]")
|
||||||
|
)
|
||||||
|
|
||||||
|
// APIClient manages communication with the Anthrove Orchestrator API API v0.1-PREVIEW
|
||||||
|
// In most cases there should be only one, shared, APIClient.
|
||||||
|
type APIClient struct {
|
||||||
|
cfg *Configuration
|
||||||
|
common service // Reuse a single struct instead of allocating one for each service on the heap.
|
||||||
|
|
||||||
|
// API Services
|
||||||
|
|
||||||
|
PlugAPI *PlugAPIService
|
||||||
|
|
||||||
|
UserAPI *UserAPIService
|
||||||
|
}
|
||||||
|
|
||||||
|
type service struct {
|
||||||
|
client *APIClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAPIClient creates a new API client. Requires a userAgent string describing your application.
|
||||||
|
// optionally a custom http.Client to allow for advanced features such as caching.
|
||||||
|
func NewAPIClient(cfg *Configuration) *APIClient {
|
||||||
|
if cfg.HTTPClient == nil {
|
||||||
|
cfg.HTTPClient = http.DefaultClient
|
||||||
|
}
|
||||||
|
|
||||||
|
c := &APIClient{}
|
||||||
|
c.cfg = cfg
|
||||||
|
c.common.client = c
|
||||||
|
|
||||||
|
// API Services
|
||||||
|
c.PlugAPI = (*PlugAPIService)(&c.common)
|
||||||
|
c.UserAPI = (*UserAPIService)(&c.common)
|
||||||
|
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
func atoi(in string) (int, error) {
|
||||||
|
return strconv.Atoi(in)
|
||||||
|
}
|
||||||
|
|
||||||
|
// selectHeaderContentType select a content type from the available list.
|
||||||
|
func selectHeaderContentType(contentTypes []string) string {
|
||||||
|
if len(contentTypes) == 0 {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
if contains(contentTypes, "application/json") {
|
||||||
|
return "application/json"
|
||||||
|
}
|
||||||
|
return contentTypes[0] // use the first content type specified in 'consumes'
|
||||||
|
}
|
||||||
|
|
||||||
|
// selectHeaderAccept join all accept types and return
|
||||||
|
func selectHeaderAccept(accepts []string) string {
|
||||||
|
if len(accepts) == 0 {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if contains(accepts, "application/json") {
|
||||||
|
return "application/json"
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.Join(accepts, ",")
|
||||||
|
}
|
||||||
|
|
||||||
|
// contains is a case insensitive match, finding needle in a haystack
|
||||||
|
func contains(haystack []string, needle string) bool {
|
||||||
|
for _, a := range haystack {
|
||||||
|
if strings.EqualFold(a, needle) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify optional parameters are of the correct type.
|
||||||
|
func typeCheckParameter(obj interface{}, expected string, name string) error {
|
||||||
|
// Make sure there is an object.
|
||||||
|
if obj == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the type is as expected.
|
||||||
|
if reflect.TypeOf(obj).String() != expected {
|
||||||
|
return fmt.Errorf("expected %s to be of type %s but received %s", name, expected, reflect.TypeOf(obj).String())
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func parameterValueToString(obj interface{}, key string) string {
|
||||||
|
if reflect.TypeOf(obj).Kind() != reflect.Ptr {
|
||||||
|
return fmt.Sprintf("%v", obj)
|
||||||
|
}
|
||||||
|
var param, ok = obj.(MappedNullable)
|
||||||
|
if !ok {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
dataMap, err := param.ToMap()
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%v", dataMap[key])
|
||||||
|
}
|
||||||
|
|
||||||
|
// parameterAddToHeaderOrQuery adds the provided object to the request header or url query
|
||||||
|
// supporting deep object syntax
|
||||||
|
func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix string, obj interface{}, collectionType string) {
|
||||||
|
var v = reflect.ValueOf(obj)
|
||||||
|
var value = ""
|
||||||
|
if v == reflect.ValueOf(nil) {
|
||||||
|
value = "null"
|
||||||
|
} else {
|
||||||
|
switch v.Kind() {
|
||||||
|
case reflect.Invalid:
|
||||||
|
value = "invalid"
|
||||||
|
|
||||||
|
case reflect.Struct:
|
||||||
|
if t, ok := obj.(MappedNullable); ok {
|
||||||
|
dataMap, err := t.ToMap()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, dataMap, collectionType)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if t, ok := obj.(time.Time); ok {
|
||||||
|
parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, t.Format(time.RFC3339), collectionType)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
value = v.Type().String() + " value"
|
||||||
|
case reflect.Slice:
|
||||||
|
var indValue = reflect.ValueOf(obj)
|
||||||
|
if indValue == reflect.ValueOf(nil) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var lenIndValue = indValue.Len()
|
||||||
|
for i := 0; i < lenIndValue; i++ {
|
||||||
|
var arrayValue = indValue.Index(i)
|
||||||
|
parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, arrayValue.Interface(), collectionType)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
case reflect.Map:
|
||||||
|
var indValue = reflect.ValueOf(obj)
|
||||||
|
if indValue == reflect.ValueOf(nil) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
iter := indValue.MapRange()
|
||||||
|
for iter.Next() {
|
||||||
|
k, v := iter.Key(), iter.Value()
|
||||||
|
parameterAddToHeaderOrQuery(headerOrQueryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface(), collectionType)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
case reflect.Interface:
|
||||||
|
fallthrough
|
||||||
|
case reflect.Ptr:
|
||||||
|
parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, v.Elem().Interface(), collectionType)
|
||||||
|
return
|
||||||
|
|
||||||
|
case reflect.Int, reflect.Int8, reflect.Int16,
|
||||||
|
reflect.Int32, reflect.Int64:
|
||||||
|
value = strconv.FormatInt(v.Int(), 10)
|
||||||
|
case reflect.Uint, reflect.Uint8, reflect.Uint16,
|
||||||
|
reflect.Uint32, reflect.Uint64, reflect.Uintptr:
|
||||||
|
value = strconv.FormatUint(v.Uint(), 10)
|
||||||
|
case reflect.Float32, reflect.Float64:
|
||||||
|
value = strconv.FormatFloat(v.Float(), 'g', -1, 32)
|
||||||
|
case reflect.Bool:
|
||||||
|
value = strconv.FormatBool(v.Bool())
|
||||||
|
case reflect.String:
|
||||||
|
value = v.String()
|
||||||
|
default:
|
||||||
|
value = v.Type().String() + " value"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch valuesMap := headerOrQueryParams.(type) {
|
||||||
|
case url.Values:
|
||||||
|
if collectionType == "csv" && valuesMap.Get(keyPrefix) != "" {
|
||||||
|
valuesMap.Set(keyPrefix, valuesMap.Get(keyPrefix)+","+value)
|
||||||
|
} else {
|
||||||
|
valuesMap.Add(keyPrefix, value)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case map[string]string:
|
||||||
|
valuesMap[keyPrefix] = value
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// helper for converting interface{} parameters to json strings
|
||||||
|
func parameterToJson(obj interface{}) (string, error) {
|
||||||
|
jsonBuf, err := json.Marshal(obj)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return string(jsonBuf), err
|
||||||
|
}
|
||||||
|
|
||||||
|
// callAPI do the request.
|
||||||
|
func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) {
|
||||||
|
if c.cfg.Debug {
|
||||||
|
dump, err := httputil.DumpRequestOut(request, true)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
log.Printf("\n%s\n", string(dump))
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := c.cfg.HTTPClient.Do(request)
|
||||||
|
if err != nil {
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.cfg.Debug {
|
||||||
|
dump, err := httputil.DumpResponse(resp, true)
|
||||||
|
if err != nil {
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
log.Printf("\n%s\n", string(dump))
|
||||||
|
}
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow modification of underlying config for alternate implementations and testing
|
||||||
|
// Caution: modifying the configuration while live can cause data races and potentially unwanted behavior
|
||||||
|
func (c *APIClient) GetConfig() *Configuration {
|
||||||
|
return c.cfg
|
||||||
|
}
|
||||||
|
|
||||||
|
type formFile struct {
|
||||||
|
fileBytes []byte
|
||||||
|
fileName string
|
||||||
|
formFileName string
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepareRequest build the request
|
||||||
|
func (c *APIClient) prepareRequest(
|
||||||
|
ctx context.Context,
|
||||||
|
path string, method string,
|
||||||
|
postBody interface{},
|
||||||
|
headerParams map[string]string,
|
||||||
|
queryParams url.Values,
|
||||||
|
formParams url.Values,
|
||||||
|
formFiles []formFile) (localVarRequest *http.Request, err error) {
|
||||||
|
|
||||||
|
var body *bytes.Buffer
|
||||||
|
|
||||||
|
// Detect postBody type and post.
|
||||||
|
if postBody != nil {
|
||||||
|
contentType := headerParams["Content-Type"]
|
||||||
|
if contentType == "" {
|
||||||
|
contentType = detectContentType(postBody)
|
||||||
|
headerParams["Content-Type"] = contentType
|
||||||
|
}
|
||||||
|
|
||||||
|
body, err = setBody(postBody, contentType)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add form parameters and file if available.
|
||||||
|
if strings.HasPrefix(headerParams["Content-Type"], "multipart/form-data") && len(formParams) > 0 || (len(formFiles) > 0) {
|
||||||
|
if body != nil {
|
||||||
|
return nil, errors.New("Cannot specify postBody and multipart form at the same time.")
|
||||||
|
}
|
||||||
|
body = &bytes.Buffer{}
|
||||||
|
w := multipart.NewWriter(body)
|
||||||
|
|
||||||
|
for k, v := range formParams {
|
||||||
|
for _, iv := range v {
|
||||||
|
if strings.HasPrefix(k, "@") { // file
|
||||||
|
err = addFile(w, k[1:], iv)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else { // form value
|
||||||
|
w.WriteField(k, iv)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, formFile := range formFiles {
|
||||||
|
if len(formFile.fileBytes) > 0 && formFile.fileName != "" {
|
||||||
|
w.Boundary()
|
||||||
|
part, err := w.CreateFormFile(formFile.formFileName, filepath.Base(formFile.fileName))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_, err = part.Write(formFile.fileBytes)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the Boundary in the Content-Type
|
||||||
|
headerParams["Content-Type"] = w.FormDataContentType()
|
||||||
|
|
||||||
|
// Set Content-Length
|
||||||
|
headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len())
|
||||||
|
w.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 {
|
||||||
|
if body != nil {
|
||||||
|
return nil, errors.New("Cannot specify postBody and x-www-form-urlencoded form at the same time.")
|
||||||
|
}
|
||||||
|
body = &bytes.Buffer{}
|
||||||
|
body.WriteString(formParams.Encode())
|
||||||
|
// Set Content-Length
|
||||||
|
headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup path and query parameters
|
||||||
|
url, err := url.Parse(path)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Override request host, if applicable
|
||||||
|
if c.cfg.Host != "" {
|
||||||
|
url.Host = c.cfg.Host
|
||||||
|
}
|
||||||
|
|
||||||
|
// Override request scheme, if applicable
|
||||||
|
if c.cfg.Scheme != "" {
|
||||||
|
url.Scheme = c.cfg.Scheme
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adding Query Param
|
||||||
|
query := url.Query()
|
||||||
|
for k, v := range queryParams {
|
||||||
|
for _, iv := range v {
|
||||||
|
query.Add(k, iv)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Encode the parameters.
|
||||||
|
url.RawQuery = queryParamSplit.ReplaceAllStringFunc(query.Encode(), func(s string) string {
|
||||||
|
pieces := strings.Split(s, "=")
|
||||||
|
pieces[0] = queryDescape.Replace(pieces[0])
|
||||||
|
return strings.Join(pieces, "=")
|
||||||
|
})
|
||||||
|
|
||||||
|
// Generate a new request
|
||||||
|
if body != nil {
|
||||||
|
localVarRequest, err = http.NewRequest(method, url.String(), body)
|
||||||
|
} else {
|
||||||
|
localVarRequest, err = http.NewRequest(method, url.String(), nil)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// add header parameters, if any
|
||||||
|
if len(headerParams) > 0 {
|
||||||
|
headers := http.Header{}
|
||||||
|
for h, v := range headerParams {
|
||||||
|
headers[h] = []string{v}
|
||||||
|
}
|
||||||
|
localVarRequest.Header = headers
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the user agent to the request.
|
||||||
|
localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent)
|
||||||
|
|
||||||
|
if ctx != nil {
|
||||||
|
// add context to the request
|
||||||
|
localVarRequest = localVarRequest.WithContext(ctx)
|
||||||
|
|
||||||
|
// Walk through any authentication.
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for header, value := range c.cfg.DefaultHeader {
|
||||||
|
localVarRequest.Header.Add(header, value)
|
||||||
|
}
|
||||||
|
return localVarRequest, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) {
|
||||||
|
if len(b) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if s, ok := v.(*string); ok {
|
||||||
|
*s = string(b)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if f, ok := v.(*os.File); ok {
|
||||||
|
f, err = os.CreateTemp("", "HttpClientFile")
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, err = f.Write(b)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, err = f.Seek(0, io.SeekStart)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if f, ok := v.(**os.File); ok {
|
||||||
|
*f, err = os.CreateTemp("", "HttpClientFile")
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, err = (*f).Write(b)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, err = (*f).Seek(0, io.SeekStart)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if XmlCheck.MatchString(contentType) {
|
||||||
|
if err = xml.Unmarshal(b, v); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if JsonCheck.MatchString(contentType) {
|
||||||
|
if actualObj, ok := v.(interface{ GetActualInstance() interface{} }); ok { // oneOf, anyOf schemas
|
||||||
|
if unmarshalObj, ok := actualObj.(interface{ UnmarshalJSON([]byte) error }); ok { // make sure it has UnmarshalJSON defined
|
||||||
|
if err = unmarshalObj.UnmarshalJSON(b); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return errors.New("Unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined")
|
||||||
|
}
|
||||||
|
} else if err = json.Unmarshal(b, v); err != nil { // simple model
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return errors.New("undefined response type")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add a file to the multipart request
|
||||||
|
func addFile(w *multipart.Writer, fieldName, path string) error {
|
||||||
|
file, err := os.Open(filepath.Clean(path))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = file.Close()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
part, err := w.CreateFormFile(fieldName, filepath.Base(path))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = io.Copy(part, file)
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent trying to import "fmt"
|
||||||
|
func reportError(format string, a ...interface{}) error {
|
||||||
|
return fmt.Errorf(format, a...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// A wrapper for strict JSON decoding
|
||||||
|
func newStrictDecoder(data []byte) *json.Decoder {
|
||||||
|
dec := json.NewDecoder(bytes.NewBuffer(data))
|
||||||
|
dec.DisallowUnknownFields()
|
||||||
|
return dec
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set request body from an interface{}
|
||||||
|
func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) {
|
||||||
|
if bodyBuf == nil {
|
||||||
|
bodyBuf = &bytes.Buffer{}
|
||||||
|
}
|
||||||
|
|
||||||
|
if reader, ok := body.(io.Reader); ok {
|
||||||
|
_, err = bodyBuf.ReadFrom(reader)
|
||||||
|
} else if fp, ok := body.(*os.File); ok {
|
||||||
|
_, err = bodyBuf.ReadFrom(fp)
|
||||||
|
} else if b, ok := body.([]byte); ok {
|
||||||
|
_, err = bodyBuf.Write(b)
|
||||||
|
} else if s, ok := body.(string); ok {
|
||||||
|
_, err = bodyBuf.WriteString(s)
|
||||||
|
} else if s, ok := body.(*string); ok {
|
||||||
|
_, err = bodyBuf.WriteString(*s)
|
||||||
|
} else if JsonCheck.MatchString(contentType) {
|
||||||
|
err = json.NewEncoder(bodyBuf).Encode(body)
|
||||||
|
} else if XmlCheck.MatchString(contentType) {
|
||||||
|
var bs []byte
|
||||||
|
bs, err = xml.Marshal(body)
|
||||||
|
if err == nil {
|
||||||
|
bodyBuf.Write(bs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if bodyBuf.Len() == 0 {
|
||||||
|
err = fmt.Errorf("invalid body type %s\n", contentType)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return bodyBuf, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// detectContentType method is used to figure out `Request.Body` content type for request header
|
||||||
|
func detectContentType(body interface{}) string {
|
||||||
|
contentType := "text/plain; charset=utf-8"
|
||||||
|
kind := reflect.TypeOf(body).Kind()
|
||||||
|
|
||||||
|
switch kind {
|
||||||
|
case reflect.Struct, reflect.Map, reflect.Ptr:
|
||||||
|
contentType = "application/json; charset=utf-8"
|
||||||
|
case reflect.String:
|
||||||
|
contentType = "text/plain; charset=utf-8"
|
||||||
|
default:
|
||||||
|
if b, ok := body.([]byte); ok {
|
||||||
|
contentType = http.DetectContentType(b)
|
||||||
|
} else if kind == reflect.Slice {
|
||||||
|
contentType = "application/json; charset=utf-8"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return contentType
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go
|
||||||
|
type cacheControl map[string]string
|
||||||
|
|
||||||
|
func parseCacheControl(headers http.Header) cacheControl {
|
||||||
|
cc := cacheControl{}
|
||||||
|
ccHeader := headers.Get("Cache-Control")
|
||||||
|
for _, part := range strings.Split(ccHeader, ",") {
|
||||||
|
part = strings.Trim(part, " ")
|
||||||
|
if part == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if strings.ContainsRune(part, '=') {
|
||||||
|
keyval := strings.Split(part, "=")
|
||||||
|
cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",")
|
||||||
|
} else {
|
||||||
|
cc[part] = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cc
|
||||||
|
}
|
||||||
|
|
||||||
|
// CacheExpires helper function to determine remaining time before repeating a request.
|
||||||
|
func CacheExpires(r *http.Response) time.Time {
|
||||||
|
// Figure out when the cache expires.
|
||||||
|
var expires time.Time
|
||||||
|
now, err := time.Parse(time.RFC1123, r.Header.Get("date"))
|
||||||
|
if err != nil {
|
||||||
|
return time.Now()
|
||||||
|
}
|
||||||
|
respCacheControl := parseCacheControl(r.Header)
|
||||||
|
|
||||||
|
if maxAge, ok := respCacheControl["max-age"]; ok {
|
||||||
|
lifetime, err := time.ParseDuration(maxAge + "s")
|
||||||
|
if err != nil {
|
||||||
|
expires = now
|
||||||
|
} else {
|
||||||
|
expires = now.Add(lifetime)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
expiresHeader := r.Header.Get("Expires")
|
||||||
|
if expiresHeader != "" {
|
||||||
|
expires, err = time.Parse(time.RFC1123, expiresHeader)
|
||||||
|
if err != nil {
|
||||||
|
expires = now
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return expires
|
||||||
|
}
|
||||||
|
|
||||||
|
func strlen(s string) int {
|
||||||
|
return utf8.RuneCountInString(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GenericOpenAPIError Provides access to the body, error and model on returned errors.
|
||||||
|
type GenericOpenAPIError struct {
|
||||||
|
body []byte
|
||||||
|
error string
|
||||||
|
model interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error returns non-empty string if there was an error.
|
||||||
|
func (e GenericOpenAPIError) Error() string {
|
||||||
|
return e.error
|
||||||
|
}
|
||||||
|
|
||||||
|
// Body returns the raw bytes of the response
|
||||||
|
func (e GenericOpenAPIError) Body() []byte {
|
||||||
|
return e.body
|
||||||
|
}
|
||||||
|
|
||||||
|
// Model returns the unpacked model of the error
|
||||||
|
func (e GenericOpenAPIError) Model() interface{} {
|
||||||
|
return e.model
|
||||||
|
}
|
||||||
|
|
||||||
|
// format error message using title and detail when model implements rfc7807
|
||||||
|
func formatErrorMessage(status string, v interface{}) string {
|
||||||
|
str := ""
|
||||||
|
metaValue := reflect.ValueOf(v).Elem()
|
||||||
|
|
||||||
|
if metaValue.Kind() == reflect.Struct {
|
||||||
|
field := metaValue.FieldByName("Title")
|
||||||
|
if field != (reflect.Value{}) {
|
||||||
|
str = fmt.Sprintf("%s", field.Interface())
|
||||||
|
}
|
||||||
|
|
||||||
|
field = metaValue.FieldByName("Detail")
|
||||||
|
if field != (reflect.Value{}) {
|
||||||
|
str = fmt.Sprintf("%s (%s)", str, field.Interface())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.TrimSpace(fmt.Sprintf("%s %s", status, str))
|
||||||
|
}
|
215
configuration.go
Normal file
215
configuration.go
Normal file
@ -0,0 +1,215 @@
|
|||||||
|
/*
|
||||||
|
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 (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// contextKeys are used to identify the type of value in the context.
|
||||||
|
// Since these are string, it is possible to get a short description of the
|
||||||
|
// context key for logging and debugging using key.String().
|
||||||
|
|
||||||
|
type contextKey string
|
||||||
|
|
||||||
|
func (c contextKey) String() string {
|
||||||
|
return "auth " + string(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// ContextServerIndex uses a server configuration from the index.
|
||||||
|
ContextServerIndex = contextKey("serverIndex")
|
||||||
|
|
||||||
|
// ContextOperationServerIndices uses a server configuration from the index mapping.
|
||||||
|
ContextOperationServerIndices = contextKey("serverOperationIndices")
|
||||||
|
|
||||||
|
// ContextServerVariables overrides a server configuration variables.
|
||||||
|
ContextServerVariables = contextKey("serverVariables")
|
||||||
|
|
||||||
|
// ContextOperationServerVariables overrides a server configuration variables using operation specific values.
|
||||||
|
ContextOperationServerVariables = contextKey("serverOperationVariables")
|
||||||
|
)
|
||||||
|
|
||||||
|
// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
|
||||||
|
type BasicAuth struct {
|
||||||
|
UserName string `json:"userName,omitempty"`
|
||||||
|
Password string `json:"password,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// APIKey provides API key based authentication to a request passed via context using ContextAPIKey
|
||||||
|
type APIKey struct {
|
||||||
|
Key string
|
||||||
|
Prefix string
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServerVariable stores the information about a server variable
|
||||||
|
type ServerVariable struct {
|
||||||
|
Description string
|
||||||
|
DefaultValue string
|
||||||
|
EnumValues []string
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServerConfiguration stores the information about a server
|
||||||
|
type ServerConfiguration struct {
|
||||||
|
URL string
|
||||||
|
Description string
|
||||||
|
Variables map[string]ServerVariable
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServerConfigurations stores multiple ServerConfiguration items
|
||||||
|
type ServerConfigurations []ServerConfiguration
|
||||||
|
|
||||||
|
// Configuration stores the configuration of the API client
|
||||||
|
type Configuration struct {
|
||||||
|
Host string `json:"host,omitempty"`
|
||||||
|
Scheme string `json:"scheme,omitempty"`
|
||||||
|
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
|
||||||
|
UserAgent string `json:"userAgent,omitempty"`
|
||||||
|
Debug bool `json:"debug,omitempty"`
|
||||||
|
Servers ServerConfigurations
|
||||||
|
OperationServers map[string]ServerConfigurations
|
||||||
|
HTTPClient *http.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewConfiguration returns a new Configuration object
|
||||||
|
func NewConfiguration() *Configuration {
|
||||||
|
cfg := &Configuration{
|
||||||
|
DefaultHeader: make(map[string]string),
|
||||||
|
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
||||||
|
Debug: false,
|
||||||
|
Servers: ServerConfigurations{
|
||||||
|
{
|
||||||
|
URL: "/api/v1",
|
||||||
|
Description: "No description provided",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
OperationServers: map[string]ServerConfigurations{},
|
||||||
|
}
|
||||||
|
return cfg
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddDefaultHeader adds a new HTTP header to the default header in the request
|
||||||
|
func (c *Configuration) AddDefaultHeader(key string, value string) {
|
||||||
|
c.DefaultHeader[key] = value
|
||||||
|
}
|
||||||
|
|
||||||
|
// URL formats template on a index using given variables
|
||||||
|
func (sc ServerConfigurations) URL(index int, variables map[string]string) (string, error) {
|
||||||
|
if index < 0 || len(sc) <= index {
|
||||||
|
return "", fmt.Errorf("index %v out of range %v", index, len(sc)-1)
|
||||||
|
}
|
||||||
|
server := sc[index]
|
||||||
|
url := server.URL
|
||||||
|
|
||||||
|
// go through variables and replace placeholders
|
||||||
|
for name, variable := range server.Variables {
|
||||||
|
if value, ok := variables[name]; ok {
|
||||||
|
found := bool(len(variable.EnumValues) == 0)
|
||||||
|
for _, enumValue := range variable.EnumValues {
|
||||||
|
if value == enumValue {
|
||||||
|
found = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
return "", fmt.Errorf("the variable %s in the server URL has invalid value %v. Must be %v", name, value, variable.EnumValues)
|
||||||
|
}
|
||||||
|
url = strings.Replace(url, "{"+name+"}", value, -1)
|
||||||
|
} else {
|
||||||
|
url = strings.Replace(url, "{"+name+"}", variable.DefaultValue, -1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return url, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServerURL returns URL based on server settings
|
||||||
|
func (c *Configuration) ServerURL(index int, variables map[string]string) (string, error) {
|
||||||
|
return c.Servers.URL(index, variables)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getServerIndex(ctx context.Context) (int, error) {
|
||||||
|
si := ctx.Value(ContextServerIndex)
|
||||||
|
if si != nil {
|
||||||
|
if index, ok := si.(int); ok {
|
||||||
|
return index, nil
|
||||||
|
}
|
||||||
|
return 0, reportError("Invalid type %T should be int", si)
|
||||||
|
}
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func getServerOperationIndex(ctx context.Context, endpoint string) (int, error) {
|
||||||
|
osi := ctx.Value(ContextOperationServerIndices)
|
||||||
|
if osi != nil {
|
||||||
|
if operationIndices, ok := osi.(map[string]int); !ok {
|
||||||
|
return 0, reportError("Invalid type %T should be map[string]int", osi)
|
||||||
|
} else {
|
||||||
|
index, ok := operationIndices[endpoint]
|
||||||
|
if ok {
|
||||||
|
return index, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return getServerIndex(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getServerVariables(ctx context.Context) (map[string]string, error) {
|
||||||
|
sv := ctx.Value(ContextServerVariables)
|
||||||
|
if sv != nil {
|
||||||
|
if variables, ok := sv.(map[string]string); ok {
|
||||||
|
return variables, nil
|
||||||
|
}
|
||||||
|
return nil, reportError("ctx value of ContextServerVariables has invalid type %T should be map[string]string", sv)
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func getServerOperationVariables(ctx context.Context, endpoint string) (map[string]string, error) {
|
||||||
|
osv := ctx.Value(ContextOperationServerVariables)
|
||||||
|
if osv != nil {
|
||||||
|
if operationVariables, ok := osv.(map[string]map[string]string); !ok {
|
||||||
|
return nil, reportError("ctx value of ContextOperationServerVariables has invalid type %T should be map[string]map[string]string", osv)
|
||||||
|
} else {
|
||||||
|
variables, ok := operationVariables[endpoint]
|
||||||
|
if ok {
|
||||||
|
return variables, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return getServerVariables(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServerURLWithContext returns a new server URL given an endpoint
|
||||||
|
func (c *Configuration) ServerURLWithContext(ctx context.Context, endpoint string) (string, error) {
|
||||||
|
sc, ok := c.OperationServers[endpoint]
|
||||||
|
if !ok {
|
||||||
|
sc = c.Servers
|
||||||
|
}
|
||||||
|
|
||||||
|
if ctx == nil {
|
||||||
|
return sc.URL(0, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
index, err := getServerOperationIndex(ctx, endpoint)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
variables, err := getServerOperationVariables(ctx, endpoint)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return sc.URL(index, variables)
|
||||||
|
}
|
93
docs/ModelsOrchestratorTask.md
Normal file
93
docs/ModelsOrchestratorTask.md
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
# ModelsOrchestratorTask
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**AnthroveUserId** | **string** | |
|
||||||
|
**DeepScrape** | **bool** | |
|
||||||
|
**PlugTask** | [**ModelsPlugTask**](ModelsPlugTask.md) | |
|
||||||
|
|
||||||
|
## Methods
|
||||||
|
|
||||||
|
### NewModelsOrchestratorTask
|
||||||
|
|
||||||
|
`func NewModelsOrchestratorTask(anthroveUserId string, deepScrape bool, plugTask ModelsPlugTask, ) *ModelsOrchestratorTask`
|
||||||
|
|
||||||
|
NewModelsOrchestratorTask instantiates a new ModelsOrchestratorTask object
|
||||||
|
This constructor will assign default values to properties that have it defined,
|
||||||
|
and makes sure properties required by API are set, but the set of arguments
|
||||||
|
will change when the set of required properties is changed
|
||||||
|
|
||||||
|
### NewModelsOrchestratorTaskWithDefaults
|
||||||
|
|
||||||
|
`func NewModelsOrchestratorTaskWithDefaults() *ModelsOrchestratorTask`
|
||||||
|
|
||||||
|
NewModelsOrchestratorTaskWithDefaults instantiates a new ModelsOrchestratorTask object
|
||||||
|
This constructor will only assign default values to properties that have it defined,
|
||||||
|
but it doesn't guarantee that properties required by API are set
|
||||||
|
|
||||||
|
### GetAnthroveUserId
|
||||||
|
|
||||||
|
`func (o *ModelsOrchestratorTask) GetAnthroveUserId() string`
|
||||||
|
|
||||||
|
GetAnthroveUserId returns the AnthroveUserId field if non-nil, zero value otherwise.
|
||||||
|
|
||||||
|
### GetAnthroveUserIdOk
|
||||||
|
|
||||||
|
`func (o *ModelsOrchestratorTask) GetAnthroveUserIdOk() (*string, bool)`
|
||||||
|
|
||||||
|
GetAnthroveUserIdOk returns a tuple with the AnthroveUserId field if it's non-nil, zero value otherwise
|
||||||
|
and a boolean to check if the value has been set.
|
||||||
|
|
||||||
|
### SetAnthroveUserId
|
||||||
|
|
||||||
|
`func (o *ModelsOrchestratorTask) SetAnthroveUserId(v string)`
|
||||||
|
|
||||||
|
SetAnthroveUserId sets AnthroveUserId field to given value.
|
||||||
|
|
||||||
|
|
||||||
|
### GetDeepScrape
|
||||||
|
|
||||||
|
`func (o *ModelsOrchestratorTask) GetDeepScrape() bool`
|
||||||
|
|
||||||
|
GetDeepScrape returns the DeepScrape field if non-nil, zero value otherwise.
|
||||||
|
|
||||||
|
### GetDeepScrapeOk
|
||||||
|
|
||||||
|
`func (o *ModelsOrchestratorTask) GetDeepScrapeOk() (*bool, bool)`
|
||||||
|
|
||||||
|
GetDeepScrapeOk returns a tuple with the DeepScrape field if it's non-nil, zero value otherwise
|
||||||
|
and a boolean to check if the value has been set.
|
||||||
|
|
||||||
|
### SetDeepScrape
|
||||||
|
|
||||||
|
`func (o *ModelsOrchestratorTask) SetDeepScrape(v bool)`
|
||||||
|
|
||||||
|
SetDeepScrape sets DeepScrape field to given value.
|
||||||
|
|
||||||
|
|
||||||
|
### GetPlugTask
|
||||||
|
|
||||||
|
`func (o *ModelsOrchestratorTask) GetPlugTask() ModelsPlugTask`
|
||||||
|
|
||||||
|
GetPlugTask returns the PlugTask field if non-nil, zero value otherwise.
|
||||||
|
|
||||||
|
### GetPlugTaskOk
|
||||||
|
|
||||||
|
`func (o *ModelsOrchestratorTask) GetPlugTaskOk() (*ModelsPlugTask, bool)`
|
||||||
|
|
||||||
|
GetPlugTaskOk returns a tuple with the PlugTask field if it's non-nil, zero value otherwise
|
||||||
|
and a boolean to check if the value has been set.
|
||||||
|
|
||||||
|
### SetPlugTask
|
||||||
|
|
||||||
|
`func (o *ModelsOrchestratorTask) SetPlugTask(v ModelsPlugTask)`
|
||||||
|
|
||||||
|
SetPlugTask sets PlugTask field to given value.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
103
docs/ModelsPlugTask.md
Normal file
103
docs/ModelsPlugTask.md
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
# ModelsPlugTask
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**Id** | Pointer to **string** | | [optional]
|
||||||
|
**TaskState** | Pointer to [**ModelsPlugTaskState**](ModelsPlugTaskState.md) | | [optional]
|
||||||
|
**UserId** | **string** | |
|
||||||
|
|
||||||
|
## Methods
|
||||||
|
|
||||||
|
### NewModelsPlugTask
|
||||||
|
|
||||||
|
`func NewModelsPlugTask(userId string, ) *ModelsPlugTask`
|
||||||
|
|
||||||
|
NewModelsPlugTask instantiates a new ModelsPlugTask object
|
||||||
|
This constructor will assign default values to properties that have it defined,
|
||||||
|
and makes sure properties required by API are set, but the set of arguments
|
||||||
|
will change when the set of required properties is changed
|
||||||
|
|
||||||
|
### NewModelsPlugTaskWithDefaults
|
||||||
|
|
||||||
|
`func NewModelsPlugTaskWithDefaults() *ModelsPlugTask`
|
||||||
|
|
||||||
|
NewModelsPlugTaskWithDefaults instantiates a new ModelsPlugTask object
|
||||||
|
This constructor will only assign default values to properties that have it defined,
|
||||||
|
but it doesn't guarantee that properties required by API are set
|
||||||
|
|
||||||
|
### GetId
|
||||||
|
|
||||||
|
`func (o *ModelsPlugTask) GetId() string`
|
||||||
|
|
||||||
|
GetId returns the Id field if non-nil, zero value otherwise.
|
||||||
|
|
||||||
|
### GetIdOk
|
||||||
|
|
||||||
|
`func (o *ModelsPlugTask) GetIdOk() (*string, bool)`
|
||||||
|
|
||||||
|
GetIdOk returns a tuple with the Id field if it's non-nil, zero value otherwise
|
||||||
|
and a boolean to check if the value has been set.
|
||||||
|
|
||||||
|
### SetId
|
||||||
|
|
||||||
|
`func (o *ModelsPlugTask) SetId(v string)`
|
||||||
|
|
||||||
|
SetId sets Id field to given value.
|
||||||
|
|
||||||
|
### HasId
|
||||||
|
|
||||||
|
`func (o *ModelsPlugTask) HasId() bool`
|
||||||
|
|
||||||
|
HasId returns a boolean if a field has been set.
|
||||||
|
|
||||||
|
### GetTaskState
|
||||||
|
|
||||||
|
`func (o *ModelsPlugTask) GetTaskState() ModelsPlugTaskState`
|
||||||
|
|
||||||
|
GetTaskState returns the TaskState field if non-nil, zero value otherwise.
|
||||||
|
|
||||||
|
### GetTaskStateOk
|
||||||
|
|
||||||
|
`func (o *ModelsPlugTask) GetTaskStateOk() (*ModelsPlugTaskState, bool)`
|
||||||
|
|
||||||
|
GetTaskStateOk returns a tuple with the TaskState field if it's non-nil, zero value otherwise
|
||||||
|
and a boolean to check if the value has been set.
|
||||||
|
|
||||||
|
### SetTaskState
|
||||||
|
|
||||||
|
`func (o *ModelsPlugTask) SetTaskState(v ModelsPlugTaskState)`
|
||||||
|
|
||||||
|
SetTaskState sets TaskState field to given value.
|
||||||
|
|
||||||
|
### HasTaskState
|
||||||
|
|
||||||
|
`func (o *ModelsPlugTask) HasTaskState() bool`
|
||||||
|
|
||||||
|
HasTaskState returns a boolean if a field has been set.
|
||||||
|
|
||||||
|
### GetUserId
|
||||||
|
|
||||||
|
`func (o *ModelsPlugTask) GetUserId() string`
|
||||||
|
|
||||||
|
GetUserId returns the UserId field if non-nil, zero value otherwise.
|
||||||
|
|
||||||
|
### GetUserIdOk
|
||||||
|
|
||||||
|
`func (o *ModelsPlugTask) GetUserIdOk() (*string, bool)`
|
||||||
|
|
||||||
|
GetUserIdOk returns a tuple with the UserId field if it's non-nil, zero value otherwise
|
||||||
|
and a boolean to check if the value has been set.
|
||||||
|
|
||||||
|
### SetUserId
|
||||||
|
|
||||||
|
`func (o *ModelsPlugTask) SetUserId(v string)`
|
||||||
|
|
||||||
|
SetUserId sets UserId field to given value.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
17
docs/ModelsPlugTaskState.md
Normal file
17
docs/ModelsPlugTaskState.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# ModelsPlugTaskState
|
||||||
|
|
||||||
|
## Enum
|
||||||
|
|
||||||
|
|
||||||
|
* `PlugTaskStateUnknown` (value: `"UNKNOWN"`)
|
||||||
|
|
||||||
|
* `PlugTaskStateStarted` (value: `"STARTED"`)
|
||||||
|
|
||||||
|
* `PlugTaskStateRunning` (value: `"RUNNING"`)
|
||||||
|
|
||||||
|
* `PlugTaskStateStopped` (value: `"STOPPED"`)
|
||||||
|
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
223
docs/PlugAPI.md
Normal file
223
docs/PlugAPI.md
Normal file
@ -0,0 +1,223 @@
|
|||||||
|
# \PlugAPI
|
||||||
|
|
||||||
|
All URIs are relative to */api/v1*
|
||||||
|
|
||||||
|
Method | HTTP request | Description
|
||||||
|
------------- | ------------- | -------------
|
||||||
|
[**PlugPlugTypePut**](PlugAPI.md#PlugPlugTypePut) | **Put** /plug/{plug_type} | Initiates a scraping operation for a user with a specific plug type
|
||||||
|
[**PlugPlugTypeTaskIdDelete**](PlugAPI.md#PlugPlugTypeTaskIdDelete) | **Delete** /plug/{plug_type}/{task_id} | Stops a scraping operation for a user with a specific plug type
|
||||||
|
[**PlugPlugTypeTaskIdGet**](PlugAPI.md#PlugPlugTypeTaskIdGet) | **Get** /plug/{plug_type}/{task_id} | Retrieves the status of a specific task type
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## PlugPlugTypePut
|
||||||
|
|
||||||
|
> PlugPlugTypePut(ctx, plugType).Request(request).Execute()
|
||||||
|
|
||||||
|
Initiates a scraping operation for a user with a specific plug type
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
openapiclient "git.dragse.it/anthrove/orchestrator-swagger-go-client"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
plugType := "plugType_example" // string | supported plug type
|
||||||
|
request := *openapiclient.NewModelsOrchestratorTask("AnthroveUserId_example", false, *openapiclient.NewModelsPlugTask("UserId_example")) // ModelsOrchestratorTask | aa
|
||||||
|
|
||||||
|
configuration := openapiclient.NewConfiguration()
|
||||||
|
apiClient := openapiclient.NewAPIClient(configuration)
|
||||||
|
r, err := apiClient.PlugAPI.PlugPlugTypePut(context.Background(), plugType).Request(request).Execute()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "Error when calling `PlugAPI.PlugPlugTypePut``: %v\n", err)
|
||||||
|
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Path Parameters
|
||||||
|
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc.
|
||||||
|
**plugType** | **string** | supported plug type |
|
||||||
|
|
||||||
|
### Other Parameters
|
||||||
|
|
||||||
|
Other parameters are passed through a pointer to a apiPlugPlugTypePutRequest struct via the builder pattern
|
||||||
|
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
|
||||||
|
**request** | [**ModelsOrchestratorTask**](ModelsOrchestratorTask.md) | aa |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
(empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/json
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models)
|
||||||
|
[[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
||||||
|
## PlugPlugTypeTaskIdDelete
|
||||||
|
|
||||||
|
> PlugPlugTypeTaskIdDelete(ctx, plugType, taskId).Execute()
|
||||||
|
|
||||||
|
Stops a scraping operation for a user with a specific plug type
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
openapiclient "git.dragse.it/anthrove/orchestrator-swagger-go-client"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
plugType := "plugType_example" // string | supported plug type
|
||||||
|
taskId := "taskId_example" // string | id of task
|
||||||
|
|
||||||
|
configuration := openapiclient.NewConfiguration()
|
||||||
|
apiClient := openapiclient.NewAPIClient(configuration)
|
||||||
|
r, err := apiClient.PlugAPI.PlugPlugTypeTaskIdDelete(context.Background(), plugType, taskId).Execute()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "Error when calling `PlugAPI.PlugPlugTypeTaskIdDelete``: %v\n", err)
|
||||||
|
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Path Parameters
|
||||||
|
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc.
|
||||||
|
**plugType** | **string** | supported plug type |
|
||||||
|
**taskId** | **string** | id of task |
|
||||||
|
|
||||||
|
### Other Parameters
|
||||||
|
|
||||||
|
Other parameters are passed through a pointer to a apiPlugPlugTypeTaskIdDeleteRequest struct via the builder pattern
|
||||||
|
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
(empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models)
|
||||||
|
[[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
||||||
|
## PlugPlugTypeTaskIdGet
|
||||||
|
|
||||||
|
> PlugPlugTypeTaskIdGet(ctx, plugType, taskId).Execute()
|
||||||
|
|
||||||
|
Retrieves the status of a specific task type
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
openapiclient "git.dragse.it/anthrove/orchestrator-swagger-go-client"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
plugType := "plugType_example" // string | supported plug type
|
||||||
|
taskId := "taskId_example" // string | id of task
|
||||||
|
|
||||||
|
configuration := openapiclient.NewConfiguration()
|
||||||
|
apiClient := openapiclient.NewAPIClient(configuration)
|
||||||
|
r, err := apiClient.PlugAPI.PlugPlugTypeTaskIdGet(context.Background(), plugType, taskId).Execute()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "Error when calling `PlugAPI.PlugPlugTypeTaskIdGet``: %v\n", err)
|
||||||
|
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Path Parameters
|
||||||
|
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc.
|
||||||
|
**plugType** | **string** | supported plug type |
|
||||||
|
**taskId** | **string** | id of task |
|
||||||
|
|
||||||
|
### Other Parameters
|
||||||
|
|
||||||
|
Other parameters are passed through a pointer to a apiPlugPlugTypeTaskIdGetRequest struct via the builder pattern
|
||||||
|
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
(empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models)
|
||||||
|
[[Back to README]](../README.md)
|
||||||
|
|
77
docs/UserAPI.md
Normal file
77
docs/UserAPI.md
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
# \UserAPI
|
||||||
|
|
||||||
|
All URIs are relative to */api/v1*
|
||||||
|
|
||||||
|
Method | HTTP request | Description
|
||||||
|
------------- | ------------- | -------------
|
||||||
|
[**UserUserIdPut**](UserAPI.md#UserUserIdPut) | **Put** /user/{user_id} | Initiates a scraping operation for the entire user
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## UserUserIdPut
|
||||||
|
|
||||||
|
> UserUserIdPut(ctx, userId).Execute()
|
||||||
|
|
||||||
|
Initiates a scraping operation for the entire user
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
openapiclient "git.dragse.it/anthrove/orchestrator-swagger-go-client"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
userId := "userId_example" // string | Anthrove UserID
|
||||||
|
|
||||||
|
configuration := openapiclient.NewConfiguration()
|
||||||
|
apiClient := openapiclient.NewAPIClient(configuration)
|
||||||
|
r, err := apiClient.UserAPI.UserUserIdPut(context.Background(), userId).Execute()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "Error when calling `UserAPI.UserUserIdPut``: %v\n", err)
|
||||||
|
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Path Parameters
|
||||||
|
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc.
|
||||||
|
**userId** | **string** | Anthrove UserID |
|
||||||
|
|
||||||
|
### Other Parameters
|
||||||
|
|
||||||
|
Other parameters are passed through a pointer to a apiUserUserIdPutRequest struct via the builder pattern
|
||||||
|
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
(empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models)
|
||||||
|
[[Back to README]](../README.md)
|
||||||
|
|
57
git_push.sh
Normal file
57
git_push.sh
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||||
|
#
|
||||||
|
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
|
||||||
|
|
||||||
|
git_user_id=$1
|
||||||
|
git_repo_id=$2
|
||||||
|
release_note=$3
|
||||||
|
git_host=$4
|
||||||
|
|
||||||
|
if [ "$git_host" = "" ]; then
|
||||||
|
git_host="github.com"
|
||||||
|
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$git_user_id" = "" ]; then
|
||||||
|
git_user_id="GIT_USER_ID"
|
||||||
|
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$git_repo_id" = "" ]; then
|
||||||
|
git_repo_id="GIT_REPO_ID"
|
||||||
|
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$release_note" = "" ]; then
|
||||||
|
release_note="Minor update"
|
||||||
|
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Initialize the local directory as a Git repository
|
||||||
|
git init
|
||||||
|
|
||||||
|
# Adds the files in the local repository and stages them for commit.
|
||||||
|
git add .
|
||||||
|
|
||||||
|
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||||
|
git commit -m "$release_note"
|
||||||
|
|
||||||
|
# Sets the new remote
|
||||||
|
git_remote=$(git remote)
|
||||||
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||||
|
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
|
else
|
||||||
|
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
git pull origin master
|
||||||
|
|
||||||
|
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||||
|
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||||
|
git push origin master 2>&1 | grep -v 'To https'
|
11
go.mod
Normal file
11
go.mod
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
module git.dragse.it/anthrove/orchestrator-swagger-go-client
|
||||||
|
|
||||||
|
go 1.18
|
||||||
|
|
||||||
|
require github.com/stretchr/testify v1.9.0
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
)
|
10
go.sum
Normal file
10
go.sum
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||||
|
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
213
model_models_orchestrator_task.go
Normal file
213
model_models_orchestrator_task.go
Normal file
@ -0,0 +1,213 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// checks if the ModelsOrchestratorTask type satisfies the MappedNullable interface at compile time
|
||||||
|
var _ MappedNullable = &ModelsOrchestratorTask{}
|
||||||
|
|
||||||
|
// ModelsOrchestratorTask struct for ModelsOrchestratorTask
|
||||||
|
type ModelsOrchestratorTask struct {
|
||||||
|
AnthroveUserId string `json:"anthrove_user_id"`
|
||||||
|
DeepScrape bool `json:"deep_scrape"`
|
||||||
|
PlugTask ModelsPlugTask `json:"plug_task"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type _ModelsOrchestratorTask ModelsOrchestratorTask
|
||||||
|
|
||||||
|
// NewModelsOrchestratorTask instantiates a new ModelsOrchestratorTask object
|
||||||
|
// This constructor will assign default values to properties that have it defined,
|
||||||
|
// and makes sure properties required by API are set, but the set of arguments
|
||||||
|
// will change when the set of required properties is changed
|
||||||
|
func NewModelsOrchestratorTask(anthroveUserId string, deepScrape bool, plugTask ModelsPlugTask) *ModelsOrchestratorTask {
|
||||||
|
this := ModelsOrchestratorTask{}
|
||||||
|
this.AnthroveUserId = anthroveUserId
|
||||||
|
this.DeepScrape = deepScrape
|
||||||
|
this.PlugTask = plugTask
|
||||||
|
return &this
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewModelsOrchestratorTaskWithDefaults instantiates a new ModelsOrchestratorTask object
|
||||||
|
// This constructor will only assign default values to properties that have it defined,
|
||||||
|
// but it doesn't guarantee that properties required by API are set
|
||||||
|
func NewModelsOrchestratorTaskWithDefaults() *ModelsOrchestratorTask {
|
||||||
|
this := ModelsOrchestratorTask{}
|
||||||
|
return &this
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAnthroveUserId returns the AnthroveUserId field value
|
||||||
|
func (o *ModelsOrchestratorTask) GetAnthroveUserId() string {
|
||||||
|
if o == nil {
|
||||||
|
var ret string
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
return o.AnthroveUserId
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAnthroveUserIdOk returns a tuple with the AnthroveUserId field value
|
||||||
|
// and a boolean to check if the value has been set.
|
||||||
|
func (o *ModelsOrchestratorTask) GetAnthroveUserIdOk() (*string, bool) {
|
||||||
|
if o == nil {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
return &o.AnthroveUserId, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAnthroveUserId sets field value
|
||||||
|
func (o *ModelsOrchestratorTask) SetAnthroveUserId(v string) {
|
||||||
|
o.AnthroveUserId = v
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetDeepScrape returns the DeepScrape field value
|
||||||
|
func (o *ModelsOrchestratorTask) GetDeepScrape() bool {
|
||||||
|
if o == nil {
|
||||||
|
var ret bool
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
return o.DeepScrape
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetDeepScrapeOk returns a tuple with the DeepScrape field value
|
||||||
|
// and a boolean to check if the value has been set.
|
||||||
|
func (o *ModelsOrchestratorTask) GetDeepScrapeOk() (*bool, bool) {
|
||||||
|
if o == nil {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
return &o.DeepScrape, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetDeepScrape sets field value
|
||||||
|
func (o *ModelsOrchestratorTask) SetDeepScrape(v bool) {
|
||||||
|
o.DeepScrape = v
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPlugTask returns the PlugTask field value
|
||||||
|
func (o *ModelsOrchestratorTask) GetPlugTask() ModelsPlugTask {
|
||||||
|
if o == nil {
|
||||||
|
var ret ModelsPlugTask
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
return o.PlugTask
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPlugTaskOk returns a tuple with the PlugTask field value
|
||||||
|
// and a boolean to check if the value has been set.
|
||||||
|
func (o *ModelsOrchestratorTask) GetPlugTaskOk() (*ModelsPlugTask, bool) {
|
||||||
|
if o == nil {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
return &o.PlugTask, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPlugTask sets field value
|
||||||
|
func (o *ModelsOrchestratorTask) SetPlugTask(v ModelsPlugTask) {
|
||||||
|
o.PlugTask = v
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o ModelsOrchestratorTask) MarshalJSON() ([]byte, error) {
|
||||||
|
toSerialize, err := o.ToMap()
|
||||||
|
if err != nil {
|
||||||
|
return []byte{}, err
|
||||||
|
}
|
||||||
|
return json.Marshal(toSerialize)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o ModelsOrchestratorTask) ToMap() (map[string]interface{}, error) {
|
||||||
|
toSerialize := map[string]interface{}{}
|
||||||
|
toSerialize["anthrove_user_id"] = o.AnthroveUserId
|
||||||
|
toSerialize["deep_scrape"] = o.DeepScrape
|
||||||
|
toSerialize["plug_task"] = o.PlugTask
|
||||||
|
return toSerialize, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *ModelsOrchestratorTask) UnmarshalJSON(data []byte) (err error) {
|
||||||
|
// This validates that all required properties are included in the JSON object
|
||||||
|
// by unmarshalling the object into a generic map with string keys and checking
|
||||||
|
// that every required field exists as a key in the generic map.
|
||||||
|
requiredProperties := []string{
|
||||||
|
"anthrove_user_id",
|
||||||
|
"deep_scrape",
|
||||||
|
"plug_task",
|
||||||
|
}
|
||||||
|
|
||||||
|
allProperties := make(map[string]interface{})
|
||||||
|
|
||||||
|
err = json.Unmarshal(data, &allProperties)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, requiredProperty := range requiredProperties {
|
||||||
|
if _, exists := allProperties[requiredProperty]; !exists {
|
||||||
|
return fmt.Errorf("no value given for required property %v", requiredProperty)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
varModelsOrchestratorTask := _ModelsOrchestratorTask{}
|
||||||
|
|
||||||
|
decoder := json.NewDecoder(bytes.NewReader(data))
|
||||||
|
decoder.DisallowUnknownFields()
|
||||||
|
err = decoder.Decode(&varModelsOrchestratorTask)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
*o = ModelsOrchestratorTask(varModelsOrchestratorTask)
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
type NullableModelsOrchestratorTask struct {
|
||||||
|
value *ModelsOrchestratorTask
|
||||||
|
isSet bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableModelsOrchestratorTask) Get() *ModelsOrchestratorTask {
|
||||||
|
return v.value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableModelsOrchestratorTask) Set(val *ModelsOrchestratorTask) {
|
||||||
|
v.value = val
|
||||||
|
v.isSet = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableModelsOrchestratorTask) IsSet() bool {
|
||||||
|
return v.isSet
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableModelsOrchestratorTask) Unset() {
|
||||||
|
v.value = nil
|
||||||
|
v.isSet = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNullableModelsOrchestratorTask(val *ModelsOrchestratorTask) *NullableModelsOrchestratorTask {
|
||||||
|
return &NullableModelsOrchestratorTask{value: val, isSet: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableModelsOrchestratorTask) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(v.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableModelsOrchestratorTask) UnmarshalJSON(src []byte) error {
|
||||||
|
v.isSet = true
|
||||||
|
return json.Unmarshal(src, &v.value)
|
||||||
|
}
|
229
model_models_plug_task.go
Normal file
229
model_models_plug_task.go
Normal file
@ -0,0 +1,229 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// checks if the ModelsPlugTask type satisfies the MappedNullable interface at compile time
|
||||||
|
var _ MappedNullable = &ModelsPlugTask{}
|
||||||
|
|
||||||
|
// ModelsPlugTask struct for ModelsPlugTask
|
||||||
|
type ModelsPlugTask struct {
|
||||||
|
Id *string `json:"id,omitempty"`
|
||||||
|
TaskState *ModelsPlugTaskState `json:"task_state,omitempty"`
|
||||||
|
UserId string `json:"user_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type _ModelsPlugTask ModelsPlugTask
|
||||||
|
|
||||||
|
// NewModelsPlugTask instantiates a new ModelsPlugTask object
|
||||||
|
// This constructor will assign default values to properties that have it defined,
|
||||||
|
// and makes sure properties required by API are set, but the set of arguments
|
||||||
|
// will change when the set of required properties is changed
|
||||||
|
func NewModelsPlugTask(userId string) *ModelsPlugTask {
|
||||||
|
this := ModelsPlugTask{}
|
||||||
|
this.UserId = userId
|
||||||
|
return &this
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewModelsPlugTaskWithDefaults instantiates a new ModelsPlugTask object
|
||||||
|
// This constructor will only assign default values to properties that have it defined,
|
||||||
|
// but it doesn't guarantee that properties required by API are set
|
||||||
|
func NewModelsPlugTaskWithDefaults() *ModelsPlugTask {
|
||||||
|
this := ModelsPlugTask{}
|
||||||
|
return &this
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetId returns the Id field value if set, zero value otherwise.
|
||||||
|
func (o *ModelsPlugTask) GetId() string {
|
||||||
|
if o == nil || IsNil(o.Id) {
|
||||||
|
var ret string
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
return *o.Id
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetIdOk returns a tuple with the Id field value if set, nil otherwise
|
||||||
|
// and a boolean to check if the value has been set.
|
||||||
|
func (o *ModelsPlugTask) GetIdOk() (*string, bool) {
|
||||||
|
if o == nil || IsNil(o.Id) {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
return o.Id, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasId returns a boolean if a field has been set.
|
||||||
|
func (o *ModelsPlugTask) HasId() bool {
|
||||||
|
if o != nil && !IsNil(o.Id) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetId gets a reference to the given string and assigns it to the Id field.
|
||||||
|
func (o *ModelsPlugTask) SetId(v string) {
|
||||||
|
o.Id = &v
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetTaskState returns the TaskState field value if set, zero value otherwise.
|
||||||
|
func (o *ModelsPlugTask) GetTaskState() ModelsPlugTaskState {
|
||||||
|
if o == nil || IsNil(o.TaskState) {
|
||||||
|
var ret ModelsPlugTaskState
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
return *o.TaskState
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetTaskStateOk returns a tuple with the TaskState field value if set, nil otherwise
|
||||||
|
// and a boolean to check if the value has been set.
|
||||||
|
func (o *ModelsPlugTask) GetTaskStateOk() (*ModelsPlugTaskState, bool) {
|
||||||
|
if o == nil || IsNil(o.TaskState) {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
return o.TaskState, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasTaskState returns a boolean if a field has been set.
|
||||||
|
func (o *ModelsPlugTask) HasTaskState() bool {
|
||||||
|
if o != nil && !IsNil(o.TaskState) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetTaskState gets a reference to the given ModelsPlugTaskState and assigns it to the TaskState field.
|
||||||
|
func (o *ModelsPlugTask) SetTaskState(v ModelsPlugTaskState) {
|
||||||
|
o.TaskState = &v
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserId returns the UserId field value
|
||||||
|
func (o *ModelsPlugTask) GetUserId() string {
|
||||||
|
if o == nil {
|
||||||
|
var ret string
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
return o.UserId
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserIdOk returns a tuple with the UserId field value
|
||||||
|
// and a boolean to check if the value has been set.
|
||||||
|
func (o *ModelsPlugTask) GetUserIdOk() (*string, bool) {
|
||||||
|
if o == nil {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
return &o.UserId, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUserId sets field value
|
||||||
|
func (o *ModelsPlugTask) SetUserId(v string) {
|
||||||
|
o.UserId = v
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o ModelsPlugTask) MarshalJSON() ([]byte, error) {
|
||||||
|
toSerialize, err := o.ToMap()
|
||||||
|
if err != nil {
|
||||||
|
return []byte{}, err
|
||||||
|
}
|
||||||
|
return json.Marshal(toSerialize)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o ModelsPlugTask) ToMap() (map[string]interface{}, error) {
|
||||||
|
toSerialize := map[string]interface{}{}
|
||||||
|
if !IsNil(o.Id) {
|
||||||
|
toSerialize["id"] = o.Id
|
||||||
|
}
|
||||||
|
if !IsNil(o.TaskState) {
|
||||||
|
toSerialize["task_state"] = o.TaskState
|
||||||
|
}
|
||||||
|
toSerialize["user_id"] = o.UserId
|
||||||
|
return toSerialize, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *ModelsPlugTask) UnmarshalJSON(data []byte) (err error) {
|
||||||
|
// This validates that all required properties are included in the JSON object
|
||||||
|
// by unmarshalling the object into a generic map with string keys and checking
|
||||||
|
// that every required field exists as a key in the generic map.
|
||||||
|
requiredProperties := []string{
|
||||||
|
"user_id",
|
||||||
|
}
|
||||||
|
|
||||||
|
allProperties := make(map[string]interface{})
|
||||||
|
|
||||||
|
err = json.Unmarshal(data, &allProperties)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, requiredProperty := range requiredProperties {
|
||||||
|
if _, exists := allProperties[requiredProperty]; !exists {
|
||||||
|
return fmt.Errorf("no value given for required property %v", requiredProperty)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
varModelsPlugTask := _ModelsPlugTask{}
|
||||||
|
|
||||||
|
decoder := json.NewDecoder(bytes.NewReader(data))
|
||||||
|
decoder.DisallowUnknownFields()
|
||||||
|
err = decoder.Decode(&varModelsPlugTask)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
*o = ModelsPlugTask(varModelsPlugTask)
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
type NullableModelsPlugTask struct {
|
||||||
|
value *ModelsPlugTask
|
||||||
|
isSet bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableModelsPlugTask) Get() *ModelsPlugTask {
|
||||||
|
return v.value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableModelsPlugTask) Set(val *ModelsPlugTask) {
|
||||||
|
v.value = val
|
||||||
|
v.isSet = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableModelsPlugTask) IsSet() bool {
|
||||||
|
return v.isSet
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableModelsPlugTask) Unset() {
|
||||||
|
v.value = nil
|
||||||
|
v.isSet = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNullableModelsPlugTask(val *ModelsPlugTask) *NullableModelsPlugTask {
|
||||||
|
return &NullableModelsPlugTask{value: val, isSet: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableModelsPlugTask) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(v.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableModelsPlugTask) UnmarshalJSON(src []byte) error {
|
||||||
|
v.isSet = true
|
||||||
|
return json.Unmarshal(src, &v.value)
|
||||||
|
}
|
115
model_models_plug_task_state.go
Normal file
115
model_models_plug_task_state.go
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
/*
|
||||||
|
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 (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ModelsPlugTaskState the model 'ModelsPlugTaskState'
|
||||||
|
type ModelsPlugTaskState string
|
||||||
|
|
||||||
|
// List of models.PlugTaskState
|
||||||
|
const (
|
||||||
|
PlugTaskStateUnknown ModelsPlugTaskState = "UNKNOWN"
|
||||||
|
PlugTaskStateStarted ModelsPlugTaskState = "STARTED"
|
||||||
|
PlugTaskStateRunning ModelsPlugTaskState = "RUNNING"
|
||||||
|
PlugTaskStateStopped ModelsPlugTaskState = "STOPPED"
|
||||||
|
)
|
||||||
|
|
||||||
|
// All allowed values of ModelsPlugTaskState enum
|
||||||
|
var AllowedModelsPlugTaskStateEnumValues = []ModelsPlugTaskState{
|
||||||
|
"UNKNOWN",
|
||||||
|
"STARTED",
|
||||||
|
"RUNNING",
|
||||||
|
"STOPPED",
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *ModelsPlugTaskState) UnmarshalJSON(src []byte) error {
|
||||||
|
var value string
|
||||||
|
err := json.Unmarshal(src, &value)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
enumTypeValue := ModelsPlugTaskState(value)
|
||||||
|
for _, existing := range AllowedModelsPlugTaskStateEnumValues {
|
||||||
|
if existing == enumTypeValue {
|
||||||
|
*v = enumTypeValue
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Errorf("%+v is not a valid ModelsPlugTaskState", value)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewModelsPlugTaskStateFromValue returns a pointer to a valid ModelsPlugTaskState
|
||||||
|
// for the value passed as argument, or an error if the value passed is not allowed by the enum
|
||||||
|
func NewModelsPlugTaskStateFromValue(v string) (*ModelsPlugTaskState, error) {
|
||||||
|
ev := ModelsPlugTaskState(v)
|
||||||
|
if ev.IsValid() {
|
||||||
|
return &ev, nil
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("invalid value '%v' for ModelsPlugTaskState: valid values are %v", v, AllowedModelsPlugTaskStateEnumValues)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsValid return true if the value is valid for the enum, false otherwise
|
||||||
|
func (v ModelsPlugTaskState) IsValid() bool {
|
||||||
|
for _, existing := range AllowedModelsPlugTaskStateEnumValues {
|
||||||
|
if existing == v {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ptr returns reference to models.PlugTaskState value
|
||||||
|
func (v ModelsPlugTaskState) Ptr() *ModelsPlugTaskState {
|
||||||
|
return &v
|
||||||
|
}
|
||||||
|
|
||||||
|
type NullableModelsPlugTaskState struct {
|
||||||
|
value *ModelsPlugTaskState
|
||||||
|
isSet bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableModelsPlugTaskState) Get() *ModelsPlugTaskState {
|
||||||
|
return v.value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableModelsPlugTaskState) Set(val *ModelsPlugTaskState) {
|
||||||
|
v.value = val
|
||||||
|
v.isSet = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableModelsPlugTaskState) IsSet() bool {
|
||||||
|
return v.isSet
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableModelsPlugTaskState) Unset() {
|
||||||
|
v.value = nil
|
||||||
|
v.isSet = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNullableModelsPlugTaskState(val *ModelsPlugTaskState) *NullableModelsPlugTaskState {
|
||||||
|
return &NullableModelsPlugTaskState{value: val, isSet: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableModelsPlugTaskState) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(v.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableModelsPlugTaskState) UnmarshalJSON(src []byte) error {
|
||||||
|
v.isSet = true
|
||||||
|
return json.Unmarshal(src, &v.value)
|
||||||
|
}
|
48
response.go
Normal file
48
response.go
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
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 (
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// APIResponse stores the API response returned by the server.
|
||||||
|
type APIResponse struct {
|
||||||
|
*http.Response `json:"-"`
|
||||||
|
Message string `json:"message,omitempty"`
|
||||||
|
// Operation is the name of the OpenAPI operation.
|
||||||
|
Operation string `json:"operation,omitempty"`
|
||||||
|
// RequestURL is the request URL. This value is always available, even if the
|
||||||
|
// embedded *http.Response is nil.
|
||||||
|
RequestURL string `json:"url,omitempty"`
|
||||||
|
// Method is the HTTP method used for the request. This value is always
|
||||||
|
// available, even if the embedded *http.Response is nil.
|
||||||
|
Method string `json:"method,omitempty"`
|
||||||
|
// Payload holds the contents of the response body (which may be nil or empty).
|
||||||
|
// This is provided here as the raw response.Body() reader will have already
|
||||||
|
// been drained.
|
||||||
|
Payload []byte `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAPIResponse returns a new APIResponse object.
|
||||||
|
func NewAPIResponse(r *http.Response) *APIResponse {
|
||||||
|
|
||||||
|
response := &APIResponse{Response: r}
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAPIResponseWithError returns a new APIResponse object with the provided error message.
|
||||||
|
func NewAPIResponseWithError(errorMessage string) *APIResponse {
|
||||||
|
|
||||||
|
response := &APIResponse{Message: errorMessage}
|
||||||
|
return response
|
||||||
|
}
|
66
test/api_plug_test.go
Normal file
66
test/api_plug_test.go
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
Anthrove Orchestrator API
|
||||||
|
|
||||||
|
Testing PlugAPIService
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech);
|
||||||
|
|
||||||
|
package openapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
openapiclient "git.dragse.it/anthrove/orchestrator-swagger-go-client"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Test_openapi_PlugAPIService(t *testing.T) {
|
||||||
|
|
||||||
|
configuration := openapiclient.NewConfiguration()
|
||||||
|
apiClient := openapiclient.NewAPIClient(configuration)
|
||||||
|
|
||||||
|
t.Run("Test PlugAPIService PlugPlugTypePut", func(t *testing.T) {
|
||||||
|
|
||||||
|
t.Skip("skip test") // remove to run test
|
||||||
|
|
||||||
|
var plugType string
|
||||||
|
|
||||||
|
httpRes, err := apiClient.PlugAPI.PlugPlugTypePut(context.Background(), plugType).Execute()
|
||||||
|
|
||||||
|
require.Nil(t, err)
|
||||||
|
assert.Equal(t, 200, httpRes.StatusCode)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("Test PlugAPIService PlugPlugTypeTaskIdDelete", func(t *testing.T) {
|
||||||
|
|
||||||
|
t.Skip("skip test") // remove to run test
|
||||||
|
|
||||||
|
var plugType string
|
||||||
|
var taskId string
|
||||||
|
|
||||||
|
httpRes, err := apiClient.PlugAPI.PlugPlugTypeTaskIdDelete(context.Background(), plugType, taskId).Execute()
|
||||||
|
|
||||||
|
require.Nil(t, err)
|
||||||
|
assert.Equal(t, 200, httpRes.StatusCode)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("Test PlugAPIService PlugPlugTypeTaskIdGet", func(t *testing.T) {
|
||||||
|
|
||||||
|
t.Skip("skip test") // remove to run test
|
||||||
|
|
||||||
|
var plugType string
|
||||||
|
var taskId string
|
||||||
|
|
||||||
|
httpRes, err := apiClient.PlugAPI.PlugPlugTypeTaskIdGet(context.Background(), plugType, taskId).Execute()
|
||||||
|
|
||||||
|
require.Nil(t, err)
|
||||||
|
assert.Equal(t, 200, httpRes.StatusCode)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
38
test/api_user_test.go
Normal file
38
test/api_user_test.go
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
Anthrove Orchestrator API
|
||||||
|
|
||||||
|
Testing UserAPIService
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech);
|
||||||
|
|
||||||
|
package openapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
openapiclient "git.dragse.it/anthrove/orchestrator-swagger-go-client"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Test_openapi_UserAPIService(t *testing.T) {
|
||||||
|
|
||||||
|
configuration := openapiclient.NewConfiguration()
|
||||||
|
apiClient := openapiclient.NewAPIClient(configuration)
|
||||||
|
|
||||||
|
t.Run("Test UserAPIService UserUserIdPut", func(t *testing.T) {
|
||||||
|
|
||||||
|
t.Skip("skip test") // remove to run test
|
||||||
|
|
||||||
|
var userId string
|
||||||
|
|
||||||
|
httpRes, err := apiClient.UserAPI.UserUserIdPut(context.Background(), userId).Execute()
|
||||||
|
|
||||||
|
require.Nil(t, err)
|
||||||
|
assert.Equal(t, 200, httpRes.StatusCode)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
348
utils.go
Normal file
348
utils.go
Normal file
@ -0,0 +1,348 @@
|
|||||||
|
/*
|
||||||
|
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 (
|
||||||
|
"encoding/json"
|
||||||
|
"reflect"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// PtrBool is a helper routine that returns a pointer to given boolean value.
|
||||||
|
func PtrBool(v bool) *bool { return &v }
|
||||||
|
|
||||||
|
// PtrInt is a helper routine that returns a pointer to given integer value.
|
||||||
|
func PtrInt(v int) *int { return &v }
|
||||||
|
|
||||||
|
// PtrInt32 is a helper routine that returns a pointer to given integer value.
|
||||||
|
func PtrInt32(v int32) *int32 { return &v }
|
||||||
|
|
||||||
|
// PtrInt64 is a helper routine that returns a pointer to given integer value.
|
||||||
|
func PtrInt64(v int64) *int64 { return &v }
|
||||||
|
|
||||||
|
// PtrFloat32 is a helper routine that returns a pointer to given float value.
|
||||||
|
func PtrFloat32(v float32) *float32 { return &v }
|
||||||
|
|
||||||
|
// PtrFloat64 is a helper routine that returns a pointer to given float value.
|
||||||
|
func PtrFloat64(v float64) *float64 { return &v }
|
||||||
|
|
||||||
|
// PtrString is a helper routine that returns a pointer to given string value.
|
||||||
|
func PtrString(v string) *string { return &v }
|
||||||
|
|
||||||
|
// PtrTime is helper routine that returns a pointer to given Time value.
|
||||||
|
func PtrTime(v time.Time) *time.Time { return &v }
|
||||||
|
|
||||||
|
type NullableBool struct {
|
||||||
|
value *bool
|
||||||
|
isSet bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableBool) Get() *bool {
|
||||||
|
return v.value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableBool) Set(val *bool) {
|
||||||
|
v.value = val
|
||||||
|
v.isSet = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableBool) IsSet() bool {
|
||||||
|
return v.isSet
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableBool) Unset() {
|
||||||
|
v.value = nil
|
||||||
|
v.isSet = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNullableBool(val *bool) *NullableBool {
|
||||||
|
return &NullableBool{value: val, isSet: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableBool) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(v.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableBool) UnmarshalJSON(src []byte) error {
|
||||||
|
v.isSet = true
|
||||||
|
return json.Unmarshal(src, &v.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
type NullableInt struct {
|
||||||
|
value *int
|
||||||
|
isSet bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableInt) Get() *int {
|
||||||
|
return v.value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableInt) Set(val *int) {
|
||||||
|
v.value = val
|
||||||
|
v.isSet = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableInt) IsSet() bool {
|
||||||
|
return v.isSet
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableInt) Unset() {
|
||||||
|
v.value = nil
|
||||||
|
v.isSet = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNullableInt(val *int) *NullableInt {
|
||||||
|
return &NullableInt{value: val, isSet: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableInt) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(v.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableInt) UnmarshalJSON(src []byte) error {
|
||||||
|
v.isSet = true
|
||||||
|
return json.Unmarshal(src, &v.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
type NullableInt32 struct {
|
||||||
|
value *int32
|
||||||
|
isSet bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableInt32) Get() *int32 {
|
||||||
|
return v.value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableInt32) Set(val *int32) {
|
||||||
|
v.value = val
|
||||||
|
v.isSet = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableInt32) IsSet() bool {
|
||||||
|
return v.isSet
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableInt32) Unset() {
|
||||||
|
v.value = nil
|
||||||
|
v.isSet = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNullableInt32(val *int32) *NullableInt32 {
|
||||||
|
return &NullableInt32{value: val, isSet: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableInt32) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(v.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableInt32) UnmarshalJSON(src []byte) error {
|
||||||
|
v.isSet = true
|
||||||
|
return json.Unmarshal(src, &v.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
type NullableInt64 struct {
|
||||||
|
value *int64
|
||||||
|
isSet bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableInt64) Get() *int64 {
|
||||||
|
return v.value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableInt64) Set(val *int64) {
|
||||||
|
v.value = val
|
||||||
|
v.isSet = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableInt64) IsSet() bool {
|
||||||
|
return v.isSet
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableInt64) Unset() {
|
||||||
|
v.value = nil
|
||||||
|
v.isSet = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNullableInt64(val *int64) *NullableInt64 {
|
||||||
|
return &NullableInt64{value: val, isSet: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableInt64) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(v.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableInt64) UnmarshalJSON(src []byte) error {
|
||||||
|
v.isSet = true
|
||||||
|
return json.Unmarshal(src, &v.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
type NullableFloat32 struct {
|
||||||
|
value *float32
|
||||||
|
isSet bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableFloat32) Get() *float32 {
|
||||||
|
return v.value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableFloat32) Set(val *float32) {
|
||||||
|
v.value = val
|
||||||
|
v.isSet = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableFloat32) IsSet() bool {
|
||||||
|
return v.isSet
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableFloat32) Unset() {
|
||||||
|
v.value = nil
|
||||||
|
v.isSet = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNullableFloat32(val *float32) *NullableFloat32 {
|
||||||
|
return &NullableFloat32{value: val, isSet: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableFloat32) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(v.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableFloat32) UnmarshalJSON(src []byte) error {
|
||||||
|
v.isSet = true
|
||||||
|
return json.Unmarshal(src, &v.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
type NullableFloat64 struct {
|
||||||
|
value *float64
|
||||||
|
isSet bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableFloat64) Get() *float64 {
|
||||||
|
return v.value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableFloat64) Set(val *float64) {
|
||||||
|
v.value = val
|
||||||
|
v.isSet = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableFloat64) IsSet() bool {
|
||||||
|
return v.isSet
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableFloat64) Unset() {
|
||||||
|
v.value = nil
|
||||||
|
v.isSet = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNullableFloat64(val *float64) *NullableFloat64 {
|
||||||
|
return &NullableFloat64{value: val, isSet: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableFloat64) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(v.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableFloat64) UnmarshalJSON(src []byte) error {
|
||||||
|
v.isSet = true
|
||||||
|
return json.Unmarshal(src, &v.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
type NullableString struct {
|
||||||
|
value *string
|
||||||
|
isSet bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableString) Get() *string {
|
||||||
|
return v.value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableString) Set(val *string) {
|
||||||
|
v.value = val
|
||||||
|
v.isSet = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableString) IsSet() bool {
|
||||||
|
return v.isSet
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableString) Unset() {
|
||||||
|
v.value = nil
|
||||||
|
v.isSet = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNullableString(val *string) *NullableString {
|
||||||
|
return &NullableString{value: val, isSet: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableString) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(v.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableString) UnmarshalJSON(src []byte) error {
|
||||||
|
v.isSet = true
|
||||||
|
return json.Unmarshal(src, &v.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
type NullableTime struct {
|
||||||
|
value *time.Time
|
||||||
|
isSet bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableTime) Get() *time.Time {
|
||||||
|
return v.value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableTime) Set(val *time.Time) {
|
||||||
|
v.value = val
|
||||||
|
v.isSet = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableTime) IsSet() bool {
|
||||||
|
return v.isSet
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableTime) Unset() {
|
||||||
|
v.value = nil
|
||||||
|
v.isSet = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNullableTime(val *time.Time) *NullableTime {
|
||||||
|
return &NullableTime{value: val, isSet: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v NullableTime) MarshalJSON() ([]byte, error) {
|
||||||
|
return v.value.MarshalJSON()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *NullableTime) UnmarshalJSON(src []byte) error {
|
||||||
|
v.isSet = true
|
||||||
|
return json.Unmarshal(src, &v.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsNil checks if an input is nil
|
||||||
|
func IsNil(i interface{}) bool {
|
||||||
|
if i == nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
switch reflect.TypeOf(i).Kind() {
|
||||||
|
case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.UnsafePointer, reflect.Interface, reflect.Slice:
|
||||||
|
return reflect.ValueOf(i).IsNil()
|
||||||
|
case reflect.Array:
|
||||||
|
return reflect.ValueOf(i).IsZero()
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
type MappedNullable interface {
|
||||||
|
ToMap() (map[string]interface{}, error)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user