postman

package
v3.75.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SourceType       = sourcespb.SourceType_SOURCE_TYPE_POSTMAN
	LINK_BASE_URL    = "https://go.postman.co/"
	GLOBAL_TYPE      = "globals"
	ENVIRONMENT_TYPE = "environment"
	AUTH_TYPE        = "authorization"
	REQUEST_TYPE     = "request"
	FOLDER_TYPE      = "folder"
	COLLECTION_TYPE  = "collection"
	EVENT_TYPE       = "script"
)
View Source
const (
	GLOBAL_VARS_URL = "https://www.postman.com/_api/workspace/%s/globals"
	//Note: This is an undocumented API endpoint. The office API endpoint keeps returning 502.
	//We'll shift this once that behavior is resolved and stable.
	//Official API Endpoint: "https://api.getpostman.com/workspaces/%s/global-variables"
	//GLOBAL_VARS_URL  = "https://api.getpostman.com/workspaces/%s/global-variables"
	WORKSPACE_URL    = "https://api.getpostman.com/workspaces/%s"
	ENVIRONMENTS_URL = "https://api.getpostman.com/environments/%s"
	COLLECTIONS_URL  = "https://api.getpostman.com/collections/%s"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Type   string     `json:"type"`
	Apikey []KeyValue `json:"apikey,omitempty"`
	Bearer []KeyValue `json:"bearer,omitempty"`
	AWSv4  []KeyValue `json:"awsv4,omitempty"`
	Basic  []KeyValue `json:"basic,omitempty"`
	OAuth2 []KeyValue `json:"oauth2,omitempty"`
}

type Body

type Body struct {
	Mode       string      `json:"mode"`
	Raw        string      `json:"raw,omitempty"`
	File       BodyFile    `json:"file,omitempty"`
	URLEncoded []KeyValue  `json:"urlencoded,omitempty"` //FINISH
	FormData   []KeyValue  `json:"formdata,omitempty"`   //FINISH
	GraphQL    BodyGraphQL `json:"graphql,omitempty"`
}

type BodyFile

type BodyFile struct {
	Src string `json:"src"`
}

type BodyGraphQL

type BodyGraphQL struct {
	Query     string `json:"query"`
	Variables string `json:"variables"`
}

type Client

type Client struct {
	// HTTP client used to communicate with the API
	HTTPClient *http.Client

	// Headers to attach to every requests made with the client.
	Headers map[string]string
}

A Client manages communication with the Postman API.

func NewClient

func NewClient(postmanToken string) *Client

NewClient returns a new Postman API client.

func (*Client) EnumerateWorkspaces

func (c *Client) EnumerateWorkspaces() ([]Workspace, error)

EnumerateWorkspaces returns the workspaces for a given user (both private, public, team and personal). Consider adding additional flags to support filtering.

func (*Client) GetCollection

func (c *Client) GetCollection(collection_uuid string) (Collection, error)

GetCollection returns the collection for a given collection

func (*Client) GetEnvironmentVariables

func (c *Client) GetEnvironmentVariables(environment_uuid string) (VariableData, error)

GetEnvironmentVariables returns the environment variables for a given environment

func (*Client) GetGlobalVariables

func (c *Client) GetGlobalVariables(workspace_uuid string) (VariableData, error)

GetGlobalVariables returns the global variables for a given workspace

func (*Client) GetWorkspace

func (c *Client) GetWorkspace(workspaceUUID string) (Workspace, error)

GetWorkspace returns the workspace for a given workspace

func (*Client) NewRequest

func (c *Client) NewRequest(urlStr string, headers map[string]string) (*http.Request, error)

NewRequest creates an API request (Only GET needed for our interaction w/ Postman) If specified, the map provided by headers will be used to update request headers.

type Collection

type Collection struct {
	Info      Info       `json:"info"`
	Items     []Item     `json:"item,omitempty"`
	Auth      Auth       `json:"auth,omitempty"`
	Events    []Event    `json:"event,omitempty"`
	Variables []KeyValue `json:"variable,omitempty"`
}

type Environment

type Environment struct {
	VariableData `json:"environment"`
}

type Event

type Event struct {
	Listen string `json:"listen"`
	Script Script `json:"script"`
}

type GlobalVars

type GlobalVars struct {
	VariableData `json:"data"`
}

type IDNameUUID

type IDNameUUID struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	UUID string `json:"uid"`
}

type Info

type Info struct {
	PostmanID   string    `json:"_postman_id"` // This is a UUID. Needs createdBy ID prefix to be used with API.
	Name        string    `json:"name"`
	Description string    `json:"description"`
	Schema      string    `json:"schema"`
	UpdatedAt   time.Time `json:"updatedAt"`
	UID         string    `json:"uid"` //Need to use this to get the collection via API
}

type Item

