pleasant

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Copyright © 2023 Martijn Evers

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	PathRootFolder   = "/api/v5/rest/folders/root"
	PathEntry        = "/api/v5/rest/entries"
	PathFolders      = "/api/v5/rest/folders"
	PathAccessLevels = "/api/v5/rest/accesslevels"
	PathSearch       = "/api/v5/rest/search"
	PathServerInfo   = "/api/v5/rest/GetServerInfo"
	PathPwStr        = "/api/v5/rest/passwordstrength"
)

Variables

View Source
var (
	ErrNotFound            = errors.New("error: the requested resource was not found")
	ErrBadRequest          = errors.New("error: bad request")
	ErrUnauthorized        = errors.New("error: unauthorized, please log in again")
	ErrInvalidCredentials  = errors.New("error: invalid or incomplete credentials")
	ErrPathStartIncorrect  = errors.New("error: path must start with 'Root/'")
	ErrInvalidResourceType = errors.New("error: invalid resource type, must be 'entry' or 'folder'")
	ErrNoResult            = errors.New("error: no matching entries or folders")
	ErrParentNotFound      = errors.New("error: parent folder not found")
	ErrAmbiguousResult     = errors.New("error: ambiguous result, multiple matching entries or folders")
	ErrDuplicateEntry      = errors.New("error: duplicate entry found, skipping creation")
	ErrDuplicateFolder     = errors.New("error: duplicate folder found, skipping creation")
	ErrArchiveNotEnabled   = errors.New("error: entry/folder/accessrowid does not exist or archiving is possibly disabled")
)

Functions

func CheckPrerequisites

func CheckPrerequisites(prereq ...*prerequisite) bool

func DeleteJsonString added in v0.2.0

func DeleteJsonString(baseUrl, path, jsonString, bearerToken string) (string, error)

func DuplicateEntryExists added in v0.0.2

func DuplicateEntryExists(baseUrl, jsonString, bearerToken string) (bool, error)

func DuplicateEntryId added in v0.1.0

func DuplicateEntryId(baseUrl, jsonString, bearerToken string) (string, error)

func DuplicateFolderExists added in v0.0.2

func DuplicateFolderExists(baseUrl, jsonString, bearerToken string) (bool, error)

func DuplicateFolderId added in v0.1.0

func DuplicateFolderId(baseUrl, jsonString, bearerToken string) (string, error)

func GetIdByResourcePath

func GetIdByResourcePath(baseUrl, resourcePath, resourceType, bearerToken string) (string, error)

func GetJsonBody

func GetJsonBody(baseUrl, path, bearerToken string) (string, error)

func GetParentIdByResourcePath

func GetParentIdByResourcePath(baseUrl, resourcePath, bearerToken string) (string, error)

func IsServerUrlSet

func IsServerUrlSet() *prerequisite

func IsTokenValid

func IsTokenValid() *prerequisite

func LoadConfig added in v0.5.0

func LoadConfig() (string, string)

func MarshalEntry added in v0.0.2

func MarshalEntry(entry *Entry) (string, error)

func MarshalFolder added in v0.0.2

func MarshalFolder(folder *Folder) (string, error)

func PasswordPrompt

func PasswordPrompt(label string) string

func PatchJsonString added in v0.1.0

func PatchJsonString(baseUrl, path, jsonString, bearerToken string) (string, error)

func PathAndNameMatching

func PathAndNameMatching(resourcePath, name string) bool

func PostJsonString

func PostJsonString(baseUrl, path, jsonString, bearerToken string) (string, error)

func PostSearch

func PostSearch(baseUrl, query, bearerToken string) (string, error)

func PrettyPrintJson added in v0.2.0

func PrettyPrintJson(jsonString string) (string, error)

func StringPrompt

func StringPrompt(label string) string

func TrimDoubleQuotes added in v0.3.0

func TrimDoubleQuotes(str string) string

func WriteConfigFile

func WriteConfigFile(file, key string, value string) error

func WriteTokenFile

func WriteTokenFile(file, accessToken string, expiresAt int64) error

Types

type BearerToken

type BearerToken struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
}

func GetBearerToken

func GetBearerToken(baseUrl, username, password string) (*BearerToken, error)

type ConfigFile

type ConfigFile struct {
	ServerUrl string `yaml:"serverurl"`
	Timeout   int    `yaml:"timeout"`
}

type Entry added in v0.0.2

type Entry struct {
	Tags     []Tag
	Id       string
	Name     string
	Username string
	Password string
	Url      string
	Notes    string
	GroupId  string
	Expires  string
}

func UnmarshalEntry added in v0.0.2

func UnmarshalEntry(jsonString string) (*Entry, error)

type Folder added in v0.0.2

type Folder struct {
	Children []Entry
	Tags     []Tag
	Id       string
	Name     string
	ParentId string
	Notes    string
	Expires  string
}

func UnmarshalFolder added in v0.0.2

func UnmarshalFolder(jsonString string) (*Folder, error)

type FolderOutput added in v0.0.2

type FolderOutput struct {
	Credentials []Entry
	Children    []Folder
}

func UnmarshalFolderOutput added in v0.0.2

func UnmarshalFolderOutput(jsonString string) (*FolderOutput, error)

type SearchEntry added in v0.0.2

type SearchEntry struct {
	Id       string
	Name     string
	Username string
	Url      string
	Notes    string
	GroupId  string
	Path     string
}

type SearchGroup added in v0.0.2

type SearchGroup struct {
	Id       string
	Name     string
	FullPath string
}

type SearchOutput added in v0.0.2

type SearchOutput struct {
	Credentials []SearchEntry
	Groups      []SearchGroup
}

type Tag added in v0.0.3

type Tag struct {
	Name string
}

type Token

type Token struct {
	AccessToken string `yaml:"accesstoken"`
	ExpiresAt   int64  `yaml:"expiresat"`
}

type TokenFile

type TokenFile struct {
	Token *Token `yaml:"bearertoken"`
}

Jump to

Keyboard shortcuts

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