C# Client Library
A C# Client Library for the AnalyzeRe REST API
AnalyzeRe.API Class Reference

API methods / requests made available to the user. More...

Classes

class  Parameters
 Parameters that can be added to your REST requests to access additional API features. More...
 
class  PollingOptions
 A duplicate of the AnalyzeRe.PollingOptions class. More...
 
class  PortfolioViewMarginals
 Represents the endpoint on the server for requesting marginal portfolios. More...
 

Public Types

enum  SearchType { SearchType.Basic, SearchType.Advanced }
 The search type determines the interpretation of the query string. More...
 

Public Member Functions

delegate void AuthenticationRequestedHandler (ref IAccessToken ToAuthenticate, string RequestedAuthentication)
 A handler that can respond to a AuthenticationRequestedHandler event. More...
 

Static Public Member Functions

static ICollectionResponse< IAPIResourceBatchGet (Type resourceType, IEnumerable< string > ids, IEnumerable< Parameter > requestParameters=null, string collectionNameOverride=null, int?timeout=null)
 Get a collection of resources from the server that match the set of resource ids specified. More...
 
static ICollectionResponse< T > BatchGet< T > (IEnumerable< string > ids, IEnumerable< Parameter > requestParameters=null, string collectionNameOverride=null, int?timeout=null)
 Get a collection of resources from the server that match the set of resource ids specified. More...
 
static void ClearCachedAuthenticationCredentials (string server=null)
 The Analyze Re API .NET Client Library caches authentication tokens that have been validated via the AuthenticationRequested event. This means that all applications on the same machine using this library can be authenticated once the first application is authenticated. These credentials will automatically be forgotten if they are revoked by the server, but this method can be used to forget all cached credentials, or just the credentials for a specific server if one is specified. More...
 
static IRestResponse ExecuteRestRequest (string resource, Method method, IEnumerable< Parameter > requestParameters=null, int?timeout=null, bool returnRawResponse=false, Action< Stream > responseStreamReader=null)
 Perform a REST request on the server. More...
 
static object ExtractRestResponse (IRestResponse response, Type deserializeType)
 Attempts to deserialize an IRestResponse content to the specified run-time type More...
 
static T ExtractRestResponse< T > (IRestResponse response)
 Attempts to deserialize an IRestResponse content to the specified type T More...
 
static T Get< T > (string id, IEnumerable< Parameter > requestParameters=null, int?timeout=null)
 Get the selected resource by ID. The appropriate collection is automatically determined by the resource type. More...
 
static AuthenticationStatus GetAuthenticationStatus (bool force_request=false)
 Determines whether we are currently authenticated against the server with the global default AuthenticationToken. If the current authentication status is unknown, Invokes a request to test the authentication status. More...
 
static string GetCollectionName (Type requestType)
 Gets the collection name for the given APIResource type, whether it's instantiable or not. More...
 
static string GetCollectionName (Type requestType, out Type declaringClassType, bool suppress_throw=false)
 Gets the collection name for the given APIResource type, whether it's instantiable or not. More...
 
static string GetCollectionName< T > ()
 Gets the collection name for the given APIResource type, whether it's instantiable or not. More...
 
static string GetCollectionName< T > (out Type declaringClassType)
 Gets the collection name for the given APIResource type, whether it's instantiable or not. More...
 
static string GetCollectionNameFromResourceHref (string href)
 Return the collection name implied by the href for a given resource assuming the URL is in the format: https://apiurl.net/collection_name/guid More...
 
static string GetCurrentAuthorizationString ()
 Return the Authorization header string formed by the current AuthenticationToken. More...
 
static ICollectionResponse< IAPIResourceGetResourceList (Type resourceType, IEnumerable< Parameter > requestParameters=null, string collectionNameOverride=null, int?timeout=null)
 Get a collection of resources from the server. More...
 
static ICollectionResponse< T > GetResourceList< T > (IEnumerable< Parameter > requestParameters=null, string collectionNameOverride=null, int?timeout=null)
 Get a collection of resources from the server. More...
 
static object GetUri (Type deserializeType, Uri href, IEnumerable< Parameter > requestParameters=null, int?timeout=null)
 Perform a GET on an arbitrary resource by extracting the path and query parameters from a manually specified Uri. More...
 
static T GetUri< T > (Uri href, IEnumerable< Parameter > requestParameters=null, int?timeout=null)
 Perform a GET on an arbitrary resource by extracting the path and query parameters from a manually specified Uri. More...
 
static bool IsAReServerActive (string checkServerURL, int?timeout=null)
 Determines if the provided URL is a valid running Analyze Re server. More...
 
static bool IsSuccessful (this IRestResponse response)
 Extension method that returns true if the restResponse was completed and contains a successful status code. More...
 
static void LoadSettings ()
 Reloads all shared client library settings from the current statically configured SharedSettingsProvider.GlobalSettingsLocation. If this method is not invoked, or settings are not individually set, settings are loaded automatically when the first request is made, but can be repeated manually if the external settings file is modified or the desired settings location is changed. More...
 
static OptionsResponse Options (IEnumerable< Parameter > requestParameters=null, int?timeout=null)
 Perform an OPTIONS request on the API, which returns a list of features supported for the current authenticated user. More...
 
static void PollUntil (Func< bool > request, AnalyzeRe.PollingOptions pollingOptions=null)
 Poll the specified request until it returns true. More...
 
static TResponse PollUntil< TResponse > (Func< TResponse > request, Func< TResponse, bool > isPollingComplete, AnalyzeRe.PollingOptions pollingOptions=null)
 Poll the requested resource until a desired state is attained. More...
 
