Class ClientUtils
Utility functions providing some benefit to API client consumers.
Inherited Members
Namespace: Pulumi.Esc.Sdk.Client
Assembly: Pulumi.Esc.Sdk.dll
Syntax
public static class ClientUtils
Fields
View SourceBASE_ADDRESS
The base path of the API
Declaration
public const string BASE_ADDRESS = "https://api.pulumi.com/api/esc"
Field Value
| Type | Description |
|---|---|
| string |
CONTEXT_PATH
The context path of the API
Declaration
public const string CONTEXT_PATH = "/api/esc"
Field Value
| Type | Description |
|---|---|
| string |
HOST
The host of the API
Declaration
public const string HOST = "api.pulumi.com"
Field Value
| Type | Description |
|---|---|
| string |
ISO8601_DATETIME_FORMAT
The format to use for DateTime serialization
Declaration
public const string ISO8601_DATETIME_FORMAT = "o"
Field Value
| Type | Description |
|---|---|
| string |
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 |
SCHEME
The scheme of the API
Declaration
public const string SCHEME = "https"
Field Value
| Type | Description |
|---|---|
| string |
Methods
View SourceApiKeyHeaderToString(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 |
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. |
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. |
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. |
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 |
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 |
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. |
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. |
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 |
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 |
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 |