public IDefinitionAfterResourceGroup WithNewResourceGroup(ICreatable <IResourceGroup> creatable)
 {
     groupName = creatable.Name;
     newGroup  = creatable;
     AddCreatableDependency(creatable as IResourceCreator <IHasId>);
     return(this as IDefinitionAfterResourceGroup);
 }
        ///GENMHASH:0DD84D78FBDC44F17C987B4E4F0943A1:72AF6C9B67EFB1A3C9DC1BFCEB5C0559
        internal LoadBalancerImpl WithNewPublicIPAddress(ICreatable <IPublicIPAddress> creatablePip, string frontendName)
        {
            string existingPipFrontendName = null;

            creatablePIPKeys.TryGetValue(creatablePip.Key, out existingPipFrontendName);
            if (frontendName == null)
            {
                if (existingPipFrontendName != null)
                {
                    // Reuse frontend already associated with this PIP
                    frontendName = existingPipFrontendName;
                }
                else
                {
                    // Auto-named unique frontend
                    frontendName = EnsureUniqueFrontend().Name();
                }
            }

            if (existingPipFrontendName == null)
            {
                // No frontend associated with this PIP yet so create new association
                creatablePIPKeys[creatablePip.Key] = frontendName;
                AddCreatableDependency(creatablePip as IResourceCreator <IHasId>);
            }
            else if (!existingPipFrontendName.Equals(frontendName, StringComparison.CurrentCultureIgnoreCase))
            {
                // Existing PIP definition already in use but under a different frontend, so error
                throw new ArgumentOutOfRangeException("This public IP address definition is already associated with a frontend under a different name.");
            }

            return(this);
        }
        ///GENMHASH:4F8AF5E60457FDACF0707ABBD081EACF:9D863DCE5EEA7214E8AFD3B3448DD802
        internal LoadBalancingRuleImpl FromNewPublicIPAddress(ICreatable <IPublicIPAddress> pipDefinition)
        {
            string frontendName = SdkContext.RandomResourceName("fe", 20);

            Parent.WithNewPublicIPAddress(pipDefinition, frontendName);
            return(FromFrontend(frontendName));
        }
Exemple #4
0
 public OrderController(ICreatable <Order> _creatable, IDeletable _deletable, IUpdatable <Order> _updatable, IReadable <Order> _readable)
 {
     creatable = _creatable;
     deletable = _deletable;
     updatable = _updatable;
     readable  = _readable;
 }
        /// <summary>
        /// try to create an instance of an object with only it's type name
        /// returns null if the creation failed
        /// </summary>
        /// <param name="typeString"></param>
        /// <returns></returns>
        private static object TryCreateInstance(string typeString)
        {
            if (provider?.IsTypeStringValid(typeString) == true)
            {
                ICreatable creatableNode = provider.CreateFromTypeString(typeString);
                //CreatableNode creatableNode = CreatableNode.CreateDynamic(FindFileWithName(typeString));
                if (creatableNode == null)
                {
#if LOGGER
                    Logger.WriteLine("coudln't create CreatableNode python object");
#endif
                    return(null);
                }
                return(creatableNode.CreateInstance());
            }
            else
            {
                Type type = Type.GetType(typeString);
                if (type != null)
                {
                    return(TryCreateInstance(type));
                }
                else
                {
#if LOGGER
                    Logger.WriteLine("couldn't create type from string:" + typeString);
#endif
                    return(null);
                }
            }
        }