static T PollUntilReady< T > (Func< T > functionThatMight503, AnalyzeRe.PollingOptions pollingOptions=null)
 Specialized polling that will executes the specified request delegate, but if a 503 retry-after APIRequestException is encountered, it blocks until the request returns successfully or the maximum polling time is exceeded. More...
 
static T PollUntilReady< T > (Func< T > functionThatMight503, double minPollInterval=0d, double maxPollInterval=Double.MaxValue, double maxPollTotalTime=Double.MaxValue)
 Obsolete.

See also
PollUntilReady<T>(Func<T>,AnalyzeRe.PollingOptions)

Executes the specified request delegate, but if a 503 retry-after APIRequestException is encountered, it blocks until the request returns successfully or the maximum polling time is exceeded. More...

 
static string PrettyPrint (this IRestRequest request)
 Extension method that generates a helpful string representation of an IRestRequest. More...
 
static string PrettyPrint (this IRestResponse response)
 Extension method that generates a helpful string representation of an IRestResponse. More...
 
static object RequestAndParse (Type deserializeType, string resource, Method method, IEnumerable< Parameter > requestParameters=null, int?timeout=null)
 Perform a REST request on the server and serializes the response to the desired compile-time type. More...
 
static T RequestAndParse< T > (string resource, Method method, IEnumerable< Parameter > requestParameters=null, int?timeout=null)
 Perform a REST request on the server and serializes the response to the desired compile-time type. More...
 
static ICollectionResponse< IAPIResourceSearchResourceList (Type resourceType, string searchTerms, IEnumerable< Parameter > requestParameters=null, string collectionNameOverride=null, int?timeout=null, SearchType searchType=SearchType.Basic)
 Get a collection of resources from the server that match the specified search criteria. More...
 
static ICollectionResponse< T > SearchResourceList< T > (string searchTerms, IEnumerable< Parameter > requestParameters=null, string collectionNameOverride=null, int?timeout=null, SearchType searchType=SearchType.Basic)
 Get a collection of resources from the server that match the specified search criteria. More...
 
static bool TryHandleAuthenticationErrors (IRestResponse response, int sequentialAttempts=0)
 Checks an IRestResponse object for authentication errors, then invokes configured authentication delegates if the response was an "unauthorized" error. More...
 
static void TryPromptForAuthentication ()
 Invoke the AuthenticationRequested event, which requests authentication credentials for the server. Note: this will have no effect if already authenticated or authentication is not required for this server. More...
 

Static Public Attributes

static readonly ResourceCollection< AgentAgents
 The collection of Agents on the server. More...
 
static readonly ResourceCollection< AnalysisAnalyses
 The collection of Analyses on the server. More...
 
static readonly ResourceCollection< AnalysisProfileAnalysisProfiles
 The collection of AnalysisProfiles on the server. More...
 
static readonly string AnalyzeReCustomServerHeader = "ARE-Server"
 The Custom Server Header returned by valid AnalyzeRe servers. More...
 
static readonly string AnalyzeReServerIdentity = "ARE-API"
 The Server identity returned by valid AnalyzeRe servers. More...
 
static readonly string DateTimeFormat = @"O"
 The format used when transmitting DateTime information to Analyze Re servers. More...
 
static string DefaultServerURL => TryGetLibrarySettingObj(() => Settings.Default.DefaultServerURL)
 The Default ServerURL the API is instantiated with, as configured in the settings. More...
 
static readonly ResourceCollection< IDistributionDistributions
 The collection of Distributions on the server. More...
 
static readonly ResourceCollection< EventCatalogEventCatalogs
 The collection of EventCatalogs on the server. More...
 
static readonly ResourceCollection< ExchangeRateProfileExchangeRateProfiles
 The collection of ExchangeRateProfiles on the server. More...
 
static readonly ResourceCollection< ExchangeRateTableExchangeRateTables
 The collection of ExchangeRateTables on the server. More...
 
static readonly ResourceCollection< DataFileFiles
 The collection of Files on the server. More...
 
static readonly ResourceCollection< ILayerLayers
 The collection of Layers on the server. More...
 
static readonly ResourceCollection< ILayerViewLayerViews
 The collection of LayerViews on the server. More...
 
static readonly ResourceCollection< LossFilterLossFilters
 The collection of LossFilters on the server. More...
 
static readonly ResourceCollection< LossSetLossSets
 The collection of LossSets on the server. More...
 
static volatile int MaxRequestRetries = 3
 When a temporary communication failure occurs (such as a socket error or an authentication failure for which there is a handler) this property determines how many times the client will automatically retry the same request before returning the error. More...
 
static readonly ResourceCollection< MetricsFunctionMetricsFunctions
 The collection of optimization metrics functions on the server. More...
 
static readonly ResourceCollection< OptimizationViewOptimizationViews
 The collection of OptimizationViews on the server. More...
 
static readonly ResourceCollection< PortfolioPortfolios
 The collection of Portfolios on the server. More...
 
static readonly ResourceCollection< PortfolioViewPortfolioViews
 The collection of PortfolioViews on the server. More...
 
static readonly ResourceCollection< ProjectionFunctionProjectionFunctions
 The collection of optimization projection functions on the server. More...
 
static readonly ResourceCollection< SimulationSimulations
 The collection of Simulations on the server. More...
 

Properties

static IAccessToken AuthenticationToken [get, set]
 The AccessToken storing authentication information for requests made to the server. More...
 
static int DefaultRequestTimeout [get, set]
 The default timeout used for all simple server requests, in milliseconds. More...
 
static int DefaultRequestTimeoutCollections [get, set]
 The default timeout used when requesting a resource collection from the server, in milliseconds. More...
 
