public override void ResolveInlineCreatable(IAzure azure, IGroupableModel parentModel) { if (this.creatable == null) { if (this.AddressSpace != null && this.AddressSpace.Cidr != null) { Microsoft.Azure.Management.Network.Fluent.Network.Definition.IWithGroup withGroup; withGroup = azure.Networks .Define(SdkContext.RandomResourceName("nw", 15)) .WithRegion(parentModel.Location()); Microsoft.Azure.Management.Network.Fluent.Network.Definition.IWithCreate withCreate; if (parentModel.CreatableResourceGroup() != null) { withCreate = withCreate = withGroup.WithNewResourceGroup(parentModel.CreatableResourceGroup()); } else if (parentModel.ResourceGroup() != null) { withCreate = withGroup.WithExistingResourceGroup(parentModel.ResourceGroup()); } else { withCreate = withGroup.WithNewResourceGroup(); } Microsoft.Azure.Management.Network.Fluent.Network.Definition.IWithCreateAndSubnet withCreateAndSubnet = withCreate.WithAddressSpace(this.AddressSpace.Cidr); if (this.AddressSpace.Subnets != null) { withCreateAndSubnet.WithSubnets(this.AddressSpace.Subnets); } this.creatable = withCreateAndSubnet; } } }
public override void ResolveInlineCreatable(IAzure azure, IGroupableModel parentModel) { if (this.creatable == null) { if (this.Name != null) { Microsoft.Azure.Management.Storage.Fluent.StorageAccount.Definition.IWithGroup withGroup; withGroup = azure.StorageAccounts.Define(this.Name) .WithRegion(parentModel.Location()); Microsoft.Azure.Management.Storage.Fluent.StorageAccount.Definition.IWithCreate withCreate; if (parentModel.CreatableResourceGroup() != null) { withCreate = withCreate = withGroup.WithNewResourceGroup(parentModel.CreatableResourceGroup()); } else if (parentModel.ResourceGroup() != null) { withCreate = withGroup.WithExistingResourceGroup(parentModel.ResourceGroup()); } else { withCreate = withGroup.WithNewResourceGroup(); } withCreate = withCreate .WithGeneralPurposeAccountKind(); base.creatable = withCreate; } } }
public override void ResolveInlineCreatable(IAzure azure, IGroupableModel parentModel) { if (this.creatable == null) { if (this.LeafDomainLabel != null) { Microsoft.Azure.Management.Network.Fluent.PublicIPAddress.Definition.IWithGroup withGroup; withGroup = azure.PublicIPAddresses.Define(SdkContext.RandomResourceName("pip", 15)) .WithRegion(parentModel.Location()); Microsoft.Azure.Management.Network.Fluent.PublicIPAddress.Definition.IWithCreate withCreate; if (parentModel.CreatableResourceGroup() != null) { withCreate = withCreate = withGroup.WithNewResourceGroup(parentModel.CreatableResourceGroup()); } else if (parentModel.ResourceGroup() != null) { withCreate = withGroup.WithExistingResourceGroup(parentModel.ResourceGroup()); } else { withCreate = withGroup.WithNewResourceGroup(); } withCreate = withCreate .WithLeafDomainLabel(this.LeafDomainLabel); base.creatable = withCreate; } } }
public override void ResolveInlineCreatable(IAzure azure, IGroupableModel parentModel) { if (this.creatable == null) { if (this.Name != null) { base.creatable = azure.ResourceGroups.Define(this.Name) .WithRegion(parentModel.Location()); } } }
public Task ValidateAndResolveAsync(IAzure azure, FluentRequestModel fluentRequestModel, string propertyName, IGroupableModel parentModel, CancellationToken cancellationToken = default(CancellationToken)) { foreach (NewResourceT item in this) { item.Validate(propertyName); } foreach (NewResourceT item in this) { item.ResolveInlineCreatable(azure, parentModel); item.ResolveCreatableReference(azure, fluentRequestModel); } return(Task.CompletedTask); }
public virtual void ResolveInlineCreatable(IAzure azure, IGroupableModel parentModel) { // NOP }
public Task ValidateAndResolveAsync(IAzure azure, FluentRequestModel fluentRequestModel, string propertyName, IGroupableModel parentModel, CancellationToken cancellationToken = default(CancellationToken)) { if (this.Region == null) { if (parentModel.Location() != null) { this.Region = parentModel.Location().ToString(); } else { this.Region = Microsoft.Azure.Management.ResourceManager.Fluent.Core.Region.USEast2.ToString(); } } // // This model has no "New{Resource}" properties on which Validation and Resolution // needs to be run // return(Task.CompletedTask); }
public async Task ValidateAndResolveAsync(IAzure azure, FluentRequestModel fluentRequestModel, string propertyName, IGroupableModel parentModel, CancellationToken cancellationToken = default(CancellationToken)) { int i = 0; foreach (var model in this) { await model.ValidateAndResolveAsync(azure, fluentRequestModel, $"{propertyName}[{i}]", parentModel, cancellationToken); i++; } }
public async Task ValidateAndResolveAsync(IAzure azure, FluentRequestModel fluentRequestModel, string propertyName, IGroupableModel parentModel, CancellationToken cancellationToken = default(CancellationToken)) { if (ResourceGroupModels != null) { await ResourceGroupModels.ValidateAndResolveAsync(azure, fluentRequestModel, "resourceGroups", parentModel, cancellationToken); } if (NetworkModels != null) { await NetworkModels.ValidateAndResolveAsync(azure, fluentRequestModel, "networks", parentModel, cancellationToken); } if (PublicIPAddressModels != null) { await PublicIPAddressModels.ValidateAndResolveAsync(azure, fluentRequestModel, "publicIpAddresses", parentModel, cancellationToken); } if (NetworkSecurityGroupModels != null) { await NetworkSecurityGroupModels.ValidateAndResolveAsync(azure, fluentRequestModel, "networkSecurityGroups", parentModel, cancellationToken); } if (NetworkInterfaceModels != null) { await NetworkInterfaceModels.ValidateAndResolveAsync(azure, fluentRequestModel, "networkInterfaces", parentModel, cancellationToken); } if (StorageAccountModels != null) { await StorageAccountModels.ValidateAndResolveAsync(azure, fluentRequestModel, "storageAccounts", parentModel, cancellationToken); } if (VirtualMachineModels != null) { await VirtualMachineModels.ValidateAndResolveAsync(azure, fluentRequestModel, "virtualMachines", parentModel, cancellationToken); } }
public override async Task ValidateAndResolveAsync(IAzure azure, FluentRequestModel fluentRequestModel, string propertyName, IGroupableModel parentModel, CancellationToken cancellationToken) { await this.ValidateAndResolveResourceGroupAsync(azure, fluentRequestModel, propertyName, parentModel, cancellationToken); if (this.Linux != null) { this.Linux.Validate($"{propertyName}.linux"); } else if (this.Windows != null) { this.Windows.Validate($"{propertyName}.windows"); } else { throw new ArgumentException($"{propertyName}.linux or {propertyName}.windows should be specified"); } if (NewPrimaryNetwork != null) { NewPrimaryNetwork.Validate($"{propertyName}.newPrimaryNetwork"); NewPrimaryNetwork.ResolveInlineCreatable(azure, this); NewPrimaryNetwork.ResolveCreatableReference(azure, fluentRequestModel); } if (ExistingPrimaryNetwork != null) { ExistingPrimaryNetwork.Validate($"{propertyName}.existingPrimaryNetwork"); await ExistingPrimaryNetwork.ResolveResourceAsync(azure, cancellationToken); } if (NewPrimaryPublicIPAddress != null) { NewPrimaryPublicIPAddress.Validate($"{propertyName}.newPrimaryPublicIPAddress"); NewPrimaryPublicIPAddress.ResolveInlineCreatable(azure, this); NewPrimaryPublicIPAddress.ResolveCreatableReference(azure, fluentRequestModel); } if (ExistingPrimaryPublicIPAddress != null) { ExistingPrimaryPublicIPAddress.Validate($"{propertyName}.existingPrimaryPublicIPAddress"); await ExistingPrimaryPublicIPAddress.ResolveResourceAsync(azure, cancellationToken); } if (NewPrimaryNetworkInterface != null) { NewPrimaryNetworkInterface.Validate($"{propertyName}.newPrimaryNetworkInterface"); NewPrimaryNetworkInterface.ResolveInlineCreatable(azure, this); NewPrimaryNetworkInterface.ResolveCreatableReference(azure, fluentRequestModel); } if (ExistingPrimaryNetworkInterface != null) { ExistingPrimaryNetworkInterface.Validate($"{propertyName}.existingPrimaryNetworkInterface"); await ExistingPrimaryNetworkInterface.ResolveResourceAsync(azure, cancellationToken); } if (this.BootDiagnostics != null) { await this.BootDiagnostics.ValidateAndResolveAsync(azure, fluentRequestModel, $"{propertyName}.bootDiagnostics", this, cancellationToken); } }
public override async Task ValidateAndResolveAsync(IAzure azure, FluentRequestModel fluentRequestModel, string propertyName, IGroupableModel parentModel, CancellationToken cancellationToken = default(CancellationToken)) { await base.ValidateAndResolveResourceGroupAsync(azure, fluentRequestModel, propertyName, parentModel); }
public async Task ValidateAndResolveAsync(IAzure azure, FluentRequestModel fluentRequestModel, string propertyName, IGroupableModel parentModel, CancellationToken cancellationToken = default(CancellationToken)) { if (this.Enabled == null) { throw new ArgumentException($"{propertyName} is specified then {propertyName}.enabled must be specified"); } if (this.NewStorageAccount != null) { NewStorageAccount.Validate($"{propertyName}.newStorageAccount"); NewStorageAccount.ResolveInlineCreatable(azure, parentModel); NewStorageAccount.ResolveCreatableReference(azure, fluentRequestModel); } if (this.ExistingStorageAccount != null) { ExistingStorageAccount.Validate($"{propertyName}.existingStorageAccount"); await ExistingStorageAccount.ResolveResourceAsync(azure, cancellationToken); } }
protected async Task ValidateAndResolveResourceGroupAsync(IAzure azure, FluentRequestModel fluentRequestModel, string propertyName, IGroupableModel parentModel, CancellationToken cancellationToken = default(CancellationToken)) { if (this.NewResourceGroup != null) { this.NewResourceGroup.Validate($"{propertyName}.newResourceGroup"); this.NewResourceGroup.ResolveInlineCreatable(azure, parentModel); this.NewResourceGroup.ResolveCreatableReference(azure, fluentRequestModel); // this.creatableResourceGroup = this.NewResourceGroup.GetCreatable(); } if (this.ExistingResourceGroup != null) { this.ExistingResourceGroup.Validate($"{propertyName}.existingResourceGroup"); await this.ExistingResourceGroup.ResolveResourceAsync(azure, cancellationToken); // this.resourceGroup = this.ExistingResourceGroup.GetResource(); } if (this.creatableResourceGroup == null && this.resourceGroup == null) { // if 'NewResourceGroup' and/or 'ExistingResourceGroup' is not set // in the request use parent model's resource group. // if (parentModel.CreatableResourceGroup() != null) { this.creatableResourceGroup = parentModel.CreatableResourceGroup(); } if (parentModel.ResourceGroup() != null) { this.resourceGroup = parentModel.ResourceGroup(); } if (this.creatableResourceGroup == null && this.resourceGroup == null) { throw new InvalidOperationException("Unable to derive resource group locally or from parent model"); } } if (this.Region == null) { this.Region = parentModel.Location(); if (this.Region == null) { throw new InvalidOperationException("Unable to derive region locally or from parent model"); } } }
public abstract Task ValidateAndResolveAsync(IAzure azure, FluentRequestModel fluentRequestModel, string propertyName, IGroupableModel parentModel, CancellationToken cancellationToken = default(CancellationToken));
public override async Task ValidateAndResolveAsync(IAzure azure, FluentRequestModel fluentRequestModel, string propertyName, IGroupableModel parentModel, CancellationToken cancellationToken = default(CancellationToken)) { await base.ValidateAndResolveResourceGroupAsync(azure, fluentRequestModel, propertyName, parentModel, cancellationToken); if (NewPrimaryNetwork != null) { NewPrimaryNetwork.Validate($"{propertyName}.newPrimaryNetwork"); NewPrimaryNetwork.ResolveInlineCreatable(azure, this); NewPrimaryNetwork.ResolveCreatableReference(azure, fluentRequestModel); } if (ExistingPrimaryNetwork != null) { ExistingPrimaryNetwork.Validate($"{propertyName}.existingPrimaryNetwork"); await ExistingPrimaryNetwork.ResolveResourceAsync(azure, cancellationToken); } if (NewPrimaryPublicIPAddress != null) { NewPrimaryPublicIPAddress.Validate($"{propertyName}.newPrimaryPublicIPAddress"); NewPrimaryPublicIPAddress.ResolveInlineCreatable(azure, this); NewPrimaryPublicIPAddress.ResolveCreatableReference(azure, fluentRequestModel); } if (ExistingPrimiaryPublicIPAddress != null) { ExistingPrimiaryPublicIPAddress.Validate($"{propertyName}.existingPrimiaryPublicIPAddress"); await ExistingPrimiaryPublicIPAddress.ResolveResourceAsync(azure, cancellationToken); } if (ExistingLoadBalancerBackends != null) { await ExistingLoadBalancerBackends.ValidateAndResolveAsync(azure, fluentRequestModel, $"{propertyName}.loadBalancerBackends", this, cancellationToken); } if (ExistingLoadBalancerInboundNatRules != null) { await ExistingLoadBalancerInboundNatRules.ValidateAndResolveAsync(azure, fluentRequestModel, $"{propertyName}.loadBalancerBackends", this, cancellationToken); } if (NewNetworkSecurityGroups != null) { await NewNetworkSecurityGroups.ValidateAndResolveAsync(azure, fluentRequestModel, $"{propertyName}.newPrimaryPublicIPAddress", this, cancellationToken); } if (ExistingNetworkSecurityGroups != null) { await ExistingNetworkSecurityGroups.ValidateAndResolveAsync(azure, fluentRequestModel, $"{propertyName}.existingNetworkSecurityGroups", this, cancellationToken); } }
public override async Task ValidateAndResolveAsync(IAzure azure, FluentRequestModel fluentRequestModel, string propertyName, IGroupableModel parentModel, CancellationToken cancellationToken) { await base.ValidateAndResolveResourceGroupAsync(azure, fluentRequestModel, propertyName, parentModel, cancellationToken); if (this.Rules != null) { int i = 0; foreach (var rule in Rules) { rule.Value.Validate($"{propertyName}.rules[{i}]"); i++; } } }
public async Task ValidateAndResolveAsync(IAzure azure, FluentRequestModel fluentRequestModel, string propertyName, IGroupableModel parentModel, CancellationToken cancellationToken = default(CancellationToken)) { foreach (ExistingResourceT item in this) { item.Validate(propertyName); } foreach (ExistingResourceT item in this) { await item.ResolveResourceAsync(azure, cancellationToken); } }
public override async Task ValidateAndResolveAsync(IAzure azure, FluentRequestModel fluentRequestModel, string propertyName, IGroupableModel parentModel, CancellationToken cancellationToken = default(CancellationToken)) { await base.ValidateAndResolveResourceGroupAsync(azure, fluentRequestModel, propertyName, parentModel, cancellationToken); if (this.AddressSpace != null && this.AddressSpace.Cidr == null && this.AddressSpace.Subnets != null) { throw new ArgumentException($"Specifying {propertyName}.addressSpace.subnets requires {propertyName}.addressSpace.cidr to present"); } }