当前位置: 首页>>代码示例>>Golang>>正文


Golang glacier.Glacier类代码示例

本文整理汇总了Golang中github.com/aws/aws-sdk-go/service/glacier.Glacier的典型用法代码示例。如果您正苦于以下问题:Golang Glacier类的具体用法?Golang Glacier怎么用?Golang Glacier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Glacier类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: resourceAwsGlacierVaultPolicyUpdate

func resourceAwsGlacierVaultPolicyUpdate(glacierconn *glacier.Glacier, d *schema.ResourceData) error {
	vaultName := d.Id()
	policyContents := d.Get("access_policy").(string)

	policy := &glacier.VaultAccessPolicy{
		Policy: aws.String(policyContents),
	}

	if policyContents != "" {
		log.Printf("[DEBUG] Glacier Vault: %s, put policy", vaultName)

		_, err := glacierconn.SetVaultAccessPolicy(&glacier.SetVaultAccessPolicyInput{
			VaultName: aws.String(d.Id()),
			Policy:    policy,
		})

		if err != nil {
			return fmt.Errorf("Error putting Glacier Vault policy: %s", err.Error())
		}
	} else {
		log.Printf("[DEBUG] Glacier Vault: %s, delete policy: %s", vaultName, policy)
		_, err := glacierconn.DeleteVaultAccessPolicy(&glacier.DeleteVaultAccessPolicyInput{
			VaultName: aws.String(d.Id()),
		})

		if err != nil {
			return fmt.Errorf("Error deleting Glacier Vault policy: %s", err.Error())
		}
	}

	return nil
}
开发者ID:AssertSelenium,项目名称:terraform,代码行数:32,代码来源:resource_aws_glacier_vault.go

示例2: DescribeJob

func DescribeJob(glacierClient *glacier.Glacier, name string, jobID string) (*glacier.JobDescription, error) {
	log.Printf("[DEBUG] Call Describe Job from Glacier vault : %s %s",
		name, jobID)
	return glacierClient.DescribeJob(&glacier.DescribeJobInput{
		VaultName: aws.String(name),
		JobId:     aws.String(jobID),
	})
}
开发者ID:nlamirault,项目名称:aneto,代码行数:8,代码来源:glacier.go

示例3: DeleteArchive

func DeleteArchive(glacierClient *glacier.Glacier, name string,
	archiveID string) (*glacier.DeleteArchiveOutput, error) {
	log.Printf("[DEBUG] Call Delete archive from Glacier vault : %s %s",
		name, archiveID)
	return glacierClient.DeleteArchive(&glacier.DeleteArchiveInput{
		VaultName: aws.String(name),
		ArchiveId: aws.String(archiveID),
	})
}
开发者ID:nlamirault,项目名称:aneto,代码行数:9,代码来源:glacier.go

示例4: UploadArchive

func UploadArchive(glacierClient *glacier.Glacier, name string, archive []byte,
	description string) (*glacier.ArchiveCreationOutput, error) {
	log.Printf("[DEBUG] Call Upload archive to Glacier vault : %s", name)
	return glacierClient.UploadArchive(&glacier.UploadArchiveInput{
		VaultName:          aws.String(name),
		ArchiveDescription: aws.String(description),
		Body:               bytes.NewReader(archive),
	})
}
开发者ID:nlamirault,项目名称:aneto,代码行数:9,代码来源:glacier.go

示例5: DisplayVault

func DisplayVault(glacierClient *glacier.Glacier, name string) (*glacier.InitiateJobOutput, error) {
	log.Printf("[DEBUG] Call Display Glacier vault : %s", name)
	params := &glacier.InitiateJobInput{
		VaultName: aws.String(name),
		JobParameters: &glacier.JobParameters{
			InventoryRetrievalParameters: &glacier.InventoryRetrievalJobInput{},
			Type: aws.String("inventory-retrieval"),
		},
	}
	return glacierClient.InitiateJob(params)
}
开发者ID:nlamirault,项目名称:aneto,代码行数:11,代码来源:glacier.go

示例6: getGlacierVaultTags

func getGlacierVaultTags(glacierconn *glacier.Glacier, vaultName string) (map[string]string, error) {
	request := &glacier.ListTagsForVaultInput{
		VaultName: aws.String(vaultName),
	}

	log.Printf("[DEBUG] Getting the tags: for %s", vaultName)
	response, err := glacierconn.ListTagsForVault(request)
	if awserr, ok := err.(awserr.Error); ok && awserr.Code() == "NoSuchTagSet" {
		return map[string]string{}, nil
	} else if err != nil {
		return nil, err
	}

	return glacierVaultTagsToMap(response.Tags), nil
}
开发者ID:AssertSelenium,项目名称:terraform,代码行数:15,代码来源:resource_aws_glacier_vault.go