Exemple #6
0
        internal override async Task <Models.SiteInner> SubmitAppSettingsAsync(SiteInner site, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (storageAccountCreatable != null && CreatedResource(storageAccountCreatable.Key) != null)
            {
                storageAccountToSet = (IStorageAccount)CreatedResource(storageAccountCreatable.Key);
            }
            if (storageAccountToSet == null)
            {
                return(await base.SubmitAppSettingsAsync(site, cancellationToken));
            }
            else
            {
                AzureEnvironment environment    = ResourceUtils.ExtractAzureEnvironment(Manager.RestClient) ?? AzureEnvironment.AzureGlobalCloud;
                string           endpointSuffix = Regex.Replace(environment.StorageEndpointSuffix ?? AzureEnvironment.AzureGlobalCloud.StorageEndpointSuffix, "^\\.*", "");
                var servicePlanTask             = Manager.AppServicePlans.GetByIdAsync(this.AppServicePlanId());
                var keys = await storageAccountToSet.GetKeysAsync(cancellationToken);

                var connectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1};EndpointSuffix={2}",
                                                     storageAccountToSet.Name, keys[0].Value, endpointSuffix);
                AddAppSettingIfNotModified("AzureWebJobsStorage", connectionString);
                AddAppSettingIfNotModified("AzureWebJobsDashboard", connectionString);
                if (IsConsumptionAppServicePlan((await servicePlanTask)?.PricingTier))
                {
                    AddAppSettingIfNotModified("WEBSITE_CONTENTAZUREFILECONNECTIONSTRING", connectionString);
                    AddAppSettingIfNotModified("WEBSITE_CONTENTSHARE", SdkContext.RandomResourceName(Name, 32));
                }

                // clean up
                currentStorageAccount   = storageAccountToSet;
                storageAccountToSet     = null;
                storageAccountCreatable = null;

                return(await base.SubmitAppSettingsAsync(site, cancellationToken));
            }
        }
        internal override async Task <Models.SiteInner> SubmitAppSettingsAsync(SiteInner site, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (storageAccountCreatable != null && CreatedResource(storageAccountCreatable.Key) != null)
            {
                storageAccountToSet = (IStorageAccount)CreatedResource(storageAccountCreatable.Key);
            }
            if (storageAccountToSet == null)
            {
                return(await base.SubmitAppSettingsAsync(site, cancellationToken));
            }
            else
            {
                var keys = await storageAccountToSet.GetKeysAsync(cancellationToken);

                var connectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}",
                                                     storageAccountToSet.Name, keys[0].Value);
                WithAppSetting("AzureWebJobsStorage", connectionString);
                WithAppSetting("AzureWebJobsDashboard", connectionString);
                WithAppSetting("WEBSITE_CONTENTAZUREFILECONNECTIONSTRING", connectionString);
                WithAppSetting("WEBSITE_CONTENTSHARE", SdkContext.RandomResourceName(Name, 32));

                // clean up
                currentStorageAccount   = storageAccountToSet;
                storageAccountToSet     = null;
                storageAccountCreatable = null;

                return(await base.SubmitAppSettingsAsync(site, cancellationToken));
            }
        }
Exemple #8
0
        ///GENMHASH:7D841E597D17BCD179F2A65D493BE179:15B38D169822D948E4502A0888DA84AA
        public EventHubDisasterRecoveryPairingImpl WithNewSecondaryNamespace(ICreatable <Microsoft.Azure.Management.Eventhub.Fluent.IEventHubNamespace> namespaceCreatable)
        {
            this.AddCreatableDependency(namespaceCreatable as IResourceCreator <IHasId>);
            EventHubNamespaceImpl ehNamespace = ((EventHubNamespaceImpl)namespaceCreatable);

            this.Inner.PartnerNamespace = ehNamespace.Name;
            return(this);
        }
Exemple #9
0
 ///GENMHASH:1F5324043331585B2120A5C89F84F5DB:0CFB327CCEC02962E7DF01BD3571BC6E
 public SqlDatabaseExportRequestImpl ExportTo(ICreatable <Microsoft.Azure.Management.Storage.Fluent.IStorageAccount> storageAccountCreatable, string containerName, string fileName)
 {
     this.storageAccountCreatable = storageAccountCreatable ?? throw new System.ArgumentNullException("storageAccountCreatable");
     this.containerName           = containerName ?? throw new System.ArgumentNullException("containerName");
     this.fileName       = fileName ?? throw new System.ArgumentNullException("fileName");
     this.storageAccount = null;
     return(this);
 }
        ///GENMHASH:6369056F27BCEB7CF168B7771AFF9AF7:25F30D04BAADB2D9857456903299E903
        public EventHubImpl WithNewNamespace(ICreatable <Microsoft.Azure.Management.Eventhub.Fluent.IEventHubNamespace> namespaceCreatable)
        {
            this.AddCreatableDependency(namespaceCreatable as IResourceCreator <IHasId>);
            EventHubNamespaceImpl ehNamespace = ((EventHubNamespaceImpl)namespaceCreatable);

            this.ancestor = new OneAncestor(ehNamespace.ResourceGroupName, namespaceCreatable.Name);
            return(this);
        }
