當前位置: 首頁>>代碼示例>>Golang>>正文


Golang elastictranscoder.New函數代碼示例

本文整理匯總了Golang中github.com/aws/aws-sdk-go/service/elastictranscoder.New函數的典型用法代碼示例。如果您正苦於以下問題:Golang New函數的具體用法?Golang New怎麽用?Golang New使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了New函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: ExampleElasticTranscoder_TestRole

func ExampleElasticTranscoder_TestRole() {
	svc := elastictranscoder.New(nil)

	params := &elastictranscoder.TestRoleInput{
		InputBucket:  aws.String("BucketName"), // Required
		OutputBucket: aws.String("BucketName"), // Required
		Role:         aws.String("Role"),       // Required
		Topics: []*string{ // Required
			aws.String("SnsTopic"), // Required
			// More values...
		},
	}
	resp, err := svc.TestRole(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))
}
開發者ID:Talos208,項目名稱:aws-sdk-go,代碼行數:32,代碼來源:examples_test.go

示例2: ExampleElasticTranscoder_UpdatePipelineNotifications

func ExampleElasticTranscoder_UpdatePipelineNotifications() {
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println("failed to create session,", err)
		return
	}

	svc := elastictranscoder.New(sess)

	params := &elastictranscoder.UpdatePipelineNotificationsInput{
		Id: aws.String("Id"), // Required
		Notifications: &elastictranscoder.Notifications{ // Required
			Completed:   aws.String("SnsTopic"),
			Error:       aws.String("SnsTopic"),
			Progressing: aws.String("SnsTopic"),
			Warning:     aws.String("SnsTopic"),
		},
	}
	resp, err := svc.UpdatePipelineNotifications(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)
}
開發者ID:acquia,項目名稱:fifo2kinesis,代碼行數:30,代碼來源:examples_test.go

示例3: ExampleElasticTranscoder_UpdatePipelineStatus

func ExampleElasticTranscoder_UpdatePipelineStatus() {
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println("failed to create session,", err)
		return
	}

	svc := elastictranscoder.New(sess)

	params := &elastictranscoder.UpdatePipelineStatusInput{
		Id:     aws.String("Id"),             // Required
		Status: aws.String("PipelineStatus"), // Required
	}
	resp, err := svc.UpdatePipelineStatus(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)
}
開發者ID:acquia,項目名稱:fifo2kinesis,代碼行數:25,代碼來源:examples_test.go

示例4: ExampleElasticTranscoder_TestRole

func ExampleElasticTranscoder_TestRole() {
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println("failed to create session,", err)
		return
	}

	svc := elastictranscoder.New(sess)

	params := &elastictranscoder.TestRoleInput{
		InputBucket:  aws.String("BucketName"), // Required
		OutputBucket: aws.String("BucketName"), // Required
		Role:         aws.String("Role"),       // Required
		Topics: []*string{ // Required
			aws.String("SnsTopic"), // Required
			// More values...
		},
	}
	resp, err := svc.TestRole(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)
}
開發者ID:acquia,項目名稱:fifo2kinesis,代碼行數:30,代碼來源:examples_test.go

示例5: ExampleElasticTranscoder_ListPresets

func ExampleElasticTranscoder_ListPresets() {
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println("failed to create session,", err)
		return
	}

	svc := elastictranscoder.New(sess)

	params := &elastictranscoder.ListPresetsInput{
		Ascending: aws.String("Ascending"),
		PageToken: aws.String("Id"),
	}
	resp, err := svc.ListPresets(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)
}
開發者ID:acquia,項目名稱:fifo2kinesis,代碼行數:25,代碼來源:examples_test.go

示例6: ExampleElasticTranscoder_UpdatePipelineStatus

func ExampleElasticTranscoder_UpdatePipelineStatus() {
	svc := elastictranscoder.New(nil)

	params := &elastictranscoder.UpdatePipelineStatusInput{
		ID:     aws.String("Id"),             // Required
		Status: aws.String("PipelineStatus"), // Required
	}
	resp, err := svc.UpdatePipelineStatus(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))
}
開發者ID:Talos208,項目名稱:aws-sdk-go,代碼行數:27,代碼來源:examples_test.go

