client

package
v1.0.2-0...-5351147 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2018 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Overview

Package client provides a rest api client for the Team Password Manager api

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version holds the version number of the tpm rest api client library
	Version string
)

Functions

This section is empty.

Types

type APIVersion

type APIVersion struct {
	Version string `json:"version"`
	Date    string `json:"version_date"`
	Number  string `json:"api_version"`
}

APIVersion represents the version of the team password manager server

type Count

type Count struct {
	Items        int `json:"num_items"`
	Pages        int `json:"num_pages"`
	ItemsPerPage int `json:"num_items_per_page"`
}

Count describes how many items and pages exist in a collection such as projects or passwords.

type CustomField

type CustomField struct {
	Type  string `json:"type"`
	Label string `json:"label"`
	Data  string `json:"data"`
}

CustomField holds generic data associated with a Password

type GeneratedPassword

type GeneratedPassword struct {
	Value string `json:"password"`
}

GeneratedPassword represents a API response with the generated password

type Password

type Password struct {
	ID              string  `json:"id"`
	AccessInfo      string  `json:"access_info"`
	Archived        bool    `json:"archived"`
	CreatedBy       User    `json:"created_by"`
	CreatedOn       string  `json:"created_on"`
	Email           string  `json:"email"`
	ExpiryDate      string  `json:"expiry_date"`
	ExpiryStatus    int     `json:"expiry_status"`
	ExternalSharing bool    `json:"external_sharing"`
	ExternalURL     string  `json:"external_url"`
	Favorite        bool    `json:"favorite"`
	Locked          bool    `json:"locked"`
	ManagedBy       User    `json:"managed_by"`
	Name            string  `json:"name"`
	Notes           string  `json:"notes"`
	NumFiles        string  `json:"num_files"`
	Password        string  `json:"password"`
	Project         Project `json:"project"`
	Tags            string  `json:"tags"`
	UpdatedBy       User    `json:"updated_by"`
	UpdatedOn       string  `json:"updated_on"`
	Username        string  `json:"username"`

	CustomField1 CustomField `json:"custom_field1"`
	CustomField2 CustomField `json:"custom_field2"`
	CustomField3 CustomField `json:"custom_field3"`
	CustomField4 CustomField `json:"custom_field4"`
	CustomField5 CustomField `json:"custom_field5"`
	CustomField6 CustomField `json:"custom_field6"`
	CustomField7 CustomField `json:"custom_field7"`
	CustomField8 CustomField `json:"custom_field8"`
	CustomField9 CustomField `json:"custom_field9"`
}

Password represents a password from the team password manager API

func (*Password) UnmarshalJSON

func (v *Password) UnmarshalJSON(data []byte) error

UnmarshalJSON handles id's from team password manager as int and string

type Passwords

type Passwords []Password

Passwords is a collection of team password manager Password types

func (*Passwords) UnmarshalJSON

func (v *Passwords) UnmarshalJSON(data []byte) error

UnmarshalJSON handles id's from team password manager as int and string

type Project

type Project struct {
	ID        string `json:"id"`
	ParentID  int    `json:"parent_id"`
	Name      string `json:"name"`
	Notes     string `json:"notes"`
	Tags      string `json:"tags"`
	Archived  bool   `json:"archived"`
	Favorite  bool   `json:"favorite"`
	NumFiles  int    `json:"num_files"`
	CreatedOn string `json:"created_on"`
	CreatedBy User   `json:"created_by"`
	UpdatedOn string `json:"updated_on"`
	UpdatedBy User   `json:"updated_by"`
	ManagedBy User   `json:"managed_by"`
}

Project represents a team password manager Project

func (*Project) UnmarshalJSON

func (v *Project) UnmarshalJSON(data []byte) error

UnmarshalJSON handles id's from team password manager as int and string

type Projects

type Projects []Project

Projects is a collection of team password manager Project types

func (*Projects) UnmarshalJSON

func (v *Projects) UnmarshalJSON(data []byte) error

UnmarshalJSON handles id's from team password manager as int and string

type TpmClient

type TpmClient struct {
	Client      *http.Client
	Server      string
	Username    string
	Password    string
	ContentType string
	UserAgent   string
}

TpmClient represents the client that handles all interaction with the server

func New

func New(server string, username string, password string) TpmClient

New creates a new instance of TpmClient which can then be used to make api calls It configures the underlying net/http.client with a sensible timeout.

func (*TpmClient) GeneratePassword

func (client *TpmClient) GeneratePassword() (*GeneratedPassword, error)

GeneratePassword uses the team password manager API to generate a random password

func (*TpmClient) PasswordGet

func (client *TpmClient) PasswordGet(id string) (*Password, error)

PasswordGet fetches a single password by ID from the API

func (*TpmClient) PasswordList

func (client *TpmClient) PasswordList(search string) (Passwords, error)

PasswordList retrieves a list of password matching the given search from the API

func (*TpmClient) ProjectArchive

func (client *TpmClient) ProjectArchive(id string) error

ProjectArchive archives a project

func (*TpmClient) ProjectDelete

func (client *TpmClient) ProjectDelete(id string) error

ProjectDelete removes a project

func (*TpmClient) ProjectGet

func (client *TpmClient) ProjectGet(id string) (*Project, error)

ProjectGet fetches a single project by ID from the API

func (*TpmClient) ProjectList

func (client *TpmClient) ProjectList(search string) (Projects, error)

ProjectList retrieves a list of projects from the API

func (*TpmClient) ProjectUnarchive

func (client *TpmClient) ProjectUnarchive(id string) error

ProjectUnarchive unarchives a project

func (*TpmClient) Version

func (client *TpmClient) Version() (*APIVersion, error)

Version fetches the team password manager server verison. It returns a struct APIVersion and any error encountered

type User

type User struct {
	ID           int    `json:"id"`
	Name         string `json:"name"`
	Username     string `json:"username"`
	EmailAddress string `json:"email_address"`
	Role         string `json:"role"`
}

User represents a team password manager user

Jump to

Keyboard shortcuts

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