Show / Hide Table of Contents

Class ClientUtils

Utility functions providing some benefit to API client consumers.

Inheritance
object
ClientUtils
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Pulumi.Esc.Sdk.Client
Assembly: Pulumi.Esc.Sdk.dll
Syntax
public static class ClientUtils

Fields

View Source

BASE_ADDRESS

The base path of the API

Declaration
public const string BASE_ADDRESS = "https://api.pulumi.com/api/esc"
Field Value
Type Description
string
View Source

CONTEXT_PATH

The context path of the API

Declaration
public const string CONTEXT_PATH = "/api/esc"
Field Value
Type Description
string
View Source

HOST

The host of the API

Declaration
public const string HOST = "api.pulumi.com"
Field Value
Type Description
string
View Source

ISO8601_DATETIME_FORMAT

The format to use for DateTime serialization

Declaration
public const string ISO8601_DATETIME_FORMAT = "o"
Field Value
Type Description
string
View Source

JsonRegex

Provides a case-insensitive check that a provided content type is a known JSON-like content type.

Declaration
public static readonly Regex JsonRegex
Field Value
Type Description
Regex
View Source

SCHEME

The scheme of the API

Declaration
public const string SCHEME = "https"
Field Value
Type Description
string

Methods

View Source

ApiKeyHeaderToString(ApiKeyHeader)

Converte an ApiKeyHeader to a string

Declaration
public static string ApiKeyHeaderToString(ClientUtils.ApiKeyHeader value)
Parameters
Type Name Description
ClientUtils.ApiKeyHeader value
Returns
Type Description
string
Exceptions
Type Condition
InvalidEnumArgumentException
View Source

Base64Encode(string)

Encode string in base64 format.

Declaration
public static string Base64Encode(string text)
Parameters
Type Name Description
string text

string to be encoded.

Returns
Type Description
string

Encoded string.

View Source

IsJsonMime(string)

Check if the given MIME is a JSON MIME. JSON MIME examples: application/json application/json; charset=UTF8 APPLICATION/JSON application/vnd.company+json

Declaration
public static bool IsJsonMime(string mime)
Parameters
Type Name Description
string mime

MIME

Returns
Type Description
bool

Returns True if MIME type is json.

View Source

ParameterToString(object?, string?)

If parameter is DateTime, output in a formatted string (default ISO 8601), customizable with Configuration.DateTime. If parameter is a list, join the list with ",". Otherwise just return the string.

Declaration
public static string? ParameterToString(object? obj, string? format = "o")
Parameters
Type Name Description
object obj

The parameter (header, path, query, form).

string format

The DateTime serialization format.

Returns
Type Description
string

Formatted string.

View Source

ReadAsBytes(Stream)

Convert stream to byte array

Declaration
public static byte[] ReadAsBytes(Stream inputStream)
Parameters
Type Name Description
Stream inputStream

Input stream to be converted

Returns
Type Description
byte[]

Byte array

View Source

SanitizeFilename(string)

Sanitize filename by removing the path

Declaration
public static string SanitizeFilename(string filename)
Parameters
Type Name Description
string filename

Filename

Returns
Type Description
string

Filename

View Source

SelectHeaderAccept(string[])

Select the Accept header's value from the given accepts array: if JSON exists in the given array, use it; otherwise use all of them (joining into a string)

Declaration
public static string? SelectHeaderAccept(string[] accepts)
Parameters
Type Name Description
string[] accepts

The accepts array to select from.

Returns
Type Description
string

The Accept header to use.

View Source

SelectHeaderContentType(string[])

Select the Content-Type header's value from the given content-type array: if JSON type exists in the given array, use it; otherwise use the first one defined in 'consumes'

Declaration
public static string? SelectHeaderContentType(string[] contentTypes)
Parameters
Type Name Description
string[] contentTypes

The Content-Type array to select from.

Returns
Type Description
string

The Content-Type header to use.

View Source

TryDeserialize<T>(string, JsonSerializerOptions, out T?)

Returns true when deserialization succeeds.

Declaration
public static bool TryDeserialize<T>(string json, JsonSerializerOptions options, out T? result)
Parameters
Type Name Description
string json
JsonSerializerOptions options
T result
Returns
Type Description
bool
Type Parameters
Name Description
T
View Source

TryDeserialize<T>(ref Utf8JsonReader, JsonSerializerOptions, out T?)

Returns true when deserialization succeeds.

Declaration
public static bool TryDeserialize<T>(ref Utf8JsonReader reader, JsonSerializerOptions options, out T? result)
Parameters
Type Name Description
Utf8JsonReader reader
JsonSerializerOptions options
T result
Returns
Type Description
bool
Type Parameters
Name Description
T
View Source

UrlEncode(string)

URL encode a string Credit/Ref: https://github.com/restsharp/RestSharp/blob/master/RestSharp/Extensions/StringExtensions.cs#L50

Declaration
public static string UrlEncode(string input)
Parameters
Type Name Description
string input

string to be URL encoded

Returns
Type Description
string

Byte array

Version 0.13.1

  • View Source
Back to top Copyright 2016-2023, Pulumi Corporation.