forked from SumoLogic/terraform-provider-sumologic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9891e44
commit 021200c
Showing
5 changed files
with
136 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package sumologic | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" | ||
) | ||
|
||
func dataSourceSumologicPartition() *schema.Resource { | ||
return &schema.Resource{ | ||
Read: dataSourceSumologicPartitionRead, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"name": { | ||
Type: schema.TypeString, | ||
}, | ||
"routing_expression": { | ||
Type: schema.TypeString, | ||
}, | ||
"analytics_tier": { | ||
Type: schema.TypeString, | ||
}, | ||
"retention_period": { | ||
Type: schema.TypeInt, | ||
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { | ||
return new == "-1" && old != "" | ||
}, | ||
}, | ||
"is_compliant": { | ||
Type: schema.TypeBool, | ||
}, | ||
"total_bytes": { | ||
Type: schema.TypeInt, | ||
}, | ||
"data_forwarding_id": { | ||
Type: schema.TypeString, | ||
}, | ||
"is_active": { | ||
Type: schema.TypeBool, | ||
}, | ||
"index_type": { | ||
Type: schema.TypeString, | ||
}, | ||
"reduce_retention_period_immediately": { | ||
Type: schema.TypeBool, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceSumologicPartitionRead(d *schema.ResourceData, meta interface{}) error { | ||
c := meta.(*Client) | ||
|
||
id := d.Id() | ||
spartition, err := c.GetPartition(id) | ||
|
||
if err != nil { | ||
return fmt.Errorf("error retrieving partition: %v", err) | ||
} | ||
|
||
if spartition == nil { | ||
d.SetId("") | ||
return nil | ||
} | ||
|
||
d.Set("routing_expression", spartition.RoutingExpression) | ||
d.Set("name", spartition.Name) | ||
d.Set("analytics_tier", spartition.AnalyticsTier) | ||
d.Set("retention_period", spartition.RetentionPeriod) | ||
d.Set("is_compliant", spartition.IsCompliant) | ||
d.Set("data_forwarding_id", spartition.DataForwardingId) | ||
d.Set("is_active", spartition.IsActive) | ||
d.Set("total_bytes", spartition.TotalBytes) | ||
d.Set("index_type", spartition.IndexType) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package sumologic | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" | ||
) | ||
|
||
func dataSourceSumologicPartitions() *schema.Resource { | ||
return &schema.Resource{ | ||
Read: dataSourceSumologicPartitionsRead, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"ids": { | ||
Type: schema.TypeList, | ||
Computed: true, | ||
Elem: &schema.Schema{Type: schema.TypeString}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceSumologicPartitionsRead(d *schema.ResourceData, meta interface{}) error { | ||
c := meta.(*Client) | ||
spartitions, err := c.ListPartitions() | ||
if err != nil { | ||
return fmt.Errorf("error retrieving partitions: %v", err) | ||
} | ||
|
||
ids := make([]string, 0, len(spartitions)) | ||
|
||
for _, partition := range spartitions { | ||
ids = append(ids, partition.ID) | ||
} | ||
|
||
d.SetId(c.BaseURL.Host) | ||
d.Set("ids", ids) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters