Documentation ¶
Index ¶
- func DeleteDocument(token, url, databaseName, _id, _rev string) string
- func GetAllDBs(token, url string) []string
- func GetAllDocuments(token, url, dbName string) string
- func GetDBDetails(token, url, dbName string) string
- func GetDocument(token, url, databaseName, _id string) string
- func InsertBulkDocument(token, url, dbName string, jsons []string) string
- func InsertDocument(token, url, databaseName string, json []byte) bool
- func RemoveDB(token, dbName, url string) bool
- func UpdateDocument(token, url, databaseName, _id string) string
- type Auth
- type Conf
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteDocument ¶
DeleteDocument is delegated to retrieve a specific document by the related `_id` https://cloud.ibm.com/docs/services/Cloudant?topic=cloudant-documents#delete-a-document token: bearer auth header retrieved from RetrieveToken() url: URL related to the DB instance databaseName: DB that we want to retrieve the information _id: Key for retrieve the document
func GetAllDBs ¶
GetAllDBs is delegated to fetch and retrieve all DB(s) name from the Cloudant instance https://cloud.ibm.com/docs/services/Cloudant?topic=cloudant-databases#get-a-list-of-all-databases-in-the-account token: bearer auth header retrieved from RetrieveToken() host: URL related to the DB instance
func GetAllDocuments ¶
GetAllDocuments is delegated to retrieve all documents associated to the given DB https://cloud.ibm.com/docs/services/Cloudant?topic=cloudant-databases#get-documents token: bearer auth header retrieved from RetrieveToken() url: URL related to the DB instance dbName: DB that we want to retrieve the information
func GetDBDetails ¶
GetDBDetails is delegated to retrieve the information related to the given DB https://cloud.ibm.com/docs/services/Cloudant?topic=cloudant-databases#getting-database-details token: bearer auth header retrieved from RetrieveToken() url: URL related to the DB instance dbName: DB that we want to retrieve the information
func GetDocument ¶
GetDocument is delegated to retrieve a specific document by the related mandatory `_id` https://cloud.ibm.com/docs/services/Cloudant?topic=cloudant-documents#read-document token: bearer auth header retrieved from RetrieveToken() url: URL related to the DB instance databaseName: DB that we want to retrieve the information _id: Key for retrieve the document
func InsertBulkDocument ¶
InsertBulkDocument is delegated to insert a list of document. It will concatenate all the json in input and will insert all the document in a single request token: bearer auth header retrieved from RetrieveToken() url: URL related to the DB instance dbName: DB that we want to retrieve the information jsons: list of document that we want to insert in bulk
func InsertDocument ¶
InsertDocument is delegated to insert a new document into the given DB https://cloud.ibm.com/docs/services/Cloudant?topic=cloudant-documents#create-document token: bearer auth header retrieved from RetrieveToken() url: URL related to the DB instance databaseName: DB that we want to retrieve the information json: document to insert
func RemoveDB ¶
RemoveDB is delegated to delete the given DB https://cloud.ibm.com/docs/services/Cloudant?topic=cloudant-databases#deleting-a-database token: bearer auth header retrieved from RetrieveToken() url: URL related to the DB instance dbName: DB that we want to retrieve the information
func UpdateDocument ¶
UpdateDocument is delegated to update a specific document by the related mandatory '_id' parameter https://cloud.ibm.com/docs/services/Cloudant?topic=cloudant-documents#update token: bearer auth header retrieved from RetrieveToken() url: URL related to the DB instance databaseName: DB that we want to retrieve the information _id: Key for retrieve the document
Types ¶
type Auth ¶
type Auth struct { // USER:PASSWORD encoded for basic auth (basic auth headers) BasicAuth string // Cookie for authenticate the session (cookie) SessionCookie string // IAM Token related to IBM Cloud service (bearer auth headers) IAMToken string // URL related to the Cloudant instance DB DBUrl string }
Auth is delegated to store the necessary token for authenticate to the service Cloudant HTTP call can be made using one of authentication credential
func (Auth) CreateDB ¶
CreateDB is delegated to initializate a new database. https://cloud.ibm.com/docs/services/Cloudant?topic=cloudant-databases#create-database token: bearer auth header retrieved from RetrieveToken() url: URL related to the DB instance dbName: DB that we want to retrieve the information partitioned: boolean value for enabled partitioned option
func (Auth) GetSessionInfo ¶
GetSessionInfo is delegated to retrieve the information related to the current session
func (Auth) PingCloudant ¶
PingCloudant is delegated to verify that the Cloudant DB instance can be reached token: bearer auth header retrieved from RetrieveToken() host: URL related to the DB instance
type Conf ¶
type Conf struct { // Key used for retrieve the bearer token Apikey string `json:"apikey"` // Hostname of the cloudant instance Host string `json:"host"` IAMApikeyDescription string `json:"iam_apikey_description"` IAMApikeyName string `json:"iam_apikey_name"` IAMRoleCrn string `json:"iam_role_crn"` IAMServiceidCrn string `json:"iam_serviceid_crn"` // Password for authenticate to the service Password string `json:"password"` // Port for reach the server Port int `json:"port"` // Url using BasicAuth, avoid using this url with basicauth for performance URL string `json:"url"` // Username related to the Cloudant instance Username string `json:"username"` }
Conf is delegated to save the information related to the Cloudant account
func (Conf) GenerateCookie ¶
GenerateCookie is delegated to inititialize a new session cookie based https://cloud.ibm.com/docs/services/Cloudant?topic=cloudant-authentication#cookie-authentication The method use the username and password for initialize a new Cloudant session for authenticate into IBM Cloud Cloudant instance that have to be used as Authorization token NOTE: Every request have to be sent using the token retrieved by this method as a 'Bearer Authorization"
func (Conf) GenerateIBMToken ¶
GenerateIBMToken is delegated to retrieve the token for authenticate the HTTP request. It can be used for 3600 seconds https://cloud.ibm.com/docs/iam?topic=iam-iamtoken_from_apikey The method use the apikey related to your Cloudant instance for authenticate into the IBM Cloud, and return back the token that have to be used as Authorization token NOTE: Every request have to be sent using the token retrieved by this method as a 'Bearer Authorization"
func (Conf) InitAuth ¶
InitAuth is delegated to initialize the Authentication details for authenticate every request. The method will initialize the three method for authenticate the HTTP request: - BasicAuth -> Create the header for authenticate the request - SessionCookie -> Initialize a new session cookie-based and return the cookie for authenticate the request - IAMToken -> Retrieve the IAM token that expire after 3600 seconds