Esempio n. 1
0
func ExampleDeviceFarm_ListUploads() {
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println("failed to create session,", err)
		return
	}

	svc := devicefarm.New(sess)

	params := &devicefarm.ListUploadsInput{
		Arn:       aws.String("AmazonResourceName"), // Required
		NextToken: aws.String("PaginationToken"),
	}
	resp, err := svc.ListUploads(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Esempio n. 2
0
func ExampleDeviceFarm_UpdateDevicePool() {
	svc := devicefarm.New(session.New())

	params := &devicefarm.UpdateDevicePoolInput{
		Arn:         aws.String("AmazonResourceName"), // Required
		Description: aws.String("Message"),
		Name:        aws.String("Name"),
		Rules: []*devicefarm.Rule{
			{ // Required
				Attribute: aws.String("DeviceAttribute"),
				Operator:  aws.String("RuleOperator"),
				Value:     aws.String("String"),
			},
			// More values...
		},
	}
	resp, err := svc.UpdateDevicePool(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Esempio n. 3
0
func ExampleDeviceFarm_GetDevicePoolCompatibility() {
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println("failed to create session,", err)
		return
	}

	svc := devicefarm.New(sess)

	params := &devicefarm.GetDevicePoolCompatibilityInput{
		DevicePoolArn: aws.String("AmazonResourceName"), // Required
		AppArn:        aws.String("AmazonResourceName"),
		TestType:      aws.String("TestType"),
	}
	resp, err := svc.GetDevicePoolCompatibility(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Esempio n. 4
0
func ExampleDeviceFarm_CreateDevicePool() {
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println("failed to create session,", err)
		return
	}

	svc := devicefarm.New(sess)

	params := &devicefarm.CreateDevicePoolInput{
		Name:       aws.String("Name"),               // Required
		ProjectArn: aws.String("AmazonResourceName"), // Required
		Rules: []*devicefarm.Rule{ // Required
			{ // Required
				Attribute: aws.String("DeviceAttribute"),
				Operator:  aws.String("RuleOperator"),
				Value:     aws.String("String"),
			},
			// More values...
		},
		Description: aws.String("Message"),
	}
	resp, err := svc.CreateDevicePool(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Esempio n. 5
0
func ExampleDeviceFarm_RenewOffering() {
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println("failed to create session,", err)
		return
	}

	svc := devicefarm.New(sess)

	params := &devicefarm.RenewOfferingInput{
		OfferingId: aws.String("OfferingIdentifier"),
		Quantity:   aws.Int64(1),
	}
	resp, err := svc.RenewOffering(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Esempio n. 6
0
func init() {
	Before("@devicefarm", func() {
		// FIXME remove custom region
		World["client"] = devicefarm.New(smoke.Session,
			aws.NewConfig().WithRegion("us-west-2"))
	})
}
Esempio n. 7
0
func ExampleDeviceFarm_ListUniqueProblems() {
	svc := devicefarm.New(nil)

	params := &devicefarm.ListUniqueProblemsInput{
		Arn:       aws.String("AmazonResourceName"), // Required
		NextToken: aws.String("PaginationToken"),
	}
	resp, err := svc.ListUniqueProblems(params)

	if err != nil {
		if awsErr, ok := err.(awserr.Error); ok {
			// Generic AWS error with Code, Message, and original error (if any)
			fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
			if reqErr, ok := err.(awserr.RequestFailure); ok {
				// A service error occurred
				fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
			}
		} else {
			// This case should never be hit, the SDK should always return an
			// error which satisfies the awserr.Error interface.
			fmt.Println(err.Error())
		}
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.Prettify(resp))
}
Esempio n. 8
0
func ExampleDeviceFarm_CreateUpload() {
	svc := devicefarm.New(nil)

	params := &devicefarm.CreateUploadInput{
		Name:        aws.String("Name"),               // Required
		ProjectARN:  aws.String("AmazonResourceName"), // Required
		Type:        aws.String("UploadType"),         // Required
		ContentType: aws.String("ContentType"),
	}
	resp, err := svc.CreateUpload(params)

	if err != nil {
		if awsErr, ok := err.(awserr.Error); ok {
			// Generic AWS error with Code, Message, and original error (if any)
			fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
			if reqErr, ok := err.(awserr.RequestFailure); ok {
				// A service error occurred
				fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
			}
		} else {
			// This case should never be hit, the SDK should always return an
			// error which satisfies the awserr.Error interface.
			fmt.Println(err.Error())
		}
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.Prettify(resp))
}
Esempio n. 9
0
func ExampleDeviceFarm_CreateUpload() {
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println("failed to create session,", err)
		return
	}

	svc := devicefarm.New(sess)

	params := &devicefarm.CreateUploadInput{
		Name:        aws.String("Name"),               // Required
		ProjectArn:  aws.String("AmazonResourceName"), // Required
		Type:        aws.String("UploadType"),         // Required
		ContentType: aws.String("ContentType"),
	}
	resp, err := svc.CreateUpload(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Esempio n. 10
0
func ExampleDeviceFarm_CreateRemoteAccessSession() {
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println("failed to create session,", err)
		return
	}

	svc := devicefarm.New(sess)

	params := &devicefarm.CreateRemoteAccessSessionInput{
		DeviceArn:  aws.String("AmazonResourceName"), // Required
		ProjectArn: aws.String("AmazonResourceName"), // Required
		Configuration: &devicefarm.CreateRemoteAccessSessionConfiguration{
			BillingMethod: aws.String("BillingMethod"),
		},
		Name: aws.String("Name"),
	}
	resp, err := svc.CreateRemoteAccessSession(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Esempio n. 11
0
func ExampleDeviceFarm_InstallToRemoteAccessSession() {
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println("failed to create session,", err)
		return
	}

	svc := devicefarm.New(sess)

	params := &devicefarm.InstallToRemoteAccessSessionInput{
		AppArn:                 aws.String("AmazonResourceName"), // Required
		RemoteAccessSessionArn: aws.String("AmazonResourceName"), // Required
	}
	resp, err := svc.InstallToRemoteAccessSession(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Esempio n. 12
0
func getAWSClient() *devicefarm.DeviceFarm {
	config := awsconfig.New()
	if *config.Region != "us-west-2" {
		config.WithRegion("us-west-2")
	}
	session := session.New(config)
	return devicefarm.New(session)
}
Esempio n. 13
0
func ExampleDeviceFarm_ScheduleRun() {
	svc := devicefarm.New(nil)

	params := &devicefarm.ScheduleRunInput{
		AppARN:        aws.String("AmazonResourceName"), // Required
		DevicePoolARN: aws.String("AmazonResourceName"), // Required
		ProjectARN:    aws.String("AmazonResourceName"), // Required
		Test: &devicefarm.ScheduleRunTest{ // Required
			Type:   aws.String("TestType"), // Required
			Filter: aws.String("Filter"),
			Parameters: map[string]*string{
				"Key": aws.String("String"), // Required
				// More values...
			},
			TestPackageARN: aws.String("AmazonResourceName"),
		},
		Configuration: &devicefarm.ScheduleRunConfiguration{
			AuxiliaryApps: []*string{
				aws.String("AmazonResourceName"), // Required
				// More values...
			},
			BillingMethod:       aws.String("BillingMethod"),
			ExtraDataPackageARN: aws.String("AmazonResourceName"),
			Locale:              aws.String("String"),
			Location: &devicefarm.Location{
				Latitude:  aws.Float64(1.0), // Required
				Longitude: aws.Float64(1.0), // Required
			},
			NetworkProfileARN: aws.String("AmazonResourceName"),
			Radios: &devicefarm.Radios{
				Bluetooth: aws.Bool(true),
				Gps:       aws.Bool(true),
				Nfc:       aws.Bool(true),
				Wifi:      aws.Bool(true),
			},
		},
		Name: aws.String("Name"),
	}
	resp, err := svc.ScheduleRun(params)

	if err != nil {
		if awsErr, ok := err.(awserr.Error); ok {
			// Generic AWS error with Code, Message, and original error (if any)
			fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
			if reqErr, ok := err.(awserr.RequestFailure); ok {
				// A service error occurred
				fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
			}
		} else {
			// This case should never be hit, the SDK should always return an
			// error which satisfies the awserr.Error interface.
			fmt.Println(err.Error())
		}
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.Prettify(resp))
}
Esempio n. 14
0
func ExampleDeviceFarm_ScheduleRun() {
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println("failed to create session,", err)
		return
	}

	svc := devicefarm.New(sess)

	params := &devicefarm.ScheduleRunInput{
		DevicePoolArn: aws.String("AmazonResourceName"), // Required
		ProjectArn:    aws.String("AmazonResourceName"), // Required
		Test: &devicefarm.ScheduleRunTest{ // Required
			Type:   aws.String("TestType"), // Required
			Filter: aws.String("Filter"),
			Parameters: map[string]*string{
				"Key": aws.String("String"), // Required
				// More values...
			},
			TestPackageArn: aws.String("AmazonResourceName"),
		},
		AppArn: aws.String("AmazonResourceName"),
		Configuration: &devicefarm.ScheduleRunConfiguration{
			AuxiliaryApps: []*string{
				aws.String("AmazonResourceName"), // Required
				// More values...
			},
			BillingMethod:       aws.String("BillingMethod"),
			ExtraDataPackageArn: aws.String("AmazonResourceName"),
			Locale:              aws.String("String"),
			Location: &devicefarm.Location{
				Latitude:  aws.Float64(1.0), // Required
				Longitude: aws.Float64(1.0), // Required
			},
			NetworkProfileArn: aws.String("AmazonResourceName"),
			Radios: &devicefarm.Radios{
				Bluetooth: aws.Bool(true),
				Gps:       aws.Bool(true),
				Nfc:       aws.Bool(true),
				Wifi:      aws.Bool(true),
			},
		},
		Name: aws.String("Name"),
	}
	resp, err := svc.ScheduleRun(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Esempio n. 15
0
func ExampleDeviceFarm_GetAccountSettings() {
	svc := devicefarm.New(session.New())

	var params *devicefarm.GetAccountSettingsInput
	resp, err := svc.GetAccountSettings(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Esempio n. 16
0
func ExampleDeviceFarm_ListOfferings() {
	svc := devicefarm.New(session.New())

	params := &devicefarm.ListOfferingsInput{
		NextToken: aws.String("PaginationToken"),
	}
	resp, err := svc.ListOfferings(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Esempio n. 17
0
func ExampleDeviceFarm_CreateProject() {
	svc := devicefarm.New(session.New())

	params := &devicefarm.CreateProjectInput{
		Name: aws.String("Name"), // Required
	}
	resp, err := svc.CreateProject(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Esempio n. 18
0
func ExampleDeviceFarm_DeleteDevicePool() {
	svc := devicefarm.New(session.New())

	params := &devicefarm.DeleteDevicePoolInput{
		Arn: aws.String("AmazonResourceName"), // Required
	}
	resp, err := svc.DeleteDevicePool(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Esempio n. 19
0
func ExampleDeviceFarm_PurchaseOffering() {
	svc := devicefarm.New(session.New())

	params := &devicefarm.PurchaseOfferingInput{
		OfferingId: aws.String("OfferingIdentifier"),
		Quantity:   aws.Int64(1),
	}
	resp, err := svc.PurchaseOffering(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Esempio n. 20
0
func ExampleDeviceFarm_ListUniqueProblems() {
	svc := devicefarm.New(nil)

	params := &devicefarm.ListUniqueProblemsInput{
		Arn:       aws.String("AmazonResourceName"), // Required
		NextToken: aws.String("PaginationToken"),
	}
	resp, err := svc.ListUniqueProblems(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Esempio n. 21
0
func ExampleDeviceFarm_GetOfferingStatus() {
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println("failed to create session,", err)
		return
	}

	svc := devicefarm.New(sess)

	params := &devicefarm.GetOfferingStatusInput{
		NextToken: aws.String("PaginationToken"),
	}
	resp, err := svc.GetOfferingStatus(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Esempio n. 22
0
func ExampleDeviceFarm_CreateDevicePool() {
	svc := devicefarm.New(nil)

	params := &devicefarm.CreateDevicePoolInput{
		Name:       aws.String("Name"),               // Required
		ProjectARN: aws.String("AmazonResourceName"), // Required
		Rules: []*devicefarm.Rule{ // Required
			{ // Required
				Attribute: aws.String("DeviceAttribute"),
				Operator:  aws.String("RuleOperator"),
				Value:     aws.String("String"),
			},
			// More values...
		},
		Description: aws.String("Message"),
	}
	resp, err := svc.CreateDevicePool(params)

	if err != nil {
		if awsErr, ok := err.(awserr.Error); ok {
			// Generic AWS error with Code, Message, and original error (if any)
			fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
			if reqErr, ok := err.(awserr.RequestFailure); ok {
				// A service error occurred
				fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
			}
		} else {
			// This case should never be hit, the SDK should always return an
			// error which satisfies the awserr.Error interface.
			fmt.Println(err.Error())
		}
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.Prettify(resp))
}
Esempio n. 23
0
func ExampleDeviceFarm_GetAccountSettings() {
	svc := devicefarm.New(nil)

	var params *devicefarm.GetAccountSettingsInput
	resp, err := svc.GetAccountSettings(params)

	if err != nil {
		if awsErr, ok := err.(awserr.Error); ok {
			// Generic AWS error with Code, Message, and original error (if any)
			fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
			if reqErr, ok := err.(awserr.RequestFailure); ok {
				// A service error occurred
				fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
			}
		} else {
			// This case should never be hit, the SDK should always return an
			// error which satisfies the awserr.Error interface.
			fmt.Println(err.Error())
		}
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.Prettify(resp))
}
Esempio n. 24
0
func TestInterface(t *testing.T) {
	assert.Implements(t, (*devicefarmiface.DeviceFarmAPI)(nil), devicefarm.New(nil))
}
package service

import (
	"fmt"
	"testing"

	"github.com/artemnikitin/aws-config"
	"github.com/artemnikitin/devicefarm-ci-tool/model"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/devicefarm"
)

var client = devicefarm.New(session.New(awsconfig.New()))

func TestGenerateScheduleRunInputWithConfigurationBlock(t *testing.T) {
	input := []byte(`{"runName":"name","test":{"type":"string","testPackageArn":"string","filter":"string","parameters":{"key1":"value","key2":"value"}},"additionalData":{"extraDataPackageArn":"string","networkProfileArn":"string","locale":"string","location":{"latitude":1.222,"longitude":1.222},"radios":{"wifi":"","bluetooth":"true","nfc":"true","gps":"false"},"auxiliaryApps":["string1","string2"],"billingMethod":"METERED"}}`)
	deviceFarmConfig := create(input)
	if *deviceFarmConfig.Configuration.BillingMethod != "METERED" {
		t.Error("billing method should be 'METERED'")
	}
	if *deviceFarmConfig.Configuration.ExtraDataPackageArn != "string" {
		t.Error("extraDataPackageARN should be 'string'")
	}
	if *deviceFarmConfig.Configuration.NetworkProfileArn != "string" {
		t.Error("networkProfileARN should be 'string'")
	}
	if *deviceFarmConfig.Configuration.Locale != "string" {
		t.Error("locale should be 'string'")
	}
	if len(deviceFarmConfig.Configuration.AuxiliaryApps) != 2 {
		t.Error("should be 2 aux apps")
package service

import (
	"os"
	"testing"

	"github.com/artemnikitin/aws-config"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/devicefarm"
)

var (
	project    = os.Getenv("AWS_DEVICE_FARM_PROJECT")
	testClient = devicefarm.New(session.New(awsconfig.New().WithRegion("us-west-2")))
)

func TestGetProjectArnForExistedProject(t *testing.T) {
	result := GetProjectArn(testClient, project)
	if len(result) == 0 {
		t.Error("For existed project ARN should be returned")
	}
}

func TestGetProjectArnForUnexistedProject(t *testing.T) {
	result := GetProjectArn(testClient, "bla-bla-bla2234342")
	if len(result) != 0 {
		t.Error("For unexisted project ARN should be blank string")
	}
}
Esempio n. 27
0
func main() {

	svc := devicefarm.New(&aws.Config{Region: aws.String("us-west-2")})

	app := cli.NewApp()
	app.Name = "devicefarm-cli"
	app.Usage = "allows you to interact with AWS devicefarm from the command line"
	app.Version = "0.0.1"
	app.Authors = []cli.Author{
		cli.Author{Name: "Patrick Debois",
			Email: "*****@*****.**",
		},
	}

	app.Commands = []cli.Command{
		{
			Name:  "create",
			Usage: "create devicefarm elements", // of an account
			Subcommands: []cli.Command{
				{
					Name:  "devicepool",
					Usage: "create devicepool from device",
					Flags: []cli.Flag{
						cli.StringFlag{
							Name:   "project",
							EnvVar: "DF_PROJECT",
							Usage:  "project arn or project description",
						},
						cli.StringFlag{
							Name:   "device",
							EnvVar: "DF_DEVICE",
							Usage:  "device name",
						},
						cli.StringFlag{
							Name:  "name",
							Usage: "pool name",
						},
					},
					Action: func(c *cli.Context) {
						projectArn := c.String("project")
						deviceName := c.String("device")
						poolName := c.String("name")
						createPoolFromDevice(svc, poolName, deviceName, projectArn)
					},
				},
			},
		},
		{
			Name:  "list",
			Usage: "list various elements on devicefarm",
			Subcommands: []cli.Command{
				{
					Name:  "projects",
					Usage: "list the projects", // of an account
					Action: func(c *cli.Context) {
						listProjects(svc)
					},
				},
				{
					Name:  "devices",
					Usage: "list the devices", // globally
					Action: func(c *cli.Context) {
						listDevices(svc)
					},
				},
				{
					Name:  "samples",
					Usage: "list the samples",
					Action: func(c *cli.Context) {
						// Not yet implemented
						// listSamples()
					},
				},
				{
					Name:  "jobs",
					Usage: "list the jobs", // of a test
					Flags: []cli.Flag{
						cli.StringFlag{
							Name:   "run",
							EnvVar: "DF_RUN",
							Usage:  "run arn or run description",
						},
					},
					Action: func(c *cli.Context) {
						runArn := c.String("run")

						listJobs(svc, runArn)
					},
				},
				{
					Name:  "uploads",
					Usage: "lists all uploads", // of a Project
					Flags: []cli.Flag{
						cli.StringFlag{
							Name:   "project",
							EnvVar: "DF_PROJECT",
							Usage:  "project arn or project description",
						},
					},
					Action: func(c *cli.Context) {
						projectArn := c.String("project")
						listUploads(svc, projectArn)
					},
				},
				{
					Name:  "artifacts",
					Usage: "list the artifacts", // of a test
					Flags: []cli.Flag{
						cli.StringFlag{
							Name:   "run",
							EnvVar: "DF_RUN",
							Usage:  "run arn or run description",
						},
						cli.StringFlag{
							Name:   "job",
							EnvVar: "DF_JOB",
							Usage:  "job arn or run description",
						},
						cli.StringFlag{
							Name:   "type",
							EnvVar: "DF_ARTIFACT_TYPE",
							Usage:  "type of the artifact [LOG,FILE,SCREENSHOT]",
						},
					},
					Action: func(c *cli.Context) {
						runArn := c.String("run")
						jobArn := c.String("job")

						filterArn := ""
						if runArn != "" {
							filterArn = runArn
						} else {
							filterArn = jobArn
						}

						artifactType := c.String("type")
						listArtifacts(svc, filterArn, artifactType)
					},
				},
				{
					Name:  "suites",
					Usage: "list the suites",
					Flags: []cli.Flag{
						cli.StringFlag{
							Name:   "run",
							EnvVar: "DF_RUN",
							Usage:  "run arn or run description",
						},
						cli.StringFlag{
							Name:   "job",
							EnvVar: "DF_JOB",
							Usage:  "job arn or run description",
						},
					},
					Action: func(c *cli.Context) {
						runArn := c.String("run")
						jobArn := c.String("job")
						filterArn := ""
						if runArn != "" {
							filterArn = runArn
						} else {
							filterArn = jobArn
						}
						listSuites(svc, filterArn)
					},
				},
				{
					Name:  "devicepools",
					Usage: "list the devicepools", //globally
					Flags: []cli.Flag{
						cli.StringFlag{
							Name:   "project",
							EnvVar: "DF_PROJECT",
							Usage:  "project arn or project description",
						},
					},
					Action: func(c *cli.Context) {

						projectArn := c.String("project")
						listDevicePools(svc, projectArn)
					},
				},
				{
					Name: "problems",
					Flags: []cli.Flag{
						cli.StringFlag{
							Name:   "run",
							EnvVar: "DF_RUN",
							Usage:  "run arn or run description",
						},
					},
					Usage: "list the problems", // of Test
					Action: func(c *cli.Context) {
						runArn := c.String("run")
						listUniqueProblems(svc, runArn)
					},
				},
				{
					Name:  "tests",
					Usage: "list the tests", // of a Run
					Flags: []cli.Flag{
						cli.StringFlag{
							Name:   "run",
							EnvVar: "DF_RUN",
							Usage:  "run arn or run description",
						},
						cli.StringFlag{
							Name:   "job",
							EnvVar: "DF_JOB",
							Usage:  "job arn or run description",
						},
					},
					Action: func(c *cli.Context) {
						runArn := c.String("run")
						jobArn := c.String("job")
						filterArn := ""
						if runArn != "" {
							filterArn = runArn
						} else {
							filterArn = jobArn
						}
						listTests(svc, filterArn)
					},
				},
				{
					Name:  "runs",
					Usage: "list the runs",
					Flags: []cli.Flag{
						cli.StringFlag{
							Name:   "project",
							EnvVar: "DF_PROJECT",
							Usage:  "project arn or project description",
						},
					},
					Action: func(c *cli.Context) {
						projectArn := c.String("project")
						listRuns(svc, projectArn)
					},
				},
			},
		},
		{
			Name:  "download",
			Usage: "download various devicefarm elements",
			Subcommands: []cli.Command{
				{
					Name:  "artifacts",
					Usage: "download the artifacts",
					Flags: []cli.Flag{
						cli.StringFlag{
							Name:   "run",
							EnvVar: "DF_RUN",
							Usage:  "run arn or run description",
						},
						cli.StringFlag{
							Name:   "job",
							EnvVar: "DF_JOB",
							Usage:  "job arn or run description",
						},
						cli.StringFlag{
							Name:   "type",
							EnvVar: "DF_ARTIFACT_TYPE",
							Usage:  "type of the artifact [LOG,FILE,SCREENSHOT]",
						},
					},
					Action: func(c *cli.Context) {
						runArn := c.String("run")
						jobArn := c.String("job")

						filterArn := ""
						if runArn != "" {
							filterArn = runArn
						} else {
							filterArn = jobArn
						}

						artifactType := c.String("type")
						downloadArtifacts(svc, filterArn, artifactType)
					},
				},
			},
		},
		{
			Name:  "status",
			Usage: "get the status of a run",
			Flags: []cli.Flag{
				cli.StringFlag{
					Name:   "run",
					EnvVar: "DF_RUN",
					Usage:  "run arn or run description",
				},
			},
			Action: func(c *cli.Context) {
				runArn := c.String("run")
				runStatus(svc, runArn)
			},
		},
		{
			Name:  "report",
			Usage: "get report about a run",
			Flags: []cli.Flag{
				cli.StringFlag{
					Name:   "run",
					EnvVar: "DF_RUN",
					Usage:  "run arn or run description",
				},
			},
			Action: func(c *cli.Context) {
				runArn := c.String("run")
				runReport(svc, runArn)
			},
		},
		{
			Name:  "schedule",
			Usage: "schedule a run",
			Flags: []cli.Flag{
				cli.StringFlag{
					Name:   "project",
					EnvVar: "DF_PROJECT",
					Usage:  "project arn or project description",
				},
				cli.StringFlag{
					Name:   "device-pool",
					EnvVar: "DF_DEVICE_POOL",
					Usage:  "devicepool arn or devicepool name",
				},
				cli.StringFlag{
					Name:   "device",
					EnvVar: "DF_DEVICE",
					Usage:  "device arn or devicepool name to run the test on",
				},
				cli.StringFlag{
					Name:   "name",
					EnvVar: "DF_RUN_NAME",
					Usage:  "name to give to the run that is scheduled",
				},
				cli.StringFlag{
					Name:   "app-file",
					EnvVar: "DF_APP_FILE",
					Usage:  "path of the app file to be executed",
				},
				cli.StringFlag{
					Name:   "app-type",
					EnvVar: "DF_APP_TYPE",
					Usage:  "type of app [ANDROID_APP,IOS_APP]",
				},
				cli.StringFlag{
					Name:   "test-file",
					EnvVar: "DF_TEST_FILE",
					Usage:  "path of the test file to be executed",
				},
				cli.StringFlag{
					Name:   "test-type",
					EnvVar: "DF_TEST_TYPE",
					//Usage:  "type of test [APPIUM_JAVA_JUNIT_TEST_PACKAGE, INSTRUMENTATION_TEST_PACKAGE, UIAUTOMATION_TEST_PACKAGE, APPIUM_JAVA_TESTNG_TEST_PACKAGE, IOS_APP, CALABASH_TEST_PACKAGE, ANDROID_APP, UIAUTOMATOR_TEST_PACKAGE, XCTEST_TEST_PACKAGE, EXTERNAL_DATA]",
					Usage: "type of test [UIAUTOMATOR, CALABASH, APPIUM_JAVA_TESTNG, UIAUTOMATION, BUILTIN_FUZZ, INSTRUMENTATION, APPIUM_JAVA_JUNIT, BUILTIN_EXPLORER, XCTEST]",
				},
				cli.StringFlag{
					Name:   "test",
					Usage:  "arn or name of the test upload to schedule",
					EnvVar: "DF_TEST",
				},
				cli.StringFlag{
					Name:   "app",
					Usage:  "arn or name of the app upload to schedule",
					EnvVar: "DF_APP",
				},
			},
			Action: func(c *cli.Context) {
				projectArn := c.String("project")
				runName := c.String("name")
				deviceArn := c.String("device")
				devicePoolArn := c.String("device-pool")
				appArn := c.String("app")
				appFile := c.String("app-file")
				appType := c.String("app-type")
				testPackageArn := c.String("test-package")
				testPackageType := c.String("test-type")
				testPackageFile := c.String("test-file")
				scheduleRun(svc, projectArn, runName, deviceArn, devicePoolArn, appArn, appFile, appType, testPackageArn, testPackageFile, testPackageType)
			},
		},
		{
			Name:  "create",
			Usage: "creates various devicefarm elements",
			Subcommands: []cli.Command{
				{
					Name:  "upload",
					Usage: "creates an upload",
					Flags: []cli.Flag{
						cli.StringFlag{
							Name:   "project",
							EnvVar: "DF_PROJECT",
							Usage:  "project arn or project description",
						},
						cli.StringFlag{
							Name:  "name",
							Usage: "name of the upload",
						},
						cli.StringFlag{
							Name:  "type",
							Usage: "type of upload [ANDROID_APP,IOS_APP,EXTERNAL_DATA,APPIUM_JAVA_JUNIT_TEST_PACKAGE,APPIUM_JAVA_TESTNG_TEST_PACKAGE,CALABASH_TEST_PACKAGE,INSTRUMENTATION_TEST_PACKAGE,UIAUTOMATOR_TEST_PACKAGE,XCTEST_TEST_PACKAGE",
						},
					},
					Action: func(c *cli.Context) {
						uploadName := c.String("name")
						uploadType := c.String("type")
						projectArn := c.String("project")
						uploadCreate(svc, uploadName, uploadType, projectArn)
					},
				},
			},
		},
		{
			Name:  "info",
			Usage: "get detailed info about various devicefarm elements",
			Subcommands: []cli.Command{
				{
					Name:  "run",
					Usage: "get info about a run",
					Flags: []cli.Flag{
						cli.StringFlag{
							Name:   "run",
							EnvVar: "DF_RUN",
							Usage:  "run arn or run description",
						},
					},
					Action: func(c *cli.Context) {
						runArn := c.String("run")
						runInfo(svc, runArn)
					},
				},
				{
					Name:  "upload",
					Usage: "info about uploads",
					Flags: []cli.Flag{
						cli.StringFlag{
							Name:   "upload",
							EnvVar: "DF_UPLOAD",
							Usage:  "upload arn or description",
						},
					},
					Action: func(c *cli.Context) {
						uploadArn := c.String("upload")
						uploadInfo(svc, uploadArn)
					},
				},
			},
		},
		{
			Name:  "upload",
			Usage: "uploads an app, test and data",
			Subcommands: []cli.Command{
				{
					Name:  "file",
					Usage: "uploads an file",
					Flags: []cli.Flag{
						cli.StringFlag{
							Name:   "project",
							EnvVar: "DF_PROJECT",
							Usage:  "project arn or project description",
						},
						cli.StringFlag{
							Name:  "name",
							Usage: "name of the upload",
						},
						cli.StringFlag{
							Name:  "file",
							Usage: "path to the file to upload",
						},
						cli.StringFlag{
							Name:  "type",
							Usage: "type of upload [ANDROID_APP,IOS_APP,EXTERNAL_DATA,APPIUM_JAVA_JUNIT_TEST_PACKAGE,APPIUM_JAVA_TESTNG_TEST_PACKAGE,CALABASH_TEST_PACKAGE,INSTRUMENTATION_TEST_PACKAGE,UIAUTOMATOR_TEST_PACKAGE,XCTEST_TEST_PACKAGE",
						},
					},
					Action: func(c *cli.Context) {
						uploadType := c.String("type")
						projectArn := c.String("project")
						uploadFilePath := c.String("file")
						uploadName := c.String("name")
						_, err := uploadPut(svc, uploadFilePath, uploadType, projectArn, uploadName)
						failOnErr(err, "error Uploading file")
					},
				},
			},
		},
	}

	app.Run(os.Args)

}