本文整理汇总了Golang中github.com/convox/kernel/Godeps/_workspace/src/github.com/awslabs/aws-sdk-go/aws.Boolean函数的典型用法代码示例。如果您正苦于以下问题:Golang Boolean函数的具体用法?Golang Boolean怎么用?Golang Boolean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Boolean函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ExampleCloudFormation_CreateStack
func ExampleCloudFormation_CreateStack() {
svc := cloudformation.New(nil)
params := &cloudformation.CreateStackInput{
StackName: aws.String("StackName"), // Required
Capabilities: []*string{
aws.String("Capability"), // Required
// More values...
},
DisableRollback: aws.Boolean(true),
NotificationARNs: []*string{
aws.String("NotificationARN"), // Required
// More values...
},
OnFailure: aws.String("OnFailure"),
Parameters: []*cloudformation.Parameter{
&cloudformation.Parameter{ // Required
ParameterKey: aws.String("ParameterKey"),
ParameterValue: aws.String("ParameterValue"),
UsePreviousValue: aws.Boolean(true),
},
// More values...
},
StackPolicyBody: aws.String("StackPolicyBody"),
StackPolicyURL: aws.String("StackPolicyURL"),
Tags: []*cloudformation.Tag{
&cloudformation.Tag{ // Required
Key: aws.String("TagKey"),
Value: aws.String("TagValue"),
},
// More values...
},
TemplateBody: aws.String("TemplateBody"),
TemplateURL: aws.String("TemplateURL"),
TimeoutInMinutes: aws.Long(1),
}
resp, err := svc.CreateStack(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 alwsy return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例2: ListChanges
func ListChanges(app string) (Changes, error) {
req := &dynamodb.QueryInput{
KeyConditions: &map[string]*dynamodb.Condition{
"app": &dynamodb.Condition{
AttributeValueList: []*dynamodb.AttributeValue{
&dynamodb.AttributeValue{S: aws.String(app)},
},
ComparisonOperator: aws.String("EQ"),
},
},
Limit: aws.Long(10),
ScanIndexForward: aws.Boolean(false),
TableName: aws.String(changesTable(app)),
}
res, err := DynamoDB().Query(req)
if err != nil {
return nil, err
}
changes := make(Changes, len(res.Items))
for i, item := range res.Items {
changes[i] = *changeFromItem(*item)
}
return changes, nil
}
示例3: ExampleLambda_CreateEventSourceMapping
func ExampleLambda_CreateEventSourceMapping() {
svc := lambda.New(nil)
params := &lambda.CreateEventSourceMappingInput{
EventSourceARN: aws.String("Arn"), // Required
FunctionName: aws.String("FunctionName"), // Required
StartingPosition: aws.String("EventSourcePosition"), // Required
BatchSize: aws.Long(1),
Enabled: aws.Boolean(true),
}
resp, err := svc.CreateEventSourceMapping(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 alwsy return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例4: ExampleECS_DeregisterContainerInstance
func ExampleECS_DeregisterContainerInstance() {
svc := ecs.New(nil)
params := &ecs.DeregisterContainerInstanceInput{
ContainerInstance: aws.String("String"), // Required
Cluster: aws.String("String"),
Force: aws.Boolean(true),
}
resp, err := svc.DeregisterContainerInstance(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 alwsy return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例5: ExampleCloudFormation_EstimateTemplateCost
func ExampleCloudFormation_EstimateTemplateCost() {
svc := cloudformation.New(nil)
params := &cloudformation.EstimateTemplateCostInput{
Parameters: []*cloudformation.Parameter{
&cloudformation.Parameter{ // Required
ParameterKey: aws.String("ParameterKey"),
ParameterValue: aws.String("ParameterValue"),
UsePreviousValue: aws.Boolean(true),
},
// More values...
},
TemplateBody: aws.String("TemplateBody"),
TemplateURL: aws.String("TemplateURL"),
}
resp, err := svc.EstimateTemplateCost(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 alwsy return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例6: TestPaginationTruncation
// Use S3 for simplicity
func TestPaginationTruncation(t *testing.T) {
count := 0
client := s3.New(nil)
reqNum := &count
resps := []*s3.ListObjectsOutput{
&s3.ListObjectsOutput{IsTruncated: aws.Boolean(true), Contents: []*s3.Object{&s3.Object{Key: aws.String("Key1")}}},
&s3.ListObjectsOutput{IsTruncated: aws.Boolean(true), Contents: []*s3.Object{&s3.Object{Key: aws.String("Key2")}}},
&s3.ListObjectsOutput{IsTruncated: aws.Boolean(false), Contents: []*s3.Object{&s3.Object{Key: aws.String("Key3")}}},
&s3.ListObjectsOutput{IsTruncated: aws.Boolean(true), Contents: []*s3.Object{&s3.Object{Key: aws.String("Key4")}}},
}
client.Handlers.Send.Clear() // mock sending
client.Handlers.Unmarshal.Clear()
client.Handlers.UnmarshalMeta.Clear()
client.Handlers.ValidateResponse.Clear()
client.Handlers.Unmarshal.PushBack(func(r *aws.Request) {
r.Data = resps[*reqNum]
*reqNum++
})
params := &s3.ListObjectsInput{Bucket: aws.String("bucket")}
results := []string{}
err := client.ListObjectsPages(params, func(p *s3.ListObjectsOutput, last bool) bool {
results = append(results, *p.Contents[0].Key)
return true
})
assert.Equal(t, []string{"Key1", "Key2", "Key3"}, results)
assert.Nil(t, err)
// Try again without truncation token at all
count = 0
resps[1].IsTruncated = nil
resps[2].IsTruncated = aws.Boolean(true)
results = []string{}
err = client.ListObjectsPages(params, func(p *s3.ListObjectsOutput, last bool) bool {
results = append(results, *p.Contents[0].Key)
return true
})
assert.Equal(t, []string{"Key1", "Key2"}, results)
assert.Nil(t, err)
}
示例7: ExampleCloudWatch_PutMetricAlarm
func ExampleCloudWatch_PutMetricAlarm() {
svc := cloudwatch.New(nil)
params := &cloudwatch.PutMetricAlarmInput{
AlarmName: aws.String("AlarmName"), // Required
ComparisonOperator: aws.String("ComparisonOperator"), // Required
EvaluationPeriods: aws.Long(1), // Required
MetricName: aws.String("MetricName"), // Required
Namespace: aws.String("Namespace"), // Required
Period: aws.Long(1), // Required
Statistic: aws.String("Statistic"), // Required
Threshold: aws.Double(1.0), // Required
ActionsEnabled: aws.Boolean(true),
AlarmActions: []*string{
aws.String("ResourceName"), // Required
// More values...
},
AlarmDescription: aws.String("AlarmDescription"),
Dimensions: []*cloudwatch.Dimension{
&cloudwatch.Dimension{ // Required
Name: aws.String("DimensionName"), // Required
Value: aws.String("DimensionValue"), // Required
},
// More values...
},
InsufficientDataActions: []*string{
aws.String("ResourceName"), // Required
// More values...
},
OKActions: []*string{
aws.String("ResourceName"), // Required
// More values...
},
Unit: aws.String("StandardUnit"),
}
resp, err := svc.PutMetricAlarm(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 alwsy return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例8: TestNoErrors
func TestNoErrors(t *testing.T) {
input := &StructShape{
RequiredList: []*ConditionalStructShape{},
RequiredMap: &map[string]*ConditionalStructShape{
"key1": &ConditionalStructShape{Name: aws.String("Name")},
"key2": &ConditionalStructShape{Name: aws.String("Name")},
},
RequiredBool: aws.Boolean(true),
OptionalStruct: &ConditionalStructShape{Name: aws.String("Name")},
}
req := aws.NewRequest(service, &aws.Operation{}, input, nil)
aws.ValidateParameters(req)
assert.NoError(t, req.Error)
}
示例9: GetBuild
func GetBuild(app, id string) (*Build, error) {
req := &dynamodb.GetItemInput{
ConsistentRead: aws.Boolean(true),
Key: &map[string]*dynamodb.AttributeValue{
"id": &dynamodb.AttributeValue{S: aws.String(id)},
},
TableName: aws.String(buildsTable(app)),
}
res, err := DynamoDB().GetItem(req)
if err != nil {
return nil, err
}
build := buildFromItem(*res.Item)
return build, nil
}
示例10: TestNestedMissingRequiredParameters
func TestNestedMissingRequiredParameters(t *testing.T) {
input := &StructShape{
RequiredList: []*ConditionalStructShape{&ConditionalStructShape{}},
RequiredMap: &map[string]*ConditionalStructShape{
"key1": &ConditionalStructShape{Name: aws.String("Name")},
"key2": &ConditionalStructShape{},
},
RequiredBool: aws.Boolean(true),
OptionalStruct: &ConditionalStructShape{},
}
req := aws.NewRequest(service, &aws.Operation{}, input, nil)
aws.ValidateParameters(req)
assert.Error(t, req.Error)
assert.Equal(t, "InvalidParameter", req.Error.(awserr.Error).Code())
assert.Equal(t, "3 validation errors:\n- missing required parameter: RequiredList[0].Name\n- missing required parameter: RequiredMap[\"key2\"].Name\n- missing required parameter: OptionalStruct.Name", req.Error.(awserr.Error).Message())
}
示例11: ListReleases
func ListReleases(app string, last map[string]string) (Releases, error) {
req := &dynamodb.QueryInput{
KeyConditions: &map[string]*dynamodb.Condition{
"app": &dynamodb.Condition{
AttributeValueList: []*dynamodb.AttributeValue{
&dynamodb.AttributeValue{S: aws.String(app)},
},
ComparisonOperator: aws.String("EQ"),
},
},
IndexName: aws.String("app.created"),
Limit: aws.Long(10),
ScanIndexForward: aws.Boolean(false),
TableName: aws.String(releasesTable(app)),
}
if last["id"] != "" {
req.ExclusiveStartKey = &map[string]*dynamodb.AttributeValue{
"app": &dynamodb.AttributeValue{S: aws.String(app)},
"id": &dynamodb.AttributeValue{S: aws.String(last["id"])},
"created": &dynamodb.AttributeValue{S: aws.String(last["created"])},
}
}
res, err := DynamoDB().Query(req)
if err != nil {
return nil, err
}
releases := make(Releases, len(res.Items))
for i, item := range res.Items {
releases[i] = *releaseFromItem(*item)
}
return releases, nil
}
示例12: GetRelease
func GetRelease(app, id string) (*Release, error) {
req := &dynamodb.GetItemInput{
ConsistentRead: aws.Boolean(true),
Key: &map[string]*dynamodb.AttributeValue{
"id": &dynamodb.AttributeValue{S: aws.String(id)},
},
TableName: aws.String(releasesTable(app)),
}
res, err := DynamoDB().GetItem(req)
if err != nil {
return nil, err
}
if res.Item == nil {
return nil, fmt.Errorf("release %s not found", id)
}
release := releaseFromItem(*res.Item)
return release, nil
}
示例13: UpdateParams
func (a *App) UpdateParams(changes map[string]string) error {
req := &cloudformation.UpdateStackInput{
StackName: aws.String(a.Name),
UsePreviousTemplate: aws.Boolean(true),
Capabilities: []*string{aws.String("CAPABILITY_IAM")},
}
params := a.Parameters
for key, val := range changes {
params[key] = val
}
for key, val := range params {
req.Parameters = append(req.Parameters, &cloudformation.Parameter{
ParameterKey: aws.String(key),
ParameterValue: aws.String(val),
})
}
_, err := CloudFormation().UpdateStack(req)
return err
}
示例14: ExampleECS_RegisterTaskDefinition
func ExampleECS_RegisterTaskDefinition() {
svc := ecs.New(nil)
params := &ecs.RegisterTaskDefinitionInput{
ContainerDefinitions: []*ecs.ContainerDefinition{ // Required
&ecs.ContainerDefinition{ // Required
CPU: aws.Long(1),
Command: []*string{
aws.String("String"), // Required
// More values...
},
EntryPoint: []*string{
aws.String("String"), // Required
// More values...
},
Environment: []*ecs.KeyValuePair{
&ecs.KeyValuePair{ // Required
Name: aws.String("String"),
Value: aws.String("String"),
},
// More values...
},
Essential: aws.Boolean(true),
Image: aws.String("String"),
Links: []*string{
aws.String("String"), // Required
// More values...
},
Memory: aws.Long(1),
MountPoints: []*ecs.MountPoint{
&ecs.MountPoint{ // Required
ContainerPath: aws.String("String"),
ReadOnly: aws.Boolean(true),
SourceVolume: aws.String("String"),
},
// More values...
},
Name: aws.String("String"),
PortMappings: []*ecs.PortMapping{
&ecs.PortMapping{ // Required
ContainerPort: aws.Long(1),
HostPort: aws.Long(1),
},
// More values...
},
VolumesFrom: []*ecs.VolumeFrom{
&ecs.VolumeFrom{ // Required
ReadOnly: aws.Boolean(true),
SourceContainer: aws.String("String"),
},
// More values...
},
},
// More values...
},
Family: aws.String("String"), // Required
Volumes: []*ecs.Volume{
&ecs.Volume{ // Required
Host: &ecs.HostVolumeProperties{
SourcePath: aws.String("String"),
},
Name: aws.String("String"),
},
// More values...
},
}
resp, err := svc.RegisterTaskDefinition(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 alwsy return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例15: startClusterMonitor
//.........这里部分代码省略.........
if *p.ParameterKey == "InstanceCount" {
c, err := strconv.Atoi(*p.ParameterValue)
if err != nil {
log.Error(err)
break Tick
}
instanceCount = c
break
}
}
// List and Describe ECS Container Instances
ires, err := models.ECS().ListContainerInstances(
&ecs.ListContainerInstancesInput{
Cluster: aws.String(os.Getenv("CLUSTER")),
},
)
if err != nil {
log.Error(err)
continue
}
dres, err := models.ECS().DescribeContainerInstances(
&ecs.DescribeContainerInstancesInput{
Cluster: aws.String(os.Getenv("CLUSTER")),
ContainerInstances: ires.ContainerInstanceARNs,
},
)
if err != nil {
log.Error(err)
continue
}
cInstanceIds := make([]string, 0)
cInstanceConnections := make(map[string]bool)
for _, i := range dres.ContainerInstances {
cInstanceConnections[*i.EC2InstanceID] = *i.AgentConnected
if *i.AgentConnected {
cInstanceIds = append(cInstanceIds, *i.EC2InstanceID)
}
}
// Get and Describe Rack ASG Resource
resources, err := models.ListResources(os.Getenv("RACK"))
ares, err := models.AutoScaling().DescribeAutoScalingGroups(
&autoscaling.DescribeAutoScalingGroupsInput{
AutoScalingGroupNames: []*string{
aws.String(resources["Instances"].Id),
},
},
)
if err != nil {
log.Error(err)
continue
}
// Test if ASG Instance is registered and connected in ECS cluster
aInstanceIds := []string{}
uInstanceIds := []string{}
for _, i := range ares.AutoScalingGroups[0].Instances {
if connected, exists := cInstanceConnections[*i.InstanceID]; connected && exists {
aInstanceIds = append(aInstanceIds, *i.InstanceID)
} else {
// Not registered or not connected => set Unhealthy
if *i.LifecycleState == "InService" {
_, err := models.AutoScaling().SetInstanceHealth(
&autoscaling.SetInstanceHealthInput{
HealthStatus: aws.String("Unhealthy"),
InstanceID: aws.String(*i.InstanceID),
ShouldRespectGracePeriod: aws.Boolean(true),
},
)
if err != nil {
log.Error(err)
continue
}
uInstanceIds = append(uInstanceIds, *i.InstanceID)
}
}
}
sort.Strings(aInstanceIds)
sort.Strings(cInstanceIds)
sort.Strings(uInstanceIds)
log.Log("InstanceCount=%v connected='%v' healthy='%v' marked='%s'", instanceCount, strings.Join(cInstanceIds, ","), strings.Join(aInstanceIds, ","), strings.Join(uInstanceIds, ","))
}
}