postman

package module
v0.0.0-...-84b81c9 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: MIT Imports: 12 Imported by: 0

README

Go Report Card Build Status codecov Godoc Release

Go client for Postman REST API

Coverage

API
  • POST /apis
  • GET /apis
  • GET /apis/:apiId
  • PUT /apis/:apiId
  • DELETE /apis/:apiId
  • POST /apis/versions
  • GET /apis/versions
  • GET /apis/:apiId/versions/:versionId
  • PUT /apis/:apiId/versions/:versionId
  • DELETE /apis/:apiId/versions/:versionId
  • POST /apis/versions/releases
  • GET /apis/versions/releases
  • GET /apis/:apiId/versions/:versionId/releases/:releaseId
  • PUT /apis/:apiId/versions/:versionId/releases/:releaseId
  • DELETE /apis/:apiId/versions/:versionId/releases/:releaseId
  • POST /apis/:apiId/versions/:versionId/schemas
  • GET /apis/:apiId/versions/:versionId/schemas/:schemaId
  • PUT /apis/:apiId/versions/:versionId/schemas/:schemaId
  • POST /apis/:apiId/versions/:versionId/schemas/:schemaId/collections
  • POST /apis/:apiId/versions/:versionId/relations
  • GET /apis/:apiId/versions/:versionId/relations
  • GET /apis/:apiId/versions/:versionId/test
  • GET /apis/:apiId/versions/:versionId/testsuite
  • GET /apis/:apiId/versions/:versionId/contracttest
  • GET /apis/:apiId/versions/:versionId/environment
  • GET /apis/:apiId/versions/:versionId/integrationtest
  • GET /apis/:apiId/versions/:versionId/documentation
  • GET /apis/:apiId/versions/:versionId/monitor
  • PUT /apis/:apiId/versions/:versionId/:relationType/:entityId/syncWithSchema
API Security
  • POST /security/api-validation
Audit Logs
  • GET /audit/logs
Collections
  • POST /collections
  • GET /collections
  • GET /collections/:id
  • PUT /collections/:id
  • DELETE /collections/:id
  • POST /collections/fork/:id
  • POST /collections/merge
Environments
  • POST /environments
  • GET /environments
  • GET /environments/:id
  • PUT /environments/:id
  • DELETE /environments/:id
Mocks
  • POST /mocks
  • GET /mocks
  • GET /mocks/:mockId
  • PUT /mocks/:mockId
  • DELETE /mocks/:mockId
  • POST /mocks/:mockId/server-responses
  • GET /mocks/:mockId/server-responses
  • GET /mocks/:mockId/server-responses/:serverResponseId
  • PUT /mocks/:mockId/server-respones/:serverResponseId
  • DELETE /mocks/:mockId/server-responses/:serverResponseId
  • POST /mocks/:mockId/publish
  • DELETE /mocks/:mockId/unpublish
  • GET /mocks/:mockId/call-logs
Monitors
  • POST /monitors
  • GET /monitors
  • GET /monitors/:id
  • PUT /monitors/:id
  • DELETE /monitors/:id
  • POST /monitors/:id/run
Workspaces
  • POST /workspaces
  • GET /workspaces
  • GET /workspaces/:id
  • PUT /workspaces/:id
  • DELETE /workspaces/:id
User
  • GET /me
Import
  • POST /import/openapi
  • POST /import/exported
Webhooks
  • POST /webhooks
SCIM 2.0 - Identity
  • GET /scim/v2/ResourceTypes
  • GET /scim/v2/ServiceProviderConfig
  • POST /scim/v2/Users
  • GET /scim/v2/Users
  • GET /scim/v2/Users/:id
  • PUT /scim/v2/Users/:id
  • PATCH /scim/v2/Users/:id
  • POST /scim/v2/Groups
  • GET /scim/v2/Groups
  • GET /scim/v2/Groups/:id
  • PATCH /scim/v2/Group/:id

Usage

package main

import (
	"context"
	"fmt"

	"github.com/actatum/postman-client"
	"github.com/actatum/postman-client/webhooks"
)