static bool ManagedSettingsEnabled [get, set]
 By Default, the Analyze Re Client Library will automatically save and restore certain configured settings such as timeouts and credentials. Set this to false to disable these features (for instance if they cause issues for your application). More...
 
static int Parallelism = true [get, set]
 The maximum number of concurrent requests that can be made. More...
 
static string ServerURL [get, set]
 The default server URL to be used for all API requests. On change, voids the current cached authentication credentials. More...
 
static string UserAgent [get, set]
 The UserAgent identifying the requests made by this client. This can be changed if an application wishes to better identify itself to the server. More...
 

Events

static AuthenticationRequestedHandler AuthenticationRequested
 An event that fires whenever authentication is requested by the server. This event can be used to prompt a user or other external source for credentials as needed, rather than hard-coding them into the application. More...
 

Detailed Description

API methods / requests made available to the user.

Partial class containing the members tied to requesting marginal portfolios.

API methods / requests made available to the user.

Definition at line 18 of file API.Authentication.cs.

Member Enumeration Documentation

The search type determines the interpretation of the query string.

Enumerator
Basic 

Search by keyword on predefined field.

Advanced 

Search by complex query on key-value metadata. See Parameters.AdvancedSearch for details about advanced searching.

Definition at line 289 of file API.Requests.cs.

Member Function Documentation

delegate void AnalyzeRe.API.AuthenticationRequestedHandler ( ref IAccessToken  ToAuthenticate,
string  RequestedAuthentication 
)

A handler that can respond to a AuthenticationRequestedHandler event.

Parameters
ToAuthenticateThe AccessToken to authenticate.
RequestedAuthenticationThe WWW-Authenticate header sent from the server.
static ICollectionResponse<IAPIResource> AnalyzeRe.API.BatchGet ( Type  resourceType,
IEnumerable< string >  ids,
IEnumerable< Parameter >  requestParameters = null,
string  collectionNameOverride = null,
int?  timeout = null 
)
inlinestatic

Get a collection of resources from the server that match the set of resource ids specified.

Parameters
resourceTypeThe runtime type of IAPIResource being retrieved.
idsThe list of resource ids to request from the server.
requestParametersOptional - Additional parameters to include in the request.
collectionNameOverrideOptional - The new name of the collection to search from the server (if not using the default collection for the specified resourceType )
timeoutOptional - The desired request timeout (in milliseconds).

This function will automatically set the "limit" parameter to match the number of ids requested, but the server may impose a hard limit on the number of ids that can be requested at one time. See Parameters.Ids for more details.

Returns
A list of APIResources of the matching the specified resourceType and ids.

Definition at line 406 of file API.Requests.cs.

static ICollectionResponse<T> AnalyzeRe.API.BatchGet< T > ( IEnumerable< string >  ids,
IEnumerable< Parameter >  requestParameters = null,
string  collectionNameOverride = null,
int?  timeout = null 
)
inlinestatic

Get a collection of resources from the server that match the set of resource ids specified.

Template Parameters
TThe type of IAPIResource being retrieved.
Parameters
idsThe list of resource ids to request from the server.
requestParametersOptional - Additional parameters to include in the request.
collectionNameOverrideOptional - The new name of the collection to search from the server (if not using the default collection for the resource type T )
timeoutOptional - The desired request timeout (in milliseconds).

This function will automatically set the "limit" parameter to match the number of ids requested, but the server may impose a hard limit on the number of ids that can be requested at one time. See Parameters.Ids for more details.

Returns
A list of APIResources of type T matching specified ids.
Type Constraints
T :IAPIResource 

Definition at line 378 of file API.Requests.cs.

static void AnalyzeRe.API.ClearCachedAuthenticationCredentials ( string  server = null)
inlinestatic

The Analyze Re API .NET Client Library caches authentication tokens that have been validated via the AuthenticationRequested event. This means that all applications on the same machine using this library can be authenticated once the first application is authenticated. These credentials will automatically be forgotten if they are revoked by the server, but this method can be used to forget all cached credentials, or just the credentials for a specific server if one is specified.

Parameters
server(Optional) A single server URL whose credentials should be forgotten.

Definition at line 438 of file API.Authentication.cs.

static IRestResponse AnalyzeRe.API.ExecuteRestRequest ( string  resource,
Method  method,
IEnumerable< Parameter >  requestParameters = null,
int?  timeout = null,
bool  returnRawResponse = false,
Action< Stream >  responseStreamReader = null 
)
inlinestatic

Perform a REST request on the server.

Parameters
resourceThe path of the resource or request target, from the root server URL.
methodThe HTTP method to execute, as a Rest.Method enumeration value.
requestParametersThe data to include in the request, in the form of Rest parameters.
timeoutOptional - The desired request timeout (in milliseconds).
returnRawResponseOptional (Default False) - By default, this client library will look at the response returned from the server and handle a number of known errors and response failures (like 503-RetryAfter errors) and return a more meaningful error, in some cases automatically resolving the errors itself.

You can disable this and return the raw IRestResponse from the server. To do this you must set the return type (T) to IRestResponse and set "returnRawResponse" to true.

Parameters
responseStreamReader(Optional) If supplied, the response body will be returned as a stream to the supplied delegate, rather than in the response body of the IRestResponse.
Returns
The server response, as an IRestResponse.

Definition at line 495 of file API.Requests.cs.

static object AnalyzeRe.API.ExtractRestResponse ( IRestResponse  response,
Type  deserializeType 
)
inlinestatic

Attempts to deserialize an IRestResponse content to the specified run-time type

