// deleteAllGCPPrinterJobs finds all GCP printer jobs associated with a
// a given printer id and deletes them.
func deleteAllGCPPrinterJobs(context *cli.Context) {
	config := getConfig(context)
	gcp := getGCP(config)

	jobs, err := gcp.Fetch(context.String("printer-id"))
	if err != nil {
		log.Fatalln(err)
	}

	if len(jobs) == 0 {
		fmt.Printf("No queued jobs\n")
	}

	ch := make(chan bool)
	for _, job := range jobs {
		go func(gcpJobID string) {
			err := gcp.DeleteJob(gcpJobID)
			if err != nil {
				fmt.Printf("Failed to delete GCP job %s: %s\n", gcpJobID, err)
			} else {
				fmt.Printf("Deleted GCP job %s\n", gcpJobID)
			}
			ch <- true
		}(job.GCPJobID)
	}

	for _ = range jobs {
		<-ch
	}
}
// deleteGCPJob deletes one GCP job
func deleteGCPJob(context *cli.Context) {
	config := getConfig(context)
	gcp := getGCP(config)

	err := gcp.DeleteJob(context.String("job-id"))
	if err != nil {
		fmt.Printf("Failed to delete GCP job %s: %s\n", context.String("job-id"), err)
	} else {
		fmt.Printf("Deleted GCP job %s\n", context.String("job-id"))
	}
}