public override void ExecuteCmdlet() { base.ExecuteCmdlet(); ExecuteClientAction(() => { string resourceGroupName = this.ResourceGroupName; string snapshotName = this.SnapshotName; if (!string.IsNullOrEmpty(resourceGroupName) && !string.IsNullOrEmpty(snapshotName)) { var result = SnapshotsClient.Get(resourceGroupName, snapshotName); var psObject = new PSSnapshot(); ComputeAutomationAutoMapperProfile.Mapper.Map <Snapshot, PSSnapshot>(result, psObject); WriteObject(psObject); } else if (!string.IsNullOrEmpty(resourceGroupName)) { var result = SnapshotsClient.ListByResourceGroup(resourceGroupName); var resultList = result.ToList(); var nextPageLink = result.NextPageLink; while (!string.IsNullOrEmpty(nextPageLink)) { var pageResult = SnapshotsClient.ListByResourceGroupNext(nextPageLink); foreach (var pageItem in pageResult) { resultList.Add(pageItem); } nextPageLink = pageResult.NextPageLink; } var psObject = new List <PSSnapshotList>(); foreach (var r in resultList) { psObject.Add(ComputeAutomationAutoMapperProfile.Mapper.Map <Snapshot, PSSnapshotList>(r)); } WriteObject(psObject, true); } else { var result = SnapshotsClient.List(); var resultList = result.ToList(); var nextPageLink = result.NextPageLink; while (!string.IsNullOrEmpty(nextPageLink)) { var pageResult = SnapshotsClient.ListNext(nextPageLink); foreach (var pageItem in pageResult) { resultList.Add(pageItem); } nextPageLink = pageResult.NextPageLink; } var psObject = new List <PSSnapshotList>(); foreach (var r in resultList) { psObject.Add(ComputeAutomationAutoMapperProfile.Mapper.Map <Snapshot, PSSnapshotList>(r)); } WriteObject(psObject, true); } }); }
protected void ExecuteSnapshotGetMethod(object[] invokeMethodInputParameters) { string resourceGroupName = (string)ParseParameter(invokeMethodInputParameters[0]); string snapshotName = (string)ParseParameter(invokeMethodInputParameters[1]); if (!string.IsNullOrEmpty(resourceGroupName) && !string.IsNullOrEmpty(snapshotName)) { var result = SnapshotsClient.Get(resourceGroupName, snapshotName); var psObject = new PSSnapshot(); Mapper.Map <Snapshot, PSSnapshot>(result, psObject); WriteObject(psObject); } else if (!string.IsNullOrEmpty(resourceGroupName)) { var result = SnapshotsClient.ListByResourceGroup(resourceGroupName); var resultList = result.ToList(); var nextPageLink = result.NextPageLink; while (!string.IsNullOrEmpty(nextPageLink)) { var pageResult = SnapshotsClient.ListByResourceGroupNext(nextPageLink); foreach (var pageItem in pageResult) { resultList.Add(pageItem); } nextPageLink = pageResult.NextPageLink; } var psObject = new List <PSSnapshotList>(); foreach (var r in resultList) { psObject.Add(Mapper.Map <Snapshot, PSSnapshotList>(r)); } WriteObject(psObject, true); } else { var result = SnapshotsClient.List(); var resultList = result.ToList(); var nextPageLink = result.NextPageLink; while (!string.IsNullOrEmpty(nextPageLink)) { var pageResult = SnapshotsClient.ListNext(nextPageLink); foreach (var pageItem in pageResult) { resultList.Add(pageItem); } nextPageLink = pageResult.NextPageLink; } var psObject = new List <PSSnapshotList>(); foreach (var r in resultList) { psObject.Add(Mapper.Map <Snapshot, PSSnapshotList>(r)); } WriteObject(psObject, true); } }
/// <summary>Snippet for List</summary> public void List() { // Snippet: List(string, CallSettings) // Create client SnapshotsClient snapshotsClient = SnapshotsClient.Create(); // Initialize request argument(s) string project = ""; // Make the request SnapshotList response = snapshotsClient.List(project); // End snippet }
/// <summary>Snippet for List</summary> public void ListRequestObject() { // Snippet: List(ListSnapshotsRequest, CallSettings) // Create client SnapshotsClient snapshotsClient = SnapshotsClient.Create(); // Initialize request argument(s) ListSnapshotsRequest request = new ListSnapshotsRequest { OrderBy = "", Project = "", Filter = "", ReturnPartialSuccess = false, }; // Make the request PagedEnumerable <SnapshotList, Snapshot> response = snapshotsClient.List(request); // Iterate over all response items, lazily performing RPCs as required foreach (Snapshot item in response) { // Do something with each item Console.WriteLine(item); } // Or iterate over pages (of server-defined size), performing one RPC per page foreach (SnapshotList page in response.AsRawResponses()) { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (Snapshot item in page) { // Do something with each item Console.WriteLine(item); } } // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required int pageSize = 10; Page <Snapshot> singlePage = response.ReadPage(pageSize); // Do something with the page of items Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); foreach (Snapshot item in singlePage) { // Do something with each item Console.WriteLine(item); } // Store the pageToken, for when the next page is required. string nextPageToken = singlePage.NextPageToken; // End snippet }
protected void ExecuteSnapshotListMethod(object[] invokeMethodInputParameters) { var result = SnapshotsClient.List(); var resultList = result.ToList(); var nextPageLink = result.NextPageLink; while (!string.IsNullOrEmpty(nextPageLink)) { var pageResult = SnapshotsClient.ListNext(nextPageLink); foreach (var pageItem in pageResult) { resultList.Add(pageItem); } nextPageLink = pageResult.NextPageLink; } WriteObject(resultList, true); }
/// <summary>Snippet for List</summary> public void ListRequestObject() { // Snippet: List(ListSnapshotsRequest, CallSettings) // Create client SnapshotsClient snapshotsClient = SnapshotsClient.Create(); // Initialize request argument(s) ListSnapshotsRequest request = new ListSnapshotsRequest { PageToken = "", MaxResults = 0U, Filter = "", OrderBy = "", Project = "", ReturnPartialSuccess = false, }; // Make the request SnapshotList response = snapshotsClient.List(request); // End snippet }
public override void ExecuteCmdlet() { ExecuteClientAction(() => { WriteWarning("Get-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"); string resourceGroupName = this.ResourceGroupName; string snapshotName = this.SnapshotName; if (!string.IsNullOrEmpty(resourceGroupName) && !string.IsNullOrEmpty(snapshotName)) { var result = SnapshotsClient.Get(resourceGroupName, snapshotName); var psObject = new PSSnapshot(); ComputeAutomationAutoMapperProfile.Mapper.Map <Snapshot, PSSnapshot>(result, psObject); WriteObject(psObject); } else if (!string.IsNullOrEmpty(resourceGroupName)) { var result = SnapshotsClient.ListByResourceGroup(resourceGroupName); var resultList = result.ToList(); var nextPageLink = result.NextPageLink; while (!string.IsNullOrEmpty(nextPageLink)) { var pageResult = SnapshotsClient.ListByResourceGroupNext(nextPageLink); foreach (var pageItem in pageResult) { resultList.Add(pageItem); } nextPageLink = pageResult.NextPageLink; } var psObject = new List <PSSnapshotList>(); foreach (var r in resultList) { psObject.Add(ComputeAutomationAutoMapperProfile.Mapper.Map <Snapshot, PSSnapshotList>(r)); } WriteObject(psObject, true); } else { var result = SnapshotsClient.List(); var resultList = result.ToList(); var nextPageLink = result.NextPageLink; while (!string.IsNullOrEmpty(nextPageLink)) { var pageResult = SnapshotsClient.ListNext(nextPageLink); foreach (var pageItem in pageResult) { resultList.Add(pageItem); } nextPageLink = pageResult.NextPageLink; } var psObject = new List <PSSnapshotList>(); foreach (var r in resultList) { psObject.Add(ComputeAutomationAutoMapperProfile.Mapper.Map <Snapshot, PSSnapshotList>(r)); } WriteObject(psObject, true); } }); }