IBM / cloudant-go-sdk

Cloudant SDK for Go
Apache License 2.0
21 stars 12 forks source link

What is service? #554

Open callamd opened 5 days ago

callamd commented 5 days ago

The documentation is constantly referencing service without actually ever defining it.

I'd like the examples to actually show what is meant by service.

Here is an example:

import {
    "github.com/IBM/go-sdk-core/v5/core"
    "<appropriate-git-repo-url>/exampleservicev1"
}
...
// Create the authenticator.
authenticator, err := core.NewIamAuthenticatorBuilder().
    SetApiKey("myapikey").
    Build()
if err != nil {
    panic(err)
}

// Create the service options struct.
options := &exampleservicev1.ExampleServiceV1Options{
    Authenticator: authenticator,
}

// Construct the service instance.
service, err := exampleservicev1.NewExampleServiceV1(options)
if err != nil {
    panic(err)
}

// 'service' can now be used to invoke operations.

from here

What? Why don't we just say what we mean? What is service? Why is it not defined? It seems pretty important.

ricellis commented 5 days ago

Apologies that this was unclear. That documentation is part of the go-sdk-core a shared dependency used by multiple IBM Cloud Services. As such it is very generic and service in that context is referring to any IBM Cloud SDK service client.

So

options := &exampleservicev1.ExampleServiceV1Options{
    Authenticator: authenticator,
}

// Construct the service instance.
service, err := exampleservicev1.NewExampleServiceV1(options)

for Cloudant is:

options := &cloudantv1.CloudantV1Options{
    URL:           "https://YourCloudantURL.example",
    Authenticator: authenticator,
}

service, err := cloudantv1.NewCloudantV1(options)

I'll chat to the folks repsonsible for that shared documentation and see if we can get some context added around it and we'll take a look at whether we can link to it in a more helpful way.

In the meantime there are specific Cloudant examples of programmatic authentication with Go available in the Cloudant API docs that you may find more useful. If you need a specific snippet we'd be happy to help too, just let us know.