Code Monkey home page Code Monkey logo

go-1password-cli's Introduction

go-1password-cli

Super thin wrapper around 1passwords op CLI tool.

Note: This is not for the secret automation API, but for the CLI tool. There is no authentication, you need to have the op CLI tool installed and logged in.

1Password will prompt you if you want to allow access on usage.

Installation

go get github.com/dvcrn/go-1password-cli

Usage

package main

import (
    "github.com/dvcrn/go-1password-cli/op"
)

func main() {
	client := op.NewOpClient()

	// get all vaults
	vaults, err := client.Vaults()

	// get a specific vault
	vault, err := client.Vault("Private")
	vault, err := client.Vault("<vaultID>")

	// get item
	item, err := client.Item("Netflix")
	item, err := client.Item("<itemID>")
}

API Reference

type Item

type Item struct {
    AdditionalInformation string    `json:"additional_information,omitempty"`
    Category              string    `json:"category"`
    CreatedAt             time.Time `json:"created_at"`
    Favorite              bool      `json:"favorite,omitempty"`
    ID                    string    `json:"id"`
    LastEditedBy          string    `json:"last_edited_by"`
    Tags                  []string  `json:"tags,omitempty"`
    Title                 string    `json:"title"`
    UpdatedAt             time.Time `json:"updated_at"`
    Urls                  []struct {
        Href    string `json:"href"`
        Label   string `json:"label,omitempty"`
        Primary bool   `json:"primary,omitempty"`
    }   `json:"urls,omitempty"`
    Vault struct {
        ID   string `json:"id"`
        Name string `json:"name"`
    }   `json:"vault"`
    Version int `json:"version"`
}

type Vault

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

type OpClient

type OpClient struct{}

func NewOpClient

func NewOpClient() *OpClient

func (*OpClient) Item

func (c *OpClient) Item(itemIDOrName string) (*Item, error)

Item returns an item by its ID or name, across all Vaults the user has access to To get items scoped to a specific Vault, use VaultItem()

func (*OpClient) ReadItemField

func (c *OpClient) ReadItemField(vaultIdOrName string, itemIdOrName string, fieldName string) (string, error)

ReadItemField does a lookup of a specific field within an item, within a vault This is equivalent to op read op://<vault>/<item>/<field>

func (*OpClient) Vault

func (c *OpClient) Vault(vaultIDOrName string) (*Vault, error)

Vault retrieves a vault by its ID or name If you have a Vault named "Private", you can specify this as either "Private" or with its ID

func (*OpClient) VaultItem

func (c *OpClient) VaultItem(itemIDOrName string, vaultIDOrName string) (*Item, error)

VaultItem returns an item by it's ID or name, within the specified Vault To get items across all Vaults, use Item()

func (*OpClient) Vaults

func (c *OpClient) Vaults() ([]*Vault, error)

Vaults returns a list of all vaults in the current 1Password account

go-1password-cli's People

Contributors

dvcrn avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.