|
3 | 3 |
|
4 | 4 | package fleet_apps_management |
5 | 5 |
|
6 | | -import ( |
7 | | - "context" |
8 | | - |
9 | | - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" |
10 | | - oci_fleet_apps_management "github.com/oracle/oci-go-sdk/v65/fleetappsmanagement" |
11 | | - |
12 | | - "github.com/oracle/terraform-provider-oci/internal/client" |
13 | | - "github.com/oracle/terraform-provider-oci/internal/tfresource" |
14 | | -) |
15 | | - |
16 | | -func FleetAppsManagementCompliancePolicyRuleDataSource() *schema.Resource { |
17 | | - fieldMap := make(map[string]*schema.Schema) |
18 | | - fieldMap["compliance_policy_rule_id"] = &schema.Schema{ |
19 | | - Type: schema.TypeString, |
20 | | - Required: true, |
21 | | - } |
22 | | - return tfresource.GetSingularDataSourceItemSchema(FleetAppsManagementCompliancePolicyRuleResource(), fieldMap, readSingularFleetAppsManagementCompliancePolicyRule) |
23 | | -} |
24 | | - |
25 | | -func readSingularFleetAppsManagementCompliancePolicyRule(d *schema.ResourceData, m interface{}) error { |
26 | | - sync := &FleetAppsManagementCompliancePolicyRuleDataSourceCrud{} |
27 | | - sync.D = d |
28 | | - sync.Client = m.(*client.OracleClients).FleetAppsManagementAdminClient() |
29 | | - |
30 | | - return tfresource.ReadResource(sync) |
31 | | -} |
32 | | - |
33 | | -type FleetAppsManagementCompliancePolicyRuleDataSourceCrud struct { |
34 | | - D *schema.ResourceData |
35 | | - Client *oci_fleet_apps_management.FleetAppsManagementAdminClient |
36 | | - Res *oci_fleet_apps_management.GetCompliancePolicyRuleResponse |
37 | | -} |
38 | | - |
39 | | -func (s *FleetAppsManagementCompliancePolicyRuleDataSourceCrud) VoidState() { |
40 | | - s.D.SetId("") |
41 | | -} |
42 | | - |
43 | | -func (s *FleetAppsManagementCompliancePolicyRuleDataSourceCrud) Get() error { |
44 | | - request := oci_fleet_apps_management.GetCompliancePolicyRuleRequest{} |
45 | | - |
46 | | - if compliancePolicyRuleId, ok := s.D.GetOkExists("compliance_policy_rule_id"); ok { |
47 | | - tmp := compliancePolicyRuleId.(string) |
48 | | - request.CompliancePolicyRuleId = &tmp |
49 | | - } |
50 | | - |
51 | | - request.RequestMetadata.RetryPolicy = tfresource.GetRetryPolicy(false, "fleet_apps_management") |
52 | | - |
53 | | - response, err := s.Client.GetCompliancePolicyRule(context.Background(), request) |
54 | | - if err != nil { |
55 | | - return err |
56 | | - } |
57 | | - |
58 | | - s.Res = &response |
59 | | - return nil |
60 | | -} |
61 | | - |
62 | | -func (s *FleetAppsManagementCompliancePolicyRuleDataSourceCrud) SetData() error { |
63 | | - if s.Res == nil { |
64 | | - return nil |
65 | | - } |
66 | | - |
67 | | - s.D.SetId(*s.Res.Id) |
68 | | - |
69 | | - if s.Res.CompartmentId != nil { |
70 | | - s.D.Set("compartment_id", *s.Res.CompartmentId) |
71 | | - } |
72 | | - |
73 | | - if s.Res.CompliancePolicyId != nil { |
74 | | - s.D.Set("compliance_policy_id", *s.Res.CompliancePolicyId) |
75 | | - } |
76 | | - |
77 | | - if s.Res.DefinedTags != nil { |
78 | | - s.D.Set("defined_tags", tfresource.DefinedTagsToMap(s.Res.DefinedTags)) |
79 | | - } |
80 | | - |
81 | | - if s.Res.DisplayName != nil { |
82 | | - s.D.Set("display_name", *s.Res.DisplayName) |
83 | | - } |
84 | | - |
85 | | - s.D.Set("freeform_tags", s.Res.FreeformTags) |
86 | | - |
87 | | - if s.Res.GracePeriod != nil { |
88 | | - s.D.Set("grace_period", *s.Res.GracePeriod) |
89 | | - } |
90 | | - |
91 | | - if s.Res.LifecycleDetails != nil { |
92 | | - s.D.Set("lifecycle_details", *s.Res.LifecycleDetails) |
93 | | - } |
94 | | - |
95 | | - if s.Res.PatchSelection != nil { |
96 | | - patchSelectionArray := []interface{}{} |
97 | | - if patchSelectionMap := PatchSelectionDetailsToMap(&s.Res.PatchSelection); patchSelectionMap != nil { |
98 | | - patchSelectionArray = append(patchSelectionArray, patchSelectionMap) |
99 | | - } |
100 | | - s.D.Set("patch_selection", patchSelectionArray) |
101 | | - } else { |
102 | | - s.D.Set("patch_selection", nil) |
103 | | - } |
104 | | - |
105 | | - s.D.Set("patch_type", s.Res.PatchType) |
106 | | - |
107 | | - if s.Res.ProductVersion != nil { |
108 | | - s.D.Set("product_version", []interface{}{ProductVersionDetailsToMap(s.Res.ProductVersion)}) |
109 | | - } else { |
110 | | - s.D.Set("product_version", nil) |
111 | | - } |
112 | | - |
113 | | - s.D.Set("severity", s.Res.Severity) |
114 | | - |
115 | | - s.D.Set("state", s.Res.LifecycleState) |
116 | | - |
117 | | - if s.Res.SystemTags != nil { |
118 | | - s.D.Set("system_tags", tfresource.SystemTagsToMap(s.Res.SystemTags)) |
119 | | - } |
120 | | - |
121 | | - if s.Res.TimeCreated != nil { |
122 | | - s.D.Set("time_created", s.Res.TimeCreated.String()) |
123 | | - } |
124 | | - |
125 | | - if s.Res.TimeUpdated != nil { |
126 | | - s.D.Set("time_updated", s.Res.TimeUpdated.String()) |
127 | | - } |
128 | | - |
129 | | - return nil |
130 | | -} |
| 6 | +//import ( |
| 7 | +// "context" |
| 8 | +// |
| 9 | +// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" |
| 10 | +// oci_fleet_apps_management "github.com/oracle/oci-go-sdk/v65/fleetappsmanagement" |
| 11 | +// |
| 12 | +// "github.com/oracle/terraform-provider-oci/internal/client" |
| 13 | +// "github.com/oracle/terraform-provider-oci/internal/tfresource" |
| 14 | +//) |
| 15 | +// |
| 16 | +//func FleetAppsManagementCompliancePolicyRuleDataSource() *schema.Resource { |
| 17 | +// fieldMap := make(map[string]*schema.Schema) |
| 18 | +// fieldMap["compliance_policy_rule_id"] = &schema.Schema{ |
| 19 | +// Type: schema.TypeString, |
| 20 | +// Required: true, |
| 21 | +// } |
| 22 | +// return tfresource.GetSingularDataSourceItemSchema(FleetAppsManagementCompliancePolicyRuleResource(), fieldMap, readSingularFleetAppsManagementCompliancePolicyRule) |
| 23 | +//} |
| 24 | +// |
| 25 | +//func readSingularFleetAppsManagementCompliancePolicyRule(d *schema.ResourceData, m interface{}) error { |
| 26 | +// sync := &FleetAppsManagementCompliancePolicyRuleDataSourceCrud{} |
| 27 | +// sync.D = d |
| 28 | +// sync.Client = m.(*client.OracleClients).FleetAppsManagementAdminClient() |
| 29 | +// |
| 30 | +// return tfresource.ReadResource(sync) |
| 31 | +//} |
| 32 | +// |
| 33 | +//type FleetAppsManagementCompliancePolicyRuleDataSourceCrud struct { |
| 34 | +// D *schema.ResourceData |
| 35 | +// Client *oci_fleet_apps_management.FleetAppsManagementAdminClient |
| 36 | +// Res *oci_fleet_apps_management.GetCompliancePolicyRuleResponse |
| 37 | +//} |
| 38 | +// |
| 39 | +//func (s *FleetAppsManagementCompliancePolicyRuleDataSourceCrud) VoidState() { |
| 40 | +// s.D.SetId("") |
| 41 | +//} |
| 42 | +// |
| 43 | +//func (s *FleetAppsManagementCompliancePolicyRuleDataSourceCrud) Get() error { |
| 44 | +// request := oci_fleet_apps_management.GetCompliancePolicyRuleRequest{} |
| 45 | +// |
| 46 | +// if compliancePolicyRuleId, ok := s.D.GetOkExists("compliance_policy_rule_id"); ok { |
| 47 | +// tmp := compliancePolicyRuleId.(string) |
| 48 | +// request.CompliancePolicyRuleId = &tmp |
| 49 | +// } |
| 50 | +// |
| 51 | +// request.RequestMetadata.RetryPolicy = tfresource.GetRetryPolicy(false, "fleet_apps_management") |
| 52 | +// |
| 53 | +// response, err := s.Client.GetCompliancePolicyRule(context.Background(), request) |
| 54 | +// if err != nil { |
| 55 | +// return err |
| 56 | +// } |
| 57 | +// |
| 58 | +// s.Res = &response |
| 59 | +// return nil |
| 60 | +//} |
| 61 | +// |
| 62 | +//func (s *FleetAppsManagementCompliancePolicyRuleDataSourceCrud) SetData() error { |
| 63 | +// if s.Res == nil { |
| 64 | +// return nil |
| 65 | +// } |
| 66 | +// |
| 67 | +// s.D.SetId(*s.Res.Id) |
| 68 | +// |
| 69 | +// if s.Res.CompartmentId != nil { |
| 70 | +// s.D.Set("compartment_id", *s.Res.CompartmentId) |
| 71 | +// } |
| 72 | +// |
| 73 | +// if s.Res.CompliancePolicyId != nil { |
| 74 | +// s.D.Set("compliance_policy_id", *s.Res.CompliancePolicyId) |
| 75 | +// } |
| 76 | +// |
| 77 | +// if s.Res.DefinedTags != nil { |
| 78 | +// s.D.Set("defined_tags", tfresource.DefinedTagsToMap(s.Res.DefinedTags)) |
| 79 | +// } |
| 80 | +// |
| 81 | +// if s.Res.DisplayName != nil { |
| 82 | +// s.D.Set("display_name", *s.Res.DisplayName) |
| 83 | +// } |
| 84 | +// |
| 85 | +// s.D.Set("freeform_tags", s.Res.FreeformTags) |
| 86 | +// |
| 87 | +// if s.Res.GracePeriod != nil { |
| 88 | +// s.D.Set("grace_period", *s.Res.GracePeriod) |
| 89 | +// } |
| 90 | +// |
| 91 | +// if s.Res.LifecycleDetails != nil { |
| 92 | +// s.D.Set("lifecycle_details", *s.Res.LifecycleDetails) |
| 93 | +// } |
| 94 | +// |
| 95 | +// if s.Res.PatchSelection != nil { |
| 96 | +// patchSelectionArray := []interface{}{} |
| 97 | +// if patchSelectionMap := PatchSelectionDetailsToMap(&s.Res.PatchSelection); patchSelectionMap != nil { |
| 98 | +// patchSelectionArray = append(patchSelectionArray, patchSelectionMap) |
| 99 | +// } |
| 100 | +// s.D.Set("patch_selection", patchSelectionArray) |
| 101 | +// } else { |
| 102 | +// s.D.Set("patch_selection", nil) |
| 103 | +// } |
| 104 | +// |
| 105 | +// s.D.Set("patch_type", s.Res.PatchType) |
| 106 | +// |
| 107 | +// if s.Res.ProductVersion != nil { |
| 108 | +// s.D.Set("product_version", []interface{}{ProductVersionDetailsToMap(s.Res.ProductVersion)}) |
| 109 | +// } else { |
| 110 | +// s.D.Set("product_version", nil) |
| 111 | +// } |
| 112 | +// |
| 113 | +// s.D.Set("severity", s.Res.Severity) |
| 114 | +// |
| 115 | +// s.D.Set("state", s.Res.LifecycleState) |
| 116 | +// |
| 117 | +// if s.Res.SystemTags != nil { |
| 118 | +// s.D.Set("system_tags", tfresource.SystemTagsToMap(s.Res.SystemTags)) |
| 119 | +// } |
| 120 | +// |
| 121 | +// if s.Res.TimeCreated != nil { |
| 122 | +// s.D.Set("time_created", s.Res.TimeCreated.String()) |
| 123 | +// } |
| 124 | +// |
| 125 | +// if s.Res.TimeUpdated != nil { |
| 126 | +// s.D.Set("time_updated", s.Res.TimeUpdated.String()) |
| 127 | +// } |
| 128 | +// |
| 129 | +// return nil |
| 130 | +//} |
0 commit comments