func NewResource() *schema.Resource {
	return &schema.Resource{
		Schema: map[string]*schema.Schema{
			"type": &schema.Schema{
				Type:        schema.TypeString,
				Description: "The service type (e.g. campfire, pagerduty, mail, etc.)",
				Required:    true,
			},
			"title": &schema.Schema{
				Type:        schema.TypeString,
				Description: "Display title for the service",
				Required:    true,
			},
			"settings": &schema.Schema{
				Type:        schema.TypeMap,
				Description: "Hash of settings specific to the service type",
				Required:    true,
			},
		},
		Create: request.CreatorFunc("service", "/services", nil, makeBody),
		Read:   request.ReaderFunc("service", "/services/%s", request.IdPathFormatter, readBody),
		Update: request.UpdaterFunc("service", "/services/%s", request.IdPathFormatter, makeBody),
		Delete: request.DeleterFunc("service", "/services/%s", request.IdPathFormatter),
		Exists: request.ExisterFunc("service", "/services/%s", request.IdPathFormatter),
	}
}
func NewResource() *schema.Resource {
	return &schema.Resource{
		Schema: map[string]*schema.Schema{
			"name": &schema.Schema{
				Type:        schema.TypeString,
				Description: "Unique name for space",
				Required:    true,
			},
		},
		Create: request.CreatorFunc("space", "/spaces", nil, makeBody),
		Read:   request.ReaderFunc("space", "/spaces/%s", request.IdPathFormatter, readBody),
		Update: request.UpdaterFunc("space", "/spaces/%s", request.IdPathFormatter, makeBody),
		Delete: request.DeleterFunc("space", "/spaces/%s", request.IdPathFormatter),
		Exists: request.ExisterFunc("space", "/spaces/%s", request.IdPathFormatter),
	}
}
func NewResource() *schema.Resource {
	return &schema.Resource{
		Schema: map[string]*schema.Schema{
			"name": &schema.Schema{
				Type:        schema.TypeString,
				Description: "A unique name used to identify the alert",
				Required:    true,
			},
			"version": &schema.Schema{
				Type:        schema.TypeInt,
				Description: "Identifies the alert as v1 or v2",
				Optional:    true,
				Default:     2,
			},
			"description": &schema.Schema{
				Type:        schema.TypeString,
				Description: "A string describing this alert",
				Optional:    true,
			},
			"active": &schema.Schema{
				Type:        schema.TypeBool,
				Description: "Boolean: identifies whether the alert is active (can be triggered). Defaults to true",
				Optional:    true,
				Default:     true,
			},
			"rearm_seconds": &schema.Schema{
				Type:        schema.TypeInt,
				Description: "Specifies the minimum amount of time between sending alert notifications, in seconds. Required to be a multiple of 60, and when unset or null will default to 600",
				Optional:    true,
				Default:     600,
			},
			"conditions": &schema.Schema{
				Type:        schema.TypeList,
				Description: "Note an alert will fire when ALL alert conditions are met",
				Optional:    true,
				Elem: &schema.Resource{
					Schema: map[string]*schema.Schema{
						"id": &schema.Schema{
							Type:        schema.TypeInt,
							Description: "The unique id assigned by librato",
							Computed:    true,
						},
						"type": &schema.Schema{
							Type:        schema.TypeString,
							Description: "One of above, absent, or below",
							Required:    true,
						},
						"metric_name": &schema.Schema{
							Type:        schema.TypeString,
							Description: "The name of the metric this alert condition applies to",
							Required:    true,
						},
						"source": &schema.Schema{
							Type:        schema.TypeString,
							Description: "A source expression which identifies which sources for the given metric to monitor. If not specified all sources will be monitored",
							Optional:    true,
						},
						"threshold": &schema.Schema{
							Type:        schema.TypeFloat,
							Description: "Measurements over this number will fire the alert.",
							Optional:    true,
						},
						"summary_function": &schema.Schema{
							Type:        schema.TypeString,
							Description: "For gauge metrics will default to average, which is also the value of non-complex or un-aggregated measurements. If set, must be one of: [min, max, average, sum, count, derivative]",
							Optional:    true,
						},
						"duration": &schema.Schema{
							Type:        schema.TypeInt,
							Description: "Number of seconds that data for the specified metric/source combination must be above the threshold for before the condition is met. If unset, a single sample above the threshold will trigger the condition",
							Optional:    true,
						},
						"detect_reset": &schema.Schema{
							Type:        schema.TypeBool,
							Description: "If the summary_function is derivative, this toggles the method used to calculate the delta from the previous sample. When set to false (default), the delta is calculated as simple subtraction of current - previous. If true only increasing (positive) values will be reported",
							Optional:    true,
							Default:     false,
						},
					},
				},
			},
			"services": &schema.Schema{
				Type:        schema.TypeList,
				Description: "An array of services to notify for this alert",
				Optional:    true,
				Elem:        &schema.Schema{Type: schema.TypeInt},
			},
			"attributes": &schema.Schema{
				Type:        schema.TypeMap,
				Description: "A key-value hash of metadata for the alert",
				Optional:    true,
			},
		},
		Create: request.CreatorFunc("alert", "/alerts", nil, makeBody),
		Read:   request.ReaderFunc("alert", "/alerts/%s", request.IdPathFormatter, readBody),
		Update: request.UpdaterFunc("alert", "/alerts/%s", request.IdPathFormatter, makeBody),
		Delete: request.DeleterFunc("alert", "/alerts/%s", request.IdPathFormatter),
		Exists: request.ExisterFunc("alert", "/alerts/%s", request.IdPathFormatter),
	}
}
func NewResource() *schema.Resource {
	return &schema.Resource{
		Schema: map[string]*schema.Schema{
			"space": &schema.Schema{
				Type:        schema.TypeString,
				Description: "ID of the space to add this chart to",
				Required:    true,
				ForceNew:    true,
			},
			"name": &schema.Schema{
				Type:        schema.TypeString,
				Description: "Title of the chart when it is displayed",
				Required:    true,
			},
			"type": &schema.Schema{
				Type:        schema.TypeString,
				Description: "Indicates the type of chart. Must be one of line or stacked (default to line)",
				Optional:    true,
				Default:     "line",
			},
			"min": &schema.Schema{
				Type:        schema.TypeInt,
				Description: "The minimum display value of the chart's Y-axis",
				Optional:    true,
			},
			"max": &schema.Schema{
				Type:        schema.TypeInt,
				Description: "The maximum display value of the chart's Y-axis",
				Optional:    true,
			},
			"label": &schema.Schema{
				Type:        schema.TypeString,
				Description: "The Y-axis label",
				Optional:    true,
			},
			"related_space": &schema.Schema{
				Type:        schema.TypeString,
				Description: "The ID of another space to which this chart is related",
				Optional:    true,
			},
			"stream": &schema.Schema{
				Type:        schema.TypeList,
				Description: "An array of hashes describing the metrics and sources to use for data in the chart.",
				Optional:    true,
				Elem: &schema.Resource{
					Schema: map[string]*schema.Schema{
						"id": &schema.Schema{
							Type:        schema.TypeInt,
							Description: "Each stream has a unique numeric ID",
							Computed:    true,
						},
						"name": &schema.Schema{
							Type:        schema.TypeString,
							Description: "A display name to use for the stream when generating the tooltip",
							Optional:    true,
						},
						"type": &schema.Schema{
							Type:        schema.TypeString,
							Description: "The stream type",
							Optional:    true,
						},
						"metric": &schema.Schema{
							Type:        schema.TypeString,
							Description: "Name of metric",
							Optional:    true,
						},
						"source": &schema.Schema{
							Type:        schema.TypeString,
							Description: "Name of source or * to include all sources. This field will also accept specific wildcard entries",
							Optional:    true,
						},
						"group_function": &schema.Schema{
							Type:        schema.TypeString,
							Description: "How to process the results when multiple sources will be returned. Value must be one of average, sum, breakout",
							Optional:    true,
						},
						"composite": &schema.Schema{
							Type:        schema.TypeString,
							Description: "A composite metric query string to execute when this stream is displayed. This can not be specified with a metric, source or group_function",
							Optional:    true,
						},
						"summary_function": &schema.Schema{
							Type:        schema.TypeString,
							Description: "When visualizing complex measurements or a rolled-up measurement, this allows you to choose which statistic to use. If unset, defaults to average. Valid options are one of: [max, min, average, sum, count]",
							Optional:    true,
						},
						"color": &schema.Schema{
							Type:        schema.TypeString,
							Description: "Sets a color to use when rendering the stream. Must be a seven character string that represents the hex code of the color e.g. #52D74C",
							Optional:    true,
						},
						"units_short": &schema.Schema{
							Type:        schema.TypeString,
							Description: "Unit value string to use as the tooltip label",
							Optional:    true,
						},
						"units_long": &schema.Schema{
							Type:        schema.TypeString,
							Description: "String value to set as they Y-axis label. All streams that share the same units_long value will be plotted on the same Y-axis",
							Optional:    true,
						},
						"min": &schema.Schema{
							Type:        schema.TypeInt,
							Description: "Theoretical minimum Y-axis value",
							Optional:    true,
						},
						"max": &schema.Schema{
							Type:        schema.TypeInt,
							Description: "Theoretical maximum Y-axis value",
							Optional:    true,
						},
						"transform_function": &schema.Schema{
							Type:        schema.TypeString,
							Description: "Linear formula to run on each measurement prior to visualizaton",
							Optional:    true,
						},
						"period": &schema.Schema{
							Type:        schema.TypeInt,
							Description: "An integer value of seconds that defines the period this stream reports at",
							Optional:    true,
						},
					},
				},
			},
		},
		Create: request.CreatorFunc("space_chart", "/spaces/%s/charts", createPathFormatter, makeBody),
		Read:   request.ReaderFunc("space_chart", "/spaces/%s/charts/%s", pathFormatter, readBody),
		Update: request.UpdaterFunc("space_chart", "/spaces/%s/charts/%s", pathFormatter, makeBody),
		Delete: request.DeleterFunc("space_chart", "/spaces/%s/charts/%s", pathFormatter),
		Exists: request.ExisterFunc("space_chart", "/spaces/%s/charts/%s", pathFormatter),
	}
}