Overview
The Atomia Automation Server Core API is an IIS hosted SOAP service written using Windows Communication Foundation framework. It provides a set of methods for listing, adding, modifying and deleting accounts, packages and services.
Sample of using Atomia Automation Server Core API
In order to use the Atomia Automation Server Core API, a service reference pointing to the API must be added to the Microsoft Visual Studio project. Visual Studio will automatically generate necessary classes to simplify the use of the API. It will also add WCF configuration sections to the configuration file, however, the WCF configuration must be additionally manually modified so that the API can be used. In the following examples it will be shown how to connect to CoreApi, List services, and add a sample service.
- Create channel
ChannelFactory<ICoreApi> factory = new ChannelFactory<AtomiaProvisioning.ICoreApi>("WSFederationHttpBinding_ICoreApi"); factory.Credentials.UserName.UserName = "Administrator"; factory.Credentials.UserName.Password = "Administrator"; ICoreApi coreApi = factory.CreateChannel();
- Search specific service
In this example we will search for services with the name MySQLDatabase
that are located at CsDatabase/CsMySqlDatabase
(from root) and have utf8_general_ci
as a value of the property Collation
. This search will be done for account with ID 300500
long total; ServiceSearchCriteria criteria = new ServiceSearchCriteria(); criteria.ParentService = null; criteria.ServiceName = "MySQLDatabase"; criteria.ServicePath = "CsDatabase/CsMySqlDatabase"; criteria.ParentService = null; Dictionary<string, string> props = new Dictionary<string, string>(); props["Collation"] = "utf8_general_ci"; var res = coreApi.FindServicesByPathWithPaging(out total, new ServiceSearchCriteria[] { criteria }, props, "300500", null, true, 0, 10);
- List of services that we can add as root services for a specific account.
var possibleServices = coreApi.ListPossibleServices(null, "300500");
- Create service, fill properties and add this service.
if (possibleServices.Where(possibleService => possibleService.Name == "CsDomainParking").Count() > 0) { // Create service CsDomainParking (service is just created with properties that needs to be fill. // Service is not added in system yet. var newlyCreatedService = coreApi.CreateService("CsDomainParking", null, "300500"); // Fill service properties newlyCreatedService["DnsZone"] = "foocompany.com"; newlyCreatedService["Domain"] = "sell.foocompany.com"; newlyCreatedService["DnsZone"] = "sell"; // Add service on resource var addedService = coreApi.AddService(newlyCreatedService, null, "300500", null); Console.WriteLine("Service with ID '" + addedService.LogicalID + "' just added"); }
Note: In order to use the indexer for service properties you need to add a reference to Atomia.Provisioning.Base.dll
and to reuse classes from this library when you add service references to the Atomia Automation Server services.