The Enterprise Manager supplies 3 types of clients:
REST
Dotnet (using dlls)
Python (using py files)
Client Modules
In this session we use the DotNet client tools to do the connection. The location the dotnet dll files (py files for Python) is on: <AEM installation folder>\clients\dotnet
The folder contains two dlls and one cs file:
AemRestClient.dll
Newtonsoft.Json.dll
An example cs project.
Though not obligatory, copy the dll files to the working directory. To enable PowerShell using these files, use the following command:
Import-Module
*If none is available in your organization the API could be approached directly. Use the documentation (User guide).
e.g. Use the following script to import the files:
The AEM REST API uses the BASIC HTTP authorization scheme to authenticate callers and create a client session.
A client session is established using the AemLogin method, which returns the special header “EnterpriseManager.APISessionID” with a value (session token) that needs to be sent as a request header in following requests. This token is transparent to the dll users.
A session token expires 5 minutes after the last request. After the session expires, the caller must re-authenticate to establish a new session.
Authorization for performing a specific REST request relies on permission, assigned to the authenticated user either directly or by means of group membership.
Each REST request requires a minimum role, which is specified in the section describing the request.
Connecting to an AEM Server – Aem.RestClient
Initiating a connection to AEM is done by creating an object that contains all the methods necessary for working with the API.
The function is: Attunity.Aem.RestClient.AemRestClien It accept three parameters:
Credential.
The Enterprise Manager URL.
verifyCertificate ($True/$False)
E.g. $AEMServerConnection = New-Object Attunity.Aem.RestClient.AemRestClient($Credential, $AemURL, $false)
Final
To connect to Enterprise Manager you need to follow these steps:
Load the client modules
Gain credentials
Use the Attunity.Aem.RestClient.AemRestClient module to do the actual connection.
Repeat step 3 whenever you are disconnected.
The following script accepts credentials from the user and connect to an Enterprise Manager machine: