Categorygithub.com/speakeasy-sdks/testpan-go
repositorypackage
0.11.2
Repository: https://github.com/speakeasy-sdks/testpan-go.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

github.com/speakeasy-sdks/testpan-go

SDK Installation

go get github.com/speakeasy-sdks/testpan-go

SDK Example Usage

Example

package main

import (
	"context"
	testpango "github.com/speakeasy-sdks/testpan-go"
	"github.com/speakeasy-sdks/testpan-go/pkg/models/operations"
	"github.com/speakeasy-sdks/testpan-go/pkg/models/shared"
	"log"
)

func main() {
	s := testpango.New(
		testpango.WithSecurity(shared.Security{
			Password: testpango.String("<YOUR_PASSWORD_HERE>"),
		}),
	)

	ctx := context.Background()
	res, err := s.Users.DeleteUsersUserID(ctx, operations.DeleteUsersUserIDRequest{
		UserID: "2d4aef6d-76db-4c57-a2a3-fe8efd3db6e2",
	})
	if err != nil {
		log.Fatal(err)
	}
	if res != nil {
		// handle response
	}
}

Available Resources and Operations

Users

ImagesAndVulnerabilities

Advisor

AgentManagement

API

  • GetAPI - Get Secure Application API as a Swagger file

APISecurity

Performance

Bfla

APISecurityPolicies

Telemetries

Apps

EnvironmentPolicies

AuditLogs

Aws

Cd

CICDPolicies

Serverless

ConnectionPolicies

Dashboard

Deployers

Envs

Expansions

Gateways

Kubernetes

K8sCisBenchmark

ClusterEventsPolicies

Mitre

RuntimeMap

PspProfiles

Registries

RiskAssessment

Settings

ServerlessPolicies

Tokens

Cli

Truncation

TrustedSigners

Vulnerabilities

Special Types

Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or an error, they will never return both. When specified by the OpenAPI spec document, the SDK will return the appropriate subclass.

Error ObjectStatus CodeContent Type
sdkerrors.APIResponse402application/json
sdkerrors.SDKError4xx-5xx/

Example

package main

import (
	"context"
	"errors"
	testpango "github.com/speakeasy-sdks/testpan-go"
	"github.com/speakeasy-sdks/testpan-go/pkg/models/operations"
	"github.com/speakeasy-sdks/testpan-go/pkg/models/sdkerrors"
	"github.com/speakeasy-sdks/testpan-go/pkg/models/shared"
	"log"
)

func main() {
	s := testpango.New(
		testpango.WithSecurity(shared.Security{
			Password: testpango.String("<YOUR_PASSWORD_HERE>"),
		}),
	)

	ctx := context.Background()
	res, err := s.Users.PostLogin(ctx, operations.PostLoginRequest{})
	if err != nil {

		var e *sdkerrors.APIResponse
		if errors.As(err, &e) {
			// handle error
			log.Fatal(e.Error())
		}

		var e *sdkerrors.SDKError
		if errors.As(err, &e) {
			// handle error
			log.Fatal(e.Error())
		}
	}
}

Server Selection

Select Server by Index

You can override the default server globally using the WithServerIndex option when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:

#ServerVariables
0https:///apiNone

Example

package main

import (
	"context"
	testpango "github.com/speakeasy-sdks/testpan-go"
	"github.com/speakeasy-sdks/testpan-go/pkg/models/operations"
	"github.com/speakeasy-sdks/testpan-go/pkg/models/shared"
	"log"
)

func main() {
	s := testpango.New(
		testpango.WithServerIndex(0),
		testpango.WithSecurity(shared.Security{
			Password: testpango.String("<YOUR_PASSWORD_HERE>"),
		}),
	)

	ctx := context.Background()
	res, err := s.Users.DeleteUsersUserID(ctx, operations.DeleteUsersUserIDRequest{
		UserID: "2d4aef6d-76db-4c57-a2a3-fe8efd3db6e2",
	})
	if err != nil {
		log.Fatal(err)
	}
	if res != nil {
		// handle response
	}
}

Override Server URL Per-Client

The default server can also be overridden globally using the WithServerURL option when initializing the SDK client instance. For example:

package main

import (
	"context"
	testpango "github.com/speakeasy-sdks/testpan-go"
	"github.com/speakeasy-sdks/testpan-go/pkg/models/operations"
	"github.com/speakeasy-sdks/testpan-go/pkg/models/shared"
	"log"
)

func main() {
	s := testpango.New(
		testpango.WithServerURL("https:///api"),
		testpango.WithSecurity(shared.Security{
			Password: testpango.String("<YOUR_PASSWORD_HERE>"),
		}),
	)

	ctx := context.Background()
	res, err := s.Users.DeleteUsersUserID(ctx, operations.DeleteUsersUserIDRequest{
		UserID: "2d4aef6d-76db-4c57-a2a3-fe8efd3db6e2",
	})
	if err != nil {
		log.Fatal(err)
	}
	if res != nil {
		// handle response
	}
}

Custom HTTP Client

The Go SDK makes API calls that wrap an internal HTTP client. The requirements for the HTTP client are very simple. It must match this interface:

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

The built-in net/http client satisfies this interface and a default client based on the built-in is provided by default. To replace this default with a client of your own, you can implement this interface yourself or provide your own client configured as desired. Here's a simple example, which adds a client with a 30 second timeout.

import (
	"net/http"
	"time"
	"github.com/myorg/your-go-sdk"
)

var (
	httpClient = &http.Client{Timeout: 30 * time.Second}
	sdkClient  = sdk.New(sdk.WithClient(httpClient))
)

This can be a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration.

Authentication

Per-Client Security Schemes

This SDK supports the following security schemes globally:

NameTypeScheme
PasswordhttpHTTP Basic
UsernamehttpHTTP Basic

You can set the security parameters through the WithSecurity option when initializing the SDK client instance. The selected scheme will be used by default to authenticate with the API for all operations that support it. For example:

package main

import (
	"context"
	testpango "github.com/speakeasy-sdks/testpan-go"
	"github.com/speakeasy-sdks/testpan-go/pkg/models/operations"
	"github.com/speakeasy-sdks/testpan-go/pkg/models/shared"
	"log"
)

func main() {
	s := testpango.New(
		testpango.WithSecurity(shared.Security{
			Password: testpango.String("<YOUR_PASSWORD_HERE>"),
		}),
	)

	ctx := context.Background()
	res, err := s.Users.DeleteUsersUserID(ctx, operations.DeleteUsersUserIDRequest{
		UserID: "2d4aef6d-76db-4c57-a2a3-fe8efd3db6e2",
	})
	if err != nil {
		log.Fatal(err)
	}
	if res != nil {
		// handle response
	}
}

Development

Maturity

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributions

While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!

SDK Created by Speakeasy