opcli

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CategoryAPICredential        = "API Credential"
	CategoryBankAccount          = "Bank Account"
	CategoryCreditCard           = "Credit Card"
	CategoryDatabase             = "Database"
	CategoryDocument             = "Document"
	CategoryDriverLicense        = "Driver License"
	CategoryEmailAccount         = "Email Account"
	CategoryIdentity             = "Identity"
	CategoryLogin                = "Login"
	CategoryMedicalRecord        = "Medical Record"
	CategoryMembership           = "Membership"
	CategoryOutdoorLicense       = "Outdoor License"
	CategoryPassport             = "Passport"
	CategoryPassword             = "Password"
	CategoryRewardProgram        = "Reward Program"
	CategorySecureNote           = "Secure Note"
	CategoryServer               = "Server"
	CategorySocialSecurityNumber = "Social Security Number"
	CategorySoftwareLicense      = "Software License"
	CategorySSHKey               = "SSH Key"
	CategoryWirelessRouter       = "Wireless Router"
)
View Source
const (
	FieldAssignmentTypeConcealed = "concealed"
	FieldAssignmentTypeText      = "text"
	FieldAssignmentTypeEmail     = "email"
	FieldAssignmentTypeURL       = "url"
	FieldAssignmentTypeDate      = "date"
	FieldAssignmentTypeMonthYear = "monthYear"
	FieldAssignmentTypePhone     = "phone"
)
View Source
const (
	FieldTypeAddress          = "address"
	FieldTypeConcealed        = "concealed"
	FieldTypeCreditCardNumber = "ccnum"
	FieldTypeCreditCardType   = "cctype"
	FieldTypeDate             = "date"
	FieldTypeEmail            = "email"
	FieldTypeFile             = "file"
	FieldTypeGender           = "gender"
	FieldTypeMenu             = "menu"
	FieldTypeMonthYear        = "monthYear"
	FieldTypeOTP              = "OTP"
	FieldTypePhone            = "phone"
	FieldTypeReference        = "reference"
	FieldTypeSSHKey           = "sshkey"
	FieldTypeString           = "string"
	FieldTypeUnknown          = ""
	FieldTypeURL              = "URL"
)
View Source
const (
	FieldPurposeNotes    = "NOTES"
	FieldPurposePassword = "PASSWORD"
	FieldPurposeUsername = "USERNAME"
)
View Source
const (
	PasswordStrengthTerrible  = "TERRIBLE"
	PasswordStrengthWeak      = "WEAK"
	PasswordStrengthFair      = "FAIR"
	PasswordStrengthGood      = "GOOD"
	PasswordStrengthVeryGood  = "VERY_GOOD"
	PasswordStrengthExcellent = "EXCELLENT"
	PasswordStrengthFantastic = "FANTASTIC"
)
View Source
const (
	ItemStateArchived = "ARCHIVED"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CLI

type CLI struct {
	// Account specifies the account to use when executing commands.
	// Supported values are account shorthand, sign-in address, account ID, or user ID.
	Account string

	// Config specifies the 1Password CLI configuration directory to use.
	Config string

	// Path specifies the absolute path to the 1Password CLI executable.
	// When not set (default), exec.LookPath() will be utilized to find the `op` executable on $PATH.
	Path string
}

CLI represents the 1Password CLI.

func (*CLI) ArchiveItem

func (c *CLI) ArchiveItem(name string) error

ArchiveItem archives the item specified by its name, ID, or sharing link.

func (*CLI) CreateItem

func (c *CLI) CreateItem(item *Item) (*Item, error)

CreateItem creates a new item and returns it with all the fileds like ID filled.

--dry-run                      Perform a dry run of the command and output a preview of the resulting item.
--generate-password[=recipe]   Give the item a randomly generated password.

func (*CLI) DeleteItem

func (c *CLI) DeleteItem(name string) error

DeleteItem permanently deletes an item specified by its name, ID, or sharing link.

func (*CLI) GetItem

func (c *CLI) GetItem(name string, filters ...Filter) (*Item, error)

GetItem returns the details of an item specified by its name, ID, or sharing link.

Supported filters:

  • WithIncludeArchive() Include items in the Archive.
  • WithVault() Only list items in this vault.

func (*CLI) ListItems

func (c *CLI) ListItems(filters ...Filter) ([]Item, error)

ListItems returns a list of all items the account has read access to. Excludes items in the Archive by default.

Supported filters:

  • WithIncludeArchive() Include items in the Archive.
  • WithCategories() Only list items in these categories (comma-separated).
  • WithFavorite() Only list favorite items
  • WithTags() Only list items with these tags (comma-separated).
  • WithVault() Only list items in this vault.

func (CLI) Version

func (c CLI) Version() (string, error)

Version returns 1Password CLI version.

type Category

type Category string

func (*Category) UnmarshalText

func (c *Category) UnmarshalText(text []byte) error

type Field

type Field struct {
	ID              string          `json:"id"`
	Section         Section         `json:"section"`
	Type            FieldType       `json:"type"`
	Purpose         FieldPurpose    `json:"purpose"`
	Label           string          `json:"label"`
	Value           string          `json:"value"`
	TOTP            string          `json:"totp"`
	Entropy         int64           `json:"entropy"`
	PasswordDetails PasswordDetails `json:"password_details"`
	Reference       string          `json:"reference"`
}

type FieldAssignment

type FieldAssignment struct {
	Label   string              `json:"label"`
	Type    FieldAssignmentType `json:"type"`
	Value   string              `json:"value"`
	Purpose FieldPurpose        `json:"purpose"`
}

type FieldAssignmentType

type FieldAssignmentType string

type FieldPurpose

type FieldPurpose string

type FieldType

type FieldType string

func (*FieldType) UnmarshalText

func (f *FieldType) UnmarshalText(text []byte) error

type File

type File struct {
	ID          string  `json:"id"`
	Name        string  `json:"name"`
	Size        int64   `json:"size"`
	ContentPath string  `json:"content_path"`
	Section     Section `json:"section"`
}

type Filter

type Filter func() []string

Filter represents a filter flag passed to 1Password CLI some commands.

func IncludeArchive

func IncludeArchive() Filter

IncludeArchive expands item list to include items in the Archive.

func WithCategories

func WithCategories(categories ...Category) Filter

WithCategories limits results to only include items matching given categories.

func WithFavorite

func WithFavorite() Filter

WithFavorite limits results to only include favorite items.

func WithGroup

func WithGroup(name string) Filter

WithGroup limits results to only include resources from the given group.

func WithTags

func WithTags(tags ...string) Filter

WithTags limits results to only include items matching given tags.

func WithVault

func WithVault(name string) Filter

WithVault limits results to only include resources from the given vault.

type Item

type Item struct {
	ID                    string    `json:"id"`
	Title                 string    `json:"title"`
	Favorite              bool      `json:"favorite"`
	Tags                  []string  `json:"tags"`
	Version               int       `json:"version"`
	State                 ItemState `json:"state"`
	Vault                 Vault     `json:"vault"`
	Category              Category  `json:"category"`
	LastEditedBy          string    `json:"last_edited_by"`
	CreatedAt             time.Time `json:"created_at"`
	UpdatedAt             time.Time `json:"updated_at"`
	AdditionalInformation string    `json:"additional_information"`
	URLs                  []URL     `json:"urls"`

	Sections []Section `json:"sections"`
	Fields   []Field   `json:"fields"`
	Files    []File    `json:"files"`
}

func (Item) Field

func (i Item) Field(name string) *Field

func (Item) FindFields

func (i Item) FindFields(matching func(f Field) bool) []Field

type ItemState

type ItemState string

type PasswordDetails

type PasswordDetails struct {
	Entropy   int64            `json:"entropy"`
	Generated bool             `json:"generated"`
	Strength  PasswordStrength `json:"strength"`
}

type PasswordStrength

type PasswordStrength string

type Section

type Section struct {
	ID    string `json:"id"`
	Label string `json:"label"`
}

type URL

type URL struct {
	Label   string `json:"label"`
	Primary bool   `json:"primary"`
	HRef    string `json:"href"`
}

type Vault

type Vault struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

Jump to

Keyboard shortcuts

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