From 7efe5bcb04a3e49ea4887c8df759dfacb4d2141f Mon Sep 17 00:00:00 2001 From: childish-sambino Date: Tue, 15 Jun 2021 11:04:31 -0500 Subject: [PATCH] fix: correct the 'create' function resource IDs (#29) --- twilio/resources/api/v2010/api_default.go | 100 ---------------------- twilio/resources/events/v1/api_default.go | 2 +- twilio/resources/sync/v1/api_default.go | 4 +- twilio/resources/verify/v2/api_default.go | 2 +- 4 files changed, 4 insertions(+), 104 deletions(-) diff --git a/twilio/resources/api/v2010/api_default.go b/twilio/resources/api/v2010/api_default.go index 712c514..3bf1f8e 100644 --- a/twilio/resources/api/v2010/api_default.go +++ b/twilio/resources/api/v2010/api_default.go @@ -1814,103 +1814,3 @@ func updateAccountsUsageTriggers(ctx context.Context, d *schema.ResourceData, m } return nil } - -func ResourceAccountsOutgoingCallerIds() *schema.Resource { - return &schema.Resource{ - CreateContext: createAccountsOutgoingCallerIds, - ReadContext: readAccountsOutgoingCallerIds, - UpdateContext: updateAccountsOutgoingCallerIds, - DeleteContext: deleteAccountsOutgoingCallerIds, - Schema: map[string]*schema.Schema{ - "path_account_sid": AsString(SchemaOptional), - "call_delay": AsString(SchemaOptional), - "extension": AsString(SchemaOptional), - "friendly_name": AsString(SchemaOptional), - "phone_number": AsString(SchemaOptional), - "status_callback": AsString(SchemaOptional), - "status_callback_method": AsString(SchemaOptional), - "account_sid": AsString(SchemaComputed), - "call_sid": AsString(SchemaComputed), - "validation_code": AsString(SchemaComputed), - }, - } -} - -func createAccountsOutgoingCallerIds(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - params := CreateValidationRequestParams{} - if err := UnmarshalSchema(¶ms, d); err != nil { - return diag.FromErr(err) - } - - r, err := m.(*client.Config).Client.ApiV2010.CreateValidationRequest(¶ms) - if err != nil { - return diag.FromErr(err) - } - - d.SetId(*r.Sid) - err = MarshalSchema(d, r) - - if err != nil { - return diag.FromErr(err) - } - return nil -} - -func deleteAccountsOutgoingCallerIds(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - params := DeleteOutgoingCallerIdParams{} - if err := UnmarshalSchema(¶ms, d); err != nil { - return diag.FromErr(err) - } - - sid := d.Get("sid").(string) - - err := m.(*client.Config).Client.ApiV2010.DeleteOutgoingCallerId(sid, ¶ms) - d.SetId("") - - if err != nil { - return diag.FromErr(err) - } - return nil -} - -func readAccountsOutgoingCallerIds(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - params := FetchOutgoingCallerIdParams{} - if err := UnmarshalSchema(¶ms, d); err != nil { - return diag.FromErr(err) - } - - sid := d.Get("sid").(string) - - r, err := m.(*client.Config).Client.ApiV2010.FetchOutgoingCallerId(sid, ¶ms) - if err != nil { - return diag.FromErr(err) - } - - err = MarshalSchema(d, r) - - if err != nil { - return diag.FromErr(err) - } - return nil -} - -func updateAccountsOutgoingCallerIds(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - params := UpdateOutgoingCallerIdParams{} - if err := UnmarshalSchema(¶ms, d); err != nil { - return diag.FromErr(err) - } - - sid := d.Get("sid").(string) - - r, err := m.(*client.Config).Client.ApiV2010.UpdateOutgoingCallerId(sid, ¶ms) - if err != nil { - return diag.FromErr(err) - } - - err = MarshalSchema(d, r) - - if err != nil { - return diag.FromErr(err) - } - return nil -} diff --git a/twilio/resources/events/v1/api_default.go b/twilio/resources/events/v1/api_default.go index 3bf8b22..acd0d66 100644 --- a/twilio/resources/events/v1/api_default.go +++ b/twilio/resources/events/v1/api_default.go @@ -141,7 +141,7 @@ func createSubscriptionsSubscribedEvents(ctx context.Context, d *schema.Resource return diag.FromErr(err) } - d.SetId(*r.Sid) + d.SetId(*r.Type) err = MarshalSchema(d, r) if err != nil { diff --git a/twilio/resources/sync/v1/api_default.go b/twilio/resources/sync/v1/api_default.go index 7cb901a..5984b26 100644 --- a/twilio/resources/sync/v1/api_default.go +++ b/twilio/resources/sync/v1/api_default.go @@ -356,7 +356,7 @@ func createServicesListsItems(ctx context.Context, d *schema.ResourceData, m int return diag.FromErr(err) } - d.SetId(*r.Sid) + d.SetId(*r.Index) err = MarshalSchema(d, r) if err != nil { @@ -565,7 +565,7 @@ func createServicesMapsItems(ctx context.Context, d *schema.ResourceData, m inte return diag.FromErr(err) } - d.SetId(*r.Sid) + d.SetId(*r.Key) err = MarshalSchema(d, r) if err != nil { diff --git a/twilio/resources/verify/v2/api_default.go b/twilio/resources/verify/v2/api_default.go index e54d24d..dcd89f8 100644 --- a/twilio/resources/verify/v2/api_default.go +++ b/twilio/resources/verify/v2/api_default.go @@ -152,7 +152,7 @@ func createServicesMessagingConfigurations(ctx context.Context, d *schema.Resour return diag.FromErr(err) } - d.SetId(*r.Sid) + d.SetId(*r.Country) err = MarshalSchema(d, r) if err != nil {