• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/H27-Jan-2021-

githooks/H27-Jan-2021-

mongodbatlas/H27-Jan-2021-

scripts/H27-Jan-2021-

.github_changelog_generatorH A D27-Jan-202179

.gitignoreH A D27-Jan-2021447

.golangci.ymlH A D27-Jan-20211.3 KiB

CHANGELOG.mdH A D27-Jan-202128.4 KiB

CODEOWNERS.mdH A D27-Jan-2021150

CONTRIBUTING.mdH A D27-Jan-20212.8 KiB

GNUmakefileH A D27-Jan-20211 KiB

LICENSEH A D27-Jan-202111.1 KiB

README.mdH A D27-Jan-20213.1 KiB

RELEASING.mdH A D27-Jan-2021597

SECURITY.mdH A D27-Jan-2021498

go.modH A D27-Jan-2021159

go.sumH A D27-Jan-20211 KiB

README.md

1# go-client-mongodb-atlas
2[![PkgGoDev](https://pkg.go.dev/badge/go.mongodb.org/atlas)](https://pkg.go.dev/go.mongodb.org/atlas)
3![CI](https://github.com/mongodb/go-client-mongodb-atlas/workflows/CI/badge.svg)
4
5A Go HTTP client for the [MongoDB Atlas API](https://docs.atlas.mongodb.com/api/).
6
7Note that atlas only supports the two most recent major versions of Go.
8
9## Usage
10
11```go
12import "go.mongodb.org/atlas/mongodbatlas"
13```
14
15Construct a new Atlas client, then use the various services on the client to
16access different parts of the Atlas API. For example:
17
18```go
19client := mongodbatlas.NewClient(nil)
20```
21
22The services of a client divide the API into logical chunks and correspond to
23the structure of the Atlas API documentation at
24https://docs.atlas.mongodb.com/api/.
25
26**NOTE:** Using the [context](https://godoc.org/context) package, one can easily
27pass cancellation signals and deadlines to various services of the client for
28handling a request. In case there is no context available, then `context.Background()`
29can be used as a starting point.
30
31### Authentication
32
33The mongodbatlas library does not directly handle authentication. Instead, when
34creating a new client, pass an http.Client that can handle Digest Access authentication for
35you. The easiest way to do this is using the [digest](https://github.com/mongodb-forks/digest)
36library, but you can always use any other library that provides an `http.Client`.
37If you have a private and public API token pair (https://docs.atlas.mongodb.com/configure-api-access),
38you can use it with the digest library using:
39
40```go
41import (
42    "context"
43    "log"
44
45    "github.com/mongodb-forks/digest"
46    "go.mongodb.org/atlas/mongodbatlas"
47)
48
49func main() {
50    t := digest.NewTransport("your public key", "your private key")
51    tc, err := t.Client()
52    if err != nil {
53        log.Fatalf(err.Error())
54    }
55
56    client := mongodbatlas.NewClient(tc)
57    orgs, _, err := client.Projects.GetAllProjects(context.Background(), nil)
58}
59```
60
61Note that when using an authenticated Client, all calls made by the client will
62include the specified tokens. Therefore, authenticated clients should
63almost never be shared between different users.
64
65## Versioning
66
67Each version of the client is tagged and the version is updated accordingly.
68
69To see the list of past versions, run `git tag`.
70
71To release a new version, first ensure that [Version](./mongodbatlas/mongodbatlas.go) is updated
72(i.e., before running `git push origin vx.y.z`, verify that `Version=x.y.z` should match the tag being pushed to GitHub)
73
74## Roadmap
75
76This library is being initially developed for [mongocli](https://github.com/mongodb/mongocli),
77[Atlas Terraform Provider](https://github.com/mongodb/terraform-provider-mongodbatlas),
78[Atlas Vault Plugin](https://github.com/hashicorp/vault-plugin-secrets-mongodbatlas), and
79[Atlas Cloudformation Provider](https://github.com/mongodb/mongodbatlas-cloudformation-resources)
80so API methods will likely be implemented in the order that they are
81needed by those projects.
82
83## Contributing
84
85See our [CONTRIBUTING.md](CONTRIBUTING.md) Guide.
86
87## License
88
89`go-client-mongodb-atlas` is released under the Apache 2.0 license. See [LICENSE](LICENSE)
90