mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-10-18 02:52:53 +00:00
refactor: Replace interface{} with any alias in Terraform provider code
- Replace interface{} with any in providerConfigure, doRequest, get, post, put method signatures
- Replace interface{} with any in dataSourceSubscriberRead, dataSourceSystemStatsRead functions
- Replace interface{} with any in resourceSubscriberCreate/Read/Update/Delete, resourceRatingPlanCreate/Read/Update/Delete functions
- Replace map[string]interface{} with map[string]any in subscriber create/update request bodies
- Update
This commit is contained in:
@@ -19,7 +19,7 @@ type APIClient struct {
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {
|
||||
func providerConfigure(ctx context.Context, d *schema.ResourceData) (any, diag.Diagnostics) {
|
||||
apiURL := d.Get("api_url").(string)
|
||||
apiKey := d.Get("api_key").(string)
|
||||
|
||||
@@ -34,7 +34,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}
|
||||
return client, nil
|
||||
}
|
||||
|
||||
func (c *APIClient) doRequest(ctx context.Context, method, path string, body interface{}) (*http.Response, error) {
|
||||
func (c *APIClient) doRequest(ctx context.Context, method, path string, body any) (*http.Response, error) {
|
||||
var reqBody *bytes.Buffer
|
||||
if body != nil {
|
||||
jsonBody, err := json.Marshal(body)
|
||||
@@ -59,7 +59,7 @@ func (c *APIClient) doRequest(ctx context.Context, method, path string, body int
|
||||
return c.HTTPClient.Do(req)
|
||||
}
|
||||
|
||||
func (c *APIClient) get(ctx context.Context, path string, result interface{}) error {
|
||||
func (c *APIClient) get(ctx context.Context, path string, result any) error {
|
||||
resp, err := c.doRequest(ctx, http.MethodGet, path, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -73,7 +73,7 @@ func (c *APIClient) get(ctx context.Context, path string, result interface{}) er
|
||||
return json.NewDecoder(resp.Body).Decode(result)
|
||||
}
|
||||
|
||||
func (c *APIClient) post(ctx context.Context, path string, body, result interface{}) error {
|
||||
func (c *APIClient) post(ctx context.Context, path string, body, result any) error {
|
||||
resp, err := c.doRequest(ctx, http.MethodPost, path, body)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -90,7 +90,7 @@ func (c *APIClient) post(ctx context.Context, path string, body, result interfac
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *APIClient) put(ctx context.Context, path string, body, result interface{}) error {
|
||||
func (c *APIClient) put(ctx context.Context, path string, body, result any) error {
|
||||
resp, err := c.doRequest(ctx, http.MethodPut, path, body)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -73,7 +73,7 @@ func dataSourceSubscriber() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceSubscriberRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
|
||||
func dataSourceSubscriberRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
|
||||
client := meta.(*APIClient)
|
||||
id := d.Get("id").(string)
|
||||
|
||||
@@ -126,7 +126,7 @@ func dataSourceSystemStats() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceSystemStatsRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
|
||||
func dataSourceSystemStatsRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
|
||||
client := meta.(*APIClient)
|
||||
|
||||
var result SystemStats
|
||||
|
||||
@@ -2,6 +2,8 @@ module terraform-provider-telecom
|
||||
|
||||
go 1.26.1
|
||||
|
||||
exclude google.golang.org/genproto v0.0.0-20240227224415-8cebfb086075
|
||||
|
||||
require github.com/hashicorp/terraform-plugin-sdk/v2 v2.40.0
|
||||
|
||||
require (
|
||||
@@ -22,8 +24,8 @@ require (
|
||||
github.com/hashicorp/terraform-registry-address v0.4.0 // indirect
|
||||
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
|
||||
github.com/hashicorp/yamux v0.1.2 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||
github.com/mattn/go-isatty v0.0.21 // indirect
|
||||
github.com/mitchellh/copystructure v1.2.0 // indirect
|
||||
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
|
||||
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
|
||||
@@ -44,7 +46,7 @@ require (
|
||||
golang.org/x/text v0.36.0 // indirect
|
||||
golang.org/x/tools v0.44.0 // indirect
|
||||
google.golang.org/appengine v1.6.8 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260226221140-a57be14db171 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect
|
||||
google.golang.org/grpc v1.79.3 // indirect
|
||||
google.golang.org/protobuf v1.36.11 // indirect
|
||||
)
|
||||
|
||||
@@ -10,30 +10,30 @@ import (
|
||||
)
|
||||
|
||||
type Subscriber struct {
|
||||
ID int `json:"id"`
|
||||
IMSI string `json:"imsi"`
|
||||
MSISDN string `json:"msisdn"`
|
||||
FirstName string `json:"first_name"`
|
||||
LastName string `json:"last_name"`
|
||||
Email string `json:"email"`
|
||||
OrganizationID string `json:"organization_id"`
|
||||
Status string `json:"status"`
|
||||
PlanID int `json:"plan_id"`
|
||||
ID int `json:"id"`
|
||||
IMSI string `json:"imsi"`
|
||||
MSISDN string `json:"msisdn"`
|
||||
FirstName string `json:"first_name"`
|
||||
LastName string `json:"last_name"`
|
||||
Email string `json:"email"`
|
||||
OrganizationID string `json:"organization_id"`
|
||||
Status string `json:"status"`
|
||||
PlanID int `json:"plan_id"`
|
||||
Balance float64 `json:"balance"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
type RatingPlan struct {
|
||||
PlanID string `json:"plan_id"`
|
||||
Name string `json:"name"`
|
||||
DataRate float64 `json:"data_rate"`
|
||||
VoiceRate float64 `json:"voice_rate"`
|
||||
SMSRate float64 `json:"sms_rate"`
|
||||
MonthlyFee float64 `json:"monthly_fee"`
|
||||
DataLimit float64 `json:"data_limit"`
|
||||
VoiceLimit float64 `json:"voice_limit"`
|
||||
SMSLimit float64 `json:"sms_limit"`
|
||||
PlanID string `json:"plan_id"`
|
||||
Name string `json:"name"`
|
||||
DataRate float64 `json:"data_rate"`
|
||||
VoiceRate float64 `json:"voice_rate"`
|
||||
SMSRate float64 `json:"sms_rate"`
|
||||
MonthlyFee float64 `json:"monthly_fee"`
|
||||
DataLimit float64 `json:"data_limit"`
|
||||
VoiceLimit float64 `json:"voice_limit"`
|
||||
SMSLimit float64 `json:"sms_limit"`
|
||||
}
|
||||
|
||||
func resourceSubscriber() *schema.Resource {
|
||||
@@ -93,17 +93,17 @@ func resourceSubscriber() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func resourceSubscriberCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
|
||||
func resourceSubscriberCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
|
||||
client := meta.(*APIClient)
|
||||
|
||||
sub := map[string]interface{}{
|
||||
"imsi": d.Get("imsi").(string),
|
||||
"msisdn": d.Get("msisdn").(string),
|
||||
"first_name": d.Get("first_name").(string),
|
||||
"last_name": d.Get("last_name").(string),
|
||||
"email": d.Get("email").(string),
|
||||
sub := map[string]any{
|
||||
"imsi": d.Get("imsi").(string),
|
||||
"msisdn": d.Get("msisdn").(string),
|
||||
"first_name": d.Get("first_name").(string),
|
||||
"last_name": d.Get("last_name").(string),
|
||||
"email": d.Get("email").(string),
|
||||
"organization_id": d.Get("organization_id").(string),
|
||||
"plan_id": d.Get("plan_id").(int),
|
||||
"plan_id": d.Get("plan_id").(int),
|
||||
}
|
||||
|
||||
var result Subscriber
|
||||
@@ -115,7 +115,7 @@ func resourceSubscriberCreate(ctx context.Context, d *schema.ResourceData, meta
|
||||
return resourceSubscriberRead(ctx, d, meta)
|
||||
}
|
||||
|
||||
func resourceSubscriberRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
|
||||
func resourceSubscriberRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
|
||||
client := meta.(*APIClient)
|
||||
id := d.Id()
|
||||
|
||||
@@ -139,16 +139,16 @@ func resourceSubscriberRead(ctx context.Context, d *schema.ResourceData, meta in
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceSubscriberUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
|
||||
func resourceSubscriberUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
|
||||
client := meta.(*APIClient)
|
||||
id := d.Id()
|
||||
|
||||
sub := map[string]interface{}{
|
||||
"first_name": d.Get("first_name").(string),
|
||||
"last_name": d.Get("last_name").(string),
|
||||
"email": d.Get("email").(string),
|
||||
sub := map[string]any{
|
||||
"first_name": d.Get("first_name").(string),
|
||||
"last_name": d.Get("last_name").(string),
|
||||
"email": d.Get("email").(string),
|
||||
"organization_id": d.Get("organization_id").(string),
|
||||
"plan_id": d.Get("plan_id").(int),
|
||||
"plan_id": d.Get("plan_id").(int),
|
||||
}
|
||||
|
||||
var result Subscriber
|
||||
@@ -159,7 +159,7 @@ func resourceSubscriberUpdate(ctx context.Context, d *schema.ResourceData, meta
|
||||
return resourceSubscriberRead(ctx, d, meta)
|
||||
}
|
||||
|
||||
func resourceSubscriberDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
|
||||
func resourceSubscriberDelete(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
|
||||
client := meta.(*APIClient)
|
||||
id := d.Id()
|
||||
|
||||
@@ -218,13 +218,13 @@ func resourceRatingPlan() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func resourceRatingPlanCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
|
||||
func resourceRatingPlanCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
|
||||
// Placeholder - would implement actual plan creation
|
||||
d.SetId(d.Get("plan_id").(string))
|
||||
return resourceRatingPlanRead(ctx, d, meta)
|
||||
}
|
||||
|
||||
func resourceRatingPlanRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
|
||||
func resourceRatingPlanRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
|
||||
// Placeholder - would fetch actual plan data
|
||||
d.Set("plan_id", d.Get("plan_id"))
|
||||
d.Set("name", d.Get("name"))
|
||||
@@ -238,10 +238,10 @@ func resourceRatingPlanRead(ctx context.Context, d *schema.ResourceData, meta in
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceRatingPlanUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
|
||||
func resourceRatingPlanUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
|
||||
return resourceRatingPlanRead(ctx, d, meta)
|
||||
}
|
||||
|
||||
func resourceRatingPlanDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
|
||||
func resourceRatingPlanDelete(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user