示例7: getGlacierVaultNotification

func getGlacierVaultNotification(glacierconn *glacier.Glacier, vaultName string) ([]map[string]interface{}, error) {
	request := &glacier.GetVaultNotificationsInput{
		VaultName: aws.String(vaultName),
	}

	response, err := glacierconn.GetVaultNotifications(request)
	if err != nil {
		return nil, fmt.Errorf("Error reading Glacier Vault Notifications: %s", err.Error())
	}

	notifications := make(map[string]interface{}, 0)

	log.Print("[DEBUG] Flattening Glacier Vault Notifications")

	notifications["events"] = schema.NewSet(schema.HashString, glacierPointersToStringList(response.VaultNotificationConfig.Events))
	notifications["sns_topic"] = *response.VaultNotificationConfig.SNSTopic

	return []map[string]interface{}{notifications}, nil
}
开发者ID:AssertSelenium,项目名称:terraform,代码行数:19,代码来源:resource_aws_glacier_vault.go

示例8: resourceAwsGlacierVaultNotificationUpdate

func resourceAwsGlacierVaultNotificationUpdate(glacierconn *glacier.Glacier, d *schema.ResourceData) error {

	if v, ok := d.GetOk("notification"); ok {
		settings := v.([]interface{})

		if len(settings) > 1 {
			return fmt.Errorf("Only a single Notification Block is allowed for Glacier Vault")
		} else if len(settings) == 1 {
			s := settings[0].(map[string]interface{})
			var events []*string
			for _, id := range s["events"].(*schema.Set).List() {
				events = append(events, aws.String(id.(string)))
			}

			_, err := glacierconn.SetVaultNotifications(&glacier.SetVaultNotificationsInput{
				VaultName: aws.String(d.Id()),
				VaultNotificationConfig: &glacier.VaultNotificationConfig{
					SNSTopic: aws.String(s["sns_topic"].(string)),
					Events:   events,
				},
			})

			if err != nil {
				return fmt.Errorf("Error Updating Glacier Vault Notifications: %s", err.Error())
			}
		}
	} else {
		_, err := glacierconn.DeleteVaultNotifications(&glacier.DeleteVaultNotificationsInput{
			VaultName: aws.String(d.Id()),
		})

		if err != nil {
			return fmt.Errorf("Error Removing Glacier Vault Notifications: %s", err.Error())
		}

	}

	return nil
}
开发者ID:AssertSelenium,项目名称:terraform,代码行数:39,代码来源:resource_aws_glacier_vault.go

示例9: setGlacierVaultTags

func setGlacierVaultTags(conn *glacier.Glacier, d *schema.ResourceData) error {
	if d.HasChange("tags") {
		oraw, nraw := d.GetChange("tags")
		o := oraw.(map[string]interface{})
		n := nraw.(map[string]interface{})
		create, remove := diffGlacierVaultTags(mapGlacierVaultTags(o), mapGlacierVaultTags(n))

		// Set tags
		if len(remove) > 0 {
			tagsToRemove := &glacier.RemoveTagsFromVaultInput{
				VaultName: aws.String(d.Id()),
				TagKeys:   glacierStringsToPointyString(remove),
			}

			log.Printf("[DEBUG] Removing tags: from %s", d.Id())
			_, err := conn.RemoveTagsFromVault(tagsToRemove)
			if err != nil {
				return err
			}
		}
		if len(create) > 0 {
			tagsToAdd := &glacier.AddTagsToVaultInput{
				VaultName: aws.String(d.Id()),
				Tags:      glacierVaultTagsFromMap(create),
			}

			log.Printf("[DEBUG] Creating tags: for %s", d.Id())
			_, err := conn.AddTagsToVault(tagsToAdd)
			if err != nil {
				return err
			}
		}
	}

	return nil
}
开发者ID:AssertSelenium,项目名称:terraform,代码行数:36,代码来源:resource_aws_glacier_vault.go

示例10: DeleteVault

func DeleteVault(glacierClient *glacier.Glacier, name string) (*glacier.DeleteVaultOutput, error) {
	log.Printf("[DEBUG] Call Delete Glacier vault : %s", name)
	return glacierClient.DeleteVault(&glacier.DeleteVaultInput{
		VaultName: aws.String(name),
	})
}
开发者ID:nlamirault,项目名称:aneto,代码行数:6,代码来源:glacier.go

示例11: ListVaults

func ListVaults(glacierClient *glacier.Glacier) (*glacier.ListVaultsOutput, error) {
	log.Printf("[DEBUG] List Glacier vaults")
	return glacierClient.ListVaults(&glacier.ListVaultsInput{})
}
开发者ID:nlamirault,项目名称:aneto,代码行数:4,代码来源:glacier.go


注:本文中的github.com/aws/aws-sdk-go/service/glacier.Glacier类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。