Skip to content

Commit

Permalink
Merge branch 'alpha'
Browse files Browse the repository at this point in the history
  • Loading branch information
nickderobertis committed Aug 8, 2024
2 parents 63f8e52 + 04bc607 commit 4c30b40
Show file tree
Hide file tree
Showing 7 changed files with 461 additions and 193 deletions.
123 changes: 54 additions & 69 deletions provider/provider/internal/provider/credential_connection_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ func (r *CredentialConnectionResource) Schema(ctx context.Context, req resource.
"id": schema.StringAttribute{
Description: "Unique identifier of the credential connection",
Computed: true,
// PlanModifiers: []planmodifier.String{
// stringplanmodifier.UseStateForUnknown(),
// },
},
"connection_name": schema.StringAttribute{
Description: "Name of the credential connection",
Expand Down Expand Up @@ -206,15 +203,15 @@ func (r *CredentialConnectionResource) Schema(ctx context.Context, req resource.
"dnis_number_format": types.StringValue("e164"),
"codecs": types.ListValueMust(types.StringType, []attr.Value{types.StringValue("G722"), types.StringValue("G711U"), types.StringValue("G711A"), types.StringValue("G729"), types.StringValue("OPUS"), types.StringValue("H.264")}),
"default_routing_method": types.StringValue("sequential"),
"channel_limit": types.Int64Value(10),
"generate_ringback_tone": types.BoolValue(true),
"isup_headers_enabled": types.BoolValue(true),
"prack_enabled": types.BoolValue(true),
"privacy_zone_enabled": types.BoolValue(true),
"sip_compact_headers_enabled": types.BoolValue(true),
"timeout_1xx_secs": types.Int64Value(3),
"timeout_2xx_secs": types.Int64Value(90),
"shaken_stir_enabled": types.BoolValue(true),
"channel_limit": types.Int64Null(),
"generate_ringback_tone": types.BoolNull(),
"isup_headers_enabled": types.BoolNull(),
"prack_enabled": types.BoolNull(),
"privacy_zone_enabled": types.BoolNull(),
"sip_compact_headers_enabled": types.BoolNull(),
"timeout_1xx_secs": types.Int64Null(),
"timeout_2xx_secs": types.Int64Null(),
"shaken_stir_enabled": types.BoolNull(),
},
)),
Attributes: map[string]schema.Attribute{
Expand Down Expand Up @@ -247,55 +244,46 @@ func (r *CredentialConnectionResource) Schema(ctx context.Context, req resource.
Description: "Channel limit",
Optional: true,
Computed: true,
Default: int64default.StaticInt64(10),
},
"generate_ringback_tone": schema.BoolAttribute{
Description: "Generate ringback tone",
Optional: true,
Computed: true,
Default: booldefault.StaticBool(true),
},
"isup_headers_enabled": schema.BoolAttribute{
Description: "ISUP headers enabled",
Optional: true,
Computed: true,
Default: booldefault.StaticBool(true),
},
"prack_enabled": schema.BoolAttribute{
Description: "PRACK enabled",
Optional: true,
Computed: true,
Default: booldefault.StaticBool(true),
},
"privacy_zone_enabled": schema.BoolAttribute{
Description: "Privacy zone enabled",
Optional: true,
Computed: true,
Default: booldefault.StaticBool(true),
},
"sip_compact_headers_enabled": schema.BoolAttribute{
Description: "SIP compact headers enabled",
Optional: true,
Computed: true,
Default: booldefault.StaticBool(true),
},
"timeout_1xx_secs": schema.Int64Attribute{
Description: "Timeout for 1xx responses in seconds",
Optional: true,
Computed: true,
Default: int64default.StaticInt64(3),
},
"timeout_2xx_secs": schema.Int64Attribute{
Description: "Timeout for 2xx responses in seconds",
Optional: true,
Computed: true,
Default: int64default.StaticInt64(90),
},
"shaken_stir_enabled": schema.BoolAttribute{
Description: "SHAKEN/STIR enabled",
Optional: true,
Computed: true,
Default: booldefault.StaticBool(true),
},
},
},
Expand All @@ -316,12 +304,12 @@ func (r *CredentialConnectionResource) Schema(ctx context.Context, req resource.
"t38_reinvite_source": types.StringType,
},
map[string]attr.Value{
"ani_override": types.StringValue("+12345678901"),
"ani_override": types.StringValue(""),
"ani_override_type": types.StringValue("always"),
"call_parking_enabled": types.BoolValue(true),
"channel_limit": types.Int64Value(10),
"generate_ringback_tone": types.BoolValue(true),
"instant_ringback_enabled": types.BoolValue(false),
"call_parking_enabled": types.BoolValue(false),
"channel_limit": types.Int64Null(),
"generate_ringback_tone": types.BoolNull(),
"instant_ringback_enabled": types.BoolNull(),
"localization": types.StringValue("US"),
"outbound_voice_profile_id": types.StringValue(""),
"t38_reinvite_source": types.StringValue("customer"),
Expand All @@ -344,25 +332,22 @@ func (r *CredentialConnectionResource) Schema(ctx context.Context, req resource.
Description: "Call parking enabled",
Optional: true,
Computed: true,
Default: booldefault.StaticBool(true),
Default: booldefault.StaticBool(false),
},
"channel_limit": schema.Int64Attribute{
Description: "Channel limit",
Optional: true,
Computed: true,
Default: int64default.StaticInt64(10),
},
"generate_ringback_tone": schema.BoolAttribute{
Description: "Generate ringback tone",
Optional: true,
Computed: true,
Default: booldefault.StaticBool(true),
},
"instant_ringback_enabled": schema.BoolAttribute{
Description: "Instant ringback enabled",
Optional: true,
Computed: true,
Default: booldefault.StaticBool(false),
},
"localization": schema.StringAttribute{
Description: "Localization",
Expand Down Expand Up @@ -452,23 +437,23 @@ func (r *CredentialConnectionResource) Create(ctx context.Context, req resource.
DNISNumberFormat: inboundAttributes["dnis_number_format"].(types.String).ValueString(),
Codecs: codecs,
DefaultRoutingMethod: inboundAttributes["default_routing_method"].(types.String).ValueString(),
ChannelLimit: int(inboundAttributes["channel_limit"].(types.Int64).ValueInt64()),
GenerateRingbackTone: inboundAttributes["generate_ringback_tone"].(types.Bool).ValueBool(),
ISUPHeadersEnabled: inboundAttributes["isup_headers_enabled"].(types.Bool).ValueBool(),
PRACKEnabled: inboundAttributes["prack_enabled"].(types.Bool).ValueBool(),
PrivacyZoneEnabled: inboundAttributes["privacy_zone_enabled"].(types.Bool).ValueBool(),
SIPCompactHeadersEnabled: inboundAttributes["sip_compact_headers_enabled"].(types.Bool).ValueBool(),
Timeout1xxSecs: int(inboundAttributes["timeout_1xx_secs"].(types.Int64).ValueInt64()),
Timeout2xxSecs: int(inboundAttributes["timeout_2xx_secs"].(types.Int64).ValueInt64()),
ShakenSTIREnabled: inboundAttributes["shaken_stir_enabled"].(types.Bool).ValueBool(),
ChannelLimit: getIntPointer(inboundAttributes["channel_limit"].(types.Int64)),
GenerateRingbackTone: getBoolPointer(inboundAttributes["generate_ringback_tone"].(types.Bool)),
ISUPHeadersEnabled: getBoolPointer(inboundAttributes["isup_headers_enabled"].(types.Bool)),
PRACKEnabled: getBoolPointer(inboundAttributes["prack_enabled"].(types.Bool)),
PrivacyZoneEnabled: getBoolPointer(inboundAttributes["privacy_zone_enabled"].(types.Bool)),
SIPCompactHeadersEnabled: getBoolPointer(inboundAttributes["sip_compact_headers_enabled"].(types.Bool)),
Timeout1xxSecs: getIntPointer(inboundAttributes["timeout_1xx_secs"].(types.Int64)),
Timeout2xxSecs: getIntPointer(inboundAttributes["timeout_2xx_secs"].(types.Int64)),
ShakenSTIREnabled: getBoolPointer(inboundAttributes["shaken_stir_enabled"].(types.Bool)),
},
Outbound: telnyx.OutboundSettings{
ANIOverride: outboundAttributes["ani_override"].(types.String).ValueString(),
ANIOverrideType: outboundAttributes["ani_override_type"].(types.String).ValueString(),
CallParkingEnabled: outboundAttributes["call_parking_enabled"].(types.Bool).ValueBool(),
ChannelLimit: int(outboundAttributes["channel_limit"].(types.Int64).ValueInt64()),
GenerateRingbackTone: outboundAttributes["generate_ringback_tone"].(types.Bool).ValueBool(),
InstantRingbackEnabled: outboundAttributes["instant_ringback_enabled"].(types.Bool).ValueBool(),
CallParkingEnabled: getBoolPointer(outboundAttributes["call_parking_enabled"].(types.Bool)),
ChannelLimit: getIntPointer(outboundAttributes["channel_limit"].(types.Int64)),
GenerateRingbackTone: getBoolPointer(outboundAttributes["generate_ringback_tone"].(types.Bool)),
InstantRingbackEnabled: getBoolPointer(outboundAttributes["instant_ringback_enabled"].(types.Bool)),
Localization: outboundAttributes["localization"].(types.String).ValueString(),
OutboundVoiceProfileID: outboundAttributes["outbound_voice_profile_id"].(types.String).ValueString(),
T38ReinviteSource: outboundAttributes["t38_reinvite_source"].(types.String).ValueString(),
Expand Down Expand Up @@ -559,23 +544,23 @@ func (r *CredentialConnectionResource) Update(ctx context.Context, req resource.
DNISNumberFormat: plan.Inbound.Attributes()["dnis_number_format"].(types.String).ValueString(),
Codecs: codecs,
DefaultRoutingMethod: plan.Inbound.Attributes()["default_routing_method"].(types.String).ValueString(),
ChannelLimit: int(plan.Inbound.Attributes()["channel_limit"].(types.Int64).ValueInt64()),
GenerateRingbackTone: plan.Inbound.Attributes()["generate_ringback_tone"].(types.Bool).ValueBool(),
ISUPHeadersEnabled: plan.Inbound.Attributes()["isup_headers_enabled"].(types.Bool).ValueBool(),
PRACKEnabled: plan.Inbound.Attributes()["prack_enabled"].(types.Bool).ValueBool(),
PrivacyZoneEnabled: plan.Inbound.Attributes()["privacy_zone_enabled"].(types.Bool).ValueBool(),
SIPCompactHeadersEnabled: plan.Inbound.Attributes()["sip_compact_headers_enabled"].(types.Bool).ValueBool(),
Timeout1xxSecs: int(plan.Inbound.Attributes()["timeout_1xx_secs"].(types.Int64).ValueInt64()),
Timeout2xxSecs: int(plan.Inbound.Attributes()["timeout_2xx_secs"].(types.Int64).ValueInt64()),
ShakenSTIREnabled: plan.Inbound.Attributes()["shaken_stir_enabled"].(types.Bool).ValueBool(),
ChannelLimit: getIntPointer(plan.Inbound.Attributes()["channel_limit"].(types.Int64)),
GenerateRingbackTone: getBoolPointer(plan.Inbound.Attributes()["generate_ringback_tone"].(types.Bool)),
ISUPHeadersEnabled: getBoolPointer(plan.Inbound.Attributes()["isup_headers_enabled"].(types.Bool)),
PRACKEnabled: getBoolPointer(plan.Inbound.Attributes()["prack_enabled"].(types.Bool)),
PrivacyZoneEnabled: getBoolPointer(plan.Inbound.Attributes()["privacy_zone_enabled"].(types.Bool)),
SIPCompactHeadersEnabled: getBoolPointer(plan.Inbound.Attributes()["sip_compact_headers_enabled"].(types.Bool)),
Timeout1xxSecs: getIntPointer(plan.Inbound.Attributes()["timeout_1xx_secs"].(types.Int64)),
Timeout2xxSecs: getIntPointer(plan.Inbound.Attributes()["timeout_2xx_secs"].(types.Int64)),
ShakenSTIREnabled: getBoolPointer(plan.Inbound.Attributes()["shaken_stir_enabled"].(types.Bool)),
},
Outbound: telnyx.OutboundSettings{
ANIOverride: plan.Outbound.Attributes()["ani_override"].(types.String).ValueString(),
ANIOverrideType: plan.Outbound.Attributes()["ani_override_type"].(types.String).ValueString(),
CallParkingEnabled: plan.Outbound.Attributes()["call_parking_enabled"].(types.Bool).ValueBool(),
ChannelLimit: int(plan.Outbound.Attributes()["channel_limit"].(types.Int64).ValueInt64()),
GenerateRingbackTone: plan.Outbound.Attributes()["generate_ringback_tone"].(types.Bool).ValueBool(),
InstantRingbackEnabled: plan.Outbound.Attributes()["instant_ringback_enabled"].(types.Bool).ValueBool(),
CallParkingEnabled: getBoolPointer(plan.Outbound.Attributes()["call_parking_enabled"].(types.Bool)),
ChannelLimit: getIntPointer(plan.Outbound.Attributes()["channel_limit"].(types.Int64)),
GenerateRingbackTone: getBoolPointer(plan.Outbound.Attributes()["generate_ringback_tone"].(types.Bool)),
InstantRingbackEnabled: getBoolPointer(plan.Outbound.Attributes()["instant_ringback_enabled"].(types.Bool)),
Localization: plan.Outbound.Attributes()["localization"].(types.String).ValueString(),
OutboundVoiceProfileID: plan.Outbound.Attributes()["outbound_voice_profile_id"].(types.String).ValueString(),
T38ReinviteSource: plan.Outbound.Attributes()["t38_reinvite_source"].(types.String).ValueString(),
Expand Down Expand Up @@ -677,15 +662,15 @@ func setCredentialConnectionState(ctx context.Context, state *CredentialConnecti
"dnis_number_format": types.StringValue(connection.Inbound.DNISNumberFormat),
"codecs": convertStringsToList(connection.Inbound.Codecs),
"default_routing_method": types.StringValue(connection.Inbound.DefaultRoutingMethod),
"channel_limit": types.Int64Value(int64(connection.Inbound.ChannelLimit)),
"generate_ringback_tone": types.BoolValue(connection.Inbound.GenerateRingbackTone),
"isup_headers_enabled": types.BoolValue(connection.Inbound.ISUPHeadersEnabled),
"prack_enabled": types.BoolValue(connection.Inbound.PRACKEnabled),
"privacy_zone_enabled": types.BoolValue(connection.Inbound.PrivacyZoneEnabled),
"sip_compact_headers_enabled": types.BoolValue(connection.Inbound.SIPCompactHeadersEnabled),
"timeout_1xx_secs": types.Int64Value(int64(connection.Inbound.Timeout1xxSecs)),
"timeout_2xx_secs": types.Int64Value(int64(connection.Inbound.Timeout2xxSecs)),
"shaken_stir_enabled": types.BoolValue(connection.Inbound.ShakenSTIREnabled),
"channel_limit": types.Int64Value(getInt64(connection.Inbound.ChannelLimit)),
"generate_ringback_tone": types.BoolValue(getBool(connection.Inbound.GenerateRingbackTone)),
"isup_headers_enabled": types.BoolValue(getBool(connection.Inbound.ISUPHeadersEnabled)),
"prack_enabled": types.BoolValue(getBool(connection.Inbound.PRACKEnabled)),
"privacy_zone_enabled": types.BoolValue(getBool(connection.Inbound.PrivacyZoneEnabled)),
"sip_compact_headers_enabled": types.BoolValue(getBool(connection.Inbound.SIPCompactHeadersEnabled)),
"timeout_1xx_secs": types.Int64Value(getInt64(connection.Inbound.Timeout1xxSecs)),
"timeout_2xx_secs": types.Int64Value(getInt64(connection.Inbound.Timeout2xxSecs)),
"shaken_stir_enabled": types.BoolValue(getBool(connection.Inbound.ShakenSTIREnabled)),
},
)

Expand All @@ -704,10 +689,10 @@ func setCredentialConnectionState(ctx context.Context, state *CredentialConnecti
map[string]attr.Value{
"ani_override": types.StringValue(connection.Outbound.ANIOverride),
"ani_override_type": types.StringValue(connection.Outbound.ANIOverrideType),
"call_parking_enabled": types.BoolValue(connection.Outbound.CallParkingEnabled),
"channel_limit": types.Int64Value(int64(connection.Outbound.ChannelLimit)),
"generate_ringback_tone": types.BoolValue(connection.Outbound.GenerateRingbackTone),
"instant_ringback_enabled": types.BoolValue(connection.Outbound.InstantRingbackEnabled),
"call_parking_enabled": types.BoolValue(getBool(connection.Outbound.CallParkingEnabled)),
"channel_limit": types.Int64Value(getInt64(connection.Outbound.ChannelLimit)),
"generate_ringback_tone": types.BoolValue(getBool(connection.Outbound.GenerateRingbackTone)),
"instant_ringback_enabled": types.BoolValue(getBool(connection.Outbound.InstantRingbackEnabled)),
"localization": types.StringValue(connection.Outbound.Localization),
"outbound_voice_profile_id": types.StringValue(connection.Outbound.OutboundVoiceProfileID),
"t38_reinvite_source": types.StringValue(connection.Outbound.T38ReinviteSource),
Expand Down
Loading

0 comments on commit 4c30b40

Please sign in to comment.