cfnetv1

package
v6.29.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package cfnetv1 represents a CF Networking V1 client.

These sets of packages are still under development/pre-pre-pre...alpha. Use at your own risk! Functionality and design may change without warning.

For more information on the CF Networking API see https://github.com/cloudfoundry-incubator/cf-networking-release/blob/develop/docs/API.md

Method Naming Conventions

The client takes a '<Action Name><Top Level Endpoint><Return Value>' approach to method names. If the <Top Level Endpoint> and <Return Value> are similar, they do not need to be repeated. If a GUID is required for the <Top Level Endpoint>, the pluralization is removed from said endpoint in the method name.

For Example:

Method Name: GetApplication
Endpoint: /v2/applications/:guid
Action Name: Get
Top Level Endpoint: applications
Return Value: Application

Method Name: GetServiceInstances
Endpoint: /v2/service_instances
Action Name: Get
Top Level Endpoint: service_instances
Return Value: []ServiceInstance

Method Name: GetSpaceServiceInstances
Endpoint: /v2/spaces/:guid/service_instances
Action Name: Get
Top Level Endpoint: spaces
Return Value: []ServiceInstance

Use the following table to determine which HTTP Command equates to which Action Name:

HTTP Command -> Action Name
POST -> Create
GET -> Get
PUT -> Update
DELETE -> Delete

Method Locations

Methods exist in the same file as their return type, regardless of which endpoint they use.

Error Handling

All error handling that requires parsing the error_code/code returned back from the Cloud Controller should be placed in the errorWrapper. Everything else can be handled in the individual operations. All parsed cloud controller errors should exist in errors.go, all generic HTTP errors should exist in the cloudcontroller's errors.go. Errors related to the individaul operation should exist at the top of that operation's file.

No inline-relations-depth And summary Endpoints

This package will not use ever use 'inline-relations-depth' or the '/summary' endpoints for any operations. These requests can be extremely taxing on the Cloud Controller and are avoided at all costs. Additionally, the objects returned back from these requests can become extremely inconsistant across versions and are problematic to deal with in general.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a client that can be used to talk to a CF Networking API.

func NewClient

func NewClient(config Config) *Client

NewClient returns a new CF Networking client.

func (Client) CreatePolicies

func (client Client) CreatePolicies(policies []Policy) error

CreatePolicies will create the network policy with the given parameters.

func (*Client) WrapConnection

func (client *Client) WrapConnection(wrapper ConnectionWrapper)

WrapConnection wraps the current Client connection in the wrapper.

type Config

type Config struct {
	// AppName is the name of the application/process using the client.
	AppName string

	// AppVersion is the version of the application/process using the client.
	AppVersion string

	// DialTimeout is the DNS timeout used to make all requests to the Cloud
	// Controller.
	DialTimeout time.Duration

	// SkipSSLValidation controls whether a client verifies the server's
	// certificate chain and host name. If SkipSSLValidation is true, TLS accepts
	// any certificate presented by the server and any host name in that
	// certificate for *all* client requests going forward.
	//
	// In this mode, TLS is susceptible to man-in-the-middle attacks. This should
	// be used only for testing.
	SkipSSLValidation bool

	// URL is a fully qualified URL to the CF Networking API.
	URL string

	// Wrappers that apply to the client connection.
	Wrappers []ConnectionWrapper
}

Config allows the Client to be configured

type ConnectionWrapper

type ConnectionWrapper interface {
	cfnetworking.Connection
	Wrap(innerconnection cfnetworking.Connection) cfnetworking.Connection
}

ConnectionWrapper can wrap a given connection allowing the wrapper to modify all requests going in and out of the given connection.

type Params

type Params map[string]string

Params represents URI parameters for a request.

type Policy

type Policy struct {
	Source      PolicySource      `json:"source"`
	Destination PolicyDestination `json:"destination"`
}

type PolicyDestination

type PolicyDestination struct {
	ID       string         `json:"id"`
	Protocol PolicyProtocol `json:"protocol"`
	Ports    Ports          `json:"ports"`
}

type PolicyList

type PolicyList struct {
	TotalPolicies int      `json:"total_policies,omitempty"`
	Policies      []Policy `json:"policies"`
}

type PolicyProtocol

type PolicyProtocol string
const (
	PolicyProtocolTCP PolicyProtocol = "tcp"
	PolicyProtocolUDP PolicyProtocol = "udp"
)

type PolicySource

type PolicySource struct {
	ID string `json:"id"`
}

type Ports

type Ports struct {
	Start int `json:"start"`
	End   int `json:"end"`
}

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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