UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 9.34 kB
"use strict";var _a,_b,_c,_d,_e,_f;Object.defineProperty(exports,"__esModule",{value:!0}),exports.LegendPosition=exports.Color=exports.VerticalShading=exports.Shading=exports.CustomWidget=exports.SingleValueWidget=exports.GraphWidget=exports.GaugeWidget=exports.GraphWidgetView=exports.AlarmWidget=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var rendering_1=()=>{var tmp=require("./private/rendering");return rendering_1=()=>tmp,tmp},widget_1=()=>{var tmp=require("./widget");return widget_1=()=>tmp,tmp},cdk=()=>{var tmp=require("../../core");return cdk=()=>tmp,tmp};class AlarmWidget extends widget_1().ConcreteWidget{constructor(props){super(props.width||6,props.height||6);try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_AlarmWidgetProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,AlarmWidget),error}this.props=props}toJson(){return[{type:"metric",width:this.width,height:this.height,x:this.x,y:this.y,properties:{view:"timeSeries",title:this.props.title,region:this.props.region||cdk().Aws.REGION,annotations:{alarms:[this.props.alarm.alarmArn]},yAxis:{left:this.props.leftYAxis??void 0}}}]}}exports.AlarmWidget=AlarmWidget,_a=JSII_RTTI_SYMBOL_1,AlarmWidget[_a]={fqn:"aws-cdk-lib.aws_cloudwatch.AlarmWidget",version:"2.113.0"};var GraphWidgetView;(function(GraphWidgetView2){GraphWidgetView2.TIME_SERIES="timeSeries",GraphWidgetView2.BAR="bar",GraphWidgetView2.PIE="pie"})(GraphWidgetView||(exports.GraphWidgetView=GraphWidgetView={}));class GaugeWidget extends widget_1().ConcreteWidget{constructor(props){super(props.width||6,props.height||6);try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_GaugeWidgetProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,GaugeWidget),error}if(this.props=props,this.metrics=props.metrics??[],this.copyMetricWarnings(...this.metrics),props.end!==void 0&&props.start===void 0)throw new Error("If you specify a value for end, you must also specify a value for start.")}addMetric(metric){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_IMetric(metric)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addMetric),error}this.metrics.push(metric),this.copyMetricWarnings(metric)}toJson(){const metrics=(0,rendering_1().allMetricsGraphJson)(this.metrics,[]),leftYAxis={...this.props.leftYAxis,min:this.props.leftYAxis?.min??0,max:this.props.leftYAxis?.max??100};return[{type:"metric",width:this.width,height:this.height,x:this.x,y:this.y,properties:{view:"gauge",title:this.props.title,region:this.props.region||cdk().Aws.REGION,metrics:metrics.length>0?metrics:void 0,annotations:(this.props.annotations??[]).length>0?{horizontal:this.props.annotations}:void 0,yAxis:{left:leftYAxis??void 0},legend:this.props.legendPosition!==void 0?{position:this.props.legendPosition}:void 0,liveData:this.props.liveData,setPeriodToTimeRange:this.props.setPeriodToTimeRange,period:this.props.period?.toSeconds(),stat:this.props.statistic,start:this.props.start,end:this.props.end}}]}}exports.GaugeWidget=GaugeWidget,_b=JSII_RTTI_SYMBOL_1,GaugeWidget[_b]={fqn:"aws-cdk-lib.aws_cloudwatch.GaugeWidget",version:"2.113.0"};class GraphWidget extends widget_1().ConcreteWidget{static isIso8601(date){return this.ISO8601_REGEX.test(date)}constructor(props){super(props.width||6,props.height||6);try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_GraphWidgetProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,GraphWidget),error}if(props.verticalAnnotations?.forEach(annotation=>{const date=annotation.date;if(!GraphWidget.isIso8601(date))throw new Error(`Given date ${date} is not in ISO 8601 format`)}),this.props=props,this.leftMetrics=props.left??[],this.rightMetrics=props.right??[],this.copyMetricWarnings(...this.leftMetrics,...this.rightMetrics),props.end!==void 0&&props.start===void 0)throw new Error("If you specify a value for end, you must also specify a value for start.")}addLeftMetric(metric){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_IMetric(metric)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addLeftMetric),error}this.leftMetrics.push(metric),this.copyMetricWarnings(metric)}addRightMetric(metric){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_IMetric(metric)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addRightMetric),error}this.rightMetrics.push(metric),this.copyMetricWarnings(metric)}toJson(){const horizontalAnnotations=[...(this.props.leftAnnotations||[]).map(mapAnnotation("left")),...(this.props.rightAnnotations||[]).map(mapAnnotation("right"))],verticalAnnotations=(this.props.verticalAnnotations||[]).map(({date,...rest})=>({value:date,...rest})),annotations=horizontalAnnotations.length>0||verticalAnnotations.length>0?{horizontal:horizontalAnnotations.length>0?horizontalAnnotations:void 0,vertical:verticalAnnotations.length>0?verticalAnnotations:void 0}:void 0,metrics=(0,rendering_1().allMetricsGraphJson)(this.leftMetrics,this.rightMetrics);return[{type:"metric",width:this.width,height:this.height,x:this.x,y:this.y,properties:{view:this.props.view??GraphWidgetView.TIME_SERIES,title:this.props.title,region:this.props.region||cdk().Aws.REGION,stacked:this.props.stacked,metrics:metrics.length>0?metrics:void 0,annotations,yAxis:{left:this.props.leftYAxis??void 0,right:this.props.rightYAxis??void 0},legend:this.props.legendPosition!==void 0?{position:this.props.legendPosition}:void 0,liveData:this.props.liveData,setPeriodToTimeRange:this.props.setPeriodToTimeRange,period:this.props.period?.toSeconds(),stat:this.props.statistic,start:this.props.start,end:this.props.end}}]}}exports.GraphWidget=GraphWidget,_c=JSII_RTTI_SYMBOL_1,GraphWidget[_c]={fqn:"aws-cdk-lib.aws_cloudwatch.GraphWidget",version:"2.113.0"},GraphWidget.ISO8601_REGEX=/^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(.[0-9]+)?(Z)?$/;class SingleValueWidget extends widget_1().ConcreteWidget{constructor(props){super(props.width||6,props.height||3);try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_SingleValueWidgetProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,SingleValueWidget),error}if(this.props=props,this.copyMetricWarnings(...props.metrics),props.setPeriodToTimeRange&&props.sparkline)throw new Error("You cannot use setPeriodToTimeRange with sparkline");if(props.end!==void 0&&props.start===void 0)throw new Error("If you specify a value for end, you must also specify a value for start.")}toJson(){return[{type:"metric",width:this.width,height:this.height,x:this.x,y:this.y,properties:{view:"singleValue",title:this.props.title,region:this.props.region||cdk().Aws.REGION,sparkline:this.props.sparkline,metrics:(0,rendering_1().allMetricsGraphJson)(this.props.metrics,[]),setPeriodToTimeRange:this.props.setPeriodToTimeRange,singleValueFullPrecision:this.props.fullPrecision,period:this.props.period?.toSeconds(),start:this.props.start,end:this.props.end}}]}}exports.SingleValueWidget=SingleValueWidget,_d=JSII_RTTI_SYMBOL_1,SingleValueWidget[_d]={fqn:"aws-cdk-lib.aws_cloudwatch.SingleValueWidget",version:"2.113.0"};class CustomWidget extends widget_1().ConcreteWidget{constructor(props){super(props.width??6,props.height??6);try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_CustomWidgetProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,CustomWidget),error}this.props=props}toJson(){return[{type:"custom",width:this.width,height:this.height,x:this.x,y:this.y,properties:{endpoint:this.props.functionArn,params:this.props.params,title:this.props.title,updateOn:{refresh:this.props.updateOnRefresh??!0,resize:this.props.updateOnResize??!0,timeRange:this.props.updateOnTimeRangeChange??!0}}}]}}exports.CustomWidget=CustomWidget,_e=JSII_RTTI_SYMBOL_1,CustomWidget[_e]={fqn:"aws-cdk-lib.aws_cloudwatch.CustomWidget",version:"2.113.0"};var Shading;(function(Shading2){Shading2.NONE="none",Shading2.ABOVE="above",Shading2.BELOW="below"})(Shading||(exports.Shading=Shading={}));var VerticalShading;(function(VerticalShading2){VerticalShading2.NONE="none",VerticalShading2.BEFORE="before",VerticalShading2.AFTER="after"})(VerticalShading||(exports.VerticalShading=VerticalShading={}));class Color{constructor(){}}exports.Color=Color,_f=JSII_RTTI_SYMBOL_1,Color[_f]={fqn:"aws-cdk-lib.aws_cloudwatch.Color",version:"2.113.0"},Color.BLUE="#1f77b4",Color.BROWN="#8c564b",Color.GREEN="#2ca02c",Color.GREY="#7f7f7f",Color.ORANGE="#ff7f0e",Color.PINK="#e377c2",Color.PURPLE="#9467bd",Color.RED="#d62728";var LegendPosition;(function(LegendPosition2){LegendPosition2.BOTTOM="bottom",LegendPosition2.RIGHT="right",LegendPosition2.HIDDEN="hidden"})(LegendPosition||(exports.LegendPosition=LegendPosition={}));function mapAnnotation(yAxis){return a=>({...a,yAxis})}