onetimesecret-go

module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2021 License: Apache-2.0

README

Go Api Client for onetimesecret.com

onetimesecret Go Report Card

This is a Go implementation of the onetimesecret.com api api. The module aims to provide a developer friendly interface for all endpoints exposed by the api.

Installation

go get github.com/chelnak/onetimesecret-go

Usage

package main

import (
 "context"
 "fmt"

 ots "github.com/chelnak/onetimesecret-go/onetimesecret"
)

func main() {

 // Build a new client
 client := ots.NewClient(
  ots.WithUsername("otsuser@domain.com"),
  ots.WithAPIKey("xxxxxxxx"),
 )

 // Send a request with context
 ctx := context.Background()
 response, err := client.GetStatus(ctx)
 if err != nil {
  panic(err)
 }

 fmt.Println(response.Status)

}
Using a custom http.Client instance
package main

import (
    ots "github.com/chelnak/onetimesecret-go/onetimesecret"
    "context"
)

func main() {

    // Create a custom http client instance
    customHttpClient := &http.Client{ ... }

    // Build a new ots client and use WithHttpClient option
    client := ots.NewClient(
        ots.WithUsername("otsuser@domain.com"),
        ots.WithApiKey("xxxxxxxx"),
        ots.WithHttpClient(customHttpClient)
    )

    // Send a request with context
    ctx := context.Background()
    response, err := client.GetStatus(ctx)
    if err != nil {
        panic(err)
    }

    fmt.Println(response.Status)
}

Note: By default, a default http.Client instance is used if one is not passed when creating a client instance.

More documentation can be found here.

Unit testing

go test -tags unit ./... -v

Examples

export OTS_USERNAME=otsuser@domain.com
export OTS_APIKEY=xxxxx

go test -tags example ./... -v

Releasing

Releases are tag based. From the main branch do the following:

git tag -a vX.X.X -m "Release vX.X.X some reason"
git push --follow-tags

Directories

Path Synopsis
Package onetimesecret is a Go client that wraps the REST api of https://onetimesecret.com.
Package onetimesecret is a Go client that wraps the REST api of https://onetimesecret.com.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL