package runtime
import "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
Package runtime contains various facilities for creating requests and handling responses. The content is intended for SDK authors.
Index ¶
- func DecodeByteArray(s string, v *[]byte, format Base64Encoding) error
- func Drain(resp *http.Response)
- func EncodeByteArray(v []byte, format Base64Encoding) string
- func HasStatusCode(resp *http.Response, statusCodes ...int) bool
- func JoinPaths(root string, paths ...string) string
- func MarshalAsByteArray(req *policy.Request, v []byte, format Base64Encoding) error
- func MarshalAsJSON(req *policy.Request, v interface{}) error
- func MarshalAsXML(req *policy.Request, v interface{}) error
- func NewLogPolicy(o *policy.LogOptions) policy.Policy
- func NewPoller(pollerID string, resp *http.Response, pl pipeline.Pipeline, eu func(*http.Response) error) (*pollers.Poller, error)
- func NewPollerFromResumeToken(pollerID string, token string, pl pipeline.Pipeline, eu func(*http.Response) error) (*pollers.Poller, error)
- func NewRequest(ctx context.Context, httpMethod string, endpoint string) (*pipeline.Request, error)
- func NewRequestIdPolicy() policy.Policy
- func NewResponseError(inner error, resp *http.Response) error
- func NewRetryPolicy(o *policy.RetryOptions) policy.Policy
- func NewTelemetryPolicy(mod, ver string, o *policy.TelemetryOptions) policy.Policy
- func Payload(resp *http.Response) ([]byte, error)
- func SetMultipartFormData(req *policy.Request, formData map[string]interface{}) error
- func UnmarshalAsByteArray(resp *http.Response, v *[]byte, format Base64Encoding) error
- func UnmarshalAsJSON(resp *http.Response, v interface{}) error
- func UnmarshalAsXML(resp *http.Response, v interface{}) error
- type Base64Encoding
- type BearerTokenPolicy
- func NewBearerTokenPolicy(cred azcore.TokenCredential, scopes []string, opts *policy.BearerTokenOptions) *BearerTokenPolicy
- func (b *BearerTokenPolicy) Do(req *policy.Request) (*http.Response, error)
- type Pipeline
Functions ¶
func DecodeByteArray ¶
func DecodeByteArray(s string, v *[]byte, format Base64Encoding) error
DecodeByteArray will base-64 decode the provided string into v.
func Drain ¶
Drain reads the response body to completion then closes it. The bytes read are discarded.
func EncodeByteArray ¶
func EncodeByteArray(v []byte, format Base64Encoding) string
EncodeByteArray will base-64 encode the byte slice v.
func HasStatusCode ¶
HasStatusCode returns true if the Response's status code is one of the specified values.
func JoinPaths ¶
JoinPaths concatenates multiple URL path segments into one path, inserting path separation characters as required. JoinPaths will preserve query parameters in the root path
func MarshalAsByteArray ¶
func MarshalAsByteArray(req *policy.Request, v []byte, format Base64Encoding) error
MarshalAsByteArray will base-64 encode the byte slice v, then calls SetBody. The encoded value is treated as a JSON string.
func MarshalAsJSON ¶
MarshalAsJSON calls json.Marshal() to get the JSON encoding of v then calls SetBody.
func MarshalAsXML ¶
MarshalAsXML calls xml.Marshal() to get the XML encoding of v then calls SetBody.
func NewLogPolicy ¶
func NewLogPolicy(o *policy.LogOptions) policy.Policy
NewLogPolicy creates a request/response logging policy object configured using the specified options. Pass nil to accept the default values; this is the same as passing a zero-value options.
func NewPoller ¶
func NewPoller(pollerID string, resp *http.Response, pl pipeline.Pipeline, eu func(*http.Response) error) (*pollers.Poller, error)
NewPoller creates a Poller based on the provided initial response. pollerID - a unique identifier for an LRO, it's usually the client.Method string.
func NewPollerFromResumeToken ¶
func NewPollerFromResumeToken(pollerID string, token string, pl pipeline.Pipeline, eu func(*http.Response) error) (*pollers.Poller, error)
NewPollerFromResumeToken creates a Poller from a resume token string. pollerID - a unique identifier for an LRO, it's usually the client.Method string.
func NewRequest ¶
NewRequest creates a new policy.Request with the specified input.
func NewRequestIdPolicy ¶
func NewResponseError ¶
NewResponseError wraps the specified error with an error that provides access to an HTTP response. If an HTTP request returns a non-successful status code, wrap the response and the associated error in this error type so that callers can access the underlying *http.Response as required. DO NOT wrap failed HTTP requests that returned an error and no response with this type.
func NewRetryPolicy ¶
func NewRetryPolicy(o *policy.RetryOptions) policy.Policy
NewRetryPolicy creates a policy object configured using the specified options. Pass nil to accept the default values; this is the same as passing a zero-value options.
func NewTelemetryPolicy ¶
func NewTelemetryPolicy(mod, ver string, o *policy.TelemetryOptions) policy.Policy
NewTelemetryPolicy creates a telemetry policy object that adds telemetry information to outgoing HTTP requests. The format is [<application_id> ]azsdk-go-<mod>/<ver> <platform_info>. Pass nil to accept the default values; this is the same as passing a zero-value options.
func Payload ¶
Payload reads and returns the response body or an error. On a successful read, the response body is cached.
func SetMultipartFormData ¶
SetMultipartFormData writes the specified keys/values as multi-part form fields with the specified value. File content must be specified as a ReadSeekCloser. All other values are treated as string values.
func UnmarshalAsByteArray ¶
func UnmarshalAsByteArray(resp *http.Response, v *[]byte, format Base64Encoding) error
UnmarshalAsByteArray will base-64 decode the received payload and place the result into the value pointed to by v.
func UnmarshalAsJSON ¶
UnmarshalAsJSON calls json.Unmarshal() to unmarshal the received payload into the value pointed to by v.
func UnmarshalAsXML ¶
UnmarshalAsXML calls xml.Unmarshal() to unmarshal the received payload into the value pointed to by v.
Types ¶
type Base64Encoding ¶
type Base64Encoding int
Base64Encoding is usesd to specify which base-64 encoder/decoder to use when encoding/decoding a slice of bytes to/from a string.
const ( // Base64StdFormat uses base64.StdEncoding for encoding and decoding payloads. Base64StdFormat Base64Encoding = 0 // Base64URLFormat uses base64.RawURLEncoding for encoding and decoding payloads. Base64URLFormat Base64Encoding = 1 )
type BearerTokenPolicy ¶
type BearerTokenPolicy struct {
// contains filtered or unexported fields
}
BearerTokenPolicy authorizes requests with bearer tokens acquired from a TokenCredential.
func NewBearerTokenPolicy ¶
func NewBearerTokenPolicy(cred azcore.TokenCredential, scopes []string, opts *policy.BearerTokenOptions) *BearerTokenPolicy
NewBearerTokenPolicy creates a policy object that authorizes requests with bearer tokens. cred: an azcore.TokenCredential implementation such as a credential object from azidentity scopes: the list of permission scopes required for the token. opts: optional settings. Pass nil to accept default values; this is the same as passing a zero-value options.
func (*BearerTokenPolicy) Do ¶
Do authorizes a request with a bearer token
type Pipeline ¶
Pipeline represents a primitive for sending HTTP requests and receiving responses. Its behavior can be extended by specifying policies during construction.
func NewPipeline ¶
func NewPipeline(module, version string, perCall, perRetry []policy.Policy, options *policy.ClientOptions) Pipeline
NewPipeline creates a pipeline from connection options, with any additional policies as specified. module, version: used by the telemetry policy, when enabled perCall: additional policies to invoke once per request perRetry: additional policies to invoke once per request and once per retry of that request
Source Files ¶
doc.go errors.go pipeline.go policy_bearer_token.go policy_body_download.go policy_http_header.go policy_logging.go policy_request_id.go policy_retry.go policy_telemetry.go poller.go request.go response.go transport_default_http_client.go
- Version
- v0.20.0
- Published
- Oct 22, 2021
- Platform
- js/wasm
- Imports
- 32 packages
- Last checked
- 15 hours ago –
Tools for package owners.