示例7: ExampleElasticTranscoder_ListPresets

func ExampleElasticTranscoder_ListPresets() {
	svc := elastictranscoder.New(nil)

	params := &elastictranscoder.ListPresetsInput{
		Ascending: aws.String("Ascending"),
		PageToken: aws.String("Id"),
	}
	resp, err := svc.ListPresets(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.StringValue(resp))
}
開發者ID:jasonmoo,項目名稱:aws-sdk-go,代碼行數:27,代碼來源:examples_test.go

示例8: ExampleElasticTranscoder_UpdatePipeline

func ExampleElasticTranscoder_UpdatePipeline() {
	svc := elastictranscoder.New(session.New())

	params := &elastictranscoder.UpdatePipelineInput{
		Id:           aws.String("Id"), // Required
		AwsKmsKeyArn: aws.String("KeyArn"),
		ContentConfig: &elastictranscoder.PipelineOutputConfig{
			Bucket: aws.String("BucketName"),
			Permissions: []*elastictranscoder.Permission{
				{ // Required
					Access: []*string{
						aws.String("AccessControl"), // Required
						// More values...
					},
					Grantee:     aws.String("Grantee"),
					GranteeType: aws.String("GranteeType"),
				},
				// More values...
			},
			StorageClass: aws.String("StorageClass"),
		},
		InputBucket: aws.String("BucketName"),
		Name:        aws.String("Name"),
		Notifications: &elastictranscoder.Notifications{
			Completed:   aws.String("SnsTopic"),
			Error:       aws.String("SnsTopic"),
			Progressing: aws.String("SnsTopic"),
			Warning:     aws.String("SnsTopic"),
		},
		Role: aws.String("Role"),
		ThumbnailConfig: &elastictranscoder.PipelineOutputConfig{
			Bucket: aws.String("BucketName"),
			Permissions: []*elastictranscoder.Permission{
				{ // Required
					Access: []*string{
						aws.String("AccessControl"), // Required
						// More values...
					},
					Grantee:     aws.String("Grantee"),
					GranteeType: aws.String("GranteeType"),
				},
				// More values...
			},
			StorageClass: aws.String("StorageClass"),
		},
	}
	resp, err := svc.UpdatePipeline(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)
}
開發者ID:ColourboxDevelopment,項目名稱:aws-sdk-go,代碼行數:58,代碼來源:examples_test.go

示例9: processVideo

func processVideo(src io.Reader, mime string, bucket string) (*url.URL, *url.URL, error) {
	raw, err := ioutil.ReadAll(src)
	if err != nil {
		return nil, nil, err
	}

	data := bytes.NewReader(raw)
	length := int64(data.Len())
	key := fileKey(bucket, 0, 0, "")

	video_bucket := "trunq-video-uploads"

	err = storage.PutReader(video_bucket, key, data, length, mime)
	if err != nil {
		return nil, nil, err
	}

	orig_uri := fileUri(bucket, key)

	svc := elastictranscoder.New(nil) // Use DefaultConfig
	params := &elastictranscoder.CreateJobInput{
		Input: &elastictranscoder.JobInput{
			AspectRatio: aws.String("auto"),
			Container:   aws.String("auto"),
			FrameRate:   aws.String("auto"),
			Interlaced:  aws.String("auto"),
			Key:         aws.String(key),
			Resolution:  aws.String("auto"),
		},
		PipelineID: aws.String("1427912207362-9tmupe"), // Set pipeline ids via ENV?
		Output: &elastictranscoder.CreateJobOutput{
			Key:              aws.String(key + ".mp4"),
			PresetID:         aws.String("1433884957052-6rh021"), // Trunq 720p H.264
			Rotate:           aws.String("auto"),
			ThumbnailPattern: aws.String(key + "{count}-{resolution}"), // Can we add res later?
		},
	}
	_, err = svc.CreateJob(params)

	if err != nil {
		return orig_uri, &url.URL{}, err
	}

	uri := fileUri(bucket, key+".mp4")
	previewUri := fileUri(bucket, key+"00001-1280x720.jpg") // Assume 1280x720 because preset ensures it
	return uri, previewUri, nil
}
開發者ID:danrjohnson,項目名稱:media-proxy,代碼行數:47,代碼來源:handler.go