Exemple #11
0
        public void ShouldNotBeCreatedBy_CreatedBy_When_Entity_Null_Fails_Assertion()
        {
            // Arrange
            ICreatable entity = null;

            // Act & Assert
            Should.Throw <ShouldAssertException>(() => entity.ShouldNotBeCreatedBy(createdBy: Build <UserStub>()));
        }
Exemple #12
0
        public void ShouldBeCreatedBy_CreatedById_When_Entity_Null_Fails_Assertion()
        {
            // Arrange
            ICreatable entity = null;

            // Act & Assert
            Should.Throw <ShouldAssertException>(() => entity.ShouldBeCreatedBy(createdById: Random.Long()));
        }
 public ICreatable <FluentT> ToCreatable(IAzure azure)
 {
     if (this.creatable == null)
     {
         this.creatable = this.ToCreatableIntern(azure);
     }
     return(this.creatable);
 }
Exemple #14
0
        public void ShouldNotBeCreated_When_Entity_Null_Fails_Assertion()
        {
            // Arrange
            ICreatable entity = null;

            // Act & Assert
            Should.Throw <ShouldAssertException>(() => entity.ShouldNotBeCreated());
        }
 public Deployment.Definition.IWithTemplate WithNewResourceGroup(string resourceGroupName, Region region)
 {
     creatableResourceGroup = resourceManager.ResourceGroups
                              .Define(resourceGroupName)
                              .WithRegion(region);
     this.resourceGroupName = resourceGroupName;
     return(this);
 }
 ///GENMHASH:EFF5318E694B2A3BB5AEF7CA70DB29A5:7DCE188EC97FDEB5705826627CBEE021
 public ICreatable <IFluentResourceT> WithNewParentResource(ICreatable <FluentParentModelT> parentResourceCreatable)
 {
     if (creatableParentResourceKey == null)
     {
         creatableParentResourceKey = parentResourceCreatable.Key;
         AddCreatableDependency(parentResourceCreatable as IResourceCreator <IResourceT>);
     }
     return(this);
 }
Exemple #17
0
 ///GENMHASH:495111B1D55D7AA3C4EA4E49042FA05A:81AF1DB897B99ED47A56E01F499D4D5A
 public SqlDatabaseImpl WithNewElasticPool(ICreatable <ISqlElasticPool> sqlElasticPool)
 {
     if (elasticPoolCreatableKey == null)
     {
         elasticPoolCreatableKey = sqlElasticPool.Key;
         AddCreatableDependency(sqlElasticPool as IResourceCreator <IHasId>);
     }
     return(this);
 }
Exemple #18
0
        /// <summary>
        /// Sets created time property.
        /// </summary>
        /// <param name="entity">Entity.</param>
        public static void SetCreatedTime(this ICreatable entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            entity.CreatedTime = SharedLib.InternalDate.Now;
        }
        ///GENMHASH:1C505DCDEFCB5F029B7A60E2375286BF:21FFE595C29A65C12E3FE69611717038
        public VirtualNetworkGatewayImpl WithNewPublicIPAddress()
        {
            string pipName = SdkContext.RandomResourceName("pip", 9);

            this.creatablePip = this.Manager.PublicIPAddresses.Define(pipName)
                                .WithRegion(this.RegionName)
                                .WithExistingResourceGroup(this.ResourceGroupName);
            return(this);
        }
 /// <summary>
 /// Specifies that given identity should be set as one of the External Managed Service Identity
 /// of the virtual machine.
 /// </summary>
 /// <param name="creatableIdentity">Yet-to-be-created identity to be associated with the virtual machine.</param>
 /// <return>ContainerGroupMsiHandler</return>
 internal ContainerGroupMsiHandler WithNewExternalManagedServiceIdentity(ICreatable <IIdentity> creatableIdentity)
 {
     if (!this.creatableIdentityKeys.Contains(creatableIdentity.Key))
     {
         this.InitContainerGroupIdentity(ResourceIdentityType.UserAssigned);
         this.creatableIdentityKeys.Add(creatableIdentity.Key);
         ((creatableIdentity as IResourceCreator <IHasId>).CreatorTaskGroup).Merge(this.containerGroup.CreatorTaskGroup);
     }
     return(this);
 }
 ///GENMHASH:359B78C1848B4A526D723F29D8C8C558:A394B5B2A4C946983BF7F8DE2DAA697E
 protected async override Task <VirtualNetworkInner> CreateInnerAsync(CancellationToken cancellationToken)
 {
     if (ddosProtectionPlanCreatable != null)
     {
         var ddosProtectionPlan = this.CreatedResource(ddosProtectionPlanCreatable.Key);
         WithExistingDdosProtectionPlan(ddosProtectionPlan.Id);
     }
     ddosProtectionPlanCreatable = null;
     return(await this.Manager.Inner.VirtualNetworks.CreateOrUpdateAsync(this.ResourceGroupName, this.Name, this.Inner, cancellationToken));
 }
