func resourceLibratoServiceUpdate(d *schema.ResourceData, meta interface{}) error {
	client := meta.(*librato.Client)

	serviceID, err := strconv.ParseUint(d.Id(), 10, 0)
	if err != nil {
		return err
	}

	service := new(librato.Service)
	if d.HasChange("type") {
		service.Type = librato.String(d.Get("type").(string))
	}
	if d.HasChange("title") {
		service.Title = librato.String(d.Get("title").(string))
	}
	if d.HasChange("settings") {
		res, err := resourceLibratoServicesExpandSettings(normalizeJson(d.Get("settings").(string)))
		if err != nil {
			return fmt.Errorf("Error expanding Librato service settings: %s", err)
		}
		service.Settings = res
	}

	_, err = client.Services.Edit(uint(serviceID), service)
	if err != nil {
		return fmt.Errorf("Error updating Librato service: %s", err)
	}

	return resourceLibratoServiceRead(d, meta)
}
func resourceLibratoServiceCreate(d *schema.ResourceData, meta interface{}) error {
	client := meta.(*librato.Client)

	service := new(librato.Service)
	if v, ok := d.GetOk("type"); ok {
		service.Type = librato.String(v.(string))
	}
	if v, ok := d.GetOk("title"); ok {
		service.Title = librato.String(v.(string))
	}
	if v, ok := d.GetOk("settings"); ok {
		res, err := resourceLibratoServicesExpandSettings(normalizeJson(v.(string)))
		if err != nil {
			return fmt.Errorf("Error expanding Librato service settings: %s", err)
		}
		service.Settings = res
	}

	serviceResult, _, err := client.Services.Create(service)

	if err != nil {
		return fmt.Errorf("Error creating Librato service: %s", err)
	}

	resource.Retry(1*time.Minute, func() *resource.RetryError {
		_, _, err := client.Services.Get(*serviceResult.ID)
		if err != nil {
			if errResp, ok := err.(*librato.ErrorResponse); ok && errResp.Response.StatusCode == 404 {
				return resource.RetryableError(err)
			}
			return resource.NonRetryableError(err)
		}
		return nil
	})

	return resourceLibratoServiceReadResult(d, serviceResult)
}