Parameters
responseThe server response, as an IRestResponse.
deserializeTypeThe type to deserialize the JSON response to.
Returns
The string response content, or throws an exception if the response contains an error.

Definition at line 618 of file API.Requests.cs.

static T AnalyzeRe.API.ExtractRestResponse< T > ( IRestResponse  response)
inlinestatic

Attempts to deserialize an IRestResponse content to the specified type T

Template Parameters
TThe type to deserialize the JSON response to.
Parameters
responseThe server response, as an IRestResponse.
Returns
The string response content, or throws an exception if the response contains an error.

Definition at line 604 of file API.Requests.cs.

static T AnalyzeRe.API.Get< T > ( string  id,
IEnumerable< Parameter >  requestParameters = null,
int?  timeout = null 
)
inlinestatic

Get the selected resource by ID. The appropriate collection is automatically determined by the resource type.

Template Parameters
TThe expected type of the resource request response. Use 'IRestResponse' to skip deserializing the request.
Parameters
idThe id of the resource on the server.
requestParametersOptional - Additional parameters to include in the request.
timeoutOptional - The desired request timeout (in milliseconds).
Returns
The resource retrieved, deserialized to the specified type T.
Type Constraints
T :IAPIResource 

Definition at line 53 of file API.Requests.cs.

static AuthenticationStatus AnalyzeRe.API.GetAuthenticationStatus ( bool  force_request = false)
inlinestatic

Determines whether we are currently authenticated against the server with the global default AuthenticationToken. If the current authentication status is unknown, Invokes a request to test the authentication status.

Parameters
force_requestSet to true to force a request to be made to the server regardless of the cached authentication status on the current authentication token.
Returns
The current authentication status as an enumeration value.

Definition at line 388 of file API.Authentication.cs.

static string AnalyzeRe.API.GetCollectionName ( Type  requestType)
inlinestatic

Gets the collection name for the given APIResource type, whether it's instantiable or not.

Parameters
requestTypeThe type of resource for which to retrieve the collection name.
Returns
The collection name for the class. (i.e. The collection name for the Type 'CatXL' is "layers", and was defined by the class Type 'Layer')

Definition at line 263 of file API.Utilities.cs.

static string AnalyzeRe.API.GetCollectionName ( Type  requestType,
out Type  declaringClassType,
bool  suppress_throw = false 
)
inlinestatic

Gets the collection name for the given APIResource type, whether it's instantiable or not.

Parameters
requestTypeThe type of resource for which to retrieve the collection name.
declaringClassTypeWill be set to the Type that declared the collection name.
suppress_throwAllows the caller to suppress raising an exception if the no collection name exists for the specified class and return null instead.
Returns
The collection name for the class. (i.e. The collection name for the Type 'CatXL' is "layers", and was defined by the class Type 'Layer')

Definition at line 284 of file API.Utilities.cs.

static string AnalyzeRe.API.GetCollectionName< T > ( )
inlinestatic

Gets the collection name for the given APIResource type, whether it's instantiable or not.

Template Parameters
TThe type of resource for which to retrieve the collection name.
Returns
The collection name for the class. (i.e. The collection name for the Type 'CatXL' is "layers", and was defined by the class Type 'Layer')
Type Constraints
T :IAPIResource 

Definition at line 240 of file API.Utilities.cs.

static string AnalyzeRe.API.GetCollectionName< T > ( out Type  declaringClassType)
inlinestatic

Gets the collection name for the given APIResource type, whether it's instantiable or not.

Template Parameters
TThe type of resource for which to retrieve the collection name.
Parameters
declaringClassTypeWill be set to the Type that declared the collection name.
Returns
The collection name for the class. (i.e. The collection name for the Type 'CatXL' is "layers", and was defined by the class Type 'Layer')
Type Constraints
T :IAPIResource 

Definition at line 252 of file API.Utilities.cs.

static string AnalyzeRe.API.GetCollectionNameFromResourceHref ( string  href)
inlinestatic

Return the collection name implied by the href for a given resource assuming the URL is in the format: https://apiurl.net/collection_name/guid

Parameters
hrefA resource URL.
Returns
The collection_name portion of the url.

Definition at line 434 of file API.Utilities.cs.

static string AnalyzeRe.API.GetCurrentAuthorizationString ( )
inlinestatic

Return the Authorization header string formed by the current AuthenticationToken.

Returns
The string representation of the current AuthenticationToken.

Definition at line 53 of file API.Authentication.cs.

static ICollectionResponse<IAPIResource> AnalyzeRe.API.GetResourceList ( Type  resourceType,
IEnumerable< Parameter >  requestParameters = null,
string  collectionNameOverride = null,
int?  timeout = null 
)
inlinestatic

Get a collection of resources from the server.

Parameters
resourceTypeThe type of resource (any APIResource class).
requestParametersOptional - Additional parameters to include in the request.
collectionNameOverrideOptional - The new name of the collection to retrieve from the server (if not using the default collection for the resource type T)
timeoutOptional - The desired request timeout (in milliseconds).
Returns
A List of APIResources of the type T provided.

Definition at line 151 of file API.Requests.cs.

static ICollectionResponse<T> AnalyzeRe.API.GetResourceList< T > ( IEnumerable< Parameter >  requestParameters = null,
string  collectionNameOverride = null,
int?  timeout = null 
)
inlinestatic

Get a collection of resources from the server.

Template Parameters
TThe type of resource (any APIResource class).
Parameters
requestParametersOptional - Additional parameters to include in the request.
collectionNameOverrideOptional - The new name of the collection to retrieve from the server (if not using the default collection for the resource type T)
timeoutOptional - The desired request timeout (in milliseconds).
Returns
A List of APIResources of the type T provided.
Type Constraints
T :IAPIResource 