示例10: ExampleElasticTranscoder_ReadPreset

func ExampleElasticTranscoder_ReadPreset() {
	svc := elastictranscoder.New(session.New())

	params := &elastictranscoder.ReadPresetInput{
		Id: aws.String("Id"), // Required
	}
	resp, err := svc.ReadPreset(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)
}
開發者ID:ColourboxDevelopment,項目名稱:aws-sdk-go,代碼行數:18,代碼來源:examples_test.go

示例11: processAudio

func processAudio(src io.Reader, mime string, bucket string) (*url.URL, *url.URL, error) {
	raw, err := ioutil.ReadAll(src)
	if err != nil {
		return nil, nil, err
	}

	data := bytes.NewReader(raw)
	length := int64(data.Len())
	key := fileKey(bucket, 0, 0, "")

	audio_bucket := "trunq-audio-uploads"

	err = storage.PutReader(audio_bucket, key, data, length, mime)
	if err != nil {
		return nil, nil, err
	}

	orig_uri := fileUri(bucket, key)

	svc := elastictranscoder.New(nil) // Use DefaultConfig
	params := &elastictranscoder.CreateJobInput{
		Input: &elastictranscoder.JobInput{
			AspectRatio: aws.String("auto"),
			Container:   aws.String("auto"),
			FrameRate:   aws.String("auto"),
			Interlaced:  aws.String("auto"),
			Key:         aws.String(key),
			Resolution:  aws.String("auto"),
		},
		PipelineID: aws.String("1427912254873-1sf1w9"), // Set pipeline ids via ENV?
		Output: &elastictranscoder.CreateJobOutput{
			Key:      aws.String(key + ".mp3"),
			PresetID: aws.String("1351620000001-300040"), // 128k MP3
		},
	}
	_, err = svc.CreateJob(params)

	if err != nil {
		return orig_uri, &url.URL{}, err
	}

	uri := fileUri(bucket, key+".mp3")
	return uri, &url.URL{}, nil
}
開發者ID:danrjohnson,項目名稱:media-proxy,代碼行數:44,代碼來源:handler.go

示例12: ExampleElasticTranscoder_ListPipelines

func ExampleElasticTranscoder_ListPipelines() {
	svc := elastictranscoder.New(nil)

	params := &elastictranscoder.ListPipelinesInput{
		Ascending: aws.String("Ascending"),
		PageToken: aws.String("Id"),
	}
	resp, err := svc.ListPipelines(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)
}
開發者ID:jloper3,項目名稱:amazon-ecs-cli,代碼行數:19,代碼來源:examples_test.go

示例13: ExampleElasticTranscoder_ListJobsByStatus

func ExampleElasticTranscoder_ListJobsByStatus() {
	svc := elastictranscoder.New(session.New())

	params := &elastictranscoder.ListJobsByStatusInput{
		Status:    aws.String("JobStatus"), // Required
		Ascending: aws.String("Ascending"),
		PageToken: aws.String("Id"),
	}
	resp, err := svc.ListJobsByStatus(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)
}
開發者ID:ColourboxDevelopment,項目名稱:aws-sdk-go,代碼行數:20,代碼來源:examples_test.go

示例14: Client

