protected override void ProcessRecord() { AmazonCloudWatch client = base.GetClient(); Amazon.CloudWatch.Model.ListMetricsRequest request = new Amazon.CloudWatch.Model.ListMetricsRequest(); request.NextToken = this._NextToken; Amazon.CloudWatch.Model.ListMetricsResponse response = client.ListMetrics(request); base.WriteObject(response.ListMetricsResult, true); }
/// <summary> /// Initiates the asynchronous execution of the ListMetrics operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ListMetrics operation on AmazonCloudWatchClient.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndListMetrics /// operation.</returns> public IAsyncResult BeginListMetrics(ListMetricsRequest request, AsyncCallback callback, object state) { var marshaller = new ListMetricsRequestMarshaller(); var unmarshaller = ListMetricsResponseUnmarshaller.Instance; return BeginInvoke<ListMetricsRequest>(request, marshaller, unmarshaller, callback, state); }
/// <summary> /// Returns a list of valid metrics stored for the AWS account owner. Returned metrics /// can be used with <a>GetMetricStatistics</a> to obtain statistical data for a given /// metric. /// </summary> /// <param name="request">Container for the necessary parameters to execute the ListMetrics service method.</param> /// /// <returns>The response from the ListMetrics service method, as returned by CloudWatch.</returns> /// <exception cref="Amazon.CloudWatch.Model.InternalServiceException"> /// Indicates that the request processing has failed due to some unknown error, exception, /// or failure. /// </exception> /// <exception cref="Amazon.CloudWatch.Model.InvalidParameterValueException"> /// Bad or out-of-range value was supplied for the input parameter. /// </exception> public ListMetricsResponse ListMetrics(ListMetricsRequest request) { var marshaller = new ListMetricsRequestMarshaller(); var unmarshaller = ListMetricsResponseUnmarshaller.Instance; return Invoke<ListMetricsRequest,ListMetricsResponse>(request, marshaller, unmarshaller); }
/// <summary> /// <para> Returns a list of valid metrics stored for the AWS account owner. Returned metrics can be used with GetMetricStatistics to obtain /// statistical data for a given metric. </para> <para><b>NOTE:</b> Up to 500 results are returned for any one call. To retrieve further /// results, use returned NextToken values with subsequent ListMetrics operations. </para> <para><b>NOTE:</b> If you create a metric with the /// PutMetricData action, allow up to fifteen minutes for the metric to appear in calls to the ListMetrics action. Statistics about the metric, /// however, are available sooner using GetMetricStatistics. </para> /// </summary> /// /// <param name="listMetricsRequest">Container for the necessary parameters to execute the ListMetrics service method on /// AmazonCloudWatch.</param> /// /// <returns>The response from the ListMetrics service method, as returned by AmazonCloudWatch.</returns> /// /// <exception cref="T:Amazon.CloudWatch.Model.InternalServiceException" /> /// <exception cref="T:Amazon.CloudWatch.Model.InvalidParameterValueException" /> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> public Task<ListMetricsResponse> ListMetricsAsync(ListMetricsRequest listMetricsRequest, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new ListMetricsRequestMarshaller(); var unmarshaller = ListMetricsResponseUnmarshaller.GetInstance(); return Invoke<IRequest, ListMetricsRequest, ListMetricsResponse>(listMetricsRequest, marshaller, unmarshaller, signer, cancellationToken); }
internal ListMetricsResponse ListMetrics(ListMetricsRequest request) { var task = ListMetricsAsync(request); try { return task.Result; } catch(AggregateException e) { throw e.InnerException; } }
/// <summary> /// <para> Returns a list of valid metrics stored for the AWS account owner. Returned metrics can be used with GetMetricStatistics to obtain /// statistical data for a given metric. </para> <para><b>NOTE:</b> Up to 500 results are returned for any one call. To retrieve further /// results, use returned NextToken values with subsequent ListMetrics operations. </para> <para><b>NOTE:</b> If you create a metric with the /// PutMetricData action, allow up to fifteen minutes for the metric to appear in calls to the ListMetrics action. Statistics about the metric, /// however, are available sooner using GetMetricStatistics. </para> /// </summary> /// /// <param name="listMetricsRequest">Container for the necessary parameters to execute the ListMetrics service method on /// AmazonCloudWatch.</param> /// /// <returns>The response from the ListMetrics service method, as returned by AmazonCloudWatch.</returns> /// /// <exception cref="T:Amazon.CloudWatch.Model.InternalServiceException" /> /// <exception cref="T:Amazon.CloudWatch.Model.InvalidParameterValueException" /> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> public async Task<ListMetricsResponse> ListMetricsAsync(ListMetricsRequest listMetricsRequest, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new ListMetricsRequestMarshaller(); var unmarshaller = ListMetricsResponseUnmarshaller.GetInstance(); var response = await Invoke<IRequest, ListMetricsRequest, ListMetricsResponse>(listMetricsRequest, marshaller, unmarshaller, signer, cancellationToken) .ConfigureAwait(continueOnCapturedContext: false); return response; }
} IAsyncResult invokeEnableAlarmActions(EnableAlarmActionsRequest enableAlarmActionsRequest, AsyncCallback callback, object state, bool synchronized) { IRequest irequest = new EnableAlarmActionsRequestMarshaller().Marshall(enableAlarmActionsRequest); var unmarshaller = EnableAlarmActionsResponseUnmarshaller.GetInstance(); AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller); Invoke(result);
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; #pragma warning disable CS0618, CS0612 //A class member was marked with the Obsolete attribute var useParameterSelect = this.Select.StartsWith("^") || this.PassThru.IsPresent; #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute // create request and set iteration invariants var request = new Amazon.CloudWatch.Model.ListMetricsRequest(); if (cmdletContext.Dimension != null) { request.Dimensions = cmdletContext.Dimension; } if (cmdletContext.MetricName != null) { request.MetricName = cmdletContext.MetricName; } if (cmdletContext.Namespace != null) { request.Namespace = cmdletContext.Namespace; } // Initialize loop variant and commence piping var _nextToken = cmdletContext.NextToken; var _userControllingPaging = this.NoAutoIteration.IsPresent || ParameterWasBound(nameof(this.NextToken)); var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint); do { request.NextToken = _nextToken; CmdletOutput output; try { var response = CallAWSServiceOperation(client, request); object pipelineOutput = null; if (!useParameterSelect) { pipelineOutput = cmdletContext.Select(response, this); } output = new CmdletOutput { PipelineOutput = pipelineOutput, ServiceResponse = response }; _nextToken = response.NextToken; } catch (Exception e) { output = new CmdletOutput { ErrorResponse = e }; } ProcessOutput(output); } while (!_userControllingPaging && AutoIterationHelpers.HasValue(_nextToken)); if (useParameterSelect) { WriteObject(cmdletContext.Select(null, this)); } return(null); }
#region ListMetrics /// <summary> /// <para> Returns a list of valid metrics stored for the AWS account owner. Returned metrics can be used with GetMetricStatistics to obtain /// statistical data for a given metric. </para> <para><b>NOTE:</b> Up to 500 results are returned for any one call. To retrieve further /// results, use returned NextToken values with subsequent ListMetrics operations. </para> <para><b>NOTE:</b> If you create a metric with the /// PutMetricData action, allow up to fifteen minutes for the metric to appear in calls to the ListMetrics action. Statistics about the metric, /// however, are available sooner using GetMetricStatistics. </para> /// </summary> /// /// <param name="listMetricsRequest">Container for the necessary parameters to execute the ListMetrics service method on /// AmazonCloudWatch.</param> /// /// <returns>The response from the ListMetrics service method, as returned by AmazonCloudWatch.</returns> ///
internal ListMetricsResponse ListMetrics(ListMetricsRequest request) { var task = ListMetricsAsync(request); try { return task.Result; } catch(AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return null; } }
/// <summary> /// Paginator for ListMetrics operation ///</summary> public IListMetricsPaginator ListMetrics(ListMetricsRequest request) { return(new ListMetricsPaginator(this.client, request)); }
/// <summary> /// Initiates the asynchronous execution of the ListMetrics operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ListMetrics operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task<ListMetricsResponse> ListMetricsAsync(ListMetricsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new ListMetricsRequestMarshaller(); var unmarshaller = ListMetricsResponseUnmarshaller.Instance; return InvokeAsync<ListMetricsRequest,ListMetricsResponse>(request, marshaller, unmarshaller, cancellationToken); }
public static void CWListMetrics() { #region CWListMetrics var client = new AmazonCloudWatchClient(); var filter = new DimensionFilter { Name = "InstanceType", Value = "t1.micro" }; var request = new ListMetricsRequest { Dimensions = new List<DimensionFilter>() { filter }, MetricName = "CPUUtilization", Namespace = "AWS/EC2" }; var response = new ListMetricsResponse(); do { response = client.ListMetrics(request); if (response.Metrics.Count > 0) { foreach (var metric in response.Metrics) { Console.WriteLine(metric.MetricName + " (" + metric.Namespace + ")"); foreach (var dimension in metric.Dimensions) { Console.WriteLine(" " + dimension.Name + ": " + dimension.Value); } } } else { Console.WriteLine("No metrics found."); } request.NextToken = response.NextToken; } while (!string.IsNullOrEmpty(response.NextToken)); #endregion Console.ReadLine(); }
private Amazon.CloudWatch.Model.ListMetricsResponse CallAWSServiceOperation(IAmazonCloudWatch client, Amazon.CloudWatch.Model.ListMetricsRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon CloudWatch", "ListMetrics"); try { #if DESKTOP return(client.ListMetrics(request)); #elif CORECLR return(client.ListMetricsAsync(request).GetAwaiter().GetResult()); #else #error "Unknown build edition" #endif } catch (AmazonServiceException exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } throw; } }
internal ListMetricsPaginator(IAmazonCloudWatch client, ListMetricsRequest request) { this._client = client; this._request = request; }
public IAsyncResult BeginDescribeAlarmsForMetric(DescribeAlarmsForMetricRequest describeAlarmsForMetricRequest, AsyncCallback callback, object state) { return invokeDescribeAlarmsForMetric(describeAlarmsForMetricRequest, callback, state, false); } /// <summary> /// Finishes the asynchronous execution of the DescribeAlarmsForMetric operation. /// <seealso cref="Amazon.CloudWatch.AmazonCloudWatch.DescribeAlarmsForMetric"/> /// </summary> /// /// <param name="asyncResult">The IAsyncResult returned by the call to BeginDescribeAlarmsForMetric.</param> /// /// <returns>Returns a DescribeAlarmsForMetricResult from AmazonCloudWatch.</returns> public DescribeAlarmsForMetricResponse EndDescribeAlarmsForMetric(IAsyncResult asyncResult) { return endOperation<DescribeAlarmsForMetricResponse>(asyncResult); }
/// <summary> /// <para> Returns a list of valid metrics stored for the AWS account /// owner. Returned metrics can be used with <c>GetMetricStatistics</c> to /// obtain statistical data for a given metric. </para> <para><b>NOTE:</b> /// Up to 500 results are returned for any one call. To retrieve further /// results, use returned NextToken values with subsequent ListMetrics /// operations. </para> <para><b>NOTE:</b> If you create a metric with the /// PutMetricData action, allow up to fifteen minutes for the metric to /// appear in calls to the ListMetrics action. </para> /// </summary> /// /// <param name="listMetricsRequest">Container for the necessary /// parameters to execute the ListMetrics service method on /// AmazonCloudWatch.</param> /// /// <returns>The response from the ListMetrics service method, as returned /// by AmazonCloudWatch.</returns> /// /// <exception cref="InternalServiceException"/> /// <exception cref="InvalidParameterValueException"/> public ListMetricsResponse ListMetrics(ListMetricsRequest listMetricsRequest) { IRequest<ListMetricsRequest> request = new ListMetricsRequestMarshaller().Marshall(listMetricsRequest); ListMetricsResponse response = Invoke<ListMetricsRequest, ListMetricsResponse> (request, this.signer, ListMetricsResponseUnmarshaller.GetInstance()); return response; }
private void Form1_Shown(object sender, EventArgs e) { // Initialize Cloud Watch with region APNorthEast1 (Tokyo) cw = Amazon.AWSClientFactory.CreateAmazonCloudWatchClient(AWSAccessKey, AWSSecretKey, RegionEndpoint.APNortheast1); // Retrieve the list of Metrics ListMetricsRequest metricsRequest = new ListMetricsRequest(); for (int i = 1; i < namespaceList.Count; i++) { fromindex[i] = metricList.Count; metricsRequest.Namespace = namespaceList[i]; metricsRequest.NextToken = null; try { var result = cw.ListMetrics(metricsRequest).ListMetricsResult; var tempList = result.Metrics; while (result.NextToken != null) { metricsRequest.NextToken = result.NextToken; result = cw.ListMetrics(metricsRequest).ListMetricsResult; tempList.AddRange(result.Metrics); } tempList = tempList.OrderBy(a => a.Dimensions.Count) .ThenBy(a => a.MetricName) .ThenBy(a => a.Dimensions.Count > 0 ? a.Dimensions[0].Name : "") .ThenBy(a => a.Dimensions.Count > 0 ? a.Dimensions[0].Value : "") .ThenBy(a => a.Dimensions.Count > 1 ? a.Dimensions[1].Name : "") .ThenBy(a => a.Dimensions.Count > 1 ? a.Dimensions[1].Value : "").ToList(); metricList.AddRange(tempList); toindex[i] = metricList.Count; // Debug.WriteLine(metricList.Count); } catch (Exception ex) { MessageBox.Show(ex.Message); this.Close(); return; } } // For all metrics fromindex[0] = 0; toindex[0] = metricList.Count; // Initialize plottedStat for (int i = 0; i < metricList.Count; i++) { plottedStat.Add(-1); // no stat was plotted } // Give control to search text box to start a search for metrics searchTBox.Select(); }