Esempio n. 1
0
func Add(cmd *cli.Cmd) {

	identifier := cmd.String(cli.StringArg{
		Name:      "LOCATION",
		Desc:      "location to be added to your current role(i.e. us-east-1)",
		HideValue: true,
	})

	cmd.Action = func() {
		l := pools.Location{}
		l.Identifier = *identifier

		location, resp, errs := l.Create()

		if len(errs) > 0 {
			log.Fatalf("Could not add new location: %s", errs)
		}

		if resp.StatusCode != 201 {
			log.Fatalf("Cloud not add new location: %s", resp.Status)
		}

		PrintLocationBrief([]pools.Location{*location})
	}
}
Esempio n. 2
0
func List(cmd *cli.Cmd) {
	cmd.Action = func() {
		l := pools.Location{}
		locations, resp, errs := l.List()

		if len(errs) > 0 {
			log.Fatalf("Could not retrieve locations: %s", errs[0])
		}

		if resp.StatusCode != 200 {
			log.Fatalf("Cloud not retrieve locations: %s", resp.Status)
		}

		PrintLocationBrief(*locations)
	}
}
Esempio n. 3
0
func List(cmd *cli.Cmd) {
	all := cmd.BoolOpt("a all", false, "List all locations, including archived")

	cmd.Action = func() {
		l := pools.Location{}
		locations, resp, errs := l.List()

		if len(errs) > 0 {
			log.Fatalf("Could not retrieve locations: %s", errs[0])
		}

		if resp.StatusCode != 200 {
			log.Fatalf("Cloud not retrieve locations: %s", resp.Status)
		}

		PrintLocationBrief(*locations, *all)
	}
}
Esempio n. 4
0
func Archive(cmd *cli.Cmd) {
	uuid := cmd.String(cli.StringArg{
		Name:      "UUID",
		Desc:      "Region UUID",
		HideValue: true,
	})

	cmd.Action = func() {
		var l *pools.Location
		l, resp, errs := l.Delete(*uuid)

		if len(errs) > 0 {
			log.Fatalf("Could not archive location: %s", errs)
		}

		if resp.StatusCode != 202 {
			log.Fatalf("Could not archive location: %s", resp.Status)
		}

		fmt.Sprintf("Location %s accepted for archival\n", *uuid)
	}
}