// Client configures and returns a fully initialized AWSClient
func (c *Config) Client() (interface{}, error) {
	// Get the auth and region. This can fail if keys/regions were not
	// specified and we're attempting to use the environment.
	var errs []error

	log.Println("[INFO] Building AWS region structure")
	err := c.ValidateRegion()
	if err != nil {
		errs = append(errs, err)
	}

	var client AWSClient
	if len(errs) == 0 {
		// store AWS region in client struct, for region specific operations such as
		// bucket storage in S3
		client.region = c.Region

		log.Println("[INFO] Building AWS auth structure")
		creds := GetCredentials(c.AccessKey, c.SecretKey, c.Token, c.Profile, c.CredsFilename)
		// Call Get to check for credential provider. If nothing found, we'll get an
		// error, and we can present it nicely to the user
		cp, err := creds.Get()
		if err != nil {
			if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "NoCredentialProviders" {
				errs = append(errs, fmt.Errorf(`No valid credential sources found for AWS Provider.
  Please see https://terraform.io/docs/providers/aws/index.html for more information on
  providing credentials for the AWS Provider`))
			} else {
				errs = append(errs, fmt.Errorf("Error loading credentials for AWS Provider: %s", err))
			}
			return nil, &multierror.Error{Errors: errs}
		}

		log.Printf("[INFO] AWS Auth provider used: %q", cp.ProviderName)

		awsConfig := &aws.Config{
			Credentials: creds,
			Region:      aws.String(c.Region),
			MaxRetries:  aws.Int(c.MaxRetries),
			HTTPClient:  cleanhttp.DefaultClient(),
		}

		if logging.IsDebugOrHigher() {
			awsConfig.LogLevel = aws.LogLevel(aws.LogDebugWithHTTPBody)
			awsConfig.Logger = awsLogger{}
		}

		if c.Insecure {
			transport := awsConfig.HTTPClient.Transport.(*http.Transport)
			transport.TLSClientConfig = &tls.Config{
				InsecureSkipVerify: true,
			}
		}

		// Set up base session
		sess := session.New(awsConfig)
		sess.Handlers.Build.PushFrontNamed(addTerraformVersionToUserAgent)

		// Some services exist only in us-east-1, e.g. because they manage
		// resources that can span across multiple regions, or because
		// signature format v4 requires region to be us-east-1 for global
		// endpoints:
		// http://docs.aws.amazon.com/general/latest/gr/sigv4_changes.html
		usEast1Sess := sess.Copy(&aws.Config{Region: aws.String("us-east-1")})

		// Some services have user-configurable endpoints
		awsEc2Sess := sess.Copy(&aws.Config{Endpoint: aws.String(c.Ec2Endpoint)})
		awsElbSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.ElbEndpoint)})
		awsIamSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.IamEndpoint)})
		dynamoSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.DynamoDBEndpoint)})
		kinesisSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.KinesisEndpoint)})

		// These two services need to be set up early so we can check on AccountID
		client.iamconn = iam.New(awsIamSess)
		client.stsconn = sts.New(sess)

		err = c.ValidateCredentials(client.stsconn)
		if err != nil {
			errs = append(errs, err)
			return nil, &multierror.Error{Errors: errs}
		}
		accountId, err := GetAccountId(client.iamconn, client.stsconn, cp.ProviderName)
		if err == nil {
			client.accountid = accountId
		}

		authErr := c.ValidateAccountId(client.accountid)
		if authErr != nil {
			errs = append(errs, authErr)
		}

		client.apigateway = apigateway.New(sess)
		client.autoscalingconn = autoscaling.New(sess)
		client.cfconn = cloudformation.New(sess)
		client.cloudfrontconn = cloudfront.New(sess)
		client.cloudtrailconn = cloudtrail.New(sess)
		client.cloudwatchconn = cloudwatch.New(sess)
		client.cloudwatcheventsconn = cloudwatchevents.New(sess)
		client.cloudwatchlogsconn = cloudwatchlogs.New(sess)
//.........這裏部分代碼省略.........
開發者ID:yonatanp,項目名稱:terraform,代碼行數:101,代碼來源:config.go

示例15: Client

