Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update readme with examples #37

Merged
merged 1 commit into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Contributing

We love contributions! You are welcome to open a pull request, but it's a good idea to
open an issue and discuss your idea with us first.

Once you are ready to open a PR, please keep the following guidelines in mind:

1. Code should be `go fmt` compliant.
2. Types, structs and funcs should be documented.
3. Tests and linters pass.

## Getting set up

`xelon-sdk-go` uses go modules. Just fork this repo, clone your fork and off you go!
Run `make help` to see all available make commands.


## Running tests and lint

When working on code in this repository, tests and linters can be run via:

```shell
make lint test
```
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,67 @@
[![GoDoc](https://img.shields.io/badge/pkg.go.dev-doc-blue)](http://pkg.go.dev/github.com/Xelon-AG/xelon-sdk-go)

xelon-sdk-go is the official Xelon SDK for the Go programming language.

## Installation

```sh
# X.Y.Z is the version you need
go get github.com/Xelon-AG/xelon-sdk-go@vX.Y.Z


# for non Go modules usage or latest version
go get github.com/Xelon-AG/xelon-sdk-go
```

## Usage

```go
import "github.com/Xelon-AG/xelon-sdk-go"
```

Create a new Xelon client, then use the exposed services to access
different parts of the Xelon API.

### Authentication

Currently, Bearer token is the only method of authenticating with the API.
You can learn how to obtain it [here](https://www.xelon.ch/docs/xelon-api-101#authorize-youself).
Then use your token to create a new client:

```go
client := client := xelon.NewClient("my-secret-token")
```

If you want to specify more parameters by client initialization, use
`With...` methods and pass via option pattern:

```go
var opts []xelon.ClientOption
opts = append(opts, xelon.WithBaseURL(baseURL))
opts = append(opts, xelon.WithClientID(clientID))
opts = append(opts, xelon.WithUserAgent(userAgent))

client := client := xelon.NewClient("my-secret-token", opts...)
```

### Examples

List all ssh keys for the user.

```go
func main() {
client := xelon.NewClient("my-secret-token")

// list all ssh keys for the authenticated user
ctx := context.Background()
sshKeys, _, err := client.SSHKeys.List(ctx)
}
```

## Contributing

We love pull requests! Please see the [contribution guidelines](.github/CONTRIBUTING.md).

## License

This SDK is distributed under the Apache-2.0 license, see [LICENSE](LICENSE) for more information.