C# Client Library
A C# Client Library for the AnalyzeRe REST API
Loading...
Searching...
No Matches
SubResource[T].cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.IO;
4using RestSharp;
5
6namespace AnalyzeRe.APITypes
7{
13 {
16 public int? DefaultTimeout { get; set; } = null;
17
18 #region Constructors
24 #endregion Constructors
25
26 #region Implicit Operators
28 public static implicit operator T(SubResource<T> value)
29 {
30 return value.Get(timeout: value.DefaultTimeout);
31 }
32 #endregion Implicit Operators
33
34 #region REST Methods
40 public IRestResponse Head(IEnumerable<Parameter> parameters = null, int? timeout = null)
41 {
43 return API.RequestAndParse<IRestResponse>(Path, Method.HEAD, parameters, timeout ?? DefaultTimeout);
44 }
45
51 public T Get(IEnumerable<Parameter> parameters = null, int? timeout = null)
52 {
54 return API.RequestAndParse<T>(Path, Method.GET, parameters, timeout ?? DefaultTimeout);
55 }
56
73 IEnumerable<Parameter> parameters = null, int? timeout = null)
74 {
78 if (response.IsSuccessful())
79 return response;
80 throw new APIRequestException("The request failed with the status: " +
81 response.StatusCode + ". The response stream likely contains an error message " +
82 "from the API, rather than the expected requested data. Please check the data " +
83 "returned to the 'consumeStream' delegate for details.");
84 }
85 #endregion REST Methods
86 }
87}
A custom exception class that includes the RestSharp.IRestResponse that generated the exception,...
Describes a collection of resources which can be listed.
Describes an additional sub-resource available off a resource which is not actually a property of tha...
void ValidateOwnerHasId()
Verifies the owner exists and has been POSTed, ensuring that it is safe to invoke actions on this Sub...
string Path
The relative path to this endpoint from the root server URL.
Describes an additional sub-resource available off a resource which is not actually a property of tha...
IRestResponse GetStream(Action< Stream > consumeStream, IEnumerable< Parameter > parameters=null, int? timeout=null)
Perform a GET on the supplied URL and provide an action for consuming the response stream rather than...
SubResource(IEndpoint owner, string relativePath)
Defines a new sub-resource or endpoint off of some other endpoint.
IRestResponse Head(IEnumerable< Parameter > parameters=null, int? timeout=null)
Performs a HEAD request at this endpoint.
T Get(IEnumerable< Parameter > parameters=null, int? timeout=null)
Performs a GET request a at this endpoint.
int? DefaultTimeout
Can be used to override the API.DefaultRequestTimeout with one that better suits this SubResource.
API methods / requests made available to the user.
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 run-time type.
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.
Describes an endpoint on the server that can be interacted with. Inheriting from this interface means...
Definition IEndpoint.cs:10