Skip to content

Latest commit

 

History

History
485 lines (427 loc) · 26.3 KB

README.md

File metadata and controls

485 lines (427 loc) · 26.3 KB

Go API client for goyeti

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 0.1.0
  • Package version: 1.0.0
  • Generator version: 7.10.0-SNAPSHOT
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import goyeti "github.com/yeti-platform/goyeti"

To use a proxy, set the environment variable HTTP_PROXY:

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 goyeti.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), goyeti.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value goyeti.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), goyeti.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 goyeti.ContextOperationServerIndices and goyeti.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), goyeti.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), goyeti.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to http://localhost

Class Method HTTP request Description
AuthAPI LoginApiApiV2AuthApiTokenPost Post /api/v2/auth/api-token Login Api
AuthAPI LoginApiV2AuthTokenPost Post /api/v2/auth/token Login
AuthAPI LogoutApiV2AuthLogoutPost Post /api/v2/auth/logout Logout
AuthAPI MeApiV2AuthMeGet Get /api/v2/auth/me Me
DfiqAPI ConfigApiV2DfiqConfigGet Get /api/v2/dfiq/config Config
DfiqAPI DeleteApiV2DfiqDfiqIdDelete Delete /api/v2/dfiq/{dfiq_id} Delete
DfiqAPI DetailsApiV2DfiqDfiqIdGet Get /api/v2/dfiq/{dfiq_id} Details
DfiqAPI FromArchiveApiV2DfiqFromArchivePost Post /api/v2/dfiq/from_archive From Archive
DfiqAPI NewFromYamlApiV2DfiqFromYamlPost Post /api/v2/dfiq/from_yaml New From Yaml
DfiqAPI PatchApiV2DfiqDfiqIdPatch Patch /api/v2/dfiq/{dfiq_id} Patch
DfiqAPI SearchApiV2DfiqSearchPost Post /api/v2/dfiq/search Search
DfiqAPI ToArchiveApiV2DfiqToArchivePost Post /api/v2/dfiq/to_archive To Archive
DfiqAPI ValidateDfiqYamlApiV2DfiqValidatePost Post /api/v2/dfiq/validate Validate Dfiq Yaml
EntitiesAPI DeleteApiV2EntitiesEntityIdDelete Delete /api/v2/entities/{entity_id} Delete
EntitiesAPI DetailsApiV2EntitiesEntityIdGet Get /api/v2/entities/{entity_id} Details
EntitiesAPI NewApiV2EntitiesPost Post /api/v2/entities/ New
EntitiesAPI PatchApiV2EntitiesEntityIdPatch Patch /api/v2/entities/{entity_id} Patch
EntitiesAPI SearchApiV2EntitiesSearchPost Post /api/v2/entities/search Search
EntitiesAPI TagApiV2EntitiesTagPost Post /api/v2/entities/tag Tag
GraphAPI AddApiV2GraphAddPost Post /api/v2/graph/add Add
GraphAPI DeleteApiV2GraphRelationshipIdDelete Delete /api/v2/graph/{relationship_id} Delete
GraphAPI EditApiV2GraphRelationshipIdPatch Patch /api/v2/graph/{relationship_id} Edit
GraphAPI MatchApiV2GraphMatchPost Post /api/v2/graph/match Match
GraphAPI SearchApiV2GraphSearchPost Post /api/v2/graph/search Search
GraphAPI SwapApiV2GraphRelationshipIdSwapPost Post /api/v2/graph/{relationship_id}/swap Swap
ImportDataAPI ImportMispJsonApiV2ImportDataImportMispJsonPost Post /api/v2/import_data/import_misp_json Import Misp Json
ImportMispJsonAPI ImportMispJsonApiV2ImportDataImportMispJsonPost_0 Post /api/v2/import_data/import_misp_json Import Misp Json
IndicatorsAPI DeleteApiV2IndicatorsIndicatorIdDelete Delete /api/v2/indicators/{indicator_id} Delete
IndicatorsAPI DetailsApiV2IndicatorsIndicatorIdGet Get /api/v2/indicators/{indicator_id} Details
IndicatorsAPI NewApiV2IndicatorsPost Post /api/v2/indicators/ New
IndicatorsAPI PatchApiV2IndicatorsIndicatorIdPatch Patch /api/v2/indicators/{indicator_id} Patch
IndicatorsAPI SearchApiV2IndicatorsSearchPost Post /api/v2/indicators/search Search
IndicatorsAPI TagApiV2IndicatorsTagPost Post /api/v2/indicators/tag Tag
ObservablesAPI AddContextApiV2ObservablesObservableIdContextPost Post /api/v2/observables/{observable_id}/context Add Context
ObservablesAPI AddTextApiV2ObservablesAddTextPost Post /api/v2/observables/add_text Add Text
ObservablesAPI BulkAddApiV2ObservablesBulkPost Post /api/v2/observables/bulk Bulk Add
ObservablesAPI DeleteApiV2ObservablesObservableIdDelete Delete /api/v2/observables/{observable_id} Delete
ObservablesAPI DeleteContextApiV2ObservablesObservableIdContextDeletePost Post /api/v2/observables/{observable_id}/context/delete Delete Context
ObservablesAPI DetailsApiV2ObservablesObservableIdGet Get /api/v2/observables/{observable_id} Details
ObservablesAPI NewApiV2ObservablesPost Post /api/v2/observables/ New
ObservablesAPI NewExtendedApiV2ObservablesExtendedPost Post /api/v2/observables/extended New Extended
ObservablesAPI ObservablesRootApiV2ObservablesGet Get /api/v2/observables/ Observables Root
ObservablesAPI PatchApiV2ObservablesObservableIdPatch Patch /api/v2/observables/{observable_id} Patch
ObservablesAPI SearchApiV2ObservablesSearchPost Post /api/v2/observables/search Search
ObservablesAPI TagObservableApiV2ObservablesTagPost Post /api/v2/observables/tag Tag Observable
SystemAPI GetConfigApiV2SystemConfigGet Get /api/v2/system/config Get Config
SystemAPI GetWorkerStatusApiV2SystemWorkersGet Get /api/v2/system/workers Get Worker Status
SystemAPI RestartWorkerApiV2SystemRestartworkerWorkerNamePost Post /api/v2/system/restartworker/{worker_name} Restart Worker
TagsAPI DeleteApiV2TagsTagIdDelete Delete /api/v2/tags/{tag_id} Delete
TagsAPI DetailsApiV2TagsTagIdGet Get /api/v2/tags/{tag_id} Details
TagsAPI MergeApiV2TagsMergePost Post /api/v2/tags/merge Merge
TagsAPI NewApiV2TagsPost Post /api/v2/tags/ New
TagsAPI SearchApiV2TagsSearchPost Post /api/v2/tags/search Search
TagsAPI UpdateApiV2TagsTagIdPut Put /api/v2/tags/{tag_id} Update
TasksAPI DeleteExportApiV2TasksExportExportNameDelete Delete /api/v2/tasks/export/{export_name} Delete Export
TasksAPI ExportContentApiV2TasksExportExportIdContentGet Get /api/v2/tasks/export/{export_id}/content Export Content
TasksAPI NewExportApiV2TasksExportNewPost Post /api/v2/tasks/export/new New Export
TasksAPI PatchExportApiV2TasksExportExportNamePatch Patch /api/v2/tasks/export/{export_name} Patch Export
TasksAPI RunApiV2TasksTaskNameRunPost Post /api/v2/tasks/{task_name}/run Run
TasksAPI SearchApiV2TasksSearchPost Post /api/v2/tasks/search Search
TasksAPI ToggleApiV2TasksTaskNameTogglePost Post /api/v2/tasks/{task_name}/toggle Toggle
TemplatesAPI RenderApiV2TemplatesRenderPost Post /api/v2/templates/render Render
TemplatesAPI SearchApiV2TemplatesSearchPost Post /api/v2/templates/search Search
UsersAPI CreateApiV2UsersPost Post /api/v2/users/ Create
UsersAPI DeleteApiV2UsersUserIdDelete Delete /api/v2/users/{user_id} Delete
UsersAPI GetApiV2UsersUserIdGet Get /api/v2/users/{user_id} Get
UsersAPI ResetApiKeyApiV2UsersResetApiKeyPost Post /api/v2/users/reset-api-key Reset Api Key
UsersAPI ResetPasswordApiV2UsersResetPasswordPost Post /api/v2/users/reset-password Reset Password
UsersAPI SearchApiV2UsersSearchPost Post /api/v2/users/search Search
UsersAPI ToggleApiV2UsersTogglePost Post /api/v2/users/toggle Toggle

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

APIKeyHeader

  • Type: API key
  • API key parameter name: x-yeti-apikey
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: APIKeyHeader and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		goyeti.ContextAPIKeys,
		map[string]goyeti.APIKey{
			"APIKeyHeader": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

OAuth2PasswordBearer

  • Type: OAuth
  • Flow: password
  • Authorization URL:
  • Scopes: N/A

Example

auth := context.WithValue(context.Background(), goyeti.ContextAccessToken, "ACCESSTOKENSTRING")
r, err := client.Service.Operation(auth, args)

Or via OAuth2 module to automatically refresh tokens and perform user authentication.

import "golang.org/x/oauth2"

/* Perform OAuth2 round trip request and obtain a token */

tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
auth := context.WithValue(oauth2.NoContext, goyeti.ContextOAuth2, tokenSource)
r, err := client.Service.Operation(auth, args)

APIKeyCookie

  • Type: API key
  • API key parameter name: yeti_session
  • Location:

Note, each API key must be added to a map of map[string]APIKey where the key is: APIKeyCookie and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		goyeti.ContextAPIKeys,
		map[string]goyeti.APIKey{
			"APIKeyCookie": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

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