Definition at line 122 of file API.Requests.cs.

static object AnalyzeRe.API.GetUri ( Type  deserializeType,
Uri  href,
IEnumerable< Parameter >  requestParameters = null,
int?  timeout = null 
)
inlinestatic

Perform a GET on an arbitrary resource by extracting the path and query parameters from a manually specified Uri.

Parameters
deserializeTypeThe expected type of the resource request response. Use 'IRestResponse' to skip deserializing the request.
hrefThe request Uri to use. Note that only the path and query will be used. This method is not intended to facilitate requests made to a host other than the one configured as the API.ServerURL.
requestParametersOptional - Additional parameters to include in the request.
timeoutOptional - The desired request timeout (in milliseconds).
Returns
The resource retrieved, deserialized to the specified type T.

Definition at line 102 of file API.Requests.cs.

static T AnalyzeRe.API.GetUri< T > ( Uri  href,
IEnumerable< Parameter >  requestParameters = null,
int?  timeout = null 
)
inlinestatic

Perform a GET on an arbitrary resource by extracting the path and query parameters from a manually specified Uri.

Template Parameters
TThe expected type of the resource request response. Use 'IRestResponse' to skip deserializing the request.
Parameters
hrefThe request Uri to use. Note that only the path and query will be used. This method is not intended to facilitate requests made to a host other than the one configured as the API.ServerURL.
requestParametersOptional - Additional parameters to include in the request.
timeoutOptional - The desired request timeout (in milliseconds).
Returns
The resource retrieved, deserialized to the specified type T.

Definition at line 78 of file API.Requests.cs.

static bool AnalyzeRe.API.IsAReServerActive ( string  checkServerURL,
int?  timeout = null 
)
inlinestatic

Determines if the provided URL is a valid running Analyze Re server.

Parameters
checkServerURLThe server URL to check.
timeoutOptional - The desired request timeout (in milliseconds).
Returns
Returns true if the provided URL is a valid running Analyze Re server.

Definition at line 34 of file API.Utilities.cs.

static bool AnalyzeRe.API.IsSuccessful ( this IRestResponse  response)
inlinestatic

Extension method that returns true if the restResponse was completed and contains a successful status code.

Parameters
responseThe response received from the server.
Returns
True if the response is successful

Definition at line 647 of file API.Utilities.cs.

static void AnalyzeRe.API.LoadSettings ( )
static

Reloads all shared client library settings from the current statically configured SharedSettingsProvider.GlobalSettingsLocation. If this method is not invoked, or settings are not individually set, settings are loaded automatically when the first request is made, but can be repeated manually if the external settings file is modified or the desired settings location is changed.

Various default settings can be configured by modifying the appropriate Settings.Default attribute and saving changes.

static OptionsResponse AnalyzeRe.API.Options ( IEnumerable< Parameter >  requestParameters = null,
int?  timeout = null 
)
inlinestatic

Perform an OPTIONS request on the API, which returns a list of features supported for the current authenticated user.

Parameters
requestParametersOptional - Additional parameters to include in the request.
timeoutOptional - The desired request timeout (in milliseconds).
Returns
The Options response.

Definition at line 32 of file API.Requests.cs.

static void AnalyzeRe.API.PollUntil ( Func< bool >  request,
AnalyzeRe.PollingOptions  pollingOptions = null 
)
static

Poll the specified request until it returns true.

Parameters
requestA test condition that returns true or false.
pollingOptions(Optional) Polling options which determine the polling rates, total time, and allow for asynchronous cancellation.
Exceptions
NotWaitingExceptionIf the polling options max poll total time is exceeded and the request never returned true.
TaskCanceledExceptionIf the pollingOptions.CancellationToken enters the cancelled state.
static TResponse AnalyzeRe.API.PollUntil< TResponse > ( Func< TResponse >  request,
Func< TResponse, bool >  isPollingComplete,
AnalyzeRe.PollingOptions  pollingOptions = null 
)
inlinestatic

Poll the requested resource until a desired state is attained.

Template Parameters
TResponseThe type of response expected.
Parameters
requestThe delegate to invoke each time the resource is polled.
isPollingCompleteThe delegate which determines whether the response to the request is the desired state. This is evaluated after each request.
pollingOptions(Optional) Polling options which determine the polling rates, total time, and allow for asynchronous cancellation.
Returns
The last response returned after polling.
Exceptions
NotWaitingExceptionIf the polling options max poll total time is exceeded and the result is not yet available.
TaskCanceledExceptionIf the pollingOptions.CancellationToken enters the cancelled state.

Definition at line 71 of file API.Utilities.cs.

static T AnalyzeRe.API.PollUntilReady< T > ( Func< T >  functionThatMight503,
AnalyzeRe.PollingOptions  pollingOptions = null 
)
inlinestatic

Specialized polling that will executes the specified request delegate, but if a 503 retry-after APIRequestException is encountered, it blocks until the request returns successfully or the maximum polling time is exceeded.

Template Parameters
TThe return type of the delegate function.
Parameters
functionThatMight503A request delegate function to be executed which may raise a 503 retry-after APIRequestException.
pollingOptions(Optional) Determines the behaviour of the API when automatically retrying a request whose result is not yet ready for retrieval.
Returns
The result of the delegate function if successful.
Exceptions
NotWaitingExceptionIf the polling options max poll total time is exceeded and the result is not yet available.
APIRequestExceptionThe server raises an exception other than one that indicates the user should retry the request.
TimeoutExceptionA network timeout was experienced on the last attempted request and the pollingOptions.MaxPollTotalTime has elapsed.
TaskCanceledExceptionIf the pollingOptions.CancellationToken enters the cancelled state.

