Class Core
Entry class providing access to all Estrelica.Core API services.
Inherited Members
Namespace: Estrelica
Assembly: Estrelica.Core.dll
Syntax
public sealed class Core : IResolverProvider
Examples
This demonstrates how to invoke the Estrelica.Core and authenticate with an Archer instance:
core = Estrelica.Core.ValidateLicense(authenticationId,
// Any non-fatal license validation issues will return (but not throw) an exception detailing exactly what went wrong.
// This may include upcoming expiration notices or other problems which may be addressed by the customer.
// It is the responsiblity of the user to ensure that proper action takes place when these warnings or errors arise.
wm => Log(wm.Message));
// Details of the license may be displayed or logged if desired
Log(core.LicenseText);
// Once the Estrelica.Core license has been validated, the Core must authenticate with a target Archer instance
// (The username may include a domain in user@domain or domain\user format, if necessary.)
core.CreateSession(archerUrl, archerInstance, archerUsername, archerPassword);
Log($"Connected to instance {core.SessionProvider.Instance} at {core.SessionProvider.Url} (version {core.APIFacade.ArcherVersion})");
Once authenticated, the Core's resolver classes may be used to retrieve metadata:
IArcherApplication policiesApplication = MyCore.Metadata.ApplicationByName("Policies");
IEnumerable<IValuesListField> valuesListFields = policiesApplication.Fields.Where<IValuesListField>();
foreach(var valuesListField in valuesListFields)
{
Trace.WriteLine($"Values List field '{valuesListField.Name}' references Values List '{valuesListField.ValuesList.Name}'");
Trace.WriteLine("and these are the available Values for the field: " + Environment.NewLine +
valuesListField.ValuesList.Values.Select(vlv => $" '{vlv.Name}'" + Environment.NewLine));
}
and content:
IEnumerable<IArcherContentAccess> content = MyCore.Content.GetContent(policiesApplication).ContentAccess(MyCore);
foreach(var policiesRecord in content)
{
Trace.WriteLine($"Policies record {policiesRecord.Id} has these values in these fields:");
foreach(var field in policiesRecord.Fields)
{
Trace.WriteLine($" {field.FieldType} '{field.Name}' => '{policiesRecord.Value(field)}'");
}
}
among many other things. See the Estrelica.Core.Demos solution at https://github.com/CastleHillSoftware/Estrelica.Core.Demos for more complete examples.
Fields
UseRESTLogin
Specifies whether Estrelica.Core should authenticate with Archer via the REST platformapi/core/security/login endpoint (if true) or the SOAP "CreateUserSessionFromInstance" method (if false). Defaults to false in order to support SSO environments where the REST call may not be available, per advisory from Archer.
Declaration
public static bool UseRESTLogin
Field Value
bool |
Properties
APIFacade
APITimeoutSeconds
Sets the maximum number of seconds that all API calls will wait for a response from Archer before timing out and raising an exception
Declaration
public static int APITimeoutSeconds { get; set; }
Property Value
int |
Access
Content
Declaration
public IContentResolver Content { get; set; }
Property Value
IContentResolver |
Implements
CurrentUser
DisableSSLCertificateVerification
Allows SSL certificate verification to be disabled for all Archer API calls. This should only be used for development and/or testing self-signed certificates. If no assignment is made to this property or if it is explicitly set to false, all Archer API calls will be subject to SSL certification verification. If set to true, this must occur prior to any Archer API calls (e.g. before calling CreateSession()). Once set, the value may not be changed.
Declaration
public static bool DisableSSLCertificateVerification { get; set; }
Property Value
bool |
ExceptionRetryCallback
Registers a callback that will be invoked whenever an exception occurs during an API call. Examine the exception and return true if the API call should be retried.
Declaration
public static Func<Exception, bool> ExceptionRetryCallback { get; set; }
Property Value
Func<Exception, bool> |
Layout
License
Declaration
public ILicenseInformation License { get; }
Property Value
ILicenseInformation |
LicenseText
Metadata
Declaration
public IMetadataResolver Metadata { get; set; }
Property Value
IMetadataResolver |
Implements
Proxy
Injects a custom proxy into all API calls. Use this if you need to provide proxy authentication, etc.
Declaration
public static WebProxy Proxy { get; set; }
Property Value
WebProxy |
Report
RequestHeaderCallback
Allows inspection and modification of request headers associated with each HTTP call made by Estrelica.Core, prior to the request being sent to Archer. This can be used to add any additional request headers that may be required, e.g. by proxy servers.
Declaration
public static Action<IDictionary<string, string>> RequestHeaderCallback { get; set; }
Property Value
Action<IDictionary<string, string>> |
SessionProvider
Declaration
public IArcherAuthProvider SessionProvider { get; set; }
Property Value
IArcherAuthProvider |
Methods
ClearCache()
Clears all cached information held by the resolvers.
Declaration
public void ClearCache()
Implements
CreateSession(string, string, string, string, string, string, string)
Establishes a session with the target Archer instance. Must be called after ValidateLicense().
Declaration
public Core CreateSession(string archerUrl, string archerInstance, string username, string password, string userDomain = null, string archerDbConnectionString = null, string existingSessionToken = null)
Parameters
string
archerUrl
Base URL of the Archer instance server |
string
archerInstance
Instance name of the Archer instance |
string
username
Username of the account to authenticate against the Archer instance |
string
password
Password of the account to authenticate against the Archer instance |
string
userDomain
Domain (if applicable) of the Archer account (use null for non-domain accounts) |
string
archerDbConnectionString
Connection string to the Archer instance database (null if API extensions are not required, or if the CHS Extended API is available at the URL above) |
string
existingSessionToken
An optional existing session token (if one has already been established). This token will be used as needed for API calls and no user authentication will occur until the token needs to be refreshed. |
Returns
Core |
ValidateLicense(Guid, Action<Exception>, bool, string, Func<string>, Func<string, bool>)
Validates the license for the authentication key supplied by CastleHill Software. Must be called to initialize a Core instance.
Declaration
[Obfuscation(Feature = "virtualization", Exclude = false)]
public static Core ValidateLicense(Guid authenticationKey, Action<Exception> warningCallback, bool forceRefresh = false, string licenseFileLocation = null, Func<string> loadLicense = null, Func<string, bool> saveLicense = null)
Parameters
Guid
authenticationKey
Authentication key provided to the customer by CastleHill Software |
Action<Exception>
warningCallback
Action<Exception> which will receive any non-fatal exceptions (including warnings) arising from the license validation process. The caller is expected to monitor and respond appropriately to these exceptions. |
bool
forceRefresh
Force a refresh of the license regardless of the refresh cycle |
string
licenseFileLocation
Optional location where the license file resides (defaults to the execution directory of the current process) |
Func<string> loadLicense |
Func<string, bool> saveLicense |
Returns
Core
An instance of Estrelica.Core which may then be used to authenticate against an Archer instance via CreateSession() |