Add resource group utility methods
package cloudflare
+import "fmt"
+
type ResourceGroup struct {
ID string `json:"id"`
Name string `json:"name"`
@@ -15,3 +17,31 @@ type Scope struct {
type ScopeObject struct {
Key string `json:"key"`
}
+
+func NewResourceGroupForZone(zone Zone) ResourceGroup {
+ return NewResourceGroup(fmt.Sprintf("com.cloudflare.api.account.zone.%s", zone.ID))
+}
+
+func NewResourceGroupForAccount(account Account) ResourceGroup {
+ return NewResourceGroup(fmt.Sprintf("com.cloudflare.api.account.%s", account.ID))
+}
+
+func NewResourceGroup(key string) ResourceGroup {
+ scope := Scope{
+ Key: key,
+ ScopeObjects: []ScopeObject{
+ ScopeObject{
+ Key: "*",
+ },
+ },
+ }
+ resourceGroup := ResourceGroup{
+ ID: "",
+ Name: key,
+ Meta: map[string]string{
+ "editable": "false",
+ },
+ Scope: scope,
+ }
+ return resourceGroup
+}
