-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add resource
cloudavenue_backup
- Loading branch information
David MICHENEAU
committed
Oct 6, 2023
1 parent
0b6b13a
commit 13aa297
Showing
5 changed files
with
132 additions
and
50 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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package netbackup_test | ||
package backup_test | ||
|
||
import ( | ||
"context" | ||
|
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 |
---|---|---|
@@ -1,7 +1,42 @@ | ||
package netbackup | ||
package backup | ||
|
||
import "github.com/hashicorp/terraform-plugin-framework/types" | ||
import ( | ||
"context" | ||
|
||
type BackupModel struct { | ||
ID types.String `tfsdk:"id"` | ||
"github.com/hashicorp/terraform-plugin-framework/diag" | ||
|
||
supertypes "github.com/FrangipaneTeam/terraform-plugin-framework-supertypes" | ||
|
||
"github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/utils" | ||
) | ||
|
||
type backupModel struct { | ||
ID supertypes.StringValue `tfsdk:"id"` | ||
Policies supertypes.SetNestedValue `tfsdk:"policies"` | ||
TargetID supertypes.StringValue `tfsdk:"target_id"` | ||
TargetName supertypes.StringValue `tfsdk:"target_name"` | ||
Type supertypes.StringValue `tfsdk:"type"` | ||
} | ||
|
||
// * Policies. | ||
type backupModelPolicies []backupModelPolicy | ||
|
||
// * Policies. | ||
type backupModelPolicy struct { | ||
Enabled supertypes.BoolValue `tfsdk:"enabled"` | ||
PolicyID supertypes.Int64Value `tfsdk:"policy_id"` | ||
PolicyName supertypes.StringValue `tfsdk:"policy_name"` | ||
} | ||
|
||
func (rm *backupModel) Copy() *backupModel { | ||
x := &backupModel{} | ||
utils.ModelCopy(rm, x) | ||
return x | ||
} | ||
|
||
// GetPolicies returns the value of the Policies field. | ||
func (rm *backupModel) GetPolicies(ctx context.Context) (values backupModelPolicies, diags diag.Diagnostics) { | ||
values = make(backupModelPolicies, 0) | ||
d := rm.Policies.Get(ctx, &values, false) | ||
return values, d | ||
} |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package netbackup | ||
package backup | ||
|
||
const ( | ||
categoryName = "netbackup" | ||
categoryName = "backup" | ||
) |