Note This is not a definitive implementation of the CouchDB API, it's missing a lot of the endpoints for server/database managment and everything for attachments all COPY operations and probably a few other parts.
It also targets golang, as such the '#/definitions/Document' is intentionally left empty to generate a go interface
, which you can then cast to a map[string]interface{}
.
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: 4.0.0
- Package version: 1.0.0
- Build package: org.openapitools.codegen.languages.GoClientCodegen
Install the following dependencies:
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:
import couchdb_go "github.com/GIT_USER_ID/GIT_REPO_ID"
To use a proxy, set the environment variable HTTP_PROXY
:
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
Default configuration comes with Servers
field that contains server objects as defined in the OpenAPI specification.
For using other server than the one defined on index 0 set context value sw.ContextServerIndex
of type int
.
ctx := context.WithValue(context.Background(), couchdb_go.ContextServerIndex, 1)
Templated server URL is formatted using default variables from configuration or from context value sw.ContextServerVariables
of type map[string]string
.
ctx := context.WithValue(context.Background(), couchdb_go.ContextServerVariables, map[string]string{
"basePath": "v2",
})
Note, enum values are always validated and all unused variables are silently ignored.
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 sw.ContextOperationServerIndices
and sw.ContextOperationServerVariables
context maps.
ctx := context.WithValue(context.Background(), couchdb_go.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), couchdb_go.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})
All URIs are relative to https://virtserver.swaggerhub.com/RossMerr/CouchDB/4.0.0
Class | Method | HTTP request | Description |
---|---|---|---|
DatabaseApi | BulkDocs | Post /{db}/_bulk_docs | The bulk document API allows you to create and update multiple documents at the same time within a single request. |
DatabaseApi | BulkGet | Post /{db}/_bulk_get | This method can be called to query several documents in bulk. |
DatabaseApi | DbSecurityGet | Get /{db}/_security | Returns the current security object from the specified database. |
DatabaseApi | Delete | Delete /{db} | Deletes the specified database, and all the documents and attachments contained within it. |
DatabaseApi | DesignDocAllGet | Get /{db}/_design_docs | Returns a JSON structure of all of the design documents in a given database. |
DatabaseApi | DesignDocAllPost | Post /{db}/_design_docs | POST _design_docs functionality supports identical parameters and behavior as specified in the GET /{db}/_design_docs |
DatabaseApi | DocGetAll | Get /{db}/_all_docs | Executes the built-in _all_docs view |
DatabaseApi | DocPostAll | Post /{db}/_all_docs | Executes the built-in _all_docs view |
DatabaseApi | Exists | Head /{db} | Returns the HTTP Headers containing a minimal amount of information about the specified database. |
DatabaseApi | Get | Get /{db} | Gets information about the specified database. |
DatabaseApi | Put | Put /{db} | Creates a new database. |
DatabaseApi | SbSecurityPut | Put /{db}/_security | Sets the security object for the given database. |
DesignDocumentsApi | DesignDocDelete | Delete /{db}/_design/{ddoc} | Deletes the specified document from the database. You must supply the current (latest) revision, either by using the rev parameter to specify the revision. |
DesignDocumentsApi | DesignDocExists | Head /{db}/_design/{ddoc} | Returns the HTTP Headers containing a minimal amount of information about the specified design document. |
DesignDocumentsApi | DesignDocGet | Get /{db}/_design/{ddoc} | Returns the contents of the design document specified with the name of the design document and from the specified database from the URL. |
DesignDocumentsApi | DesignDocInfo | Head /{db}/_design/{ddoc}/_info | Obtains information about the specified design document, including the index, index size and current status of the design document and associated index information. |
DesignDocumentsApi | DesignDocPut | Put /{db}/_design/{ddoc} | The PUT method creates a new named design document, or creates a new revision of the existing design document. |
DesignDocumentsApi | DesignDocSearch | Get /{db}/_design/{ddoc}/_search/{index} | Executes a search request against the named index in the specified design document. |
DesignDocumentsApi | DesignDocSearchInfo | Get /{db}/_design/{ddoc}/_search_info/{index} | Executes a search request against the named index in the specified design document. |
DesignDocumentsApi | DesignDocView | Get /{db}/_design/{ddoc}/_view/{view} | Executes the specified view function from the specified design document. |
DesignDocumentsApi | DesignDocViewPost | Post /{db}/_design/{ddoc}/_view/{view} | Executes the specified view function from the specified design document. |
DocumentApi | DocDelete | Delete /{db}/{docid} | Marks the specified document as deleted by adding a field _deleted with the value true. |
DocumentApi | DocGet | Get /{db}/{docid} | Returns document by the specified docid from the specified db. Unless you request a specific revision, the latest revision of the document will always be returned. |
DocumentApi | DocInfo | Head /{db}/{docid} | Returns the HTTP Headers containing a minimal amount of information about the specified document. |
DocumentApi | DocPut | Put /{db}/{docid} | The PUT method creates a new named document, or creates a new revision of the existing document. Unlike the POST /{db}, you must specify the document ID in the request URL. |
DocumentApi | Post | Post /{db} | Creates a new document in the specified database, using the supplied JSON document structure. |
IndexApi | DbFindPost | Post /{db}/_find | Finds the document. |
IndexApi | DbIndexGet | Get /{db}/_index | Returns the current indexes object from the specified database. |
IndexApi | DbPartitionFindPost | Post /{db}/_partition/{partition}/_find | Finds the document. |
IndexApi | IndexDelete | Delete /{db}/_index/{designdoc}/json/{name} | |
IndexApi | SbIndexPost | Post /{db}/_index | Sets the index for the given database. |
PartitionApi | PartitionDesignDocSearch | Get /{db}/_partition/{partition}/_design/{ddoc}/_search/{index} | Executes a search request against the named index in the specified design document. |
PartitionApi | PartitionDesignDocView | Get /{db}/_partition/{partition}/_design/{ddoc}/_view/{view} | Executes the specified view function from the specified design document. |
PartitionApi | PartitionDesignDocViewPost | Post /{db}/_partition/{partition}/_design/{ddoc}/_view/{view} | Executes the specified view function from the specified design document. |
PartitionApi | PartitionDocGetAll | Get /{db}/_partition/{partition}/_all_docs | Executes the built-in _all_docs view |
PartitionApi | PartitionInfo | Get /{db}/_partition/{partition} | This endpoint returns information describing the provided partition. It includes document and deleted document counts along with external and active data sizes. |
ServerApi | ActiveTasks | Get /_active_tasks | List of running tasks, including the task type, name, status and process ID. |
ServerApi | AllDBs | Get /_all_dbs | Returns a list of all the databases in the CouchDB instance. |
ServerApi | ClusterSetupGet | Get /_cluster_setup | Returns the status of the node or cluster, per the cluster setup wizard. |
ServerApi | ClusterSetupPost | Post /_cluster_setup | Configure a node as a single (standalone) node, as part of a cluster, or finalise a cluster. |
ServerApi | DBsInfo | Post /_dbs_info | Returns information of a list of the specified databases in the CouchDB instance. |
ServerApi | Membership | Get /_membership | Displays the nodes that are part of the cluster as cluster_nodes. |
ServerApi | MetaInformation | Get / | Accessing the root of a CouchDB instance returns meta information about the instance. |
ServerApi | Replication | Post /_replicate | Request, configure, or stop, a replication operation. |
ServerApi | SearchAnalyze | Post /_search_analyze | Tests the results of Lucene analyzer tokenization on sample text. |
ServerApi | Up | Get /_up | Confirms that the server is up, running, and ready to respond to requests. |
- Admins
- All
- BasicDoc
- Body
- Body1
- Body2
- Body3
- Body4
- Body5
- BulkResponse
- Cluster
- Database
- DatabaseCluster
- DatabaseProps
- DatabaseSizes
- DesignDoc
- DocumentOK
- ErrorBulkGetResponse
- ErrorResponse
- Index
- IndexDefinitions
- IndexDefinitionsDef
- IndexDefinitionsDefField
- IndexResponse
- Indexes
- InlineResponse200
- InlineResponse2001
- InlineResponse2002
- InlineResponse2003
- InlineResponse2004
- InlineResponse2005
- InlineResponse2006
- InlineResponse2006ExecutionStats
- InlineResponse2007
- InlineResponse2008
- Keys
- Members
- OK
- Pagination
- Partition
- PartitionSizes
- Query
- Replicate
- ReplicateCreateTargetParams
- Replication
- ReplicationHistory
- Request
- RequestHeaders
- Results
- ResultsDocs
- ResultsResults
- Row
- SearchIndex
- Server
- ServerVendor
- Task
- ViewIndex
- ViewIndexSizes
- Type: HTTP basic authentication
Example
auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{
UserName: "username",
Password: "password",
})
r, err := client.Service.Operation(auth, args)
- Type: API key
- API key parameter name: Authorization
- Location: HTTP header
Note, each API key must be added to a map of map[string]APIKey
where the key is: Authorization and passed in as the auth context for each request.
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