Exemple #22
0
        public FluentImplT WithNewAppServicePlan(ICreatable <Microsoft.Azure.Management.AppService.Fluent.IAppServicePlan> appServicePlanCreatable)
        {
            AddCreatableDependency(appServicePlanCreatable as IResourceCreator <IHasId>);
            string id = ResourceUtils.ConstructResourceId(this.Manager.SubscriptionId,
                                                          ResourceGroupName, "Microsoft.Web", "serverFarms", appServicePlanCreatable.Name, "");

            Inner.ServerFarmId = id;
            WithOperatingSystem(((AppServicePlanImpl)appServicePlanCreatable).OperatingSystem());
            return((FluentImplT)this);
        }
Exemple #23
0
        ///GENMHASH:57034924A790F6746C59AFD837045739:49734EEA751CB09B1B581F6F3AC76156
        internal NetworkInterfaceImpl WithNewNetworkSecurityGroup(ICreatable <INetworkSecurityGroup> creatable)
        {
            if (creatableNetworkSecurityGroupKey == null)
            {
                creatableNetworkSecurityGroupKey = creatable.Key;
                AddCreatableDependency(creatable as IResourceCreator <IHasId>);
            }

            return(this);
        }
Exemple #24
0
 ///GENMHASH:4A64D79C205DE76E07E6A3581CF5E14B:1A9338236EC82827DA9F8F8293BE39FE
 public SqlElasticPoolForDatabaseImpl DefineElasticPool(string elasticPoolName)
 {
     this.parentSqlElasticPool                = new SqlElasticPoolImpl(this.resourceGroupName, this.sqlServerName, this.sqlServerLocation, elasticPoolName, new ElasticPoolInner(), this.sqlServerManager);
     this.sqlElasticPoolCreatable             = this.parentSqlElasticPool;
     this.Inner.Edition                       = null;
     this.Inner.RequestedServiceObjectiveId   = null;
     this.Inner.RequestedServiceObjectiveName = null;
     this.Inner.ElasticPoolName               = elasticPoolName;
     return(new SqlElasticPoolForDatabaseImpl(this, this.parentSqlElasticPool));
 }
 /// <summary>
 /// Specifies that given identity should be set as one of the External Managed Service Identity
 /// of the virtual machine.
 /// </summary>
 /// <param name="creatableIdentity">Yet-to-be-created identity to be associated with the virtual machine.</param>
 /// <return>VirtualMachineMsiHandler.</return>
 internal VirtualMachineMsiHelper WithNewExternalManagedServiceIdentity(ICreatable <IIdentity> creatableIdentity)
 {
     if (!this.creatableIdentityKeys.Contains(creatableIdentity.Key))
     {
         this.InitVMIdentity(Fluent.Models.ResourceIdentityType.UserAssigned);
         this.creatableIdentityKeys.Add(creatableIdentity.Key);
         ((creatableIdentity as IResourceCreator <IHasId>).CreatorTaskGroup).Merge(this.virtualMachine.CreatorTaskGroup);
     }
     return(this);
 }
Exemple #26
0
 public ProductController(ISaveChange _saveChange, ICreatable <Product> _creatable, IDeletable _deletable, IUpdatable <Product> _updatable, IReadable <Product> _readable)
 {
     //productService = _productService;
     //review_RatingService = _review_RatingService;
     creatable  = _creatable;
     deletable  = _deletable;
     updatable  = _updatable;
     readable   = _readable;
     saveChange = _saveChange;
 }
        public IDefinitionAfterResourceGroup WithNewResourceGroup(string groupName)
        {
            ICreatable <IResourceGroup> creatable = Manager
                                                    .ResourceManager
                                                    .ResourceGroups
                                                    .Define(groupName)
                                                    .WithRegion(RegionName);

            return(WithNewResourceGroup(creatable));
        }
Exemple #28
0
        ///GENMHASH:52541ED0C8AE1806DF3F2DF0DE092357:C9196B5FC5D2D3679E623C4CBFC0DCED
        internal NicIPConfigurationImpl WithNewPublicIPAddress(ICreatable <IPublicIPAddress> creatable)
        {
            if (creatablePublicIPKey == null)
            {
                creatablePublicIPKey = creatable.Key;
                Parent.AddToCreatableDependencies(creatable as IResourceCreator <Management.ResourceManager.Fluent.Core.IHasId>);
            }

            return(this);
        }
Exemple #29
0
        public RegistryImpl WithNewStorageAccount(ICreatable <Microsoft.Azure.Management.Storage.Fluent.IStorageAccount> creatable)
        {
            // This method's effect is NOT additive.
            if (this.creatableStorageAccountKey == null)
            {
                this.creatableStorageAccountKey = creatable.Key;
                this.AddCreatableDependency(creatable as IResourceCreator <IHasId>);
            }

            return(this);
        }
        ///GENMHASH:D232B3BB0D86D13CC0B242F4000DBF07:A6337C672FE4D2497063C4689F0BFDAE
        private ICreatable <Microsoft.Azure.Management.Network.Fluent.IPublicIPAddress> EnsureDefaultPipDefinition()
        {
            if (creatablePip == null)
            {
                string pipName = SdkContext.RandomResourceName("pip", 9);
                creatablePip = Manager.PublicIPAddresses.Define(pipName)
                               .WithRegion(this.RegionName)
                               .WithExistingResourceGroup(this.ResourceGroupName);
            }

            return(creatablePip);
        }
 public UserAuthenticationProvider(
     ITranslate<User, UserAccount> translateDataUserToUserAccount, 
     IRetrievable<ByUserEmail, User> retrieveUserByEmail, 
     IBulkRetrievable<ByEncodedUserId, UserAuthentication> retrieveAllUserAuthenticationByEncodedUserId, 
     IUpdatable<UserAuthentication> userAuthUpdater, 
     ICreatable<UserAuthentication> userAuthCreator, 
     IPasswords passwords, 
     IDeletable<UserAuthentication> userAuthDeleter)
 {
     _translateDataUserToUserAccount = translateDataUserToUserAccount;
     _retrieveUserByEmail = retrieveUserByEmail;
     _retrieveAllUserAuthenticationByEncodedUserId = retrieveAllUserAuthenticationByEncodedUserId;
     _userAuthUpdater = userAuthUpdater;
     _userAuthCreator = userAuthCreator;
     _passwords = passwords;
     _userAuthDeleter = userAuthDeleter;
 }
 public UserAccountProvider(
     IUserAuthenticationProvider userAuthProvider, 
     ICreatable<User> userCreator, 
     IRetrievable<ByUserId, User> userGetByUserId, 
     IRetrievable<ByUserEmail, User> retrieveUserByEmail, 
     IDeletable<User> userDeleter, 
     IUpdatable<User> userUpdater, 
     ITranslate<User, UserAccount> translateDataUserToUserAccount, 
     ISystemTime systemTime)
 {
     _userAuthProvider = userAuthProvider;
     _userCreator = userCreator;
     _userGetByUserId = userGetByUserId;
     _retrieveUserByEmail = retrieveUserByEmail;
     _userDeleter = userDeleter;
     _userUpdater = userUpdater;
     _translateDataUserToUserAccount = translateDataUserToUserAccount;
     _systemTime = systemTime;
 }