<commit_before>package aws

import (
	"github.com/hashicorp/terraform/helper/schema"
	"github.com/aws/aws-sdk-go/service/guardduty"
	"fmt"
	"github.com/aws/aws-sdk-go/aws"
	"log"
)

func resourceAwsGuardDutyInvite() *schema.Resource {
	return &schema.Resource{
		Create: resourceAwsGuardDutyInviteCreate,
		Read: resourceAwsGuardDutyInviteRead,
		Delete: resourceAwsGuardDutyInviteDelete,

		Importer: &schema.ResourceImporter{
			State: schema.ImportStatePassthrough,
		},

		Schema: map[string]*schema.Schema{
			"detector_id": {
				Type:     schema.TypeString,
				Required: true,
				ForceNew: true,
			},
			"account_ids": {
				Type:     schema.TypeList,
				Required: true,
				ForceNew: true,
			},
			"message": {
				Type:         schema.TypeString,
				Required:     false,
			},
			"unprocessed_accounts": {
				Type:     schema.TypeMap,
				Computed: true,
			},
		},
	}
}

func resourceAwsGuardDutyInviteCreate(d* schema.ResourceData, meta interface{}) error {
	conn := meta.(*AWSClient).guarddutyconn
	detectorId := d.Get("detector_id").(string)
	accountIds := d.Get("account_ids").([]string)

	params := &guardduty.InviteMembersInput{
		DetectorId: aws.String(detectorId),
		AccountIds: aws.StringSlice(accountIds),
		Message: aws.String(d.Get("message").(string)),
	}

	log.Printf("[DEBUG] GuardDuty Invite Members: %#v", params)
	resp, err := conn.InviteMembers(params)

	if err != nil {
		return fmt.Errorf("Inviting GuardDuty Member failed: %s", err)
	}


	unprocessedAccounts := make(map[string]string, len(resp.UnprocessedAccounts))
	for _, unprocessedAccount := range resp.UnprocessedAccounts {
		unprocessedAccounts[*unprocessedAccount.AccountId] = *unprocessedAccount.Result
	}

	d.SetId(detectorId)
	d.Set("unprocessed_accounts", unprocessedAccounts)

	return nil
}

func resourceAwsGuardDutyInviteRead(d *schema.ResourceData, meta interface{}) error {
	//TODO Do something?
	return nil
}

func resourceAwsGuardDutyInviteDelete(d* schema.ResourceData, meta interface{}) error {
	d.SetId("")
	return nil
}<commit_msg>add deleting method<commit_after>package aws

import (
	"github.com/hashicorp/terraform/helper/schema"
	"github.com/aws/aws-sdk-go/service/guardduty"
	"fmt"
	"github.com/aws/aws-sdk-go/aws"
	"log"
)

func resourceAwsGuardDutyInvite() *schema.Resource {
	return &schema.Resource{
		Create: resourceAwsGuardDutyInviteCreate,
		Read: resourceAwsGuardDutyInviteRead,
		Delete: resourceAwsGuardDutyInviteDelete,

		Importer: &schema.ResourceImporter{
			State: schema.ImportStatePassthrough,
		},

		Schema: map[string]*schema.Schema{
			"detector_id": {
				Type:     schema.TypeString,
				Required: true,
				ForceNew: true,
			},
			"account_ids": {
				Type:     schema.TypeList,
				Required: true,
				ForceNew: true,
			},
			"message": {
				Type:         schema.TypeString,
				Required:     false,
			},
			"unprocessed_accounts": {
				Type:     schema.TypeMap,
				Computed: true,
			},
		},
	}
}

func resourceAwsGuardDutyInviteCreate(d* schema.ResourceData, meta interface{}) error {
	conn := meta.(*AWSClient).guarddutyconn
	detectorId := d.Get("detector_id").(string)
	accountIds := d.Get("account_ids").([]string)

	params := &guardduty.InviteMembersInput{
		DetectorId: aws.String(detectorId),
		AccountIds: aws.StringSlice(accountIds),
		Message: aws.String(d.Get("message").(string)),
	}

	log.Printf("[DEBUG] GuardDuty Invite Members: %#v", params)
	resp, err := conn.InviteMembers(params)

	if err != nil {
		return fmt.Errorf("Inviting GuardDuty Member failed: %s", err)
	}

	unprocessedAccounts := make(map[string]string, len(resp.UnprocessedAccounts))
	for _, unprocessedAccount := range resp.UnprocessedAccounts {
		unprocessedAccounts[*unprocessedAccount.AccountId] = *unprocessedAccount.Result
	}

	d.SetId(detectorId)
	d.Set("unprocessed_accounts", unprocessedAccounts)

	return nil
}

func resourceAwsGuardDutyInviteRead(d *schema.ResourceData, meta interface{}) error {
	//TODO Do something?
	return nil
}

func resourceAwsGuardDutyInviteDelete(d* schema.ResourceData, meta interface{}) error {
	conn := meta.(*AWSClient).guarddutyconn

	params := &guardduty.DeleteInvitationsInput{
		AccountIds: aws.StringSlice(d.Get("account_ids").([]string),
	}

	log.Printf("[DEBUG] GuardDuty Delete Invitations: %#v", params)
	_, err := conn.DeleteInvitations(params)

	if err != nil {
		return fmt.Errorf("Deleting GuardDuty Invitations '%s' failed: %s", d.Id(), err.Error())
	}

	return nil
}
{'fraction_non_alphanumeric': 0.1340669211767348, 'fraction_numerical': 0.0, 'mean_word_length': 4.630847029077118, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3814043', 'n_tokens_mistral': 1687, 'n_tokens_neox': 1526, 'n_words': 271}