Giter Club home page Giter Club logo

couchdb_go's Introduction

Go API client for couchdb_go

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{}.

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: 4.0.0
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Installation

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")

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

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

Templated Server URL

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.

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 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",
	},
})

Documentation for API Endpoints

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.

Documentation For Models

Documentation For Authorization

BasicAuth

  • 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)

JwtAuth

  • 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.

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

couchdb_go's People

Contributors

rossmerr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.