Esempio n. 1
0
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();
            ExecuteClientAction(() =>
            {
                if (ShouldProcess(this.Name, VerbsData.Update))
                {
                    string resourceGroupName;
                    string diskEncryptionSetName;
                    switch (this.ParameterSetName)
                    {
                    case "ResourceIdParameter":
                        resourceGroupName     = GetResourceGroupName(this.ResourceId);
                        diskEncryptionSetName = GetResourceName(this.ResourceId, "Microsoft.Compute/diskEncryptionSets");
                        break;

                    case "ObjectParameter":
                        resourceGroupName     = GetResourceGroupName(this.InputObject.Id);
                        diskEncryptionSetName = GetResourceName(this.InputObject.Id, "Microsoft.Compute/diskEncryptionSets");
                        break;

                    default:
                        resourceGroupName     = this.ResourceGroupName;
                        diskEncryptionSetName = this.Name;
                        break;
                    }

                    if (this.InputObject == null)
                    {
                        BuildPatchObject();
                    }
                    else
                    {
                        BuildPutObject();
                    }
                    DiskEncryptionSetUpdate diskEncryptionSetupdate = this.DiskEncryptionSetUpdate;
                    DiskEncryptionSet parameter = new DiskEncryptionSet();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <PSDiskEncryptionSet, DiskEncryptionSet>(this.InputObject, parameter);

                    var result = (this.DiskEncryptionSetUpdate == null)
                                 ? DiskEncryptionSetsClient.CreateOrUpdate(resourceGroupName, diskEncryptionSetName, parameter)
                                 : DiskEncryptionSetsClient.Update(resourceGroupName, diskEncryptionSetName, diskEncryptionSetupdate);
                    var psObject = new PSDiskEncryptionSet();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <DiskEncryptionSet, PSDiskEncryptionSet>(result, psObject);
                    WriteObject(psObject);
                }
            });
        }
Esempio n. 2
0
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();
            ExecuteClientAction(() =>
            {
                if (ShouldProcess(this.Name, VerbsCommon.New))
                {
                    string resourceGroupName            = this.ResourceGroupName;
                    string diskEncryptionSetName        = this.Name;
                    DiskEncryptionSet diskEncryptionSet = new DiskEncryptionSet();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <PSDiskEncryptionSet, DiskEncryptionSet>(this.InputObject, diskEncryptionSet);

                    var result   = DiskEncryptionSetsClient.CreateOrUpdate(resourceGroupName, diskEncryptionSetName, diskEncryptionSet);
                    var psObject = new PSDiskEncryptionSet();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <DiskEncryptionSet, PSDiskEncryptionSet>(result, psObject);
                    WriteObject(psObject);
                }
            });
        }