protected override void ProcessRecord()
        {
            ComputeAutomationAutoMapperProfile.Initialize();
            ExecuteClientAction(() =>
            {
                if (ShouldProcess(this.ResourceGroupName, VerbsData.Update))
                {
                    string resourceGroupName = this.ResourceGroupName;
                    string snapshotName      = this.SnapshotName;

                    Snapshot snapshotObj = new Snapshot();
                    Mapper.Map <PSSnapshot, Snapshot>(this.Snapshot, snapshotObj);

                    SnapshotUpdate snapshotUpdateObj = new SnapshotUpdate();
                    Mapper.Map <PSSnapshotUpdate, SnapshotUpdate>(this.SnapshotUpdate, snapshotUpdateObj);

                    var result = (this.SnapshotUpdate == null)
                                 ? SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshotObj)
                                 : SnapshotsClient.Update(resourceGroupName, snapshotName, snapshotUpdateObj);

                    var psObject = new PSSnapshot();
                    Mapper.Map <Snapshot, PSSnapshot>(result, psObject);

                    WriteObject(psObject);
                }
            });
        }
        public override void ExecuteCmdlet()
        {
            ExecuteClientAction(() =>
            {
                WriteWarning("Update-AzureRmSnapshot: A property of the output of this cmdlet will change in an upcoming breaking change release. " +
                             "The Name property for a Sku will return Standard_LRS and Premium_LRS");

                if (ShouldProcess(this.SnapshotName, VerbsData.Update))
                {
                    string resourceGroupName      = this.ResourceGroupName;
                    string snapshotName           = this.SnapshotName;
                    SnapshotUpdate snapshotupdate = new SnapshotUpdate();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <PSSnapshotUpdate, SnapshotUpdate>(this.SnapshotUpdate, snapshotupdate);
                    Snapshot snapshot = new Snapshot();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <PSSnapshot, Snapshot>(this.Snapshot, snapshot);

                    var result = (this.SnapshotUpdate == null)
                                 ? SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshot)
                                 : SnapshotsClient.Update(resourceGroupName, snapshotName, snapshotupdate);
                    var psObject = new PSSnapshot();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <Snapshot, PSSnapshot>(result, psObject);
                    WriteObject(psObject);
                }
            });
        }
        protected void ExecuteSnapshotUpdateMethod(object[] invokeMethodInputParameters)
        {
            string           resourceGroupName = (string)ParseParameter(invokeMethodInputParameters[0]);
            string           snapshotName      = (string)ParseParameter(invokeMethodInputParameters[1]);
            PSSnapshotUpdate snapshot          = (PSSnapshotUpdate)ParseParameter(invokeMethodInputParameters[2]);
            PSSnapshot       snapshotOrg       = (PSSnapshot)ParseParameter(invokeMethodInputParameters[3]);

            var result = (snapshot == null)
                         ? SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshotOrg)
                         : SnapshotsClient.Update(resourceGroupName, snapshotName, snapshot);

            WriteObject(result);
        }
Example #4
0
        public override void ExecuteCmdlet()
        {
            ExecuteClientAction(() =>
            {
                if (ShouldProcess(this.SnapshotName, VerbsData.Update))
                {
                    string resourceGroupName      = this.ResourceGroupName;
                    string snapshotName           = this.SnapshotName;
                    SnapshotUpdate snapshotupdate = new SnapshotUpdate();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <PSSnapshotUpdate, SnapshotUpdate>(this.SnapshotUpdate, snapshotupdate);
                    Snapshot snapshot = new Snapshot();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <PSSnapshot, Snapshot>(this.Snapshot, snapshot);

                    var result = (this.SnapshotUpdate == null)
                                 ? SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshot)
                                 : SnapshotsClient.Update(resourceGroupName, snapshotName, snapshotupdate);
                    var psObject = new PSSnapshot();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <Snapshot, PSSnapshot>(result, psObject);
                    WriteObject(psObject);
                }
            });
        }
        protected override void ProcessRecord()
        {
            ExecuteClientAction(() =>
            {
                if (ShouldProcess(this.ResourceGroupName, VerbsData.Update))
                {
                    string resourceGroupName  = this.ResourceGroupName;
                    string snapshotName       = this.SnapshotName;
                    PSSnapshotUpdate snapshot = this.SnapshotUpdate;
                    PSSnapshot snapshotOrg    = this.Snapshot;

                    var result = (snapshot == null)
                                 ? SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshotOrg)
                                 : SnapshotsClient.Update(resourceGroupName, snapshotName, snapshot);

                    var psObject = new PSSnapshot();
                    Mapper.Map <Snapshot, PSSnapshot>(result, psObject);

                    WriteObject(psObject);
                }
            });
        }