postman

package module
v0.0.0-...-0e5fab6 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: MIT Imports: 1 Imported by: 1

README

postman

Postman Collection Generator Library

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Type   AuthType    `json:"type"`
	OAuth2 *OAuth2Auth `json:"oauth2,omitempty"`
	APIKey []KeyValue  `json:"apikey,omitempty"`
}

type AuthType

type AuthType string
const (
	AuthTypeNone     AuthType = "none"
	AuthTypeBasic    AuthType = "basic"
	AuthTypeBearer   AuthType = "bearer"
	AuthTypeDigest   AuthType = "digest"
	AuthTypeEdgeGrid AuthType = "edgegrid"
	AuthTypeHawk     AuthType = "hawk"
	AuthTypeOAuth1   AuthType = "oauth1"
	AuthTypeOAuth2   AuthType = "oauth2"
	AuthTypeNTLM     AuthType = "ntlm"
)

type Body

type Body struct {
	Mode       BodyMode     `json:"mode"`
	Raw        string       `json:"raw,omitempty"`
	Urlencoded []KeyValue   `json:"urlencoded,omitempty"`
	FormData   []KeyValue   `json:"formdata,omitempty"`
	File       *File        `json:"file,omitempty"`
	Options    *BodyOptions `json:"options,omitempty"`
}

func (*Body) SetLanguage

func (b *Body) SetLanguage(s string)

type BodyMode

type BodyMode string
const (
	BodyModeForm       BodyMode = "formdata"
	BodyModeURLEncoded BodyMode = "urlencoded"
	BodyModeRaw        BodyMode = "raw"
)

type BodyOptions

type BodyOptions struct {
	Raw *RawOptions `json:"raw,omitempty"`
}

type Collection

type Collection struct {
	Info     Info        `json:"info"`
	Item     []*Item     `json:"item"`
	Auth     *Auth       `json:"auth,omitempty"`
	Event    []*Event    `json:"event,omitempty"`
	Variable []*Variable `json:"variable,omitempty"`
}

func NewCollection

func NewCollection(name string, description string) *Collection

func (*Collection) AddAPI

func (c *Collection) AddAPI(item Item)

func (*Collection) AppendItem

func (c *Collection) AppendItem(item Item)

func (*Collection) CreateFolder

func (c *Collection) CreateFolder(name, description string) *Item

func (*Collection) SetVariable

func (c *Collection) SetVariable(key, value, description string)

func (*Collection) ToJson

func (c *Collection) ToJson() ([]byte, error)

type Event

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

type File

type File struct {
	Src     string `json:"src,omitempty"`
	Content string `json:"content,omitempty"`
}
type Header struct {
	Key         string `json:"key"`
	Value       string `json:"value"`
	Description string `json:"description,omitempty"`
}

type Info

type Info struct {
	PostmanID   string `json:"_postman_id,omitempty"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Schema      string `json:"schema"`
}

type Item

type Item struct {
	Name                    string                   `json:"name"`
	Description             string                   `json:"description,omitempty"`
	Request                 *Request                 `json:"request,omitempty"`
	Response                []*Response              `json:"response,omitempty"`
	ProtocolProfileBehavior *ProtocolProfileBehavior `json:"protocolProfileBehavior,omitempty"`
	Item                    []*Item                  `json:"item,omitempty"` // Nested items for folders
	Event                   []*Event                 `json:"event,omitempty"`
	Variable                []*Variable              `json:"variable,omitempty"`
}

func (*Item) AppendItem

func (c *Item) AppendItem(item Item) *Item

func (*Item) CreateFolder

func (c *Item) CreateFolder(name, description string) *Item

func (*Item) SetVariable

func (c *Item) SetVariable(key, value, description string)

type KeyValue

type KeyValue struct {
	Key         string `json:"key"`
	Value       string `json:"value"`
	Description string `json:"description,omitempty"`
	Type        string `json:"type,omitempty"`
}

type OAuth2Auth

type OAuth2Auth struct {
	GrantType   string `json:"grant_type"`
	AccessToken string `json:"accessToken"`
}

type ProtocolProfileBehavior

type ProtocolProfileBehavior struct {
	DisableBodyPruning bool `json:"disableBodyPruning,omitempty"`
}

type RawOptions

type RawOptions struct {
	Language string `json:"language"`
}

type Request

type Request struct {
	Method      string   `json:"method"`
	Header      []Header `json:"header,omitempty"`
	Body        *Body    `json:"body,omitempty"`
	Url         *Url     `json:"url,omitempty"`
	Auth        *Auth    `json:"auth,omitempty"`
	Description string   `json:"description,omitempty"`
}

type Response

type Response struct {
	Name            string   `json:"name"`
	OriginalRequest *Request `json:"originalRequest,omitempty"`
	Status          string   `json:"status"`
	Code            int      `json:"code"`
	Header          []Header `json:"header,omitempty"`
	Body            string   `json:"body,omitempty"`
}

type Script

type Script struct {
	ID          string   `json:"id,omitempty"`
	Type        string   `json:"type,omitempty"`
	Exec        []string `json:"exec,omitempty"`
	Name        string   `json:"name,omitempty"`
	Description string   `json:"description,omitempty"`
}

type Url

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

func (*Url) AddQuery

func (u *Url) AddQuery(key, value, description string)

type Variable

type Variable struct {
	Key         string `json:"key"`
	Value       string `json:"value"`
	Description string `json:"description,omitempty"`
}

Jump to

Keyboard shortcuts

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