Skip to content

Commit

Permalink
Import (#92)
Browse files Browse the repository at this point in the history
* add resource mailcow_domain_admin

* domains not optional

* add import

* revert domain admin

* revert domain admin
  • Loading branch information
l-with authored May 27, 2024
1 parent 184f2bc commit b9082de
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 221 deletions.
8 changes: 8 additions & 0 deletions api/model_create_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ func NewCreateOAuth2ClientRequest() *MailcowCreateRequest {
return &this
}

func NewCreateDomainAdminRequest() *MailcowCreateRequest {
this := MailcowCreateRequest{}
this.payload = make(map[string]interface{})
this.endpoint = "/api/v1/add/domain-admin"
this.ResourceName = "resourceDomainAdmin"
return &this
}

func (o *MailcowCreateRequest) Get(key string) interface{} {
if !o.Has(key) {
var ret bool
Expand Down
7 changes: 7 additions & 0 deletions api/model_delete_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ func NewDeleteOAuth2ClientRequest() *MailcowDeleteRequest {
return &this
}

func NewDeleteDomainAdminRequest() *MailcowDeleteRequest {
this := MailcowDeleteRequest{}
this.endpoint = "/api/v1/delete/domain-admin"
this.ResourceName = "resourceDomainadmin"
return &this
}

func (o *MailcowDeleteRequest) GetItem() *string {
log.Print("[TRACE] GetItem")
if !o.HasItem() {
Expand Down
9 changes: 9 additions & 0 deletions api/model_get_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,12 @@ func (a *ApiService) MailcowGetOAuth2Clients(ctx context.Context) ApiMailcowGetA
endpoint: "/api/v1/get/oauth2-client/all",
}
}

func (a *ApiService) MailcowGetDomainAdmin(ctx context.Context, id string) ApiMailcowGetRequest {
return ApiMailcowGetRequest{
ApiService: a,
ctx: ctx,
endpoint: "/api/v1/get/alias/{id}",
id: id,
}
}
9 changes: 9 additions & 0 deletions api/model_update_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ func NewUpdateSyncjobRequest() *MailcowUpdateRequest {
return &this
}

func NewUpdateDomainAdminRequest() *MailcowUpdateRequest {
this := MailcowUpdateRequest{}
this.attr = make(map[string]interface{})
this.items = make([]string, 1)
this.endpoint = "/api/v1/edit/domain-admin"
this.ResourceName = "resourceDomainAdmin"
return &this
}

func (o *MailcowUpdateRequest) GetAttr(key string) interface{} {
if !o.HasAttr(key) {
var ret bool
Expand Down
9 changes: 9 additions & 0 deletions mailcow/resource_alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ func resourceAlias() *schema.Resource {
ReadContext: resourceAliasRead,
UpdateContext: resourceAliasUpdate,
DeleteContext: resourceAliasDelete,

Importer: &schema.ResourceImporter{
StateContext: resourceAliasImport,
},

Schema: map[string]*schema.Schema{
"active": {
Type: schema.TypeBool,
Expand Down Expand Up @@ -52,6 +57,10 @@ func resourceAlias() *schema.Resource {
}
}

func resourceAliasImport(_ context.Context, d *schema.ResourceData, _ interface{}) ([]*schema.ResourceData, error) {
return []*schema.ResourceData{d}, nil
}

func resourceAliasCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
var diags diag.Diagnostics

Expand Down
9 changes: 9 additions & 0 deletions mailcow/resource_dkim.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ func resourceDkim() *schema.Resource {
CreateContext: resourceDkimCreate,
ReadContext: resourceDkimRead,
DeleteContext: resourceDkimDelete,

Importer: &schema.ResourceImporter{
StateContext: resourceDkimImport,
},

Schema: map[string]*schema.Schema{
"domain": {
Type: schema.TypeString,
Expand Down Expand Up @@ -46,6 +51,10 @@ func resourceDkim() *schema.Resource {
}
}

func resourceDkimImport(_ context.Context, d *schema.ResourceData, _ interface{}) ([]*schema.ResourceData, error) {
return []*schema.ResourceData{d}, nil
}

func resourceDkimCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
c := m.(*APIClient)

Expand Down
9 changes: 9 additions & 0 deletions mailcow/resource_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ func resourceDomain() *schema.Resource {
ReadContext: resourceDomainRead,
UpdateContext: resourceDomainUpdate,
DeleteContext: resourceDomainDelete,

Importer: &schema.ResourceImporter{
StateContext: resourceDomainImport,
},

Schema: map[string]*schema.Schema{
"active": {
Type: schema.TypeBool,
Expand Down Expand Up @@ -107,6 +112,10 @@ func resourceDomain() *schema.Resource {
}
}

func resourceDomainImport(_ context.Context, d *schema.ResourceData, _ interface{}) ([]*schema.ResourceData, error) {
return []*schema.ResourceData{d}, nil
}

func resourceDomainCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
var diags diag.Diagnostics

Expand Down
221 changes: 0 additions & 221 deletions mailcow/resource_domain_admin.gonot

This file was deleted.

9 changes: 9 additions & 0 deletions mailcow/resource_mailbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ func resourceMailbox() *schema.Resource {
ReadContext: resourceMailboxRead,
UpdateContext: resourceMailboxUpdate,
DeleteContext: resourceMailboxDelete,

Importer: &schema.ResourceImporter{
StateContext: resourceMailboxImport,
},

Schema: map[string]*schema.Schema{
"active": {
Type: schema.TypeBool,
Expand Down Expand Up @@ -111,6 +116,10 @@ func resourceMailbox() *schema.Resource {
}
}

func resourceMailboxImport(_ context.Context, d *schema.ResourceData, _ interface{}) ([]*schema.ResourceData, error) {
return []*schema.ResourceData{d}, nil
}

func resourceMailboxCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
var diags diag.Diagnostics

Expand Down
9 changes: 9 additions & 0 deletions mailcow/resource_oauth2_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ func resourceOAuth2Client() *schema.Resource {
CreateContext: resourceOAuth2ClientCreate,
ReadContext: resourceOAuth2ClientRead,
DeleteContext: resourceOAuth2ClientDelete,

Importer: &schema.ResourceImporter{
StateContext: resourceOAuth2ClientImport,
},

Schema: map[string]*schema.Schema{
"client_id": {
Type: schema.TypeString,
Expand All @@ -38,6 +43,10 @@ func resourceOAuth2Client() *schema.Resource {
}
}

func resourceOAuth2ClientImport(_ context.Context, d *schema.ResourceData, _ interface{}) ([]*schema.ResourceData, error) {
return []*schema.ResourceData{d}, nil
}

func resourceOAuth2ClientCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
c := m.(*APIClient)

Expand Down
Loading

0 comments on commit b9082de

Please sign in to comment.