func main() {
	cs := postman.NewClientSet("api-key")
	webhookClient := cs.Webhooks()
	webhook, err := webhookClient.Create(
		context.Background(),
		webhooks.Webhook{
			Name:       "Test Webhook",
			Collection: "collection-id",
		},
	)
	if err != nil {
		panic(err)
	}

	fmt.Printf("%v\n", webhook)
}
Missing endpoints

It's possible some endpoints may be missing from the client. You can use methods from the rest.Client to call an endpoint. rest.NewClient -> client.NewRequest -> client.DoRequest.

package main

import (
	"context"
	"fmt"
	"net/http"

	"github.com/actatum/postman-client/rest"
)

func main() {
	// Create a new rest client.
	rc := rest.NewClient("api-key")
	body := map[string]map[string]string{
		"workspace": {
			"name":        "Test Workspace",
			"type":        "personal",
			"description": "This is a test personal workspace.",
		},
	}

	// Create http request.
	r, err := rc.NewRequest(
		context.Background(),
		http.MethodPost,
		"https://api.getpostman.com/workspaces",
		body,
	)
	if err != nil {
		panic(err)
	}

	// Do request and unmarshal into response object.
	var response map[string]interface{}
	err = rc.DoRequest(r, &response)
	if err != nil {
		panic(err)
	}

	fmt.Printf("Response: %v\n", response)
}

How to Contribute

  • Fork this repository
  • Add your change or fix
  • Make sure tests pass
  • Create a pull request

Current contributors:

Tests

  • Unit tests: go test -v -race -cover -short ./...
  • Unit & Integration tests: go test -v -race -cover ./...

Documentation

Overview

Package postman provides a client set with handles to all the different postman endpoints.

Package postman provides a client set with handles to all the different postman endpoints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientSet

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

ClientSet holds handles to all the different postman endpoint clients.

func NewClientSet

func NewClientSet(apiKey string, opts ...Option) *ClientSet

NewClientSet returns a new instance of ClientSet.

func (*ClientSet) APISecurity

func (cs *ClientSet) APISecurity() *apisecurity.Client

APISecurity returns a handle to an apiesecurity.Client.

func (*ClientSet) AuditLogs

func (cs *ClientSet) AuditLogs() *auditlogs.Client

AuditLogs returns a handle to an auditlogs.Client.

func (*ClientSet) Collections

func (cs *ClientSet) Collections() *collections.Client

Collections returns a handle to a collections.Client.

func (*ClientSet) Environments

func (cs *ClientSet) Environments() *environments.Client

Environments returns a handle to an environments.Client.

func (*ClientSet) Monitors

func (cs *ClientSet) Monitors() *monitors.Client

Monitors returns a handle to a monitors.Client.

func (*ClientSet) Users

func (cs *ClientSet) Users() *user.Client

Users returns a handle to a user.Client.

func (*ClientSet) Webhooks

func (cs *ClientSet) Webhooks() *webhooks.Client

Webhooks returns a handle to a webhooks.Client.

func (*ClientSet) Workspaces

func (cs *ClientSet) Workspaces() *workspaces.Client

Workspaces returns a handle to a workspaces.Client.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option represents functional options for configuring the client.

func WithDebugLog

func WithDebugLog(w io.Writer) Option

WithDebugLog configures the io.Writer to send debug logging output to.

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient configures the client to use the given http.Client.

Directories

Path Synopsis
Package apisecurity provides types/client for making requests to /security/api-validation.
Package apisecurity provides types/client for making requests to /security/api-validation.
Package auditlogs provides types/client for making requests to /audit/logs.
Package auditlogs provides types/client for making requests to /audit/logs.
Package collections provides types/client for making requests to /collections.
Package collections provides types/client for making requests to /collections.
Package environments provides types/client for making requests to /environments.
Package environments provides types/client for making requests to /environments.
Package monitors provides types/client for making requests to /monitors.
Package monitors provides types/client for making requests to /monitors.
Package rest provides types/client for making requests to the postman REST api.
Package rest provides types/client for making requests to the postman REST api.
Package user provides types/client for making requests to /me.
Package user provides types/client for making requests to /me.
Package webhooks provides types/client for making requests to /webhooks.
Package webhooks provides types/client for making requests to /webhooks.
Package workspaces provides types/client for making requests to /workspaces.
Package workspaces provides types/client for making requests to /workspaces.

Jump to

Keyboard shortcuts

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