Пример #1
0
        public void UpdateCloudProviderService(Guid organizationId, Guid organizationCPSId, string accessId,
                                               string accessName,
                                               string accessSecret,
                                               string accessAppId,
                                               string accessAppSecret,
                                               string accessDirectory,
                                               string accessRegion)
        {
            Organization organization = FindOrganizationById(organizationId);

            if (organization == null)
            {
                throw new ApplicationException($"The organization with id {organizationId} does not exists");
            }

            OrganizationCPS organizationCPS = organization.GetCloudProviderServiceById(organizationCPSId);

            if (organizationCPS == null)
            {
                throw new ApplicationException($"The organization cloud providerservice with id {organizationCPSId} does not exists");
            }

            organizationCPS.UpdateCredentials(accessId, accessName, accessSecret, accessAppId, accessAppSecret, accessDirectory, accessRegion);
            organizationCPS.Audit(this.Id);
        }
        public void AddCloudProviderService(OrganizationCPS cloudProviderservice)
        {
            if (this.CloudProviderServices == null)
            {
                this.CloudProviderServices = new List <OrganizationCPS>();
            }

            this.CloudProviderServices.Add(cloudProviderservice);
        }
Пример #3
0
        public void DeleteCloudProviderService(Guid organizationId, Guid organizationCPSId)
        {
            Organization organization = FindOrganizationById(organizationId);

            if (organization == null)
            {
                throw new ApplicationException($"The organization with id {organizationId} does not exists");
            }

            OrganizationCPS organizationCPS = organization.GetCloudProviderServiceById(organizationCPSId);

            if (organizationCPS == null)
            {
                throw new ApplicationException($"The organization cloud providerservice with id {organizationCPSId} does not exists");
            }

            organizationCPS.Delete(this.Id);
        }
            public static OrganizationCPS Create(string name, CloudProviderService type,
                                                 string accessId,
                                                 string accessName,
                                                 string accessSecret,
                                                 string accessAppId,
                                                 string accessAppSecret,
                                                 string accessDirectory,
                                                 string accessRegion,
                                                 string createdBy)
            {
                var entity = new OrganizationCPS()
                {
                    Name            = name,
                    Type            = type,
                    AccessId        = accessId,
                    AccessName      = accessName,
                    AccessSecret    = accessSecret,
                    AccessAppId     = accessAppId,
                    AccessAppSecret = accessAppSecret,
                    AccessDirectory = accessDirectory,
                    AccessRegion    = accessRegion,
                    CreatedBy       = createdBy,
                    Status          = EntityStatus.Active
                };

                var validationResult = new DataValidatorManager <OrganizationCPS>().Build().Validate(entity);

                if (!validationResult.IsValid)
                {
                    throw new ApplicationException(validationResult.Errors);
                }

                if (type == CloudProviderService.AWS)
                {
                    if (string.IsNullOrEmpty(accessSecret))
                    {
                        throw new ApplicationException("Access Secret is required");
                    }
                }

                if (type == CloudProviderService.Azure)
                {
                    if (string.IsNullOrEmpty(accessName))
                    {
                        throw new ApplicationException("Subscription Name is required");
                    }

                    if (string.IsNullOrEmpty(accessAppId))
                    {
                        throw new ApplicationException("Application Id is required");
                    }

                    if (string.IsNullOrEmpty(accessAppSecret))
                    {
                        throw new ApplicationException("Application Secret is required");
                    }

                    if (string.IsNullOrEmpty(accessDirectory))
                    {
                        throw new ApplicationException("Directory is required");
                    }
                }

                return(entity);
            }