onepassword

package module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 7 Imported by: 35

README

1Password Go SDK

Build integrations that programmatically interact with 1Password.

Documentation | Examples


🚀 Get started

You can choose between two authentication methods for the 1Password Go SDK: local authorization prompts from the 1Password desktop app or automated authentication with a 1Password Service Account.

This project is licensed under MIT. Use of the 1Password APIs and services accessed through these tools is governed by the 1Password API Terms of Service.

Option 1: 1Password desktop app

1Password desktop app authentication is best for local integrations that require minimal setup from end users and sensitive workflows that require human-in-the-loop approval. To set up the SDK to authenticate with the 1Password app:

  1. Install the 1Password desktop app and sign in to your account in the app.

  2. Select your account or collection at the top of the sidebar, then navigate to Settings > Developer.

  3. Under Integrate with the 1Password SDKs, select Integrate with other apps.

  4. If you want to authenticate with biometrics, navigate to Settings > Security, then turn on the option to unlock using Touch ID, Windows Hello, or system authentication.

  5. Install the 1Password Go SDK in your project:

    go get github.com/1password/onepassword-sdk-go
    
  6. To use the Go SDK in your project, replace your-account-name in the code below with the name of your 1Password account as it appears at the top left sidebar of the 1Password desktop app.

package main

import (
    "context"
    "os"

    "github.com/1password/onepassword-sdk-go"
)

func main() {
    
    client, err := onepassword.NewClient(
                context.TODO(),
                onepassword.WithDesktopAppIntegration("your-account-name"),
                // TODO: Set the following to your own integration name and version.
                onepassword.WithIntegrationInfo("My 1Password Integration", "v1.0.0"),
    )
    if err != nil {
	// handle err
    }
    secret, err := client.Secrets().Resolve(context.TODO(), "op://vault/item/field")
    if err != nil {
        // handle err
    }
    // do something with the secret
}

Make sure to use secret reference URIs with the syntax op://vault/item/field to securely load secrets from 1Password into your code.

Option 2: 1Password Service Account

Service account authentication is best for automated access and limiting your integration to least privilege access. To set up the SDK to authenticate with a service account token:

  1. Create a service account and give it the appropriate permissions in the vaults where the items you want to use with the SDK are saved.

  2. Provision your service account token. We recommend provisioning your token from the environment. For example, to export your token to the OP_SERVICE_ACCOUNT_TOKEN environment variable:

    macOS or Linux

    export OP_SERVICE_ACCOUNT_TOKEN=<your-service-account-token>
    

    Windows

    $Env:OP_SERVICE_ACCOUNT_TOKEN = "<your-service-account-token>"
    
  3. Install the 1Password Go SDK in your project:

    go get github.com/1password/onepassword-sdk-go
    
  4. Use the Go SDK in your project:

package main

import (
    "context"
    "os"

    "github.com/1password/onepassword-sdk-go"
)

func main() {
    token := os.Getenv("OP_SERVICE_ACCOUNT_TOKEN")

    client, err := onepassword.NewClient(
                context.TODO(),
                onepassword.WithServiceAccountToken(token),
                // TODO: Set the following to your own integration name and version.
                onepassword.WithIntegrationInfo("My 1Password Integration", "v1.0.0"),
    )
    if err != nil {
	// handle err
    }
    secret, err := client.Secrets().Resolve(context.TODO(), "op://vault/item/field")
    if err != nil {
        // handle err
    }
    // do something with the secret
}

Make sure to use secret reference URIs with the syntax op://vault/item/field to securely load secrets from 1Password into your code.

Supported functionality

1Password SDKs are in active development. We're keen to hear what you'd like to see next. Let us know by upvoting or filing an issue.

Item management

Operations:

Field types:

  • API Keys
  • Passwords
  • Concealed fields
  • Text fields
  • Notes
  • SSH private keys, public keys, fingerprint and key type
  • One-time passwords
  • URLs
  • Websites (used to suggest and autofill logins)
  • Phone numbers
  • Credit card types
  • Credit card numbers
  • Emails
  • References to other items
  • Address
  • Date
  • MM/YY
  • File attachments and Document items
  • Menu
  • Passkeys

Vault management

User & access management

  • Provision users
  • Retrieve users
  • List users
  • Suspend users
  • Retrieve groups
  • List groups
  • Create groups
  • Update group membership

Environments management

Compliance & reporting

Authentication

Cross compilation

If you want to cross compile the Go SDK while using the 1Password desktop app to authenticate, you'll need to enable CGO.

CGO can be enabled either by default if your system permits that, or deliberately if your system doesn't permit that by:

  • Setting the CGO_ENABLED env var to 1.
  • Downloading and selecting the right cross-compiler depending on your desired target and host system.

📖 Learn more

Documentation

Overview

Code generated by typeshare 1.13.2. DO NOT EDIT.

Index

Constants

View Source
const (
	DefaultIntegrationName    = "Unknown"
	DefaultIntegrationVersion = "Unknown"
)
View Source
const ArchiveItems uint32 = 256
View Source
const CreateItems uint32 = 128
View Source
const DeleteItems uint32 = 512
View Source
const ExportItems uint32 = 4194304
View Source
const ImportItems uint32 = 2097152
View Source
const ManageVault uint32 = 2
View Source
const NoAccess uint32 = 0
View Source
const PrintItems uint32 = 8388608
View Source
const ReadItems uint32 = 32
View Source
const RecoverVault uint32 = 1
View Source
const RevealItemPassword uint32 = 16
View Source
const SendItems uint32 = 1048576
View Source
const UpdateItemHistory uint32 = 1024
View Source
const UpdateItems uint32 = 64

Variables

View Source
var Secrets = secretsUtil{}

Functions

This section is empty.

Types

type AddressFieldDetails added in v0.2.1

type AddressFieldDetails struct {
	// The street address
	Street string `json:"street"`
	// The city
	City string `json:"city"`
	// The country
	Country string `json:"country"`
	// The ZIP code
	Zip string `json:"zip"`
	// The state
	State string `json:"state"`
}

Additional attributes for OTP fields.

type AllowedRecipientType added in v0.1.6

type AllowedRecipientType string

The allowed recipient types of item sharing, enforced by account policy

const (
	// Recipients can be specified by email address
	AllowedRecipientTypeEmail AllowedRecipientType = "Email"
	// Recipients can be specified by domain
	AllowedRecipientTypeDomain AllowedRecipientType = "Domain"
)

type AllowedType added in v0.1.6

type AllowedType string

The allowed types of item sharing, enforced by account policy

const (
	// Allows creating share links with specific recipients
	AllowedTypeAuthenticated AllowedType = "Authenticated"
	// Allows creating public share links
	AllowedTypePublic AllowedType = "Public"
)

type AutofillBehavior added in v0.1.3

type AutofillBehavior string

Controls the auto-fill behavior of a website.

For more information, visit <https://support.1password.com/autofill-behavior/>

const (
	// Auto-fill any page that’s part of the website, including subdomains
	AutofillBehaviorAnywhereOnWebsite AutofillBehavior = "AnywhereOnWebsite"
	// Auto-fill only if the domain (hostname and port) is an exact match.
	AutofillBehaviorExactDomain AutofillBehavior = "ExactDomain"
	// Never auto-fill on this website
	AutofillBehaviorNever AutofillBehavior = "Never"
)

type Client

type Client struct {
	SecretsAPI      SecretsAPI
	ItemsAPI        ItemsAPI
	VaultsAPI       VaultsAPI
	EnvironmentsAPI EnvironmentsAPI
	GroupsAPI       GroupsAPI
	// contains filtered or unexported fields
}

Client represents an instance of the 1Password Go SDK client.

func NewClient

func NewClient(ctx context.Context, opts ...ClientOption) (*Client, error)

NewClient returns a 1Password Go SDK client using the provided ClientOption list.

func (*Client) Environments added in v0.4.1

func (c *Client) Environments() EnvironmentsAPI