// Client configures and returns a fully initialized AWSClient
func (c *Config) Client() (interface{}, error) {
	// Get the auth and region. This can fail if keys/regions were not
	// specified and we're attempting to use the environment.
	log.Println("[INFO] Building AWS region structure")
	err := c.ValidateRegion()
	if err != nil {
		return nil, err
	}

	var client AWSClient
	// store AWS region in client struct, for region specific operations such as
	// bucket storage in S3
	client.region = c.Region

	log.Println("[INFO] Building AWS auth structure")
	creds, err := GetCredentials(c)
	if err != nil {
		return nil, err
	}
	// Call Get to check for credential provider. If nothing found, we'll get an
	// error, and we can present it nicely to the user
	cp, err := creds.Get()
	if err != nil {
		if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "NoCredentialProviders" {
			return nil, errors.New(`No valid credential sources found for AWS Provider.
  Please see https://terraform.io/docs/providers/aws/index.html for more information on
  providing credentials for the AWS Provider`)
		}

		return nil, fmt.Errorf("Error loading credentials for AWS Provider: %s", err)
	}

	log.Printf("[INFO] AWS Auth provider used: %q", cp.ProviderName)

	awsConfig := &aws.Config{
		Credentials:      creds,
		Region:           aws.String(c.Region),
		MaxRetries:       aws.Int(c.MaxRetries),
		HTTPClient:       cleanhttp.DefaultClient(),
		S3ForcePathStyle: aws.Bool(c.S3ForcePathStyle),
	}

	if logging.IsDebugOrHigher() {
		awsConfig.LogLevel = aws.LogLevel(aws.LogDebugWithHTTPBody)
		awsConfig.Logger = awsLogger{}
	}

	if c.Insecure {
		transport := awsConfig.HTTPClient.Transport.(*http.Transport)
		transport.TLSClientConfig = &tls.Config{
			InsecureSkipVerify: true,
		}
	}

	// Set up base session
	sess, err := session.NewSession(awsConfig)
	if err != nil {
		return nil, errwrap.Wrapf("Error creating AWS session: {{err}}", err)
	}

	// Removes the SDK Version handler, so we only have the provider User-Agent
	// Ex: "User-Agent: APN/1.0 HashiCorp/1.0 Terraform/0.7.9-dev"
	sess.Handlers.Build.Remove(request.NamedHandler{Name: "core.SDKVersionUserAgentHandler"})
	sess.Handlers.Build.PushFrontNamed(addTerraformVersionToUserAgent)

	if extraDebug := os.Getenv("TERRAFORM_AWS_AUTHFAILURE_DEBUG"); extraDebug != "" {
		sess.Handlers.UnmarshalError.PushFrontNamed(debugAuthFailure)
	}

	// Some services exist only in us-east-1, e.g. because they manage
	// resources that can span across multiple regions, or because
	// signature format v4 requires region to be us-east-1 for global
	// endpoints:
	// http://docs.aws.amazon.com/general/latest/gr/sigv4_changes.html
	usEast1Sess := sess.Copy(&aws.Config{Region: aws.String("us-east-1")})

	// Some services have user-configurable endpoints
	awsEc2Sess := sess.Copy(&aws.Config{Endpoint: aws.String(c.Ec2Endpoint)})
	awsElbSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.ElbEndpoint)})
	awsIamSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.IamEndpoint)})
	awsS3Sess := sess.Copy(&aws.Config{Endpoint: aws.String(c.S3Endpoint)})
	dynamoSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.DynamoDBEndpoint)})
	kinesisSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.KinesisEndpoint)})

	// These two services need to be set up early so we can check on AccountID
	client.iamconn = iam.New(awsIamSess)
	client.stsconn = sts.New(sess)

	if !c.SkipCredsValidation {
		err = c.ValidateCredentials(client.stsconn)
		if err != nil {
			return nil, err
		}
	}

	if !c.SkipRequestingAccountId {
		partition, accountId, err := GetAccountInfo(client.iamconn, client.stsconn, cp.ProviderName)
		if err == nil {
			client.partition = partition
//.........這裏部分代碼省略.........
開發者ID:hooklift,項目名稱:terraform,代碼行數:101,代碼來源:config.go


注:本文中的github.com/aws/aws-sdk-go/service/elastictranscoder.New函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。