type Item struct {
	Name        string     `json:"name"`
	Items       []Item     `json:"item,omitempty"`
	ID          string     `json:"id,omitempty"`
	Auth        Auth       `json:"auth,omitempty"`
	Events      []Event    `json:"event,omitempty"`
	Variable    []KeyValue `json:"variable,omitempty"`
	Request     Request    `json:"request,omitempty"`
	Response    []Response `json:"response,omitempty"`
	Description string     `json:"description,omitempty"`
	UID         string     `json:"uid,omitempty"` //Need to use this to get the collection via API
}

type KeyValue

type KeyValue struct {
	Key          string      `json:"key"`
	Value        interface{} `json:"value"`
	Enabled      bool        `json:"enabled,omitempty"`
	Type         string      `json:"type,omitempty"`
	SessionValue string      `json:"sessionValue,omitempty"`
	Id           string      `json:"id,omitempty"`
}

type Metadata

type Metadata struct {
	WorkspaceUUID   string
	WorkspaceName   string
	CreatedBy       string
	EnvironmentID   string
	CollectionInfo  Info
	FolderID        string // UUID of the folder (but not full ID)
	FolderName      string
	RequestID       string // UUID of the request (but not full ID)
	RequestName     string
	FullID          string //full ID of the reference item (created_by + ID) OR just the UUID
	Link            string //direct link to the folder (could be .json file path)
	Type            string //folder, request, etc.
	EnvironmentName string
	GlobalID        string // might just be FullID, not sure
	VarType         string
	FieldName       string
	FieldType       string
	// contains filtered or unexported fields
}

type Request

type Request struct {
	Auth        Auth       `json:"auth,omitempty"`
	Method      string     `json:"method"`
	Header      []KeyValue `json:"header,omitempty"`
	Body        Body       `json:"body,omitempty"` //Need to update with additional options
	URL         URL        `json:"url"`
	Description string     `json:"description,omitempty"`
}

type Response

type Response struct {
	ID              string     `json:"id"`
	Name            string     `json:"name,omitempty"`
	OriginalRequest Request    `json:"originalRequest,omitempty"`
	Header          []KeyValue `json:"header,omitempty"`
	Body            string     `json:"body,omitempty"`
	UID             string     `json:"uid,omitempty"`
}

type Script

type Script struct {
	Type string   `json:"type"`
	Exec []string `json:"exec"`
	Id   string   `json:"id"`
}

type Source

type Source struct {
	DetectorKeywords map[string]struct{}

	sources.Progress
	sources.CommonSourceUnitUnmarshaller
	// contains filtered or unexported fields
}

func (*Source) Chunks

func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk, _ ...sources.ChunkingTarget) error

Chunks scans the Postman source and sends the data to the chunks chan. It scans the local environment, collection, and workspace files, and then scans the Postman API if a token is provided. The Postman source is different to our other sources in that we are not relying on the data we read from the source to contain all the information we need to scan, i.e, a git chunk contains all the information needed to check if a secret is present in that chunk. Postman on the other hand requires us to build context (the keywords and variables) as we scan the data. Check out the postman UI to see what I mean. Metadata is used to track information that informs the source of the chunk (e.g. the workspace -> collection -> request -> variable hierarchy).

func (*Source) Init

func (s *Source) Init(ctx context.Context, name string, jobId sources.JobID, sourceId sources.SourceID, verify bool, connection *anypb.Any, concurrency int) error

Init returns an initialized Postman source.

func (*Source) JobID

func (s *Source) JobID() sources.JobID

func (*Source) SourceID

func (s *Source) SourceID() sources.SourceID

func (*Source) Type

func (s *Source) Type() sourcespb.SourceType

Type returns the type of source. It is used for matching source types in configuration and job input.

type Substitution

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

func NewSubstitution

func NewSubstitution() *Substitution

type URL

type URL struct {
	Raw      string     `json:"raw"`
	Protocol string     `json:"protocol"`
	Host     []string   `json:"host"`
	Path     []string   `json:"path"`
	Query    []KeyValue `json:"query,omitempty"`
}

type VariableData

type VariableData struct {
	ID        string     `json:"id"` // For globals and envs, this is just the UUID, not the full ID.
	Name      string     `json:"name"`
	KeyValues []KeyValue `json:"values"`
	Owner     string     `json:"owner"`
	IsPublic  bool       `json:"isPublic"`
	CreatedAt string     `json:"createdAt"`
	UpdatedAt string     `json:"updatedAt"`
}

type VariableInfo

type VariableInfo struct {
	Metadata Metadata
	// contains filtered or unexported fields
}

type Workspace

type Workspace struct {
	ID              string       `json:"id"`
	Name            string       `json:"name"`
	Type            string       `json:"type"`
	Description     string       `json:"description"`
	Visibility      string       `json:"visibility"`
	CreatedBy       string       `json:"createdBy"`
	UpdatedBy       string       `json:"updatedBy"`
	CreatedAt       string       `json:"createdAt"`
	UpdatedAt       string       `json:"updatedAt"`
	Collections     []IDNameUUID `json:"collections"`
	Environments    []IDNameUUID `json:"environments"`
	CollectionsRaw  []Collection
	EnvironmentsRaw []VariableData
}

Jump to

Keyboard shortcuts

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