當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。