Definition at line 138 of file API.Utilities.cs.

static T AnalyzeRe.API.PollUntilReady< T > ( Func< T >  functionThatMight503,
double  minPollInterval = 0d,
double  maxPollInterval = Double.MaxValue,
double  maxPollTotalTime = Double.MaxValue 
)
inlinestatic

Obsolete.

See also
PollUntilReady<T>(Func<T>,AnalyzeRe.PollingOptions)

Executes the specified request delegate, but if a 503 retry-after APIRequestException is encountered, it blocks until the request returns successfully or the maximum polling time is exceeded.

Template Parameters
TThe return type of the delegate function.
Parameters
functionThatMight503A request delegate function to be executed which may raise a 503 retry-after APIRequestException.
minPollIntervalOptional (Default: 0) The minimum time (in seconds) to wait between retrying the request.
maxPollIntervalOptional (Default: double.MaxValue) The maximum time (in seconds) to wait between retrying the request.
maxPollTotalTimeOptional (Default: double.MaxValue) The maximum time (in seconds) to poll the request before raising a NotWaitingException.
Returns
The result of the delegate function if successful.
Exceptions
NotWaitingExceptionIf the max poll total time is exceeded and the result is not yet available.
APIRequestExceptionThe server raises an exception other than one that indicates the user should retry the request.
ArgumentOutOfRangeExceptionThe specified min and max polling intervals do not result in meaningful bounds.
TimeoutExceptionA network timeout was experienced on the last attempted request and the maxPollTotalTime has elapsed.

TODO: Delete Deprecated Methods after phase-out period.

Definition at line 723 of file API.Utilities.cs.

static string AnalyzeRe.API.PrettyPrint ( this IRestRequest  request)
inlinestatic

Extension method that generates a helpful string representation of an IRestRequest.

Parameters
requestThe IRestRequest to convert to string.
Returns
A helpful string representation of the IRestRequest.

Definition at line 566 of file API.Utilities.cs.

static string AnalyzeRe.API.PrettyPrint ( this IRestResponse  response)
inlinestatic

Extension method that generates a helpful string representation of an IRestResponse.

Parameters
responseThe IRestResponse to convert to string.
Returns
A helpful string representation of the IRestResponse.

Definition at line 599 of file API.Utilities.cs.

static object AnalyzeRe.API.RequestAndParse ( Type  deserializeType,
string  resource,
Method  method,
IEnumerable< Parameter >  requestParameters = null,
int?  timeout = null 
)
inlinestatic

Perform a REST request on the server and serializes the response to the desired compile-time type.

Parameters
deserializeTypeThe type to deserialize the JSON response to. Use 'IRestResponse' to bypass deserializing the request from JSON and return the response directly.
resourceThe path of the resource or request target, from the root server URL.
methodThe HTTP method to execute, as a Rest.Method enumeration value.
requestParametersThe data to include in the request, in the form of Rest parameters.
timeoutOptional - The desired request timeout (in milliseconds).
Returns
The server response, as an IRestResponse, or deserialized to the type T from JSON.

Definition at line 463 of file API.Requests.cs.

static T AnalyzeRe.API.RequestAndParse< T > ( string  resource,
Method  method,
IEnumerable< Parameter >  requestParameters = null,
int?  timeout = null 
)
inlinestatic

Perform a REST request on the server and serializes the response to the desired compile-time type.

Template Parameters
TThe type to deserialize the JSON response to. Use 'IRestResponse' to bypass deserializing the request from JSON and return the response directly.
Parameters
resourceThe path of the resource or request target, from the root server URL.
methodThe HTTP method to execute, as a Rest.Method enumeration value.
requestParametersThe data to include in the request, in the form of Rest parameters.
timeoutOptional - The desired request timeout (in milliseconds).
Returns
The server response deserialized to the type T from JSON.

Definition at line 436 of file API.Requests.cs.

static ICollectionResponse<IAPIResource> AnalyzeRe.API.SearchResourceList ( Type  resourceType,
string  searchTerms,
IEnumerable< Parameter >  requestParameters = null,
string  collectionNameOverride = null,
int?  timeout = null,
SearchType  searchType = SearchType.Basic 
)
inlinestatic

Get a collection of resources from the server that match the specified search criteria.

Parameters
resourceTypeThe type of resource (any APIResource class).
searchTermsThe search term to pass on to the server.
requestParametersOptional - Additional parameters to include in the request.
collectionNameOverrideOptional - The new name of the collection to search from the server (if not using the default collection for the resource type T)
timeoutOptional - The desired request timeout (in milliseconds).
searchTypeOptional - Indicates the type of search to perform, affecting search target and query interpretation. (default: SearchType.Basic)
Returns
A List of APIResources of the type T provided matching the search criteria.

Definition at line 347 of file API.Requests.cs.

static ICollectionResponse<T> AnalyzeRe.API.SearchResourceList< T > ( string  searchTerms,
IEnumerable< Parameter >  requestParameters = null,
string  collectionNameOverride = null,
int?  timeout = null,
SearchType  searchType = SearchType.Basic 
)
inlinestatic

Get a collection of resources from the server that match the specified search criteria.

Template Parameters
TThe type of resource (any APIResource class).
Parameters
searchTermsThe search term to pass on to the server.
requestParametersOptional - Additional parameters to include in the request.
collectionNameOverrideOptional - The new name of the collection to search from the server (if not using the default collection for the resource type T)
timeoutOptional - The desired request timeout (in milliseconds).
searchTypeOptional - Indicates the type of search to perform, affecting search target and query interpretation. (default: SearchType.Basic) See Parameters.AdvancedSearch for details about advanced searching.
Returns
A List of APIResources of the type T provided matching the search criteria.
Type Constraints
T :IAPIResource 

