Interfaces
Admin Hub provides extensible interfaces that enable plugins to implement custom behavior for connections, app sources, and installation operations.
IConnectionClient_TSL
The IConnectionClient_TSL interface enables plugins to implement custom connection clients for external services. This interface is implemented by the ConnectionType_TSL enum, allowing different connection types to have different implementations.
Namespace: Theta.AdminHub.Client
Methods
SetupConnection
procedure SetupConnection(Settings: Codeunit ConnectionSettings_TSL): Boolean
Opens a setup dialog for configuring the connection and returns true if the user completed the setup.
Parameters:
Settings- Connection settings codeunit containing configuration data
Returns: Boolean - True if setup was completed successfully
Usage Example:
codeunit 50100 "My Connection Client" implements IConnectionClient_TSL
{
procedure SetupConnection(Settings: Codeunit ConnectionSettings_TSL): Boolean
var
SetupPage: Page "My Connection Setup";
begin
SetupPage.SetSettings(Settings);
if SetupPage.RunModal() <> Action::OK then
exit(false);
SetupPage.GetSettings(Settings);
exit(true);
end;
}
TryConnection
procedure TryConnection(Settings: Codeunit ConnectionSettings_TSL)
Tests the connection with the provided settings. Should throw an error if the connection fails.
Parameters:
Settings- Connection settings to test
GetRequestUri
procedure GetRequestUri(Request: Record Request_TSL; Settings: Codeunit ConnectionSettings_TSL): Text
Builds the complete URI for the HTTP request.
Parameters:
Request- The request record containing the path and other detailsSettings- Connection settings containing base URL and other configuration
Returns: Text - The complete URI for the request
Example:
procedure GetRequestUri(Request: Record Request_TSL; Settings: Codeunit ConnectionSettings_TSL): Text
var
BaseUrlTok: Label 'https://api.example.com/v1%1', Locked = true;
begin
exit(StrSubstNo(BaseUrlTok, Request.Path));
end;
GetRequestHeaders
procedure GetRequestHeaders(
Request: Record Request_TSL;
Settings: Codeunit ConnectionSettings_TSL;
HttpClientHandler: Interface "Http Client Handler"
): Codeunit ConnectionRequestHeaders_TSL
Prepares HTTP headers for the request, including authentication.
Parameters:
Request- The request recordSettings- Connection settingsHttpClientHandler- HTTP client handler for making authentication requests
Returns: ConnectionRequestHeaders_TSL - Configured request headers
Example:
procedure GetRequestHeaders(
Request: Record Request_TSL;
Settings: Codeunit ConnectionSettings_TSL;
HttpClientHandler: Interface "Http Client Handler"
) RequestHeaders: Codeunit ConnectionRequestHeaders_TSL
var
AuthUrl: Text;
begin
AuthUrl := 'https://login.microsoftonline.com/common/oauth2/v2.0/token';
RequestHeaders.AddAuthorizationFromClientCredentials(HttpClientHandler, AuthUrl, Settings);
RequestHeaders.Add('Accept', 'application/json');
end;
HandleResponse
procedure HandleResponse(
Request: Record Request_TSL;
Settings: Codeunit ConnectionSettings_TSL;
var HttpResponseMessage: Codeunit "Http Response Message"
)
Processes the HTTP response and performs any necessary actions based on the response.
Parameters:
Request- The request recordSettings- Connection settingsHttpResponseMessage- The HTTP response to process
Implementation Pattern
To create a custom connection type:
- Create an enum extension for
ConnectionType_TSL - Implement the
IConnectionClient_TSLinterface in a codeunit - Assign the implementation to your enum value
enumextension 50100 "My Connection Type" extends ConnectionType_TSL
{
value(50100; "My Service")
{
Caption = 'My External Service';
Implementation = IConnectionClient_TSL = "My Connection Client";
}
}
ISourceProvider_TSL
The ISourceProvider_TSL interface enables plugins to implement custom storage strategies for Business Central app packages (.app files).
Namespace: Theta.AdminHub.App
Methods
HasSource
procedure HasSource(AppVersion: Record AppVersion_TSL): Boolean
Checks if a source package is available for the specified app version.
Parameters:
AppVersion- The app version record to check
Returns: Boolean - True if source is available
Example:
procedure HasSource(AppVersion: Record AppVersion_TSL): Boolean
var
FilePath: Text;
begin
FilePath := GetFilePath(AppVersion);
exit(File.Exists(FilePath));
end;
GetSource
procedure GetSource(AppVersion: Record AppVersion_TSL): Codeunit "Temp Blob"
Retrieves the app package source as a temporary blob.
Parameters:
AppVersion- The app version record
Returns: Codeunit "Temp Blob" - The app package content
Example:
procedure GetSource(AppVersion: Record AppVersion_TSL): Codeunit "Temp Blob"
var
TempBlob: Codeunit "Temp Blob";
InStr: InStream;
begin
AppVersion.CalcFields(Source);
AppVersion.Source.CreateInStream(InStr);
TempBlob.FromInStream(InStr);
exit(TempBlob);
end;
Built-in Implementations
- Blob - Stores app packages in the
AppVersion_TSL.Sourceblob field - Undefined - Default implementation that indicates no source is available
Implementation Pattern
To create a custom source provider:
- Create an enum extension for
SourceProvider_TSL - Implement the
ISourceProvider_TSLinterface in a codeunit - Assign the implementation to your enum value
enumextension 50101 "File System Source" extends SourceProvider_TSL
{
value(50101; "File System")
{
Caption = 'File System';
Implementation = ISourceProvider_TSL = "File System Source Provider";
}
}
codeunit 50101 "File System Source Provider" implements ISourceProvider_TSL
{
procedure HasSource(AppVersion: Record AppVersion_TSL): Boolean
var
FilePath: Text;
begin
FilePath := GetFilePath(AppVersion);
exit(File.Exists(FilePath));
end;
procedure GetSource(AppVersion: Record AppVersion_TSL): Codeunit "Temp Blob"
var
TempBlob: Codeunit "Temp Blob";
FilePath: Text;
begin
FilePath := GetFilePath(AppVersion);
TempBlob.FromFile(FilePath);
exit(TempBlob);
end;
local procedure GetFilePath(AppVersion: Record AppVersion_TSL): Text
begin
// Your logic to construct file path
end;
}
IInstaller_TSL
The IInstaller_TSL interface enables plugins to implement custom installation logic for app versions into tenant environments. This interface is specific to the Admin Center plugin.
Namespace: Theta.AdminHubBCAdminCenter
Methods
Install
procedure Install(AppVersion: Record AppVersion_TSL; var TenantEnvironment: Record TenantEnvironment_TSL)
Installs the specified app version into the tenant environment.
Parameters:
AppVersion- The app version to installTenantEnvironment- The target environment (passed by reference)
IsInstallable
procedure IsInstallable(AppVersion: Record AppVersion_TSL): Boolean
Determines if the app version can be installed using this installer.
Parameters:
AppVersion- The app version to check
Returns: Boolean - True if the installer can install this version
Usage
This interface is typically implemented by source providers to enable direct installation from their storage:
codeunit 50102 "NuGet Installer" implements IInstaller_TSL
{
procedure Install(AppVersion: Record AppVersion_TSL; var TenantEnvironment: Record TenantEnvironment_TSL)
begin
// Create request to install app from NuGet package
end;
procedure IsInstallable(AppVersion: Record AppVersion_TSL): Boolean
begin
exit(AppVersion.SourceProvider = AppVersion.SourceProvider::NuGet);
end;
}