1// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
2
3package batch_test
4
5import (
6	"fmt"
7	"strings"
8	"time"
9
10	"github.com/aws/aws-sdk-go/aws"
11	"github.com/aws/aws-sdk-go/aws/awserr"
12	"github.com/aws/aws-sdk-go/aws/session"
13	"github.com/aws/aws-sdk-go/service/batch"
14)
15
16var _ time.Duration
17var _ strings.Reader
18var _ aws.Config
19
20func parseTime(layout, value string) *time.Time {
21	t, err := time.Parse(layout, value)
22	if err != nil {
23		panic(err)
24	}
25	return &t
26}
27
28// To cancel a job
29//
30// This example cancels a job with the specified job ID.
31func ExampleBatch_CancelJob_shared00() {
32	svc := batch.New(session.New())
33	input := &batch.CancelJobInput{
34		JobId:  aws.String("1d828f65-7a4d-42e8-996d-3b900ed59dc4"),
35		Reason: aws.String("Cancelling job."),
36	}
37
38	result, err := svc.CancelJob(input)
39	if err != nil {
40		if aerr, ok := err.(awserr.Error); ok {
41			switch aerr.Code() {
42			case batch.ErrCodeClientException:
43				fmt.Println(batch.ErrCodeClientException, aerr.Error())
44			case batch.ErrCodeServerException:
45				fmt.Println(batch.ErrCodeServerException, aerr.Error())
46			default:
47				fmt.Println(aerr.Error())
48			}
49		} else {
50			// Print the error, cast err to awserr.Error to get the Code and
51			// Message from an error.
52			fmt.Println(err.Error())
53		}
54		return
55	}
56
57	fmt.Println(result)
58}
59
60// To create a managed EC2 compute environment
61//
62// This example creates a managed compute environment with specific C4 instance types
63// that are launched on demand. The compute environment is called C4OnDemand.
64func ExampleBatch_CreateComputeEnvironment_shared00() {
65	svc := batch.New(session.New())
66	input := &batch.CreateComputeEnvironmentInput{
67		ComputeEnvironmentName: aws.String("C4OnDemand"),
68		ComputeResources: &batch.ComputeResource{
69			DesiredvCpus: aws.Int64(48),
70			Ec2KeyPair:   aws.String("id_rsa"),
71			InstanceRole: aws.String("ecsInstanceRole"),
72			InstanceTypes: []*string{
73				aws.String("c4.large"),
74				aws.String("c4.xlarge"),
75				aws.String("c4.2xlarge"),
76				aws.String("c4.4xlarge"),
77				aws.String("c4.8xlarge"),
78			},
79			MaxvCpus: aws.Int64(128),
80			MinvCpus: aws.Int64(0),
81			SecurityGroupIds: []*string{
82				aws.String("sg-cf5093b2"),
83			},
84			Subnets: []*string{
85				aws.String("subnet-220c0e0a"),
86				aws.String("subnet-1a95556d"),
87				aws.String("subnet-978f6dce"),
88			},
89			Tags: map[string]*string{
90				"Name": aws.String("Batch Instance - C4OnDemand"),
91			},
92			Type: aws.String("EC2"),
93		},
94		ServiceRole: aws.String("arn:aws:iam::012345678910:role/AWSBatchServiceRole"),
95		State:       aws.String("ENABLED"),
96		Type:        aws.String("MANAGED"),
97	}
98
99	result, err := svc.CreateComputeEnvironment(input)
100	if err != nil {
101		if aerr, ok := err.(awserr.Error); ok {
102			switch aerr.Code() {
103			case batch.ErrCodeClientException:
104				fmt.Println(batch.ErrCodeClientException, aerr.Error())
105			case batch.ErrCodeServerException:
106				fmt.Println(batch.ErrCodeServerException, aerr.Error())
107			default:
108				fmt.Println(aerr.Error())
109			}
110		} else {
111			// Print the error, cast err to awserr.Error to get the Code and
112			// Message from an error.
113			fmt.Println(err.Error())
114		}
115		return
116	}
117
118	fmt.Println(result)
119}
120
121// To create a managed EC2 Spot compute environment
122//
123// This example creates a managed compute environment with the M4 instance type that
124// is launched when the Spot bid price is at or below 20% of the On-Demand price for
125// the instance type. The compute environment is called M4Spot.
126func ExampleBatch_CreateComputeEnvironment_shared01() {
127	svc := batch.New(session.New())
128	input := &batch.CreateComputeEnvironmentInput{
129		ComputeEnvironmentName: aws.String("M4Spot"),
130		ComputeResources: &batch.ComputeResource{
131			BidPercentage: aws.Int64(20),
132			DesiredvCpus:  aws.Int64(4),
133			Ec2KeyPair:    aws.String("id_rsa"),
134			InstanceRole:  aws.String("ecsInstanceRole"),
135			InstanceTypes: []*string{
136				aws.String("m4"),
137			},
138			MaxvCpus: aws.Int64(128),
139			MinvCpus: aws.Int64(0),
140			SecurityGroupIds: []*string{
141				aws.String("sg-cf5093b2"),
142			},
143			SpotIamFleetRole: aws.String("arn:aws:iam::012345678910:role/aws-ec2-spot-fleet-role"),
144			Subnets: []*string{
145				aws.String("subnet-220c0e0a"),
146				aws.String("subnet-1a95556d"),
147				aws.String("subnet-978f6dce"),
148			},
149			Tags: map[string]*string{
150				"Name": aws.String("Batch Instance - M4Spot"),
151			},
152			Type: aws.String("SPOT"),
153		},
154		ServiceRole: aws.String("arn:aws:iam::012345678910:role/AWSBatchServiceRole"),
155		State:       aws.String("ENABLED"),
156		Type:        aws.String("MANAGED"),
157	}
158
159	result, err := svc.CreateComputeEnvironment(input)
160	if err != nil {
161		if aerr, ok := err.(awserr.Error); ok {
162			switch aerr.Code() {
163			case batch.ErrCodeClientException:
164				fmt.Println(batch.ErrCodeClientException, aerr.Error())
165			case batch.ErrCodeServerException:
166				fmt.Println(batch.ErrCodeServerException, aerr.Error())
167			default:
168				fmt.Println(aerr.Error())
169			}
170		} else {
171			// Print the error, cast err to awserr.Error to get the Code and
172			// Message from an error.
173			fmt.Println(err.Error())
174		}
175		return
176	}
177
178	fmt.Println(result)
179}
180
181// To create a job queue with a single compute environment
182//
183// This example creates a job queue called LowPriority that uses the M4Spot compute
184// environment.
185func ExampleBatch_CreateJobQueue_shared00() {
186	svc := batch.New(session.New())
187	input := &batch.CreateJobQueueInput{
188		ComputeEnvironmentOrder: []*batch.ComputeEnvironmentOrder{
189			{
190				ComputeEnvironment: aws.String("M4Spot"),
191				Order:              aws.Int64(1),
192			},
193		},
194		JobQueueName: aws.String("LowPriority"),
195		Priority:     aws.Int64(1),
196		State:        aws.String("ENABLED"),
197	}
198
199	result, err := svc.CreateJobQueue(input)
200	if err != nil {
201		if aerr, ok := err.(awserr.Error); ok {
202			switch aerr.Code() {
203			case batch.ErrCodeClientException:
204				fmt.Println(batch.ErrCodeClientException, aerr.Error())
205			case batch.ErrCodeServerException:
206				fmt.Println(batch.ErrCodeServerException, aerr.Error())
207			default:
208				fmt.Println(aerr.Error())
209			}
210		} else {
211			// Print the error, cast err to awserr.Error to get the Code and
212			// Message from an error.
213			fmt.Println(err.Error())
214		}
215		return
216	}
217
218	fmt.Println(result)
219}
220
221// To create a job queue with multiple compute environments
222//
223// This example creates a job queue called HighPriority that uses the C4OnDemand compute
224// environment with an order of 1 and the M4Spot compute environment with an order of
225// 2.
226func ExampleBatch_CreateJobQueue_shared01() {
227	svc := batch.New(session.New())
228	input := &batch.CreateJobQueueInput{
229		ComputeEnvironmentOrder: []*batch.ComputeEnvironmentOrder{
230			{
231				ComputeEnvironment: aws.String("C4OnDemand"),
232				Order:              aws.Int64(1),
233			},
234			{
235				ComputeEnvironment: aws.String("M4Spot"),
236				Order:              aws.Int64(2),
237			},
238		},
239		JobQueueName: aws.String("HighPriority"),
240		Priority:     aws.Int64(10),
241		State:        aws.String("ENABLED"),
242	}
243
244	result, err := svc.CreateJobQueue(input)
245	if err != nil {
246		if aerr, ok := err.(awserr.Error); ok {
247			switch aerr.Code() {
248			case batch.ErrCodeClientException:
249				fmt.Println(batch.ErrCodeClientException, aerr.Error())
250			case batch.ErrCodeServerException:
251				fmt.Println(batch.ErrCodeServerException, aerr.Error())
252			default:
253				fmt.Println(aerr.Error())
254			}
255		} else {
256			// Print the error, cast err to awserr.Error to get the Code and
257			// Message from an error.
258			fmt.Println(err.Error())
259		}
260		return
261	}
262
263	fmt.Println(result)
264}
265
266// To delete a compute environment
267//
268// This example deletes the P2OnDemand compute environment.
269func ExampleBatch_DeleteComputeEnvironment_shared00() {
270	svc := batch.New(session.New())
271	input := &batch.DeleteComputeEnvironmentInput{
272		ComputeEnvironment: aws.String("P2OnDemand"),
273	}
274
275	result, err := svc.DeleteComputeEnvironment(input)
276	if err != nil {
277		if aerr, ok := err.(awserr.Error); ok {
278			switch aerr.Code() {
279			case batch.ErrCodeClientException:
280				fmt.Println(batch.ErrCodeClientException, aerr.Error())
281			case batch.ErrCodeServerException:
282				fmt.Println(batch.ErrCodeServerException, aerr.Error())
283			default:
284				fmt.Println(aerr.Error())
285			}
286		} else {
287			// Print the error, cast err to awserr.Error to get the Code and
288			// Message from an error.
289			fmt.Println(err.Error())
290		}
291		return
292	}
293
294	fmt.Println(result)
295}
296
297// To delete a job queue
298//
299// This example deletes the GPGPU job queue.
300func ExampleBatch_DeleteJobQueue_shared00() {
301	svc := batch.New(session.New())
302	input := &batch.DeleteJobQueueInput{
303		JobQueue: aws.String("GPGPU"),
304	}
305
306	result, err := svc.DeleteJobQueue(input)
307	if err != nil {
308		if aerr, ok := err.(awserr.Error); ok {
309			switch aerr.Code() {
310			case batch.ErrCodeClientException:
311				fmt.Println(batch.ErrCodeClientException, aerr.Error())
312			case batch.ErrCodeServerException:
313				fmt.Println(batch.ErrCodeServerException, aerr.Error())
314			default:
315				fmt.Println(aerr.Error())
316			}
317		} else {
318			// Print the error, cast err to awserr.Error to get the Code and
319			// Message from an error.
320			fmt.Println(err.Error())
321		}
322		return
323	}
324
325	fmt.Println(result)
326}
327
328// To deregister a job definition
329//
330// This example deregisters a job definition called sleep10.
331func ExampleBatch_DeregisterJobDefinition_shared00() {
332	svc := batch.New(session.New())
333	input := &batch.DeregisterJobDefinitionInput{
334		JobDefinition: aws.String("sleep10"),
335	}
336
337	result, err := svc.DeregisterJobDefinition(input)
338	if err != nil {
339		if aerr, ok := err.(awserr.Error); ok {
340			switch aerr.Code() {
341			case batch.ErrCodeClientException:
342				fmt.Println(batch.ErrCodeClientException, aerr.Error())
343			case batch.ErrCodeServerException:
344				fmt.Println(batch.ErrCodeServerException, aerr.Error())
345			default:
346				fmt.Println(aerr.Error())
347			}
348		} else {
349			// Print the error, cast err to awserr.Error to get the Code and
350			// Message from an error.
351			fmt.Println(err.Error())
352		}
353		return
354	}
355
356	fmt.Println(result)
357}
358
359// To describe a compute environment
360//
361// This example describes the P2OnDemand compute environment.
362func ExampleBatch_DescribeComputeEnvironments_shared00() {
363	svc := batch.New(session.New())
364	input := &batch.DescribeComputeEnvironmentsInput{
365		ComputeEnvironments: []*string{
366			aws.String("P2OnDemand"),
367		},
368	}
369
370	result, err := svc.DescribeComputeEnvironments(input)
371	if err != nil {
372		if aerr, ok := err.(awserr.Error); ok {
373			switch aerr.Code() {
374			case batch.ErrCodeClientException:
375				fmt.Println(batch.ErrCodeClientException, aerr.Error())
376			case batch.ErrCodeServerException:
377				fmt.Println(batch.ErrCodeServerException, aerr.Error())
378			default:
379				fmt.Println(aerr.Error())
380			}
381		} else {
382			// Print the error, cast err to awserr.Error to get the Code and
383			// Message from an error.
384			fmt.Println(err.Error())
385		}
386		return
387	}
388
389	fmt.Println(result)
390}
391
392// To describe active job definitions
393//
394// This example describes all of your active job definitions.
395func ExampleBatch_DescribeJobDefinitions_shared00() {
396	svc := batch.New(session.New())
397	input := &batch.DescribeJobDefinitionsInput{
398		Status: aws.String("ACTIVE"),
399	}
400
401	result, err := svc.DescribeJobDefinitions(input)
402	if err != nil {
403		if aerr, ok := err.(awserr.Error); ok {
404			switch aerr.Code() {
405			case batch.ErrCodeClientException:
406				fmt.Println(batch.ErrCodeClientException, aerr.Error())
407			case batch.ErrCodeServerException:
408				fmt.Println(batch.ErrCodeServerException, aerr.Error())
409			default:
410				fmt.Println(aerr.Error())
411			}
412		} else {
413			// Print the error, cast err to awserr.Error to get the Code and
414			// Message from an error.
415			fmt.Println(err.Error())
416		}
417		return
418	}
419
420	fmt.Println(result)
421}
422
423// To describe a job queue
424//
425// This example describes the HighPriority job queue.
426func ExampleBatch_DescribeJobQueues_shared00() {
427	svc := batch.New(session.New())
428	input := &batch.DescribeJobQueuesInput{
429		JobQueues: []*string{
430			aws.String("HighPriority"),
431		},
432	}
433
434	result, err := svc.DescribeJobQueues(input)
435	if err != nil {
436		if aerr, ok := err.(awserr.Error); ok {
437			switch aerr.Code() {
438			case batch.ErrCodeClientException:
439				fmt.Println(batch.ErrCodeClientException, aerr.Error())
440			case batch.ErrCodeServerException:
441				fmt.Println(batch.ErrCodeServerException, aerr.Error())
442			default:
443				fmt.Println(aerr.Error())
444			}
445		} else {
446			// Print the error, cast err to awserr.Error to get the Code and
447			// Message from an error.
448			fmt.Println(err.Error())
449		}
450		return
451	}
452
453	fmt.Println(result)
454}
455
456// To describe a specific job
457//
458// This example describes a job with the specified job ID.
459func ExampleBatch_DescribeJobs_shared00() {
460	svc := batch.New(session.New())
461	input := &batch.DescribeJobsInput{
462		Jobs: []*string{
463			aws.String("24fa2d7a-64c4-49d2-8b47-f8da4fbde8e9"),
464		},
465	}
466
467	result, err := svc.DescribeJobs(input)
468	if err != nil {
469		if aerr, ok := err.(awserr.Error); ok {
470			switch aerr.Code() {
471			case batch.ErrCodeClientException:
472				fmt.Println(batch.ErrCodeClientException, aerr.Error())
473			case batch.ErrCodeServerException:
474				fmt.Println(batch.ErrCodeServerException, aerr.Error())
475			default:
476				fmt.Println(aerr.Error())
477			}
478		} else {
479			// Print the error, cast err to awserr.Error to get the Code and
480			// Message from an error.
481			fmt.Println(err.Error())
482		}
483		return
484	}
485
486	fmt.Println(result)
487}
488
489// To list running jobs
490//
491// This example lists the running jobs in the HighPriority job queue.
492func ExampleBatch_ListJobs_shared00() {
493	svc := batch.New(session.New())
494	input := &batch.ListJobsInput{
495		JobQueue: aws.String("HighPriority"),
496	}
497
498	result, err := svc.ListJobs(input)
499	if err != nil {
500		if aerr, ok := err.(awserr.Error); ok {
501			switch aerr.Code() {
502			case batch.ErrCodeClientException:
503				fmt.Println(batch.ErrCodeClientException, aerr.Error())
504			case batch.ErrCodeServerException:
505				fmt.Println(batch.ErrCodeServerException, aerr.Error())
506			default:
507				fmt.Println(aerr.Error())
508			}
509		} else {
510			// Print the error, cast err to awserr.Error to get the Code and
511			// Message from an error.
512			fmt.Println(err.Error())
513		}
514		return
515	}
516
517	fmt.Println(result)
518}
519
520// To list submitted jobs
521//
522// This example lists jobs in the HighPriority job queue that are in the SUBMITTED job
523// status.
524func ExampleBatch_ListJobs_shared01() {
525	svc := batch.New(session.New())
526	input := &batch.ListJobsInput{
527		JobQueue:  aws.String("HighPriority"),
528		JobStatus: aws.String("SUBMITTED"),
529	}
530
531	result, err := svc.ListJobs(input)
532	if err != nil {
533		if aerr, ok := err.(awserr.Error); ok {
534			switch aerr.Code() {
535			case batch.ErrCodeClientException:
536				fmt.Println(batch.ErrCodeClientException, aerr.Error())
537			case batch.ErrCodeServerException:
538				fmt.Println(batch.ErrCodeServerException, aerr.Error())
539			default:
540				fmt.Println(aerr.Error())
541			}
542		} else {
543			// Print the error, cast err to awserr.Error to get the Code and
544			// Message from an error.
545			fmt.Println(err.Error())
546		}
547		return
548	}
549
550	fmt.Println(result)
551}
552
553// ListTagsForResource Example
554//
555// This demonstrates calling the ListTagsForResource action.
556func ExampleBatch_ListTagsForResource_shared00() {
557	svc := batch.New(session.New())
558	input := &batch.ListTagsForResourceInput{
559		ResourceArn: aws.String("arn:aws:batch:us-east-1:123456789012:job-definition/sleep30:1"),
560	}
561
562	result, err := svc.ListTagsForResource(input)
563	if err != nil {
564		if aerr, ok := err.(awserr.Error); ok {
565			switch aerr.Code() {
566			case batch.ErrCodeClientException:
567				fmt.Println(batch.ErrCodeClientException, aerr.Error())
568			case batch.ErrCodeServerException:
569				fmt.Println(batch.ErrCodeServerException, aerr.Error())
570			default:
571				fmt.Println(aerr.Error())
572			}
573		} else {
574			// Print the error, cast err to awserr.Error to get the Code and
575			// Message from an error.
576			fmt.Println(err.Error())
577		}
578		return
579	}
580
581	fmt.Println(result)
582}
583
584// To register a job definition
585//
586// This example registers a job definition for a simple container job.
587func ExampleBatch_RegisterJobDefinition_shared00() {
588	svc := batch.New(session.New())
589	input := &batch.RegisterJobDefinitionInput{
590		ContainerProperties: &batch.ContainerProperties{
591			Command: []*string{
592				aws.String("sleep"),
593				aws.String("10"),
594			},
595			Image:  aws.String("busybox"),
596			Memory: aws.Int64(128),
597			Vcpus:  aws.Int64(1),
598		},
599		JobDefinitionName: aws.String("sleep10"),
600		Type:              aws.String("container"),
601	}
602
603	result, err := svc.RegisterJobDefinition(input)
604	if err != nil {
605		if aerr, ok := err.(awserr.Error); ok {
606			switch aerr.Code() {
607			case batch.ErrCodeClientException:
608				fmt.Println(batch.ErrCodeClientException, aerr.Error())
609			case batch.ErrCodeServerException:
610				fmt.Println(batch.ErrCodeServerException, aerr.Error())
611			default:
612				fmt.Println(aerr.Error())
613			}
614		} else {
615			// Print the error, cast err to awserr.Error to get the Code and
616			// Message from an error.
617			fmt.Println(err.Error())
618		}
619		return
620	}
621
622	fmt.Println(result)
623}
624
625// RegisterJobDefinition with tags
626//
627// This demonstrates calling the RegisterJobDefinition action, including tags.
628func ExampleBatch_RegisterJobDefinition_shared01() {
629	svc := batch.New(session.New())
630	input := &batch.RegisterJobDefinitionInput{
631		ContainerProperties: &batch.ContainerProperties{
632			Command: []*string{
633				aws.String("sleep"),
634				aws.String("30"),
635			},
636			Image:  aws.String("busybox"),
637			Memory: aws.Int64(128),
638			Vcpus:  aws.Int64(1),
639		},
640		JobDefinitionName: aws.String("sleep30"),
641		Tags: map[string]*string{
642			"Department": aws.String("Engineering"),
643			"User":       aws.String("JaneDoe"),
644		},
645		Type: aws.String("container"),
646	}
647
648	result, err := svc.RegisterJobDefinition(input)
649	if err != nil {
650		if aerr, ok := err.(awserr.Error); ok {
651			switch aerr.Code() {
652			case batch.ErrCodeClientException:
653				fmt.Println(batch.ErrCodeClientException, aerr.Error())
654			case batch.ErrCodeServerException:
655				fmt.Println(batch.ErrCodeServerException, aerr.Error())
656			default:
657				fmt.Println(aerr.Error())
658			}
659		} else {
660			// Print the error, cast err to awserr.Error to get the Code and
661			// Message from an error.
662			fmt.Println(err.Error())
663		}
664		return
665	}
666
667	fmt.Println(result)
668}
669
670// To submit a job to a queue
671//
672// This example submits a simple container job called example to the HighPriority job
673// queue.
674func ExampleBatch_SubmitJob_shared00() {
675	svc := batch.New(session.New())
676	input := &batch.SubmitJobInput{
677		JobDefinition: aws.String("sleep60"),
678		JobName:       aws.String("example"),
679		JobQueue:      aws.String("HighPriority"),
680	}
681
682	result, err := svc.SubmitJob(input)
683	if err != nil {
684		if aerr, ok := err.(awserr.Error); ok {
685			switch aerr.Code() {
686			case batch.ErrCodeClientException:
687				fmt.Println(batch.ErrCodeClientException, aerr.Error())
688			case batch.ErrCodeServerException:
689				fmt.Println(batch.ErrCodeServerException, aerr.Error())
690			default:
691				fmt.Println(aerr.Error())
692			}
693		} else {
694			// Print the error, cast err to awserr.Error to get the Code and
695			// Message from an error.
696			fmt.Println(err.Error())
697		}
698		return
699	}
700
701	fmt.Println(result)
702}
703
704// TagResource Example
705//
706// This demonstrates calling the TagResource action.
707func ExampleBatch_TagResource_shared00() {
708	svc := batch.New(session.New())
709	input := &batch.TagResourceInput{
710		ResourceArn: aws.String("arn:aws:batch:us-east-1:123456789012:job-definition/sleep30:1"),
711		Tags: map[string]*string{
712			"Stage": aws.String("Alpha"),
713		},
714	}
715
716	result, err := svc.TagResource(input)
717	if err != nil {
718		if aerr, ok := err.(awserr.Error); ok {
719			switch aerr.Code() {
720			case batch.ErrCodeClientException:
721				fmt.Println(batch.ErrCodeClientException, aerr.Error())
722			case batch.ErrCodeServerException:
723				fmt.Println(batch.ErrCodeServerException, aerr.Error())
724			default:
725				fmt.Println(aerr.Error())
726			}
727		} else {
728			// Print the error, cast err to awserr.Error to get the Code and
729			// Message from an error.
730			fmt.Println(err.Error())
731		}
732		return
733	}
734
735	fmt.Println(result)
736}
737
738// To terminate a job
739//
740// This example terminates a job with the specified job ID.
741func ExampleBatch_TerminateJob_shared00() {
742	svc := batch.New(session.New())
743	input := &batch.TerminateJobInput{
744		JobId:  aws.String("61e743ed-35e4-48da-b2de-5c8333821c84"),
745		Reason: aws.String("Terminating job."),
746	}
747
748	result, err := svc.TerminateJob(input)
749	if err != nil {
750		if aerr, ok := err.(awserr.Error); ok {
751			switch aerr.Code() {
752			case batch.ErrCodeClientException:
753				fmt.Println(batch.ErrCodeClientException, aerr.Error())
754			case batch.ErrCodeServerException:
755				fmt.Println(batch.ErrCodeServerException, aerr.Error())
756			default:
757				fmt.Println(aerr.Error())
758			}
759		} else {
760			// Print the error, cast err to awserr.Error to get the Code and
761			// Message from an error.
762			fmt.Println(err.Error())
763		}
764		return
765	}
766
767	fmt.Println(result)
768}
769
770// UntagResource Example
771//
772// This demonstrates calling the UntagResource action.
773func ExampleBatch_UntagResource_shared00() {
774	svc := batch.New(session.New())
775	input := &batch.UntagResourceInput{
776		ResourceArn: aws.String("arn:aws:batch:us-east-1:123456789012:job-definition/sleep30:1"),
777		TagKeys: []*string{
778			aws.String("Stage"),
779		},
780	}
781
782	result, err := svc.UntagResource(input)
783	if err != nil {
784		if aerr, ok := err.(awserr.Error); ok {
785			switch aerr.Code() {
786			case batch.ErrCodeClientException:
787				fmt.Println(batch.ErrCodeClientException, aerr.Error())
788			case batch.ErrCodeServerException:
789				fmt.Println(batch.ErrCodeServerException, aerr.Error())
790			default:
791				fmt.Println(aerr.Error())
792			}
793		} else {
794			// Print the error, cast err to awserr.Error to get the Code and
795			// Message from an error.
796			fmt.Println(err.Error())
797		}
798		return
799	}
800
801	fmt.Println(result)
802}
803
804// To update a compute environment
805//
806// This example disables the P2OnDemand compute environment so it can be deleted.
807func ExampleBatch_UpdateComputeEnvironment_shared00() {
808	svc := batch.New(session.New())
809	input := &batch.UpdateComputeEnvironmentInput{
810		ComputeEnvironment: aws.String("P2OnDemand"),
811		State:              aws.String("DISABLED"),
812	}
813
814	result, err := svc.UpdateComputeEnvironment(input)
815	if err != nil {
816		if aerr, ok := err.(awserr.Error); ok {
817			switch aerr.Code() {
818			case batch.ErrCodeClientException:
819				fmt.Println(batch.ErrCodeClientException, aerr.Error())
820			case batch.ErrCodeServerException:
821				fmt.Println(batch.ErrCodeServerException, aerr.Error())
822			default:
823				fmt.Println(aerr.Error())
824			}
825		} else {
826			// Print the error, cast err to awserr.Error to get the Code and
827			// Message from an error.
828			fmt.Println(err.Error())
829		}
830		return
831	}
832
833	fmt.Println(result)
834}
835
836// To update a job queue
837//
838// This example disables a job queue so that it can be deleted.
839func ExampleBatch_UpdateJobQueue_shared00() {
840	svc := batch.New(session.New())
841	input := &batch.UpdateJobQueueInput{
842		JobQueue: aws.String("GPGPU"),
843		State:    aws.String("DISABLED"),
844	}
845
846	result, err := svc.UpdateJobQueue(input)
847	if err != nil {
848		if aerr, ok := err.(awserr.Error); ok {
849			switch aerr.Code() {
850			case batch.ErrCodeClientException:
851				fmt.Println(batch.ErrCodeClientException, aerr.Error())
852			case batch.ErrCodeServerException:
853				fmt.Println(batch.ErrCodeServerException, aerr.Error())
854			default:
855				fmt.Println(aerr.Error())
856			}
857		} else {
858			// Print the error, cast err to awserr.Error to get the Code and
859			// Message from an error.
860			fmt.Println(err.Error())
861		}
862		return
863	}
864
865	fmt.Println(result)
866}
867