Esempio n. 1
0
        /// <summary>
        /// Generates the model from user input.
        /// </summary>
        /// <param name="model">This is null since the instance pool doesn't exist yet</param>
        /// <returns>The generated model from user input</returns>
        protected override IEnumerable <AzureSqlInstancePoolModel> ApplyUserInputToModel
            (IEnumerable <AzureSqlInstancePoolModel> model)
        {
            string editionShort = Edition.Equals(Constants.GeneralPurposeEdition) ? "GP" :
                                  Edition.Equals(Constants.BusinessCriticalEdition) ? "BC" : "Unknown";
            string skuName = editionShort + "_" + ComputeGeneration;

            AzureSqlInstancePoolModel newEntity = new AzureSqlInstancePoolModel
            {
                Location          = this.Location,
                ResourceGroupName = this.ResourceGroupName,
                InstancePoolName  = this.Name,
                Tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true),
                Sku  = new Sku()
                {
                    Name   = skuName,
                    Tier   = Edition,
                    Family = ComputeGeneration
                },
                SubnetId    = SubnetId,
                VCores      = VCore,
                LicenseType = LicenseType,
            };

            return(new List <AzureSqlInstancePoolModel> {
                newEntity
            });
        }
        /// <summary>
        /// Creates or updates an instance pool
        /// </summary>
        /// <param name="model">The instance pool entity</param>
        /// <returns>The created or updated instance pool entity</returns>
        public AzureSqlInstancePoolModel UpsertInstancePool(AzureSqlInstancePoolModel model)
        {
            var result = Communicator.UpsertInstancePool(model.ResourceGroupName, model.InstancePoolName,
                                                         new InstancePool()
            {
                LicenseType = model.LicenseType,
                Sku         = model.Sku,
                Location    = model.Location,
                SubnetId    = model.SubnetId,
                Tags        = model.Tags,
                VCores      = model.VCores
            });

            return(CreateInstancePoolModelFromResponse(result));
        }
Esempio n. 3
0
        /// <summary>
        /// Generates the updated model from user input.
        /// </summary>
        /// <param name="existingEntity">The existing instance pool model</param>
        /// <returns>The generated model from user input</returns>
        protected override IEnumerable <AzureSqlInstancePoolModel> ApplyUserInputToModel(IEnumerable <AzureSqlInstancePoolModel> model)
        {
            var existingEntity = model.FirstOrDefault();

            AzureSqlInstancePoolModel newEntity = new AzureSqlInstancePoolModel
            {
                Location          = existingEntity.Location,
                ResourceGroupName = this.ResourceGroupName,
                InstancePoolName  = this.Name,
                Tags        = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true),
                Sku         = existingEntity.Sku,
                SubnetId    = existingEntity.SubnetId,
                VCores      = existingEntity.VCores,
                LicenseType = LicenseType != null ? this.LicenseType : existingEntity.LicenseType,
            };

            return(new List <AzureSqlInstancePoolModel> {
                newEntity
            });
        }