httpKey

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2017 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package httpKey provides a Service that is a HTTP client to an external key service that can respond to HTTP requests defined here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyBySecretRequest

type KeyBySecretRequest struct {
	Secret string `json:"secret"`
}

KeyBySecretRequest is a structure that is passed as JSON-encoded body to KeyBySecret HTTP request.

type RegenerateSecretResponse

type RegenerateSecretResponse struct {
	Secret string `json:"secret"`
}

RegenerateSecretResponse is a structure that is returned as JSON-encoded body from RegenerateSecret HTTP request.

type Service

type Service struct {
	// Client provides HTTP request making functionality.
	Client *apiClient.Client
}

Service implements gopherpit.com/gopherpit/services/key.Service interface.

func NewService

func NewService(c *apiClient.Client) *Service

NewService creates a new Service and injects key.ErrorRegistry in the API Client.

func (Service) CreateKey

func (s Service) CreateKey(ref string, o *key.Options) (k *key.Key, err error)

CreateKey creates a new Key with Options by making a HTTP POST request to {Client.Endpoint}/keys/{ref}. Post body is a JSON-encoded key.Options instance.

func (Service) DeleteKey

func (s Service) DeleteKey(ref string) error

DeleteKey deletes an existing Key by making a HTTP DELETE request to {Client.Endpoint}/keys/{ref}.

func (Service) KeyByRef

func (s Service) KeyByRef(ref string) (k *key.Key, err error)

KeyByRef retrieves a Key instance by making a HTTP GET request to {Client.Endpoint}/keys/{ref}.

func (Service) KeyBySecret

func (s Service) KeyBySecret(secret string) (k *key.Key, err error)

KeyBySecret validates a password of an existing User by making a HTTP POST request to {Client.Endpoint}/authenticate. Request body is a JSON-encoded KeyBySecretRequest instance. Expected response body is a JSON-encoded instance of key.Key.

func (Service) Keys

func (s Service) Keys(startID string, limit int) (page key.KeysPage, err error)

Keys retrieves a paginated list of Key instances by making a HTTP GET request to {Client.Endpoint}/keys.

func (Service) RegenerateSecret

func (s Service) RegenerateSecret(ref string) (secret string, err error)

RegenerateSecret generates a new secret key by making a HTTP POST request to {Client.Endpoint}/keys/{ref}/secret.

func (Service) UpdateKey

func (s Service) UpdateKey(ref string, o *key.Options) (k *key.Key, err error)

UpdateKey changes the data of an existing Key by making a HTTP PUT request to {Client.Endpoint}/keys/{ref}. Post body is a JSON-encoded key.Options instance.

Jump to

Keyboard shortcuts

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