示例#1
0
func ExampleLambda_AddEventSource() {
	svc := lambda.New(nil)

	params := &lambda.AddEventSourceInput{
		EventSource:  aws.String("String"),       // Required
		FunctionName: aws.String("FunctionName"), // Required
		Role:         aws.String("RoleArn"),      // Required
		BatchSize:    aws.Long(1),
		Parameters: &map[string]*string{
			"Key": aws.String("String"), // Required
			// More values...
		},
	}
	resp, err := svc.AddEventSource(params)

	if awserr := aws.Error(err); awserr != nil {
		// A service error occurred.
		fmt.Println("Error:", awserr.Code, awserr.Message)
	} else if err != nil {
		// A non-service error occurred.
		panic(err)
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.StringValue(resp))
}
示例#2
0
func ExampleLambda_UploadFunction() {
	svc := lambda.New(nil)

	params := &lambda.UploadFunctionInput{
		FunctionName: aws.String("FunctionName"),         // Required
		FunctionZip:  bytes.NewReader([]byte("PAYLOAD")), // Required
		Handler:      aws.String("Handler"),              // Required
		Mode:         aws.String("Mode"),                 // Required
		Role:         aws.String("RoleArn"),              // Required
		Runtime:      aws.String("Runtime"),              // Required
		Description:  aws.String("Description"),
		MemorySize:   aws.Long(1),
		Timeout:      aws.Long(1),
	}
	resp, err := svc.UploadFunction(params)

	if awserr := aws.Error(err); awserr != nil {
		// A service error occurred.
		fmt.Println("Error:", awserr.Code, awserr.Message)
	} else if err != nil {
		// A non-service error occurred.
		panic(err)
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.StringValue(resp))
}
示例#3
0
func TestMakingABasicRequest(t *testing.T) {
	client := lambda.New(nil)
	resp, e := client.ListEventSources(&lambda.ListEventSourcesInput{})
	err := aws.Error(e)
	_, _, _ = resp, e, err // avoid unused warnings

	assert.NoError(t, nil, err)

}
示例#4
0
func TestErrorHandling(t *testing.T) {
	client := lambda.New(nil)
	resp, e := client.GetEventSource(&lambda.GetEventSourceInput{
		UUID: aws.String("fake-uuid"),
	})
	err := aws.Error(e)
	_, _, _ = resp, e, err // avoid unused warnings

	assert.NotEqual(t, nil, err)
	assert.Equal(t, "ResourceNotFoundException", err.Code)
	utilassert.Match(t, "does not exist", err.Message)

}
示例#5
0
func ExampleLambda_GetFunction() {
	svc := lambda.New(nil)

	params := &lambda.GetFunctionInput{
		FunctionName: aws.String("FunctionName"), // Required
	}
	resp, err := svc.GetFunction(params)

	if awserr := aws.Error(err); awserr != nil {
		// A service error occurred.
		fmt.Println("Error:", awserr.Code, awserr.Message)
	} else if err != nil {
		// A non-service error occurred.
		panic(err)
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.StringValue(resp))
}
示例#6
0
func ExampleLambda_RemoveEventSource() {
	svc := lambda.New(nil)

	params := &lambda.RemoveEventSourceInput{
		UUID: aws.String("String"), // Required
	}
	resp, err := svc.RemoveEventSource(params)

	if awserr := aws.Error(err); awserr != nil {
		// A service error occurred.
		fmt.Println("Error:", awserr.Code, awserr.Message)
	} else if err != nil {
		// A non-service error occurred.
		panic(err)
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.StringValue(resp))
}
示例#7
0
func ExampleLambda_ListFunctions() {
	svc := lambda.New(nil)

	params := &lambda.ListFunctionsInput{
		Marker:   aws.String("String"),
		MaxItems: aws.Long(1),
	}
	resp, err := svc.ListFunctions(params)

	if awserr := aws.Error(err); awserr != nil {
		// A service error occurred.
		fmt.Println("Error:", awserr.Code, awserr.Message)
	} else if err != nil {
		// A non-service error occurred.
		panic(err)
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.StringValue(resp))
}
示例#8
0
func ExampleLambda_InvokeAsync() {
	svc := lambda.New(nil)

	params := &lambda.InvokeAsyncInput{
		FunctionName: aws.String("FunctionName"),         // Required
		InvokeArgs:   bytes.NewReader([]byte("PAYLOAD")), // Required
	}
	resp, err := svc.InvokeAsync(params)

	if awserr := aws.Error(err); awserr != nil {
		// A service error occurred.
		fmt.Println("Error:", awserr.Code, awserr.Message)
	} else if err != nil {
		// A non-service error occurred.
		panic(err)
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.StringValue(resp))
}