Export (.NET)
The Export API allows clients to export applications as a RAP file or schema file.
You can also interact with the Export API through the REST API. See Export service.
Guidelines for the Export API
Review the following guidelines for working with the Export API.
Permissions
For all endpoints in the API, users are required to be system administrators in order to have sufficient permissions.
ExportAsync
Exports the application from the workspace as a RAP file. If the application is unlocked, it will be locked. The fourth digit of the application's Version number will be auto-incremented with each export if the application is unlocked or the application schema has been modified. The Schema Version will be auto-incremented only if schema changes were made.
public async Task ExportApplicationRapByArtifactID(IApplicationManager applicationManager, int artifactID, string filePath)
{
try
{
IKeplerStream response = await applicationManager.ExportAsync(ADMIN_WORKSPACE_ID, artifactID);
string info = string.Format($"Application with Artifact ID {artifactID} successfully exported as RAP file.");
Console.WriteLine(info);
// Save the returned file stream to disk at provided file path.
Console.WriteLine(@"Attempting to save the RAP file to disk at the provided filepath.");
Stream stream = await response.GetStreamAsync();
using (FileStream fileStream = System.IO.File.Create(filePath))
{
stream.Seek(0, SeekOrigin.Begin);
stream.CopyTo(fileStream);
}
Console.WriteLine($@"RAP file successfully saved to disk at the filepath {filePath}.");
}
catch (Exception ex)
{
string exception = $"An error occurred: {ex.Message}";
Console.WriteLine(exception);
}
}
public async Task ExportApplicationRapByGuid(IApplicationManager applicationManager, Guid applicationGuid, string filePath)
{
try
{
IKeplerStream response = await applicationManager.ExportAsync(ADMIN_WORKSPACE_ID, applicationGuid);
string info = string.Format($"Application with Application Guid {applicationGuid} successfully exported as RAP file.");
Console.WriteLine(info);
// Save the returned file stream to disk at provided file path.
Console.WriteLine(@"Attempting to save the RAP file to disk at the provided filepath.");
Stream stream = await response.GetStreamAsync();
using (FileStream fileStream = System.IO.File.Create(filePath))
{
stream.Seek(0, SeekOrigin.Begin);
stream.CopyTo(fileStream);
}
Console.WriteLine($@"RAP file successfully saved to disk at the filepath {filePath}.");
}
catch (Exception ex)
{
string exception = $"An error occurred: {ex.Message}";
Console.WriteLine(exception);
}
}
ExportSchemaAsync
Exports the application schema from the workspace as an XML file.If the application is unlocked, it will be locked. The fourth digit of the application's Version number will be auto-incremented with each export if the application is unlocked or the application schema has been modified. The Schema Version will be auto-incremented only if schema changes were made.
public async Task ExportApplicationSchemaByArtifactID(IApplicationManager applicationManager, int artifactID, string filePath)
{
try
{
IKeplerStream response = await applicationManager.ExportSchemaAsync(ADMIN_WORKSPACE_ID, artifactID);
string info = string.Format($"Application with Artifact ID {artifactID} successfully exported as Schema file.");
Console.WriteLine(info);
// Save the returned file stream to disk at provided file path.
Console.WriteLine(@"Attempting to save the Schema file to disk at the provided filepath.");
Stream stream = await response.GetStreamAsync();
using (FileStream fileStream = System.IO.File.Create(filePath))
{
stream.Seek(0, SeekOrigin.Begin);
stream.CopyTo(fileStream);
}
Console.WriteLine($@"Schema file successfully saved to disk at the filepath {filePath}.");
}
catch (Exception ex)
{
string exception = $"An error occurred: {ex.Message}";
Console.WriteLine(exception);
}
}
public async Task ExportApplicationSchemaByGuid(IApplicationManager applicationManager, Guid applicationGuid, string filePath)
{
try
{
IKeplerStream response = await applicationManager.ExportSchemaAsync(ADMIN_WORKSPACE_ID, applicationGuid);
string info = string.Format($"Application with Application Guid {applicationGuid} successfully exported as Schema file.");
Console.WriteLine(info);
// Save the returned file stream to disk at provided file path.
Console.WriteLine(@"Attempting to save the Schema file to disk at the provided filepath.");
Stream stream = await response.GetStreamAsync();
using (FileStream fileStream = System.IO.File.Create(filePath))
{
stream.Seek(0, SeekOrigin.Begin);
stream.CopyTo(fileStream);
}
Console.WriteLine($@"Schema file successfully saved to disk at the filepath {filePath}.");
}
catch (Exception ex)
{
string exception = $"An error occurred: {ex.Message}";
Console.WriteLine(exception);
}
}