Definition at line 315 of file API.Requests.cs.

static bool AnalyzeRe.API.TryHandleAuthenticationErrors ( IRestResponse  response,
int  sequentialAttempts = 0 
)
inlinestatic

Checks an IRestResponse object for authentication errors, then invokes configured authentication delegates if the response was an "unauthorized" error.

When the AuthenticationRequested event has been handled, standard requests made via this client library that fail due to an authentication error will raise the event so that the user or client application can be prompted for credentials. The client library will then take care of automatically retrying the request with the supplied credentials.

The API.MaxRetries configuration property controls how many times the user will be prompted before the request fails permanently.

Parameters
responseThe response to check for authentication errors.
sequentialAttemptsThe number of times this same request has been attempted (to compare against the maximum allowed authentication retries)
Exceptions
AuthenticationExceptionRaises an AuthenticationException if authentication is requested, but there is no delegate configured to handle the request, or there is some other problem with the Authentication request.
Returns
Returns TRUE if the request was initially unauthorized and authentication was invoked, and so the request should be retried. Returns FALSE if the request did not contain an authentication error.

Definition at line 82 of file API.Authentication.cs.

static void AnalyzeRe.API.TryPromptForAuthentication ( )
inlinestatic

Invoke the AuthenticationRequested event, which requests authentication credentials for the server. Note: this will have no effect if already authenticated or authentication is not required for this server.

Definition at line 372 of file API.Authentication.cs.

Member Data Documentation

readonly ResourceCollection<Agent> AnalyzeRe.API.Agents
static
Initial value:
=
new ResourceCollection<Agent>(Agent.CLASS_COLLECTION_NAME)

The collection of Agents on the server.

Definition at line 16 of file API.Collections.cs.

readonly ResourceCollection<Analysis> AnalyzeRe.API.Analyses
static
Initial value:
=
new ResourceCollection<Analysis>(Analysis.CLASS_COLLECTION_NAME)

The collection of Analyses on the server.

Definition at line 22 of file API.Collections.cs.

readonly ResourceCollection<AnalysisProfile> AnalyzeRe.API.AnalysisProfiles
static
Initial value:
=
new ResourceCollection<AnalysisProfile>(AnalysisProfile.CLASS_COLLECTION_NAME)

The collection of AnalysisProfiles on the server.

Definition at line 26 of file API.Collections.cs.

readonly string AnalyzeRe.API.AnalyzeReCustomServerHeader = "ARE-Server"
static

The Custom Server Header returned by valid AnalyzeRe servers.

Definition at line 22 of file API.Configuration.cs.

readonly string AnalyzeRe.API.AnalyzeReServerIdentity = "ARE-API"
static

The Server identity returned by valid AnalyzeRe servers.

Definition at line 19 of file API.Configuration.cs.

readonly string AnalyzeRe.API.DateTimeFormat = @"O"
static

The format used when transmitting DateTime information to Analyze Re servers.

Definition at line 25 of file API.Configuration.cs.

string AnalyzeRe.API.DefaultServerURL => TryGetLibrarySettingObj(() => Settings.Default.DefaultServerURL)
static

The Default ServerURL the API is instantiated with, as configured in the settings.

Note: Unlike some other default settings, this setting cannot be modified using this property. To change the default Server URL for all Analyze Re applications on this machine, you should configure the appropriate Settings.Default attribute.

Definition at line 196 of file API.Configuration.cs.

readonly ResourceCollection<IDistribution> AnalyzeRe.API.Distributions
static
Initial value:
=
new ResourceCollection<IDistribution>(Distribution.CLASS_COLLECTION_NAME)

The collection of Distributions on the server.

Definition at line 30 of file API.Collections.cs.

readonly ResourceCollection<EventCatalog> AnalyzeRe.API.EventCatalogs
static
Initial value:
=
new ResourceCollection<EventCatalog>(EventCatalog.CLASS_COLLECTION_NAME)

The collection of EventCatalogs on the server.

Definition at line 34 of file API.Collections.cs.

readonly ResourceCollection<ExchangeRateProfile> AnalyzeRe.API.ExchangeRateProfiles
static
Initial value:
=
new ResourceCollection<ExchangeRateProfile>(ExchangeRateProfile.CLASS_COLLECTION_NAME)

The collection of ExchangeRateProfiles on the server.

Definition at line 38 of file API.Collections.cs.

readonly ResourceCollection<ExchangeRateTable> AnalyzeRe.API.ExchangeRateTables
static
Initial value:
=
new ResourceCollection<ExchangeRateTable>(ExchangeRateTable.CLASS_COLLECTION_NAME)

The collection of ExchangeRateTables on the server.

Definition at line 42 of file API.Collections.cs.

readonly ResourceCollection<DataFile> AnalyzeRe.API.Files
static
Initial value:
=
new ResourceCollection<DataFile>(DataFile.CLASS_COLLECTION_NAME)

The collection of Files on the server.

Definition at line 46 of file API.Collections.cs.

readonly ResourceCollection<ILayer> AnalyzeRe.API.Layers
static
Initial value:
=
new ResourceCollection<ILayer>(Layer.CLASS_COLLECTION_NAME)

The collection of Layers on the server.

Definition at line 54 of file API.Collections.cs.

readonly ResourceCollection<ILayerView> AnalyzeRe.API.LayerViews
static
Initial value:
=
new ResourceCollection<ILayerView>(AnalyzeRe.LayerViews.CLASS_COLLECTION_NAME)

The collection of LayerViews on the server.

Definition at line 50 of file API.Collections.cs.

readonly ResourceCollection<LossFilter> AnalyzeRe.API.LossFilters
static
Initial value:
=
new ResourceCollection<LossFilter>(LossFilter.CLASS_COLLECTION_NAME)

The collection of LossFilters on the server.

Definition at line 58 of file API.Collections.cs.

readonly ResourceCollection<LossSet> AnalyzeRe.API.LossSets
static
Initial value:
=
new ResourceCollection<LossSet>(LossSet.CLASS_COLLECTION_NAME)

The collection of LossSets on the server.

Definition at line 62 of file API.Collections.cs.

volatile int AnalyzeRe.API.MaxRequestRetries = 3
static

When a temporary communication failure occurs (such as a socket error or an authentication failure for which there is a handler) this property determines how many times the client will automatically retry the same request before returning the error.

Definition at line 79 of file API.Configuration.cs.

readonly ResourceCollection<MetricsFunction> AnalyzeRe.API.MetricsFunctions
static
Initial value:
=
new ResourceCollection<MetricsFunction>(MetricsFunction.CLASS_COLLECTION_NAME)

The collection of optimization metrics functions on the server.

Definition at line 74 of file API.Collections.cs.

readonly ResourceCollection<OptimizationView> AnalyzeRe.API.OptimizationViews
static
Initial value:
=
new ResourceCollection<OptimizationView>(OptimizationView.CLASS_COLLECTION_NAME)

The collection of OptimizationViews on the server.

Definition at line 66 of file API.Collections.cs.

readonly ResourceCollection<Portfolio> AnalyzeRe.API.Portfolios
static
Initial value:
=
new ResourceCollection<Portfolio>(Portfolio.CLASS_COLLECTION_NAME)

The collection of Portfolios on the server.

Definition at line 82 of file API.Collections.cs.

readonly ResourceCollection<PortfolioView> AnalyzeRe.API.PortfolioViews
static
Initial value:
=
new ResourceCollection<PortfolioView>(PortfolioView.CLASS_COLLECTION_NAME)

The collection of PortfolioViews on the server.

Definition at line 78 of file API.Collections.cs.

readonly ResourceCollection<ProjectionFunction> AnalyzeRe.API.ProjectionFunctions
static
Initial value:
=
new ResourceCollection<ProjectionFunction>(ProjectionFunction.CLASS_COLLECTION_NAME)

The collection of optimization projection functions on the server.

Definition at line 70 of file API.Collections.cs.

readonly ResourceCollection<Simulation> AnalyzeRe.API.Simulations
static
Initial value:
=
new ResourceCollection<Simulation>(Simulation.CLASS_COLLECTION_NAME)

The collection of Simulations on the server.

Definition at line 86 of file API.Collections.cs.

Property Documentation

IAccessToken AnalyzeRe.API.AuthenticationToken
staticgetset

The AccessToken storing authentication information for requests made to the server.

Definition at line 48 of file API.Authentication.cs.

int AnalyzeRe.API.DefaultRequestTimeout
staticgetset

The default timeout used for all simple server requests, in milliseconds.

Note: If ManagedSettingsEnabled (by default it is), changing this default has the side-effect of storing the user-setting permanently on the client machine.

Definition at line 107 of file API.Configuration.cs.

int AnalyzeRe.API.DefaultRequestTimeoutCollections
staticgetset

The default timeout used when requesting a resource collection from the server, in milliseconds.

Note: If ManagedSettingsEnabled (by default it is), changing this default has the side-effect of storing the user-setting permanently on the client machine.

Definition at line 129 of file API.Configuration.cs.

bool AnalyzeRe.API.ManagedSettingsEnabled
staticgetset

By Default, the Analyze Re Client Library will automatically save and restore certain configured settings such as timeouts and credentials. Set this to false to disable these features (for instance if they cause issues for your application).

Definition at line 84 of file API.Configuration.cs.

int AnalyzeRe.API.Parallelism = true
staticgetset

The maximum number of concurrent requests that can be made.

Note: Unlike many other settings, this setting is not stored to the client's local machine. To change the default degree of parallelism for all Analyze Re applications on this machine, you should configure the appropriate Settings.Default attribute.

Definition at line 91 of file API.Configuration.cs.

string AnalyzeRe.API.ServerURL
staticgetset

The default server URL to be used for all API requests. On change, voids the current cached authentication credentials.

Note: If ManagedSettingsEnabled (by default it is), changing this default has the side-effect of storing the user-setting permanently on the client machine.

Warning: This property has side effects: When changed, the client will:

  1. Unset the current AuthenticationToken (even if it may have been valid against the new server)
  2. Check the settings (if enabled) for any cached credentials for the new server URL.

Definition at line 154 of file API.Configuration.cs.

string AnalyzeRe.API.UserAgent
staticgetset

The UserAgent identifying the requests made by this client. This can be changed if an application wishes to better identify itself to the server.

Definition at line 73 of file API.Configuration.cs.

Event Documentation

AuthenticationRequestedHandler AnalyzeRe.API.AuthenticationRequested
static

An event that fires whenever authentication is requested by the server. This event can be used to prompt a user or other external source for credentials as needed, rather than hard-coding them into the application.

TODO: Authentication Requested event mechanism is flawed and should be revisited This should be a Func{args, IAccessToken} for which there is at most one implementation per instance. This is currently muddied by the API being a static class (i.e. singleton). For now, suppress the code analysis warning about event handlers.

Definition at line 44 of file API.Authentication.cs.


The documentation for this class was generated from the following files: