Example #1
0
 private void LogAdded(ProvisioningService service, ExampleModel example)
 {
     HostingControlPanelAuditLogger.Log("EXAMPLE_ADDED", $"Created example with name {example.Name}.",
                                        accountId, service.logicalId, new Dictionary <string, object> {
         { "Exampe", example }
     });
 }
Example #2
0
 private void LogDeleted(ProvisioningService service, ExampleModel example)
 {
     HostingControlPanelAuditLogger.Log("EXAMPLE_DELETED", $"Deleted example with name {GetServicePropertyValue(service, "Name")}.",
                                        accountId, service.logicalId, new Dictionary <string, object> {
         { "Example", example }
     });
 }
Example #3
0
 /// <summary>
 /// Fills the property.
 /// </summary>
 /// <param name="service">The service.</param>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="customAttributes">The custom attributes.</param>
 /// <param name="attributeName">Name of the attribute.</param>
 private static void FillProperty(ProvisioningService service, string propertyName, Dictionary <string, string> customAttributes, string attributeName)
 {
     if (customAttributes.ContainsKey(attributeName) && service.properties.Any(p => p.Name == propertyName))
     {
         service.properties.First(p => p.Name == propertyName).propStringValue = customAttributes[attributeName];
     }
 }
Example #4
0
        public static ProvisioningService GetService(RouteData routeData, string serviceName = "Example Simple Service")
        {
            var coreService = AtomiaServiceChannelManager.GetCoreService(false);
            var accountId   = routeData.Values["accountId"].ToString();
            var fetchedProvisioningDescriptionID = AtomiaServicesManager.FetchProvisioningDescriptionID(accountId);
            var serviceData = AtomiaServicesManager.FetchServiceData(
                serviceName,
                fetchedProvisioningDescriptionID,
                routeData.DataTokens["area"].ToString(),
                routeData.Values["controller"].ToString(),
                routeData.Values["action"].ToString());
            var baseService = GetRootService(routeData);
            ProvisioningService simpleService = null;

            if (baseService != null)
            {
                var servicesList = SearchServices(coreService, baseService, serviceData.ServiceName, accountId, serviceData.Path);

                if (servicesList != null && servicesList.Length > 0)
                {
                    simpleService = servicesList[0];
                }
            }

            return(simpleService);
        }
Example #5
0
        /// <summary>
        /// Modifies the product.
        /// </summary>
        /// <param name="subscription">The subscription.</param>
        /// <param name="mainSubscription">The main subscription.</param>
        /// <param name="account">The account.</param>
        /// <param name="productDescription">The product description.</param>
        /// <param name="additionalData">The additional data.</param>
        /// <exception cref="ArgumentException"></exception>
        /// <returns>Modified service.</returns>
        public ProvisioningService ModifyProduct(Subscription subscription, Subscription mainSubscription, BoAccount account, CustomProduct productDescription, Dictionary <string, object> additionalData)
        {
            ProvisioningService service = null;

            if (additionalData == null || !additionalData.ContainsKey("ModifyOperation"))
            {
                throw new AtomiaProvisioningException(string.Format("Cannot modify {0} service. Additional data are null or does not contain ModifyOperation key.", productDescription.ProvisioningService));
            }

            string operation = additionalData["ModifyOperation"].ToString();
            ProvisioningService parentService = this.GetService(subscription, productDescription, account);
            string serviceName        = GetProductProperty(productDescription, "instanceService");
            ServiceSearchCriteria ssc = new ServiceSearchCriteria
            {
                ParentService = parentService,
                ServiceName   = serviceName
            };

            ProvisioningService[] foundServices = this.coreService.FindServicesByPath(new[] { ssc }, null, account.Name, null, true);
            if (foundServices == null || foundServices.Length == 0)
            {
                throw new NullReferenceException(string.Format("Cannot modify {0} service. Service {1} cannot be found on account {2}.", productDescription.ProvisioningService, serviceName, account.Name));
            }

            service = foundServices[0];
            switch (operation)
            {
            case "Suspend":
                parentService.properties.First(property => property.Name == "State").propStringValue = "Suspended";
                this.coreService.CallOperation("Stop", string.Empty, service, account.Name);
                break;

            case "Unsuspend":
                parentService.properties.First(property => property.Name == "State").propStringValue = "Ok";
                this.coreService.CallOperation("Start", string.Empty, service, account.Name);
                break;

            default:
                throw new ArgumentException(string.Format("Cannot modify {0} service. Unknown operation: {1}.", productDescription.ProvisioningService, operation));
            }

            try
            {
                return(this.coreService.ModifyService(parentService, account.Name));
            }
            catch (Exception ex)
            {
                throw new AtomiaProvisioningException(ex.Message, ex);
            }
        }
Example #6
0
        /// <summary>
        /// Removes the product.
        /// </summary>
        /// <param name="subscription">The subscription.</param>
        /// <param name="mainSubscription">The main subscription.</param>
        /// <param name="account">The account.</param>
        /// <param name="productDescription">The product description.</param>
        /// <param name="additionalData">The additional data.</param>
        /// <returns>Service that was removed.</returns>
        public ProvisioningService RemoveProduct(Subscription subscription, Subscription mainSubscription, BoAccount account, CustomProduct productDescription, Dictionary <string, object> additionalData)
        {
            ProvisioningService service = this.GetService(subscription, productDescription, account);

            try
            {
                this.coreService.DeleteService(service, account.Name);
            }
            catch (Exception ex)
            {
                throw new AtomiaProvisioningException(ex.Message, ex);
            }

            return(service);
        }
Example #7
0
        public async Task <(CredentialRequestMessage, CredentialRecord)> CreateRequestAsync(IAgentContext agentContext, string credentialId)
        {
            var credential = await GetAsync(agentContext, credentialId);

            if (credential.State != CredentialState.Offered)
            {
                throw new AgentFrameworkException(ErrorCode.RecordInInvalidState,
                                                  $"Credential state was invalid. Expected '{CredentialState.Offered}', found '{credential.State}'");
            }

            var connection = await ConnectionService.GetAsync(agentContext, credential.ConnectionId);

            var definition =
                await LedgerService.LookupDefinitionAsync(await agentContext.Pool, credential.CredentialDefinitionId);

            var provisioning = await ProvisioningService.GetProvisioningAsync(agentContext.Wallet);

            var request = await AnonCreds.ProverCreateCredentialReqAsync(agentContext.Wallet, connection.MyDid,
                                                                         credential.OfferJson,
                                                                         definition.ObjectJson, provisioning.MasterSecretId);

            // Update local credential record with new info
            credential.CredentialRequestMetadataJson = request.CredentialRequestMetadataJson;

            await credential.TriggerAsync(CredentialTrigger.Request);

            await RecordService.UpdateAsync(agentContext.Wallet, credential);

            var threadId = credential.GetTag(TagConstants.LastThreadId);
            var response = new CredentialRequestMessage
            {
                Requests = new[] {
                    new Attachment
                    {
                        Id       = "libindy-cred-request-0",
                        MimeType = CredentialMimeTypes.ApplicationJsonMimeType,
                        Data     = new AttachmentContent
                        {
                            Base64 = request.CredentialRequestJson.GetUTF8Bytes().ToBase64String()
                        }
                    }
                }
            };

            response.ThreadFrom(threadId);
            return(response, credential);
        }
Example #8
0
        /// <summary>
        /// Adds the service.
        /// </summary>
        /// <param name="account">The account.</param>
        /// <param name="productDescription">The product description.</param>
        /// <param name="parentServiceKey">The parent service key.</param>
        /// <param name="serviceKey">The service key.</param>
        /// <param name="name">The name.</param>
        /// <param name="requestId">The request unique identifier.</param>
        /// <returns>Added service</returns>
        private ProvisioningService CreateService(BoAccount account, CustomProduct productDescription, string parentServiceKey, string serviceKey, string name, ref string requestId)
        {
            ProvisioningService parentService = this.FindService(productDescription, parentServiceKey, "rootService", account);
            ProvisioningService service       = this.PrepareService(productDescription, account, serviceKey, parentService);

            string nameValue = this.GetServiceName(account.Name, parentService, serviceKey, name);

            service.properties.First(p => p.Name == "CustomParam1").propStringValue = nameValue;
            service.properties.First(p => p.Name == "CustomParam2").propStringValue = nameValue;

            if (!string.IsNullOrEmpty(requestId))
            {
                return(this.coreService.AddServiceAsync(service, parentService, account.Name, null, ref requestId));
            }

            return(this.coreService.AddService(service, parentService, account.Name, null));
        }
Example #9
0
        /// <summary>
        /// Gets the service.
        /// </summary>
        /// <param name="subscription">The subscription.</param>
        /// <param name="productDescription">The product description.</param>
        /// <param name="account">The account.</param>
        /// <returns></returns>
        private ProvisioningService GetService(Subscription subscription, CustomProduct productDescription, BoAccount account)
        {
            if (subscription.CustomAttributes == null || !subscription.CustomAttributes.ContainsKey("ServiceId"))
            {
                throw new AtomiaProvisioningException(string.Format("Cannot get service {0}. Subscription has no custom attribute ServiceId.", productDescription.ProvisioningService));
            }

            string serviceId            = subscription.CustomAttributes["ServiceId"];
            ProvisioningService service = this.coreService.GetServiceById(serviceId, account.Name);

            if (service == null)
            {
                throw new AtomiaProvisioningException(string.Format("Cannot find service with id {0} for account {1}.", serviceId, account.Name));
            }

            return(service);
        }
Example #10
0
        private void DeprovisionTenantSite(IEnumerable <TenantModel> tenants)
        {
            var provisioningServices = new List <ProvisioningService>();

            // Create services
            foreach (var tenant in tenants)
            {
                var service = ProvisioningService.CreateForTenant(tenant.TenantId);

                // Start and Run the Deprovisioning tasks asynchronously
                var task = new Task(service.RunDeprovisioningTasks);
                task.Start();

                provisioningServices.Add(service);
            }

            // Save the Provisioning service for later access
            Session["ProvisioningService"] = provisioningServices;
        }
Example #11
0
        /// <summary>
        /// Creates the name of the service.
        /// </summary>
        /// <param name="accountId">The account unique identifier.</param>
        /// <param name="parentService">The parent service.</param>
        /// <param name="serviceName">Name of the _service.</param>
        /// <param name="name">The name.</param>
        /// <returns>Name for service</returns>
        private string GetServiceName(string accountId, ProvisioningService parentService, string serviceName, string name)
        {
            string propertyValue      = GetName(name);
            ServiceSearchCriteria ssc = new ServiceSearchCriteria
            {
                ParentService = parentService,
                ServiceName   = serviceName
            };

            ProvisioningService[] foundServices = this.coreService.FindServicesByPath(new[] { ssc }, null, accountId, null, true);
            if (foundServices.Length > 0)
            {
                while (foundServices.Any(s => s.name == propertyValue))
                {
                    propertyValue = GetName(name);
                }
            }

            return(propertyValue);
        }
Example #12
0
 public ShopifyAuthController(
     OAuthApi oAuthApi,
     CredentialsRepository connectionRepository,
     InstanceContext connectionContext,
     ShopifyHttpContext shopifyHttpContext,
     IdentityService identityService,
     StateRepository stateRepository,
     HmacCryptoService hmacCrypto,
     ProvisioningService provisioningService,
     IPushLogger logger)
 {
     _provisioningService  = provisioningService;
     _identityService      = identityService;
     _oAuthApi             = oAuthApi;
     _connectionRepository = connectionRepository;
     _connectionContext    = connectionContext;
     _shopifyHttpContext   = shopifyHttpContext;
     _stateRepository      = stateRepository;
     _hmacCrypto           = hmacCrypto;
     _logger = logger;
 }
Example #13
0
        private static ProvisioningService[] SearchServices(
            ICoreApi coreApi,
            ProvisioningService parentService,
            string serviceName,
            string accountName,
            string servicePath = null,
            Dictionary <string, string> properties = null)
        {
            if (parentService != null)
            {
                servicePath = servicePath.Substring(servicePath.LastIndexOf(parentService.name) + parentService.name.Length);
            }

            var criteria = new ServiceSearchCriteria
            {
                ParentService = parentService,
                ServiceName   = serviceName,
                ServicePath   = servicePath
            };

            return(coreApi.FindServicesByPath(new[] { criteria }, properties, accountName, null, true));
        }
Example #14
0
        public async Task Run()
        {
            DebugHelper.LogInformation("Onboarding starting");
            DebugHelper.LogInformation($"Device Provisioning State: {(SimulatedDevice.IsProvisioned ? "Provisioned" : "Not provisioned")}");

            //Init Portal Api and turn on access point
            if (!InitializePortalAPI())
            {
                return;
            }

            //Start Services
            _WifiService         = new WifiService();
            _ProvisioningService = new ProvisioningService();
            _PortalService       = new PortalService();

            //Start AP App
            AccessPointHelper.StartAccessPoint();

            //Start Stream Socker Service
            _DeviceApiServer = new WebDeviceApiServer();
            _DeviceApiServer.CommandReceived += CommandReceived;
            _DeviceApiServer.Start();

            DebugHelper.LogInformation("Onboarding started");

            //Wait for AP Timeout
            _LastAccess = DateTime.UtcNow;
            while (true)
            {
                if (_APTimeoutEnabled && SimulatedDevice.IsProvisioned &&
                    DateTime.UtcNow.AddMinutes(-(APTimeoutMinutes)) > _LastAccess)
                {
                    AccessPointHelper.StopAccessPoint();
                }
                await Task.Delay(500);
            }
        }
Example #15
0
        private static void AddTenantServices(MyAccountViewModel viewModel, bool pipelineRunning, string process)
        {
            // Add each tenants services
            foreach (var userAccount in viewModel.UserAccounts)
            {
                foreach (var company in userAccount.Tenants)
                {
                    var provisioningService = ProvisioningService.CreateForAdmin(company.Id);

                    company.Services = provisioningService.GetStatusses().Select(s => new ServiceStatusViewModel()
                    {
                        StatusId = s.Id,
                        Name     = s.Name,
                        Service  = s.Service,
                        Status   = company.AzureServicesProvisioned ? ProvisioningStatus.Deployed : ProvisioningStatus.NotDeployed
                    }).ToList();
                }

                // Update statusses
                foreach (var tenant in userAccount.Tenants)
                {
                    // Set the Status
                    if (!tenant.AzureServicesProvisioned)
                    {
                        tenant.Status = pipelineRunning
                            ? process.Equals("Provisioning") ? ProvisioningStatus.Provisioning : ProvisioningStatus.Removing
                            : ProvisioningStatus.NotDeployed;

                        tenant.Services.ForEach(s => s.Status = ProvisioningStatus.NotDeployed);
                    }
                    else
                    {
                        tenant.Status = pipelineRunning && process.Equals("Deprovisioning") ? ProvisioningStatus.Removing : ProvisioningStatus.Deployed;
                        tenant.Services.ForEach(s => s.Status = ProvisioningStatus.Deployed);
                    }
                }
            }
        }
Example #16
0
        public static string CallOperation(RouteData routeData, string operationName, string operationArgument, ProvisioningService provisioningService = null)
        {
            var accountId   = routeData.Values["accountID"].ToString();
            var coreService = AtomiaServiceChannelManager.GetCoreService(false);

            if (provisioningService == null)
            {
                provisioningService = GetService(routeData);
            }

            return(coreService.CallOperation(operationName, operationArgument, provisioningService, accountId));
        }
Example #17
0
        public ActionResult Index()
        {
            // Fetch required data
            var accountService = new UserAccountService();
            var user           = accountService.FetchByUsername(HttpContext.User.Identity.SplitName());

            var tenantService = new TenantService();
            var tenants       = tenantService.FetchTenants();

            // Build the tenants viewmodel
            var viewModel = tenants != null
                ? new MyAccountViewModel()
            {
                UserAccounts = tenants.GroupBy(u => u.Username).Select(u => new UserAccountViewModel()
                {
                    Username = u.Key,
                    Tenants  = u.Select(t => new TenantViewModel()
                    {
                        Id     = t.TenantId,
                        Plan   = t.ProvisioningOption,
                        Theme  = t.Theme,
                        Status = t.AzureServicesProvisioned ? ProvisioningStatus.Deployed : ProvisioningStatus.NotDeployed,
                        AzureServicesProvisioned = t.AzureServicesProvisioned,
                    }).ToList()
                }).ToList()
            }
                : new MyAccountViewModel();

            // Get working values
            var pipelineRunning = TempData["PipelineRunning"] != null && (bool)TempData["PipelineRunning"];
            var username        = TempData["Username"] != null ? (string)TempData["Username"] : string.Empty;

            // Add each tenants services
            foreach (var userAccount in viewModel.UserAccounts)
            {
                foreach (var company in userAccount.Tenants)
                {
                    var provisioningService = ProvisioningService.CreateForAdmin(company.Id);

                    company.Services = provisioningService.GetStatusses().Select(s => new ServiceStatusViewModel()
                    {
                        StatusId = s.Id,
                        Name     = s.Name,
                        Service  = s.Service,
                        Status   = company.AzureServicesProvisioned ? ProvisioningStatus.Deployed : ProvisioningStatus.NotDeployed
                    }).ToList();
                }

                // Set already provisioned tenant services to active
                userAccount.Tenants.Where(c => c.AzureServicesProvisioned)
                .ForEach(c => c.Services.ForEach(s => s.Status = ProvisioningStatus.Deployed));

                // Update statusses
                foreach (var tenant in userAccount.Tenants)
                {
                    // Set the Status
                    if (!tenant.AzureServicesProvisioned)
                    {
                        tenant.Status = pipelineRunning && userAccount.Username.Equals(username) ? ProvisioningStatus.Removing : ProvisioningStatus.NotDeployed;
                    }
                    else
                    {
                        tenant.Status = pipelineRunning && userAccount.Username.Equals(username) ? ProvisioningStatus.Removing : ProvisioningStatus.Deployed;
                    }
                }
            }

            // Build up the ViewBag
            ViewBag.PipelineRunning = pipelineRunning;
            ViewBag.Username        = username;

            return(View(viewModel));
        }
Example #18
0
 private string GetServicePropertyValue(ProvisioningService service, string propertyName)
 {
     return(service.properties.FirstOrDefault(p => p.Name == exampleServiceData.ServiceProperties[propertyName]).propStringValue);
 }
Example #19
0
        public async Task <(CredentialIssueMessage, CredentialRecord)> CreateCredentialAsync(IAgentContext agentContext, string credentialId, IEnumerable <CredentialPreviewAttribute> values)
        {
            var credential = await GetAsync(agentContext, credentialId);

            if (credential.State != CredentialState.Requested)
            {
                throw new AgentFrameworkException(ErrorCode.RecordInInvalidState,
                                                  $"Credential state was invalid. Expected '{CredentialState.Requested}', found '{credential.State}'");
            }

            if (values != null && values.Any())
            {
                credential.CredentialAttributesValues = values;
            }

            var definitionRecord =
                await SchemaService.GetCredentialDefinitionAsync(agentContext.Wallet, credential.CredentialDefinitionId);

            var connection = await ConnectionService.GetAsync(agentContext, credential.ConnectionId);

            var provisioning = await ProvisioningService.GetProvisioningAsync(agentContext.Wallet);

            if (connection.State != ConnectionState.Connected)
            {
                throw new AgentFrameworkException(ErrorCode.RecordInInvalidState,
                                                  $"Connection state was invalid. Expected '{ConnectionState.Connected}', found '{connection.State}'");
            }

            string            revocationRegistryId = null;
            BlobStorageReader tailsReader          = null;

            if (definitionRecord.SupportsRevocation)
            {
                var revocationRecordSearch = await RecordService.SearchAsync <RevocationRegistryRecord>(
                    agentContext.Wallet, SearchQuery.Equal(nameof(RevocationRegistryRecord.CredentialDefinitionId), definitionRecord.Id), null, 5);

                var revocationRecord = revocationRecordSearch.Single(); // TODO: Credential definition can have multiple revocation registries

                revocationRegistryId = revocationRecord.Id;
                tailsReader          = await TailsService.OpenTailsAsync(revocationRecord.TailsFile);
            }

            var issuedCredential = await AnonCreds.IssuerCreateCredentialAsync(agentContext.Wallet, credential.OfferJson,
                                                                               credential.RequestJson, CredentialUtils.FormatCredentialValues(credential.CredentialAttributesValues), revocationRegistryId, tailsReader);

            if (definitionRecord.SupportsRevocation)
            {
                var paymentInfo = await PaymentService.GetTransactionCostAsync(agentContext, TransactionTypes.REVOC_REG_ENTRY);

                await LedgerService.SendRevocationRegistryEntryAsync(
                    wallet : agentContext.Wallet,
                    pool : await agentContext.Pool,
                    issuerDid : provisioning.IssuerDid,
                    revocationRegistryDefinitionId : revocationRegistryId,
                    revocationDefinitionType : "CL_ACCUM",
                    value : issuedCredential.RevocRegDeltaJson,
                    paymentInfo : paymentInfo);

                credential.CredentialRevocationId = issuedCredential.RevocId;

                if (paymentInfo != null)
                {
                    await RecordService.UpdateAsync(agentContext.Wallet, paymentInfo.PaymentAddress);
                }
            }

            await credential.TriggerAsync(CredentialTrigger.Issue);

            await RecordService.UpdateAsync(agentContext.Wallet, credential);

            var threadId = credential.GetTag(TagConstants.LastThreadId);

            var credentialMsg = new CredentialIssueMessage
            {
                Credentials = new []
                {
                    new Attachment
                    {
                        Id       = "libindy-cred-0",
                        MimeType = CredentialMimeTypes.ApplicationJsonMimeType,
                        Data     = new AttachmentContent
                        {
                            Base64 = issuedCredential.CredentialJson
                                     .GetUTF8Bytes()
                                     .ToBase64String()
                        }
                    }
                }
            };

            credentialMsg.ThreadFrom(threadId);

            return(credentialMsg, credential);
        }
Example #20
0
        /// <summary>
        /// Adds the product.
        /// </summary>
        /// <param name="subscription">The subscription.</param>
        /// <param name="mainSubscription">The main subscription.</param>
        /// <param name="account">The account.</param>
        /// <param name="productDescription">The product description.</param>
        /// <param name="additionalData">The additional data.</param>
        /// <returns>Added service.</returns>
        public ProvisioningService AddProduct(Subscription subscription, Subscription mainSubscription, BoAccount account, CustomProduct productDescription, Dictionary <string, object> additionalData)
        {
            if (productDescription.CustomProductProperties == null)
            {
                throw new AtomiaProvisioningException(string.Format("Cannot add {0} service. Custom product {1} has no properties defined in AtomiaProvisioning section.", productDescription.ProvisioningService, productDescription.Name));
            }

            if (subscription.CustomAttributes == null || !subscription.CustomAttributes.ContainsKey("CustomAttributeParam"))
            {
                throw new AtomiaProvisioningException(string.Format("Cannot add {0} service. Subscription does not have custom attribute CustomAttributeParam.", productDescription.ProvisioningService));
            }

            string packageName = GetCustomProductProperty(productDescription, "defaultPackageName");

            if (subscription.CustomAttributes != null && subscription.CustomAttributes.Any(ca => ca.Key == "ProvisioningPackage"))
            {
                packageName = subscription.CustomAttributes["ProvisioningPackage"];
            }
            // Ensuring that package exist, if not then adds that package
            EnsurePackageExist(packageName, account.Name);

            string customAttributeParam = subscription.CustomAttributes["CustomAttributeParam"].ToLowerInvariant();
            string customServiceName    = GetProductProperty(productDescription, "linuxInstance"); // linuxInstance or windowsInstance

            ProvisioningService parentService = this.FindService(productDescription, "parentService", "rootService", account);

            ProvisioningService customService = this.coreService.CreateService(customServiceName, parentService, account.Name);

            FillServiceProperties(customService, subscription.CustomAttributes);

            customService.properties.First(p => p.Name == "Name").propStringValue = subscription.CustomAttributes.ContainsKey("CustomAttribute1")
                         ? subscription.CustomAttributes["CustomAttribute1"]
                         : this.GetServiceName(account.Name, parentService, customServiceName, customAttributeParam);

            ProvisioningService service = null;
            string requestId            = string.Empty;

            try
            {
                // Add services.


                customService.properties.First(p => p.Name == "CustomParam").propStringValue = customAttributeParam;

                service = this.coreService.AddServiceAsync(customService, parentService, account.Name, null, ref requestId);

                this.coreService.EndProvisioningRequestAsync(account.Name, requestId);

                subscription.CustomAttributes["ProvisioningRequestId"] = requestId;
                subscription.ProvisioningStatus = Subscription.ProvisioningStatusProvisioningInitiated;
            }
            catch (Exception ex)
            {
                if (!string.IsNullOrEmpty(requestId))
                {
                    string reason;
                    this.coreService.CancelProvisioningRequest(out reason, account.Name, requestId);
                }

                throw new AtomiaProvisioningException(ex.Message, ex);
            }

            return(service);
        }
Example #21
0
 /// <summary>
 /// Fills the service properties.
 /// </summary>
 /// <param name="service">The service.</param>
 /// <param name="customAttributes">The custom attributes.</param>
 private static void FillServiceProperties(ProvisioningService service, Dictionary <string, string> customAttributes)
 {
     FillProperty(service, "CustomParam1", customAttributes, "CustomAttribute1");
     FillProperty(service, "CustomParam2", customAttributes, "CustomAttribute2");
 }
Example #22
0
 private void SetServicePropertyValue(ProvisioningService service, string propertyName, string value)
 {
     service.properties.Single(p => p.Name == exampleServiceData.ServiceProperties[propertyName]).propStringValue = value;
 }
Example #23
0
        /// <summary>
        /// Prepares the service.
        /// </summary>
        /// <param name="productDescription">The product description.</param>
        /// <param name="account">The account.</param>
        /// <param name="serviceKey">The service key.</param>
        /// <param name="parentService">The parent service.</param>
        /// <returns>Prepared service.</returns>
        private ProvisioningService PrepareService(CustomProduct productDescription, BoAccount account, string serviceKey, ProvisioningService parentService)
        {
            string serviceName = string.Empty;

            if (productDescription.CustomProductProperties.Cast <Property>().Any(customProductProperty => customProductProperty.Name == serviceKey))
            {
                serviceName = productDescription.CustomProductProperties[serviceKey].Value;
            }

            if (string.IsNullOrEmpty(serviceName))
            {
                throw new AtomiaProvisioningException(string.Format("Cannot add {0} service. Property {1} is not defined in AtomiaProvisioning section.", productDescription.ProvisioningService, serviceKey));
            }

            return(this.coreService.CreateService(serviceName, parentService, account.Name));
        }
 public void Init()
 {
     service = new ProvisioningService(testUtils.GetConsumerKey(), testUtils.GetPrivateKey(), Environments.Environment.SANDBOX);
 }