func (*Client) Groups added in v0.4.0

func (c *Client) Groups() GroupsAPI

func (*Client) Items

func (c *Client) Items() ItemsAPI

func (*Client) Secrets

func (c *Client) Secrets() SecretsAPI

func (*Client) Vaults

func (c *Client) Vaults() VaultsAPI

type ClientOption

type ClientOption func(client *Client) error

func WithDesktopAppIntegration added in v0.4.0

func WithDesktopAppIntegration(accountName string) ClientOption

WithDesktopAppIntegration specifies a client should use the desktop app to authenticate. Set to your 1Password account name as shown at the top left sidebar of the app, or your account UUID.

func WithIntegrationInfo

func WithIntegrationInfo(name string, version string) ClientOption

WithIntegrationInfo specifies the name and version of the integration built using the 1Password Go SDK. If you don't know which name and version to use, use `DefaultIntegrationName` and `DefaultIntegrationVersion`, respectively.

func WithServiceAccountToken

func WithServiceAccountToken(token string) ClientOption

WithServiceAccountToken specifies the [1Password Service Account](https://developer.1password.com/docs/service-accounts) token to use to authenticate the SDK client. Read more about how to get started with service accounts: https://developer.1password.com/docs/service-accounts/get-started/#create-a-service-account

type DesktopSessionExpiredError added in v0.4.0

type DesktopSessionExpiredError struct {
	// contains filtered or unexported fields
}

func (*DesktopSessionExpiredError) Error added in v0.4.0

type DocumentCreateParams added in v0.2.0

type DocumentCreateParams struct {
	// The name of the file
	Name string `json:"name"`
	// The content of the file
	Content []byte `json:"content"`
}

type EnvironmentVariable added in v0.4.1

type EnvironmentVariable struct {
	// An environment variable's name
	Name string `json:"name"`
	// An environment variable's value
	Value string `json:"value"`
	// An environment variable's masked state
	Masked bool `json:"masked"`
}

Represents an environment variable (name:value pair) and its masked state

type EnvironmentsAPI added in v0.4.1

type EnvironmentsAPI interface {
	// Get environment variables belonging to an Environment.
	GetVariables(ctx context.Context, environmentID string) (GetVariablesResponse, error)
}

The Environments API holds all the operations the SDK client can perform on 1Password Environments.

func NewEnvironmentsSource added in v0.4.1

func NewEnvironmentsSource(inner *internal.InnerClient) EnvironmentsAPI

type EnvironmentsSource added in v0.4.1

type EnvironmentsSource struct {
	*internal.InnerClient
}

func (EnvironmentsSource) GetVariables added in v0.4.1

func (e EnvironmentsSource) GetVariables(ctx context.Context, environmentID string) (GetVariablesResponse, error)

Get environment variables belonging to an Environment.

type ErrorMessage added in v0.2.1

type ErrorMessage string

type FileAttributes added in v0.2.0

type FileAttributes struct {
	// The name of the file
	Name string `json:"name"`
	// The ID of the file retrieved from the server
	ID string `json:"id"`
	// The size of the file in bytes
	Size uint32 `json:"size"`
}

type FileCreateParams added in v0.2.0

type FileCreateParams struct {
	// The name of the file
	Name string `json:"name"`
	// The content of the file
	Content []byte `json:"content"`
	// The section id where the file should be stored
	SectionID string `json:"sectionId"`
	// The field id where the file should be stored
	FieldID string `json:"fieldId"`
}

type GeneratePasswordResponse added in v0.1.5

type GeneratePasswordResponse struct {
	// The generated password.
	Password string `json:"password"`
}

For future use, if we want to return more information about the generated password. Currently, it only returns the password itself.

type GetVariablesResponse added in v0.4.1

type GetVariablesResponse struct {
	// List of environment variables.
	Variables []EnvironmentVariable `json:"variables"`
}

Response containing the full set of environment variables from an Environment.

type Group added in v0.4.0

type Group struct {
	ID          string        `json:"id"`
	Title       string        `json:"title"`
	Description string        `json:"description"`
	GroupType   GroupType     `json:"groupType"`
	State       GroupState    `json:"state"`
	VaultAccess []VaultAccess `json:"vaultAccess,omitempty"`
}

type GroupAccess added in v0.4.0

type GroupAccess struct {
	// The group's ID
	GroupID string `json:"groupId"`
	// The group's set of permissions for the vault
	Permissions uint32 `json:"permissions"`
}

Represents a group's access to a 1Password vault. This is used for granting permissions

type GroupGetParams added in v0.4.0

type GroupGetParams struct {
	VaultPermissions *bool `json:"vaultPermissions,omitempty"`
}

type GroupState added in v0.4.0

type GroupState string
const (
	// This group is active
	GroupStateActive GroupState = "active"
	// This group has been deleted
	GroupStateDeleted GroupState = "deleted"
	// This group is in an unknown state
	GroupStateUnsupported GroupState = "unsupported"
)

type GroupType added in v0.4.0

type GroupType string
const (
	// The owners group, which gives the following permissions:
	// - Do everything the Admin group can do
	// - See every vault other than the personal vaults
	// - Change people's names
	// - See billing
	// - Change billing
	// - Make other people owners
	// - Delete a person
	GroupTypeOwners GroupType = "owners"
	// The administrators group, which gives the following permissions:
	// - Perform recovery
	// - Create new vaults
	// - Invite new members
	// - See vault metadata, including the vault name and who has access.
	// - Make other people admins
	GroupTypeAdministrators GroupType = "administrators"
	// The recovery group. It contains recovery keysets, and is added to every vault to allow for recovery.
	//
	// No one is added to this.
	GroupTypeRecovery GroupType = "recovery"
	// The external account managers group or EAM is a mandatory group for managed accounts that has
	// same permissions as the owners.
	GroupTypeExternalAccountManagers GroupType = "externalAccountManagers"
	// Members of a team that a user is on.
	GroupTypeTeamMembers GroupType = "teamMembers"
	// A custom, user defined group.
	GroupTypeUserDefined GroupType = "userDefined"
	// Support for new or renamed group types
	GroupTypeUnsupported GroupType = "unsupported"
)

type GroupVaultAccess added in v0.4.0

type GroupVaultAccess struct {
	// The vault's ID
	VaultID string `json:"vaultId"`
	// The group's ID
	GroupID string `json:"groupId"`
	// The group's set of permissions for the vault
	Permissions uint32 `json:"permissions"`
}

Represents a group's access to a 1Password vault.

type GroupsAPI added in v0.4.0

type GroupsAPI interface {
	// Get a group by its ID and parameters.
	Get(ctx context.Context, groupID string, groupParams GroupGetParams) (Group, error)
}

The Groups API holds all the operations the SDK client can perform on 1Password groups.

func NewGroupsSource added in v0.4.0

func NewGroupsSource(inner *internal.InnerClient) GroupsAPI

type GroupsSource added in v0.4.0

type GroupsSource struct {
	*internal.InnerClient
}

func (GroupsSource) Get added in v0.4.0

func (g GroupsSource) Get(ctx context.Context, groupID string, groupParams GroupGetParams) (Group, error)

Get a group by its ID and parameters.

type Item

type Item struct {
	// The item's ID
	ID string `json:"id"`
	// The item's title
	Title string `json:"title"`
	// The item's category
	Category ItemCategory `json:"category"`
	// The ID of the vault where the item is saved
	VaultID string `json:"vaultId"`
	// The item's fields
	Fields []ItemField `json:"fields"`
	// The item's sections
	Sections []ItemSection `json:"sections"`
	// The notes of the item
	Notes string `json:"notes"`
	// The item's tags
	Tags []string `json:"tags"`
	// The websites used for autofilling for items of the Login and Password categories.
	Websites []Website `json:"websites"`
	// The item's version
	Version uint32 `json:"version"`
	// The item's file fields
	Files []ItemFile `json:"files"`
	// The document file for the Document item category
	Document *FileAttributes `json:"document,omitempty"`
	// The time the item was created at
	CreatedAt time.Time `json:"createdAt"`
	// The time the item was updated at
	UpdatedAt time.Time `json:"updatedAt"`
}

Represents an active 1Password item.

type ItemCategory

type ItemCategory string
const (
	ItemCategoryLogin                ItemCategory = "Login"
	ItemCategorySecureNote           ItemCategory = "SecureNote"
	ItemCategoryCreditCard           ItemCategory = "CreditCard"
	ItemCategoryCryptoWallet         ItemCategory = "CryptoWallet"
	ItemCategoryIdentity             ItemCategory = "Identity"
	ItemCategoryPassword             ItemCategory = "Password"
	ItemCategoryDocument             ItemCategory = "Document"
	ItemCategoryAPICredentials       ItemCategory = "ApiCredentials"
	ItemCategoryBankAccount          ItemCategory = "BankAccount"
	ItemCategoryDatabase             ItemCategory = "Database"
	ItemCategoryDriverLicense        ItemCategory = "DriverLicense"
	ItemCategoryEmail                ItemCategory = "Email"
	ItemCategoryMedicalRecord        ItemCategory = "MedicalRecord"
	ItemCategoryMembership           ItemCategory = "Membership"
	ItemCategoryOutdoorLicense       ItemCategory = "OutdoorLicense"
	ItemCategoryPassport             ItemCategory = "Passport"
	ItemCategoryRewards              ItemCategory = "Rewards"
	ItemCategoryRouter               ItemCategory = "Router"
	ItemCategoryServer               ItemCategory = "Server"
	ItemCategorySSHKey               ItemCategory = "SshKey"
	ItemCategorySocialSecurityNumber ItemCategory = "SocialSecurityNumber"
	ItemCategorySoftwareLicense      ItemCategory = "SoftwareLicense"
	ItemCategoryPerson               ItemCategory = "Person"
	ItemCategoryUnsupported          ItemCategory = "Unsupported"
)

type ItemCreateParams

type ItemCreateParams struct {
	// The item's category
	Category ItemCategory `json:"category"`
	// The ID of the vault where the item is saved
	VaultID string `json:"vaultId"`
	// The item's title
	Title string `json:"title"`
	// The item's fields
	Fields []ItemField `json:"fields,omitempty"`
	// The item's sections
	Sections []ItemSection `json:"sections,omitempty"`
	// The item's notes
	Notes *string `json:"notes,omitempty"`
	// The item's tags
	Tags []string `json:"tags,omitempty"`
	// The websites used for autofilling for items of the Login and Password categories.
	Websites []Website `json:"websites,omitempty"`
	// The item's files stored as fields
	Files []FileCreateParams `json:"files,omitempty"`
	// The document file for the Document item type. Empty when the item isn't of Document type.
	Document *DocumentCreateParams `json:"document,omitempty"`
}

type ItemField

type ItemField struct {
	// The field's ID
	ID string `json:"id"`
	// The field's title
	Title string `json:"title"`
	// The ID of the section containing the field. Built-in fields such as usernames and passwords don't require a section.
	SectionID *string `json:"sectionId,omitempty"`
	// The field's type
	FieldType ItemFieldType `json:"fieldType"`
	// The string representation of the field's value
	Value string `json:"value"`
	// Field type-specific attributes.
	Details *ItemFieldDetails `json:"details,omitempty"`
}

Represents a field within an item.

type ItemFieldDetails

type ItemFieldDetails struct {
	Type ItemFieldDetailsTypes `json:"type"`
	// contains filtered or unexported fields
}

func NewItemFieldDetailsTypeVariantAddress added in v0.2.1

func NewItemFieldDetailsTypeVariantAddress(content *AddressFieldDetails) ItemFieldDetails

func NewItemFieldDetailsTypeVariantOTP

func NewItemFieldDetailsTypeVariantOTP(content *OTPFieldDetails) ItemFieldDetails

func NewItemFieldDetailsTypeVariantSSHKey added in v0.2.0

func NewItemFieldDetailsTypeVariantSSHKey(content *SSHKeyAttributes) ItemFieldDetails

func (ItemFieldDetails) Address added in v0.2.1

func (ItemFieldDetails) MarshalJSON

func (i ItemFieldDetails) MarshalJSON() ([]byte, error)

func (ItemFieldDetails) OTP

func (ItemFieldDetails) SSHKey added in v0.2.0

func (i ItemFieldDetails) SSHKey() *SSHKeyAttributes

func (*ItemFieldDetails) UnmarshalJSON

func (i *ItemFieldDetails) UnmarshalJSON(data []byte) error

type ItemFieldDetailsTypes

type ItemFieldDetailsTypes string

Field type-specific attributes.

const (
	// The computed OTP code and other details
	ItemFieldDetailsTypeVariantOTP ItemFieldDetailsTypes = "Otp"
	// Computed SSH Key attributes
	ItemFieldDetailsTypeVariantSSHKey ItemFieldDetailsTypes = "SshKey"
	// Address components
	ItemFieldDetailsTypeVariantAddress ItemFieldDetailsTypes = "Address"
)

type ItemFieldType

type ItemFieldType string
const (
	ItemFieldTypeText             ItemFieldType = "Text"
	ItemFieldTypeConcealed        ItemFieldType = "Concealed"
	ItemFieldTypeCreditCardType   ItemFieldType = "CreditCardType"
	ItemFieldTypeCreditCardNumber ItemFieldType = "CreditCardNumber"
	ItemFieldTypePhone            ItemFieldType = "Phone"
	ItemFieldTypeURL              ItemFieldType = "Url"
	ItemFieldTypeTOTP             ItemFieldType = "Totp"
	ItemFieldTypeEmail            ItemFieldType = "Email"
	ItemFieldTypeReference        ItemFieldType = "Reference"
	ItemFieldTypeSSHKey           ItemFieldType = "SshKey"
	ItemFieldTypeMenu             ItemFieldType = "Menu"
	ItemFieldTypeMonthYear        ItemFieldType = "MonthYear"
	ItemFieldTypeAddress          ItemFieldType = "Address"
	ItemFieldTypeDate             ItemFieldType = "Date"
	ItemFieldTypeUnsupported      ItemFieldType = "Unsupported"
)

type ItemFile added in v0.2.0

type ItemFile struct {
	// the attributes of the file
	Attributes FileAttributes `json:"attributes"`
	// the section id where the file should be stored
	SectionID string `json:"sectionId"`
	// the field id where the file should be stored
	FieldID string `json:"fieldId"`
}

type ItemListFilter added in v0.3.0

type ItemListFilter struct {
	Type ItemListFilterTypes `json:"type"`
	// contains filtered or unexported fields
}

func NewItemListFilterTypeVariantByState added in v0.3.0

func NewItemListFilterTypeVariantByState(content *ItemListFilterByStateInner) ItemListFilter

func (ItemListFilter) ByState added in v0.3.0

func (ItemListFilter) MarshalJSON added in v0.3.0

func (i ItemListFilter) MarshalJSON() ([]byte, error)

func (*ItemListFilter) UnmarshalJSON added in v0.3.0

func (i *ItemListFilter) UnmarshalJSON(data []byte) error

type ItemListFilterByStateInner added in v0.3.0

type ItemListFilterByStateInner struct {
	Active   bool `json:"active"`
	Archived bool `json:"archived"`
}

Generated type representing the anonymous struct variant `ByState` of the `ItemListFilter` Rust enum

type ItemListFilterTypes added in v0.3.0

type ItemListFilterTypes string
const (
	ItemListFilterTypeVariantByState ItemListFilterTypes = "ByState"
)

type ItemOverview

type ItemOverview struct {
	// The item's ID
	ID string `json:"id"`
	// The item's title
	Title string `json:"title"`
	// The item's category
	Category ItemCategory `json:"category"`
	// The ID of the vault where the item is saved
	VaultID string `json:"vaultId"`
	// The websites used for autofilling for items of the Login and Password categories.
	Websites []Website `json:"websites"`
	// The item tags
	Tags []string `json:"tags"`
	// The time the item was created at
	CreatedAt time.Time `json:"createdAt"`
	// The time the item was updated at
	UpdatedAt time.Time `json:"updatedAt"`
	// Indicates the state of the item
	State ItemState `json:"state"`
}

Represents a decrypted 1Password item overview.

type ItemSection

type ItemSection struct {
	// The section's unique ID
	ID string `json:"id"`
	// The section's title
	Title string `json:"title"`
}

A section groups together multiple fields in an item.

type ItemShareAccountPolicy added in v0.1.6

type ItemShareAccountPolicy struct {
	// The maximum duration that an item can be shared for
	MaxExpiry ItemShareDuration `json:"maxExpiry"`
	// The default duration that an item is shared for
	DefaultExpiry ItemShareDuration `json:"defaultExpiry"`
	// The maximum number of times an item can be viewed. A null value means unlimited views
	MaxViews *uint32 `json:"maxViews,omitempty"`
	// The allowed types of item sharing - either "Authenticated" (share to specific users) or "Public" (share to anyone with a link)
	AllowedTypes []AllowedType `json:"allowedTypes"`
	// The allowed recipient types of item sharing - either "Email" or "Domain"
	AllowedRecipientTypes []AllowedRecipientType `json:"allowedRecipientTypes"`
	// The file sharing policy
	Files ItemShareFiles `json:"files"`
}

The account policy for sharing items, set by your account owner/admin This policy is enforced server-side when sharing items

type ItemShareDuration added in v0.1.6

type ItemShareDuration string

The valid duration options for sharing an item

const (
	// The share will expire in one hour
	ItemShareDurationOneHour ItemShareDuration = "OneHour"
	// The share will expire in one day
	ItemShareDurationOneDay ItemShareDuration = "OneDay"
	// The share will expire in seven days
	ItemShareDurationSevenDays ItemShareDuration = "SevenDays"
	// The share will expire in fourteen days
	ItemShareDurationFourteenDays ItemShareDuration = "FourteenDays"
	// The share will expire in thirty days
	ItemShareDurationThirtyDays ItemShareDuration = "ThirtyDays"
)

type ItemShareFiles added in v0.2.1

type ItemShareFiles struct {
	// Whether files can be included in item shares
	Allowed bool `json:"allowed"`
	// The maximum encrypted size (in bytes) an included file can be
	MaxSize uint32 `json:"maxSize"`
	// The allowed types of item sharing - either "Authenticated" (share to specific users) or "Public" (share to anyone with a link)
	AllowedTypes []AllowedType `json:"allowedTypes,omitempty"`
	// The allowed recipient types of item sharing - either "Email" or "Domain"
	AllowedRecipientTypes []AllowedRecipientType `json:"allowedRecipientTypes,omitempty"`
	// The maximum duration that an item can be shared for
	MaxExpiry *ItemShareDuration `json:"maxExpiry,omitempty"`
	// The default duration that an item is shared for
	DefaultExpiry *ItemShareDuration `json:"defaultExpiry,omitempty"`
	// The maximum number of times an item can be viewed. A null value means unlimited views
	MaxViews *uint32 `json:"maxViews,omitempty"`
}

The file sharing policy

type ItemShareParams added in v0.1.6

type ItemShareParams struct {
	// Emails or domains of the item share recipients. If not provided, everyone with the share link will have access
	Recipients []ValidRecipient `json:"recipients,omitempty"`
	// The duration of the share in seconds. If not provided, defaults to the account policy's default expiry
	ExpireAfter *ItemShareDuration `json:"expireAfter,omitempty"`
	// Whether the item can only be viewed once per recipient
	OneTimeOnly bool `json:"oneTimeOnly"`
}

The configuration options for sharing an item These must respect the account policy on item sharing

type ItemState added in v0.3.0

type ItemState string

Represents the state of an item in the SDK.

const (
	// The item is active
	ItemStateActive ItemState = "active"
	// The item is archived meaning it's hidden from regular view and stored in the archive.
	ItemStateArchived ItemState = "archived"
)

type ItemUpdateFailureReason added in v0.4.0

type ItemUpdateFailureReason struct {
	Type ItemUpdateFailureReasonTypes `json:"type"`
	// contains filtered or unexported fields
}

func NewItemUpdateFailureReasonTypeVariantInternal added in v0.4.0

func NewItemUpdateFailureReasonTypeVariantInternal(content ErrorMessage) ItemUpdateFailureReason

func NewItemUpdateFailureReasonTypeVariantItemNotFound added in v0.4.0

func NewItemUpdateFailureReasonTypeVariantItemNotFound() ItemUpdateFailureReason

func NewItemUpdateFailureReasonTypeVariantItemStatusFileNotFound added in v0.4.0

func NewItemUpdateFailureReasonTypeVariantItemStatusFileNotFound() ItemUpdateFailureReason

func NewItemUpdateFailureReasonTypeVariantItemStatusIncorrectItemVersion added in v0.4.0

func NewItemUpdateFailureReasonTypeVariantItemStatusIncorrectItemVersion() ItemUpdateFailureReason

func NewItemUpdateFailureReasonTypeVariantItemStatusPermissionError added in v0.4.0

func NewItemUpdateFailureReasonTypeVariantItemStatusPermissionError() ItemUpdateFailureReason

func NewItemUpdateFailureReasonTypeVariantItemStatusTooBig added in v0.4.0

func NewItemUpdateFailureReasonTypeVariantItemStatusTooBig() ItemUpdateFailureReason

func NewItemUpdateFailureReasonTypeVariantItemValidationError added in v0.4.0

func NewItemUpdateFailureReasonTypeVariantItemValidationError(content ErrorMessage) ItemUpdateFailureReason

func (ItemUpdateFailureReason) Internal added in v0.4.0

func (ItemUpdateFailureReason) ItemValidationError added in v0.4.0

func (i ItemUpdateFailureReason) ItemValidationError() ErrorMessage

func (ItemUpdateFailureReason) MarshalJSON added in v0.4.0

func (i ItemUpdateFailureReason) MarshalJSON() ([]byte, error)

func (*ItemUpdateFailureReason) UnmarshalJSON added in v0.4.0

func (i *ItemUpdateFailureReason) UnmarshalJSON(data []byte) error

type ItemUpdateFailureReasonTypes added in v0.4.0

type ItemUpdateFailureReasonTypes string
const (
	// Item update operation failed due to bad user input.
	ItemUpdateFailureReasonTypeVariantItemValidationError ItemUpdateFailureReasonTypes = "itemValidationError"
	// Item update operation is forbidden, permission issue. Make sure you have the correct permissions to update items in this vault.
	ItemUpdateFailureReasonTypeVariantItemStatusPermissionError ItemUpdateFailureReasonTypes = "itemStatusPermissionError"
	// Item update operation failed due to incorrect version.
	ItemUpdateFailureReasonTypeVariantItemStatusIncorrectItemVersion ItemUpdateFailureReasonTypes = "itemStatusIncorrectItemVersion"
	// Item update operation failed because a file reference didn't match a known file.
	ItemUpdateFailureReasonTypeVariantItemStatusFileNotFound ItemUpdateFailureReasonTypes = "itemStatusFileNotFound"
	// Item update request is too big to be sent to the server.
	ItemUpdateFailureReasonTypeVariantItemStatusTooBig ItemUpdateFailureReasonTypes = "itemStatusTooBig"
	// The item was not found
	ItemUpdateFailureReasonTypeVariantItemNotFound ItemUpdateFailureReasonTypes = "itemNotFound"
	// Item update operation experienced an internal error.
	ItemUpdateFailureReasonTypeVariantInternal ItemUpdateFailureReasonTypes = "internal"
)

type ItemsAPI

type ItemsAPI interface {
	// Create a new item.
	Create(ctx context.Context, params ItemCreateParams) (Item, error)

	// Create items in batch, within a single vault.
	CreateAll(ctx context.Context, vaultID string, params []ItemCreateParams) (ItemsUpdateAllResponse, error)

	// Get an item by vault and item ID.
	Get(ctx context.Context, vaultID string, itemID string) (Item, error)

	// Get items by vault and their item IDs.
	GetAll(ctx context.Context, vaultID string, itemIds []string) (ItemsGetAllResponse, error)

	// Update an existing item.
	Put(ctx context.Context, item Item) (Item, error)

	// Delete an item.
	Delete(ctx context.Context, vaultID string, itemID string) error

	// Delete items in batch, within a single vault.
	DeleteAll(ctx context.Context, vaultID string, itemIds []string) (ItemsDeleteAllResponse, error)

	// Archive an item.
	Archive(ctx context.Context, vaultID string, itemID string) error

	// List items based on filters.
	List(ctx context.Context, vaultID string, filters ...ItemListFilter) ([]ItemOverview, error)

	// ----- Sub APIs - these methods are used to access subordinate function groups -----
	Shares() ItemsSharesAPI
	Files() ItemsFilesAPI
}

The Items API holds all operations the SDK client can perform on 1Password items.

func NewItemsSource

func NewItemsSource(inner *internal.InnerClient) ItemsAPI

type ItemsDeleteAllResponse added in v0.4.0

type ItemsDeleteAllResponse struct {
	IndividualResponses map[string]Response[struct{}, ItemUpdateFailureReason] `json:"individualResponses"`
}

type ItemsFilesAPI added in v0.2.0

type ItemsFilesAPI interface {
	// Attach files to Items.
	Attach(ctx context.Context, item Item, fileParams FileCreateParams) (Item, error)

	// Read file content from the Item.
	Read(ctx context.Context, vaultID string, itemID string, attr FileAttributes) ([]byte, error)

	// Delete a field file from Item using the section and field IDs.
	Delete(ctx context.Context, item Item, sectionID string, fieldID string) (Item, error)

	// Replace the document file within a document item.
	ReplaceDocument(ctx context.Context, item Item, docParams DocumentCreateParams) (Item, error)
}

func NewItemsFilesSource added in v0.2.0

func NewItemsFilesSource(inner *internal.InnerClient) ItemsFilesAPI

type ItemsFilesSource added in v0.2.0

type ItemsFilesSource struct {
	*internal.InnerClient
}

func (ItemsFilesSource) Attach added in v0.2.0

func (i ItemsFilesSource) Attach(ctx context.Context, item Item, fileParams FileCreateParams) (Item, error)

Attach files to Items.

func (ItemsFilesSource) Delete added in v0.2.0

func (i ItemsFilesSource) Delete(ctx context.Context, item Item, sectionID string, fieldID string) (Item, error)

Delete a field file from Item using the section and field IDs.

func (ItemsFilesSource) Read added in v0.2.0

func (i ItemsFilesSource) Read(ctx context.Context, vaultID string, itemID string, attr FileAttributes) ([]byte, error)

Read file content from the Item.

func (ItemsFilesSource) ReplaceDocument added in v0.2.0

func (i ItemsFilesSource) ReplaceDocument(ctx context.Context, item Item, docParams DocumentCreateParams) (Item, error)

Replace the document file within a document item.

type ItemsGetAllError added in v0.4.0

type ItemsGetAllError struct {
	Type ItemsGetAllErrorTypes `json:"type"`
	// contains filtered or unexported fields
}

func NewItemsGetAllErrorTypeVariantInternal added in v0.4.0

func NewItemsGetAllErrorTypeVariantInternal(content ErrorMessage) ItemsGetAllError

func NewItemsGetAllErrorTypeVariantItemNotFound added in v0.4.0

func NewItemsGetAllErrorTypeVariantItemNotFound() ItemsGetAllError

func (ItemsGetAllError) Internal added in v0.4.0

func (i ItemsGetAllError) Internal() ErrorMessage

func (ItemsGetAllError) MarshalJSON added in v0.4.0

func (i ItemsGetAllError) MarshalJSON() ([]byte, error)

func (*ItemsGetAllError) UnmarshalJSON added in v0.4.0

func (i *ItemsGetAllError) UnmarshalJSON(data []byte) error

type ItemsGetAllErrorTypes added in v0.4.0

type ItemsGetAllErrorTypes string
const (
	ItemsGetAllErrorTypeVariantItemNotFound ItemsGetAllErrorTypes = "itemNotFound"
	ItemsGetAllErrorTypeVariantInternal     ItemsGetAllErrorTypes = "internal"
)

type ItemsGetAllResponse added in v0.4.0

type ItemsGetAllResponse struct {
	IndividualResponses []Response[Item, ItemsGetAllError] `json:"individualResponses"`
}

type ItemsSharesAPI added in v0.2.0

type ItemsSharesAPI interface {
	// Get the item sharing policy of your account.
	GetAccountPolicy(ctx context.Context, vaultID string, itemID string) (ItemShareAccountPolicy, error)

	// Validate the recipients of an item sharing link.
	ValidateRecipients(ctx context.Context, policy ItemShareAccountPolicy, recipients []string) ([]ValidRecipient, error)

	// Create a new item sharing link.
	Create(ctx context.Context, item Item, policy ItemShareAccountPolicy, params ItemShareParams) (string, error)
}

func NewItemsSharesSource added in v0.1.6

func NewItemsSharesSource(inner *internal.InnerClient) ItemsSharesAPI

type ItemsSharesSource added in v0.1.6

type ItemsSharesSource struct {
	*internal.InnerClient
}

func (ItemsSharesSource) Create added in v0.1.6

Create a new item sharing link.

func (ItemsSharesSource) GetAccountPolicy added in v0.1.6

func (i ItemsSharesSource) GetAccountPolicy(ctx context.Context, vaultID string, itemID string) (ItemShareAccountPolicy, error)

Get the item sharing policy of your account.

func (ItemsSharesSource) ValidateRecipients added in v0.1.6

func (i ItemsSharesSource) ValidateRecipients(ctx context.Context, policy ItemShareAccountPolicy, recipients []string) ([]ValidRecipient, error)

Validate the recipients of an item sharing link.

type ItemsSource

type ItemsSource struct {
	*internal.InnerClient
	SharesAPI ItemsSharesAPI
	FilesAPI  ItemsFilesAPI
}

func (ItemsSource) Archive added in v0.1.6

func (i ItemsSource) Archive(ctx context.Context, vaultID string, itemID string) error

Archive an item.

func (ItemsSource) Create

func (i ItemsSource) Create(ctx context.Context, params ItemCreateParams) (Item, error)

Create a new item.

func (ItemsSource) CreateAll added in v0.4.0

func (i ItemsSource) CreateAll(ctx context.Context, vaultID string, params []ItemCreateParams) (ItemsUpdateAllResponse, error)

Create items in batch, within a single vault.

func (ItemsSource) Delete

func (i ItemsSource) Delete(ctx context.Context, vaultID string, itemID string) error

Delete an item.

func (ItemsSource) DeleteAll added in v0.4.0

func (i ItemsSource) DeleteAll(ctx context.Context, vaultID string, itemIds []string) (ItemsDeleteAllResponse, error)

Delete items in batch, within a single vault.

func (ItemsSource) Files added in v0.2.0

func (i ItemsSource) Files() ItemsFilesAPI

func (ItemsSource) Get

func (i ItemsSource) Get(ctx context.Context, vaultID string, itemID string) (Item, error)

Get an item by vault and item ID.

func (ItemsSource) GetAll added in v0.4.0

func (i ItemsSource) GetAll(ctx context.Context, vaultID string, itemIds []string) (ItemsGetAllResponse, error)

Get items by vault and their item IDs.

func (ItemsSource) List added in v0.3.0

func (i ItemsSource) List(ctx context.Context, vaultID string, filters ...ItemListFilter) ([]ItemOverview, error)

List items based on filters.

func (ItemsSource) Put

func (i ItemsSource) Put(ctx context.Context, item Item) (Item, error)

Update an existing item.

func (ItemsSource) Shares added in v0.1.6

func (i ItemsSource) Shares() ItemsSharesAPI

type ItemsUpdateAllResponse added in v0.4.0

type ItemsUpdateAllResponse struct {
	IndividualResponses []Response[Item, ItemUpdateFailureReason] `json:"individualResponses"`
}

type OTPFieldDetails

type OTPFieldDetails struct {
	// The OTP code, if successfully computed
	Code *string `json:"code,omitempty"`
	// The error message, if the OTP code could not be computed
	ErrorMessage *string `json:"errorMessage,omitempty"`
}

Additional attributes for OTP fields.

type PasswordRecipe added in v0.1.5

type PasswordRecipe struct {
	Type PasswordRecipeTypes `json:"type"`
	// contains filtered or unexported fields
}

func NewPasswordRecipeTypeVariantMemorable added in v0.1.5

func NewPasswordRecipeTypeVariantMemorable(content *PasswordRecipeMemorableInner) PasswordRecipe

func NewPasswordRecipeTypeVariantPin added in v0.1.5

func NewPasswordRecipeTypeVariantPin(content *PasswordRecipePinInner) PasswordRecipe

func NewPasswordRecipeTypeVariantRandom added in v0.1.5

func NewPasswordRecipeTypeVariantRandom(content *PasswordRecipeRandomInner) PasswordRecipe

func (PasswordRecipe) MarshalJSON added in v0.1.5

func (p PasswordRecipe) MarshalJSON() ([]byte, error)

func (PasswordRecipe) Memorable added in v0.1.5

func (PasswordRecipe) Pin added in v0.1.5

func (PasswordRecipe) Random added in v0.1.5

func (*PasswordRecipe) UnmarshalJSON added in v0.1.5

func (p *PasswordRecipe) UnmarshalJSON(data []byte) error

type PasswordRecipeMemorableInner added in v0.1.5

type PasswordRecipeMemorableInner struct {
	// The type of separator between chunks.
	SeparatorType SeparatorType `json:"separatorType"`
	// Uppercase one randomly selected chunk.
	Capitalize bool `json:"capitalize"`
	// The type of word list used.
	WordListType WordListType `json:"wordListType"`
	// The number of "words" (words or syllables).
	WordCount uint32 `json:"wordCount"`
}

Generated type representing the anonymous struct variant `Memorable` of the `PasswordRecipe` Rust enum

type PasswordRecipePinInner added in v0.1.5

type PasswordRecipePinInner struct {
	// Number of digits in the PIN.
	Length uint32 `json:"length"`
}

Generated type representing the anonymous struct variant `Pin` of the `PasswordRecipe` Rust enum

type PasswordRecipeRandomInner added in v0.1.5

type PasswordRecipeRandomInner struct {
	// Include at least one digit in the password.
	IncludeDigits bool `json:"includeDigits"`
	// Include at least one symbol in the password.
	IncludeSymbols bool `json:"includeSymbols"`
	// The length of the password.
	Length uint32 `json:"length"`
}

Generated type representing the anonymous struct variant `Random` of the `PasswordRecipe` Rust enum

type PasswordRecipeTypes added in v0.1.5

type PasswordRecipeTypes string
const (
	PasswordRecipeTypeVariantMemorable PasswordRecipeTypes = "Memorable"
	PasswordRecipeTypeVariantPin       PasswordRecipeTypes = "Pin"
	PasswordRecipeTypeVariantRandom    PasswordRecipeTypes = "Random"
)

type RateLimitExceededError added in v0.1.7

type RateLimitExceededError struct {
	// contains filtered or unexported fields
}

func (*RateLimitExceededError) Error added in v0.1.7

func (e *RateLimitExceededError) Error() string

type ResolveAllResponse added in v0.2.1

type ResolveAllResponse struct {
	IndividualResponses map[string]Response[ResolvedReference, ResolveReferenceError] `json:"individualResponses"`
}

type ResolveReferenceError added in v0.2.1

type ResolveReferenceError struct {
	Type ResolveReferenceErrorTypes `json:"type"`
	// contains filtered or unexported fields
}

func NewResolveReferenceErrorTypeVariantFieldNotFound added in v0.2.1

func NewResolveReferenceErrorTypeVariantFieldNotFound() ResolveReferenceError

func NewResolveReferenceErrorTypeVariantIncompatibleSSHKeyQueryParameterField added in v0.2.1

func NewResolveReferenceErrorTypeVariantIncompatibleSSHKeyQueryParameterField() ResolveReferenceError

func NewResolveReferenceErrorTypeVariantIncompatibleTOTPQueryParameterField added in v0.2.1

func NewResolveReferenceErrorTypeVariantIncompatibleTOTPQueryParameterField() ResolveReferenceError

func NewResolveReferenceErrorTypeVariantItemNotFound added in v0.2.1

func NewResolveReferenceErrorTypeVariantItemNotFound() ResolveReferenceError

func NewResolveReferenceErrorTypeVariantNoMatchingSections added in v0.2.1

func NewResolveReferenceErrorTypeVariantNoMatchingSections() ResolveReferenceError

func NewResolveReferenceErrorTypeVariantOther added in v0.2.1

func NewResolveReferenceErrorTypeVariantOther() ResolveReferenceError

func NewResolveReferenceErrorTypeVariantParsing added in v0.2.1

func NewResolveReferenceErrorTypeVariantParsing(content ErrorMessage) ResolveReferenceError

func NewResolveReferenceErrorTypeVariantSSHKeyMetadataNotFound added in v0.2.1

func NewResolveReferenceErrorTypeVariantSSHKeyMetadataNotFound() ResolveReferenceError

func NewResolveReferenceErrorTypeVariantTooManyItems added in v0.2.1

func NewResolveReferenceErrorTypeVariantTooManyItems() ResolveReferenceError

func NewResolveReferenceErrorTypeVariantTooManyMatchingFields added in v0.2.1

func NewResolveReferenceErrorTypeVariantTooManyMatchingFields() ResolveReferenceError

func NewResolveReferenceErrorTypeVariantTooManyVaults added in v0.2.1

func NewResolveReferenceErrorTypeVariantTooManyVaults() ResolveReferenceError

func NewResolveReferenceErrorTypeVariantUnableToFormatPrivateKeyToOpenSSH added in v0.2.1

func NewResolveReferenceErrorTypeVariantUnableToFormatPrivateKeyToOpenSSH() ResolveReferenceError

func NewResolveReferenceErrorTypeVariantUnableToGenerateTOTPCode added in v0.2.1

func NewResolveReferenceErrorTypeVariantUnableToGenerateTOTPCode(content ErrorMessage) ResolveReferenceError

func NewResolveReferenceErrorTypeVariantUnableToParsePrivateKey added in v0.2.1

func NewResolveReferenceErrorTypeVariantUnableToParsePrivateKey() ResolveReferenceError

func NewResolveReferenceErrorTypeVariantUnsupportedFileFormat added in v0.2.1

func NewResolveReferenceErrorTypeVariantUnsupportedFileFormat() ResolveReferenceError

func NewResolveReferenceErrorTypeVariantVaultNotFound added in v0.2.1

func NewResolveReferenceErrorTypeVariantVaultNotFound() ResolveReferenceError

func (ResolveReferenceError) MarshalJSON added in v0.2.1

func (r ResolveReferenceError) MarshalJSON() ([]byte, error)

func (ResolveReferenceError) Parsing added in v0.2.1

func (r ResolveReferenceError) Parsing() ErrorMessage

func (ResolveReferenceError) UnableToGenerateTOTPCode added in v0.2.1

func (r ResolveReferenceError) UnableToGenerateTOTPCode() ErrorMessage

func (*ResolveReferenceError) UnmarshalJSON added in v0.2.1

func (r *ResolveReferenceError) UnmarshalJSON(data []byte) error

type ResolveReferenceErrorTypes added in v0.2.1

type ResolveReferenceErrorTypes string
const (
	// Error parsing the secret reference
	ResolveReferenceErrorTypeVariantParsing ResolveReferenceErrorTypes = "parsing"
	// The specified reference cannot be found within the item
	ResolveReferenceErrorTypeVariantFieldNotFound ResolveReferenceErrorTypes = "fieldNotFound"
	// No vault matched the secret reference query
	ResolveReferenceErrorTypeVariantVaultNotFound ResolveReferenceErrorTypes = "vaultNotFound"
	// More than one vault matched the secret reference query
	ResolveReferenceErrorTypeVariantTooManyVaults ResolveReferenceErrorTypes = "tooManyVaults"
	// No item matched the secret reference query
	ResolveReferenceErrorTypeVariantItemNotFound ResolveReferenceErrorTypes = "itemNotFound"
	// More than one item matched the secret reference query
	ResolveReferenceErrorTypeVariantTooManyItems ResolveReferenceErrorTypes = "tooManyItems"
	// More than one field matched the provided secret reference
	ResolveReferenceErrorTypeVariantTooManyMatchingFields ResolveReferenceErrorTypes = "tooManyMatchingFields"
	// No section found within the item for the provided identifier
	ResolveReferenceErrorTypeVariantNoMatchingSections ResolveReferenceErrorTypes = "noMatchingSections"
	// Incompatiable TOTP query parameters
	ResolveReferenceErrorTypeVariantIncompatibleTOTPQueryParameterField ResolveReferenceErrorTypes = "incompatibleTOTPQueryParameterField"
	// The totp was not able to be generated
	ResolveReferenceErrorTypeVariantUnableToGenerateTOTPCode ResolveReferenceErrorTypes = "unableToGenerateTotpCode"
	// Couldn't find attributes specific to an SSH Key field
	ResolveReferenceErrorTypeVariantSSHKeyMetadataNotFound ResolveReferenceErrorTypes = "sSHKeyMetadataNotFound"
	// Currently only support text files
	ResolveReferenceErrorTypeVariantUnsupportedFileFormat ResolveReferenceErrorTypes = "unsupportedFileFormat"
	// Trying to convert a non-private key to a private key format
	ResolveReferenceErrorTypeVariantIncompatibleSSHKeyQueryParameterField ResolveReferenceErrorTypes = "incompatibleSshKeyQueryParameterField"
	// Unable to properly parse a private key string to convert to an internal Private Key type
	ResolveReferenceErrorTypeVariantUnableToParsePrivateKey ResolveReferenceErrorTypes = "unableToParsePrivateKey"
	// Unable to format a private key to OpenSSH format
	ResolveReferenceErrorTypeVariantUnableToFormatPrivateKeyToOpenSSH ResolveReferenceErrorTypes = "unableToFormatPrivateKeyToOpenSsh"
	// Other type
	ResolveReferenceErrorTypeVariantOther ResolveReferenceErrorTypes = "other"
)

type ResolvedReference added in v0.2.1

type ResolvedReference struct {
	Secret  string `json:"secret"`
	ItemID  string `json:"itemId"`
	VaultID string `json:"vaultId"`
}

type Response added in v0.2.1

type Response[T any, E any] struct {
	Content *T `json:"content,omitempty"`
	Error   *E `json:"error,omitempty"`
}

type SSHKeyAttributes added in v0.2.0

type SSHKeyAttributes struct {
	// The public part of the SSH Key
	PublicKey string `json:"publicKey"`
	// The fingerprint of the SSH Key
	Fingerprint string `json:"fingerprint"`
	// The key type ("Ed25519" or "RSA, {length}-bit")
	KeyType string `json:"keyType"`
}

type SecretsAPI

type SecretsAPI interface {
	// Resolve returns the secret the provided secret reference points to.
	Resolve(ctx context.Context, secretReference string) (string, error)

	// Resolve takes in a list of secret references and returns the secrets they point to or errors if any.
	ResolveAll(ctx context.Context, secretReferences []string) (ResolveAllResponse, error)
}

The Secrets API includes all operations the SDK client can perform on secrets. Use secret reference URIs to securely load secrets from 1Password: `op://<vault-name>/<item-name>[/<section-name>]/<field-name>`

func NewSecretsSource

func NewSecretsSource(inner *internal.InnerClient) SecretsAPI

type SecretsSource

type SecretsSource struct {
	*internal.InnerClient
}

func (SecretsSource) Resolve

func (s SecretsSource) Resolve(ctx context.Context, secretReference string) (string, error)

Resolve returns the secret the provided secret reference points to.

func (SecretsSource) ResolveAll added in v0.2.1

func (s SecretsSource) ResolveAll(ctx context.Context, secretReferences []string) (ResolveAllResponse, error)

Resolve takes in a list of secret references and returns the secrets they point to or errors if any.

type SeparatorType added in v0.1.5

type SeparatorType string
const (
	// Randomly selected digits.
	// E.g, "`correct4horse0battery1staple`"
	SeparatorTypeDigits SeparatorType = "digits"
	// Randomly selected digits and symbols.
	// This is useful to get word-based passwords to meet complexity requirements
	// E.g, "`correct4horse-battery1staple`"
	SeparatorTypeDigitsAndSymbols SeparatorType = "digitsAndSymbols"
	// Spaces, like the original Diceware.
	// Great for mobile keyboards, not so great when people can overhear you type the password.
	// E.g, "`correct horse battery staple`"
	SeparatorTypeSpaces SeparatorType = "spaces"
	// Hyphens "`-`".
	// E.g, "`correct-horse-battery-staple`"
	SeparatorTypeHyphens SeparatorType = "hyphens"
	// "`_`".
	// E.g, "`correct_horse_battery_staple`"
	SeparatorTypeUnderscores SeparatorType = "underscores"
	// Period (full stop) "`.`".
	// E.g, "`correct.horse.battery.staple`"
	SeparatorTypePeriods SeparatorType = "periods"
	// Comma "`,`".
	// E.g, "`correct,horse,battery,staple`"
	SeparatorTypeCommas SeparatorType = "commas"
)

type ValidRecipient added in v0.1.6

type ValidRecipient struct {
	Type ValidRecipientTypes `json:"type"`
	// contains filtered or unexported fields
}

func NewValidRecipientTypeVariantDomain added in v0.1.6

func NewValidRecipientTypeVariantDomain(content *ValidRecipientDomainInner) ValidRecipient

func NewValidRecipientTypeVariantEmail added in v0.1.6

func NewValidRecipientTypeVariantEmail(content *ValidRecipientEmailInner) ValidRecipient

func (ValidRecipient) Domain added in v0.1.6

func (ValidRecipient) Email added in v0.1.6

func (ValidRecipient) MarshalJSON added in v0.1.6

func (v ValidRecipient) MarshalJSON() ([]byte, error)

func (*ValidRecipient) UnmarshalJSON added in v0.1.6

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

type ValidRecipientDomainInner added in v0.1.6

type ValidRecipientDomainInner struct {
	Domain string `json:"domain"`
}

Generated type representing the anonymous struct variant `Domain` of the `ValidRecipient` Rust enum

type ValidRecipientEmailInner added in v0.1.6

type ValidRecipientEmailInner struct {
	Email string `json:"email"`
}

Generated type representing the anonymous struct variant `Email` of the `ValidRecipient` Rust enum

type ValidRecipientTypes added in v0.1.6

type ValidRecipientTypes string

The validated recipient of an item share

const (
	// This exact email address
	ValidRecipientTypeVariantEmail ValidRecipientTypes = "Email"
	// Anyone with an email address from the specified domain
	ValidRecipientTypeVariantDomain ValidRecipientTypes = "Domain"
)

type Vault added in v0.4.0

type Vault struct {
	// The vault's ID.
	ID string `json:"id"`
	// The vault's title.
	Title string `json:"title"`
	// The description of the vault.
	Description string `json:"description"`
	// The type of the vault.
	VaultType VaultType `json:"vaultType"`
	// The number of active items within the vault.
	ActiveItemCount uint32 `json:"activeItemCount"`
	// The content version number of the vault. It gets incremented whenever the state of the vault's contents changes (e.g. items from within the vault get created or updated).
	ContentVersion uint32 `json:"contentVersion"`
	// The attribute version number of the vault. It gets incremented whenever vault presentation information changes, such as its title or icon.
	AttributeVersion uint32 `json:"attributeVersion"`
	// The access information associated with the vault.
	Access []VaultAccess `json:"access,omitempty"`
}

Represents regular vault information together with the vault's access information.

type VaultAccess added in v0.4.0

type VaultAccess struct {
	// The vault's UUID.
	VaultUuid string `json:"vaultUuid"`
	// The vault's accessor type.
	AccessorType VaultAccessorType `json:"accessorType"`
	// The vault's accessor UUID.
	AccessorUuid string `json:"accessorUuid"`
	// The permissions granted to this vault
	Permissions uint32 `json:"permissions"`
}

Represents the vault access information.

type VaultAccessorType added in v0.4.0

type VaultAccessorType string
const (
	VaultAccessorTypeUser  VaultAccessorType = "user"
	VaultAccessorTypeGroup VaultAccessorType = "group"
)

type VaultCreateParams added in v0.4.0

type VaultCreateParams struct {
	Title             string  `json:"title"`
	Description       *string `json:"description,omitempty"`
	AllowAdminsAccess *bool   `json:"allowAdminsAccess,omitempty"`
}

type VaultGetParams added in v0.4.0

type VaultGetParams struct {
	// The vault's accessor params.
	Accessors *bool `json:"accessors,omitempty"`
}

Represents the possible query parameters used for retrieving extra information about a vault.

type VaultListParams added in v0.4.0

type VaultListParams struct {
	DecryptDetails *bool `json:"decryptDetails,omitempty"`
}

type VaultOverview

type VaultOverview struct {
	// The vault's ID.
	ID string `json:"id"`
	// The vault's title.
	Title string `json:"title"`
	// The description of this vault.
	Description string `json:"description"`
	// The type of the vault.
	VaultType VaultType `json:"vaultType"`
	// The number of active items within the vault.
	ActiveItemCount uint32 `json:"activeItemCount"`
	// The content version number of the vault. It gets incremented whenever the state of the vault's contents changes (e.g. items from within the vault get created or updated).
	ContentVersion uint32 `json:"contentVersion"`
	// The attribute version number of the vault. It gets incremented whenever vault presentation information changes, such as its title or icon.
	AttributeVersion uint32 `json:"attributeVersion"`
	// The time the vault was created at
	CreatedAt time.Time `json:"createdAt"`
	// The time the vault was updated at
	UpdatedAt time.Time `json:"updatedAt"`
}

Holds information about a 1Password Vault.

type VaultType added in v0.4.0

type VaultType string

Represents the vault type.

const (
	VaultTypePersonal    VaultType = "personal"
	VaultTypeEveryone    VaultType = "everyone"
	VaultTypeTransfer    VaultType = "transfer"
	VaultTypeUserCreated VaultType = "userCreated"
	VaultTypeUnsupported VaultType = "unsupported"
)

type VaultUpdateParams added in v0.4.0

type VaultUpdateParams struct {
	Title       *string `json:"title,omitempty"`
	Description *string `json:"description,omitempty"`
}

type VaultsAPI

type VaultsAPI interface {
	// Create a new user vault.
	Create(ctx context.Context, params VaultCreateParams) (Vault, error)

	// List information about vaults that's configurable based on some input parameters.
	List(ctx context.Context, params ...VaultListParams) ([]VaultOverview, error)

	// Get an overview of a vault by its ID.
	GetOverview(ctx context.Context, vaultID string) (VaultOverview, error)

	// Get detailed vault information by vault ID and parameters.
	Get(ctx context.Context, vaultID string, vaultParams VaultGetParams) (Vault, error)

	// Update a vault
	Update(ctx context.Context, vaultID string, params VaultUpdateParams) (Vault, error)

	// Delete a vault by its ID.
	Delete(ctx context.Context, vaultID string) error

	// Grant group permissions to a vault.
	GrantGroupPermissions(ctx context.Context, vaultID string, groupPermissionsList []GroupAccess) error

	// Update group permissions for vaults.
	UpdateGroupPermissions(ctx context.Context, groupPermissionsList []GroupVaultAccess) error

	// Revoke group permissions from a vault.
	RevokeGroupPermissions(ctx context.Context, vaultID string, groupID string) error
}

The Vaults API holds all the operations the SDK client can perform on 1Password vaults.

func NewVaultsSource

func NewVaultsSource(inner *internal.InnerClient) VaultsAPI

type VaultsSource

type VaultsSource struct {
	*internal.InnerClient
}

func (VaultsSource) Create added in v0.4.0

func (v VaultsSource) Create(ctx context.Context, params VaultCreateParams) (Vault, error)

Create a new user vault.

func (VaultsSource) Delete added in v0.4.0

func (v VaultsSource) Delete(ctx context.Context, vaultID string) error

Delete a vault by its ID.

func (VaultsSource) Get added in v0.4.0

func (v VaultsSource) Get(ctx context.Context, vaultID string, vaultParams VaultGetParams) (Vault, error)

Get detailed vault information by vault ID and parameters.

func (VaultsSource) GetOverview added in v0.4.0

func (v VaultsSource) GetOverview(ctx context.Context, vaultID string) (VaultOverview, error)

Get an overview of a vault by its ID.

func (VaultsSource) GrantGroupPermissions added in v0.4.0

func (v VaultsSource) GrantGroupPermissions(ctx context.Context, vaultID string, groupPermissionsList []GroupAccess) error

Grant group permissions to a vault.

func (VaultsSource) List added in v0.3.0

func (v VaultsSource) List(ctx context.Context, params ...VaultListParams) ([]VaultOverview, error)

List information about vaults that's configurable based on some input parameters.

func (VaultsSource) RevokeGroupPermissions added in v0.4.0

func (v VaultsSource) RevokeGroupPermissions(ctx context.Context, vaultID string, groupID string) error

Revoke group permissions from a vault.

func (VaultsSource) Update added in v0.4.0

func (v VaultsSource) Update(ctx context.Context, vaultID string, params VaultUpdateParams) (Vault, error)

Update a vault

func (VaultsSource) UpdateGroupPermissions added in v0.4.0

func (v VaultsSource) UpdateGroupPermissions(ctx context.Context, groupPermissionsList []GroupVaultAccess) error

Update group permissions for vaults.

type Website added in v0.1.3

type Website struct {
	// The website URL
	URL string `json:"url"`
	// The label of the website, e.g. 'website', 'sign-in address'
	Label string `json:"label"`
	// The auto-fill behavior of the website
	//
	// For more information, visit <https://support.1password.com/autofill-behavior/>
	AutofillBehavior AutofillBehavior `json:"autofillBehavior"`
}

type WordListType added in v0.1.5

type WordListType string
const (
	// Agile wordlist
	WordListTypeFullWords WordListType = "fullWords"
	// English-like syllables
	WordListTypeSyllables WordListType = "syllables"
	// Three (random) letter "words"
	WordListTypeThreeLetters WordListType = "threeLetters"
)

Directories

Path Synopsis
example
desktop_app command
environments command
This example demonstrates reading environment variables from a 1Password Environment using the 1Password Go SDK.
This example demonstrates reading environment variables from a 1Password Environment using the 1Password Go SDK.
service_account command

Jump to

Keyboard shortcuts

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