I know how to do it for views, for example:
http://127.0.0.1:8092/<my_bucket>/_design/all/_view/all?full_set=true&key=<my_document_key>&connection_timeout=60000
And I tried:
http://127.0.0.1:8091/contacts/hello
(after creating via the UI a document with the key hello).
And the response was "Not Found."
What am I doing wrong?
Thanks,
Michael
There is no REST API for retrieving documents by key. You can either write your own thin service layer that uses the client SDK internally, or as of Couchbase 4.0, use the N1QL REST API to get the document through a query by key:
SELECT * FROM bucket USE KEYS [docId];
You can read about using the N1QL service endpoint here: http://developer.couchbase.com/documentation/server/4.1/n1ql/n1ql-rest-api/index.html
(Edit: Changed N1QL syntax to actually work. Thanks Gerald.)
In following way we can access couchbase document
Syntax:
hostname:8091/pools/default/buckets/{bucketname}/docs/{docid}
http://localhost:8091/pools/default/buckets/Aggregation/docs/AvgSumAssuredByProduct
Where
To access bucket related, use api: http://localhost:8091/pools/default/buckets/
Bucket Name: Aggregation
docid : AvgSumAssuredByProduct
If you want to use it for development purpose then you can use CLI or admin console (UI).
In production you should ALWAYS use language specific client SDK. Couchbase SDKs are intelligent as they have details about cluster map. Client knows before hand about which node should be used for CRUD operation.
Related
I have already a code to retrieve the objects in the bucket using oci-java-sdk and this is working as expected. I would like to retrieve the URL of the file which was uploaded to the bucket in object storage and when I use this URL, this should redirect to the actual location without asking any credentials.
I saw preauthenticated requests but again i need to create one more request. I dont want to send one more request and want to get URL in the existing GetObjectResponse.
Any suggestions>
Thanks,
js
The URL of an object is not returned from the API but can be built using information you know (See Update Below!). The pattern is:
https://{api_endpoint}/n/{namespace_name}/b/{bucket_name}/o/{object_name}
Accessing that URL will (generally, see below) require authentication. Our authentication mechanism is described at:
https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/signingrequests.htm
Authentication is NOT required if you configure the bucket as a Public Bucket.
https://docs.cloud.oracle.com/en-us/iaas/Content/Object/Tasks/managingbuckets.htm?TocPath=Services%7CObject%20Storage%7C_____2#publicbuckets
As you mentioned, Pre-authenticated Requests (PARs) are an option. They are generally used in this situation, and they work well.
https://docs.cloud.oracle.com/en-us/iaas/Content/Object/Tasks/usingpreauthenticatedrequests.htm
Strictly speaking, it is also possible to use our Amazon S3 Compatible API...
https://docs.cloud.oracle.com/en-us/iaas/Content/Object/Tasks/s3compatibleapi.htm
...and S3's presigned URLs to generate (without involving the API) a URL that will work without additional authentication.
https://docs.aws.amazon.com/AmazonS3/latest/dev/ShareObjectPreSignedURL.html
Update: A teammate pointed out that the OCI SDK for Java now includes a getEndpoint method that can be used to get the hostname needed when querying the Object Storage API. https://docs.cloud.oracle.com/en-us/iaas/tools/java/1.25.3/com/oracle/bmc/objectstorage/ObjectStorage.html#getEndpoint--
I'd like to write an object to gcp object store, while using the x-goog-if-generation-match feature. Using #google-cloud/storage npm library, the file object does not seem to have an option for setting the required object generation.
What are the alternatives?
As you noticed, the #google-cloud/storage npm library doesn't support generation and metageneration preconditions.
As an alternative, you may use either the Storage XML API or the Storage JSON API which do support it. Depending on if you want to use one or the other, you'll be able to use preconditions via HTTP Headers or query string parameters. You'll find the whole list of those here.
Another alternative is to use some kind of optimistic locking:
get the generation id
write object
get the generation id again
repeat until generation after = generation before + 1
I'm using Couchbase Server 4.6.4 and I'd like to create a primary index for N1QL via REST API to automate my provision. Is it possible? I got it via web console.
Thanks
You can use the query service REST API (which is on port 8093 by default. E.g.,
curl http://don:don_pw#10.17.1.72:8093/query/service?statement=create%20primary%20index%20on%20default
If you want to automate the creation of indexes, you can add a class that automatically create everything during the startup:
Java Example:
https://github.com/couchbaselabs/try-cb-java/blob/master/src/main/java/trycb/util/StartupPreparations.java
UPDATE: removed my comment as I thought it wasn't possible.
What is the difference between Couchbase java-client and couchbase-client?
I can see bulk get operation in java-client but not in couchbase-client
Is it possible to do bulk get operation in if we use couchbase-client?
For couchbase-client you refer to REST API Couchbase?
if this its true SDK java client create connection with database directly and there are many functions to get, create and update documents
you can map document in java class and even if you want put your Example.java class directly in document in spring there are documentarion for implement this.
In other way with API you can send n1ql query the response contain the document in json format.
Depends on the implementation you want.
I recomended that you will use SDK JAVA
Good luck.
I'm attempting to query an REST service with fairly limited idea of how to approach it.
I'm using Delphi XE6 (upd 1)
The company providing the API have said that: "The API is implemented as JSON via SSL"
and they go on to say that:
Access to any API endpoint requires authentication via signed requests, created with publicand secret API
keys
I have the keys defined above.
The signature is an HMACSHA256 hash of a string containing the request contenttype, host,
URL, date timestamp (matching the request Date header) and request content (eg POST
parameters) separated by a single newline, and passed with the public key in a custom header
XAPIAuthorization along with the public key, in the format PUBLICKEY:SIGNATURE
I understand each request needs to be signed.
How do I sign an http request with Delphi XE6?
The confusion for me at the moment is it seems Delphi has a number of built-in components have accessing RSET servers and parsing the JSON returned. I can't see any obvious way of signing requests using these components.
Specifically is there any help from the built-in Rest components or do I have to provide my own solution?