-
Notifications
You must be signed in to change notification settings - Fork 669
/
resource_ibm_cm_object.go
603 lines (561 loc) · 21 KB
/
resource_ibm_cm_object.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
// Copyright IBM Corp. 2022 All Rights Reserved.
// Licensed under the Mozilla Public License v2.0
package catalogmanagement
import (
"context"
"encoding/json"
"fmt"
"log"
"strconv"
"strings"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns"
"github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex"
"github.com/IBM/go-sdk-core/v5/core"
"github.com/IBM/platform-services-go-sdk/catalogmanagementv1"
)
func ResourceIBMCmObject() *schema.Resource {
return &schema.Resource{
CreateContext: resourceIBMCmObjectCreate,
ReadContext: resourceIBMCmObjectRead,
UpdateContext: resourceIBMCmObjectUpdate,
DeleteContext: resourceIBMCmObjectDelete,
Importer: &schema.ResourceImporter{},
Schema: map[string]*schema.Schema{
"catalog_id": &schema.Schema{
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "Catalog identifier.",
},
"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
Description: "The programmatic name of this object.",
},
"kind": &schema.Schema{
Type: schema.TypeString,
Required: true,
Description: "Kind of object. Options are \"vpe\", \"preset_configuration\", or \"proxy_source\".",
},
"crn": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The crn for this specific object.",
},
"url": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The url for this specific object.",
},
"parent_id": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Description: "The parent for this specific object.",
},
"label_i18n": &schema.Schema{
Type: schema.TypeMap,
Optional: true,
Description: "A map of translated strings, by language code.",
Elem: &schema.Schema{Type: schema.TypeString},
},
"label": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Description: "Display name in the requested language.",
},
"tags": &schema.Schema{
Type: schema.TypeList,
Optional: true,
Description: "List of tags associated with this catalog.",
Elem: &schema.Schema{Type: schema.TypeString},
},
"created": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The date and time this catalog was created.",
},
"updated": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The date and time this catalog was last updated.",
},
"short_description": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Description: "Short description in the requested language.",
},
"short_description_i18n": &schema.Schema{
Type: schema.TypeMap,
Optional: true,
Description: "A map of translated strings, by language code.",
Elem: &schema.Schema{Type: schema.TypeString},
},
"publish": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Description: "Publish information.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"permit_ibm_public_publish": &schema.Schema{
Type: schema.TypeBool,
Computed: true,
Description: "Is it permitted to request publishing to IBM or Public.",
},
"ibm_approved": &schema.Schema{
Type: schema.TypeBool,
Computed: true,
Description: "Indicates if this offering has been approved for use by all IBMers.",
},
"public_approved": &schema.Schema{
Type: schema.TypeBool,
Computed: true,
Description: "Indicates if this offering has been approved for use by all IBM Cloud users.",
},
"portal_approval_record": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The portal's approval record ID.",
},
"portal_url": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The portal UI URL.",
},
},
},
},
"state": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Description: "Offering state.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"current": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "one of: new, validated, account-published, ibm-published, public-published.",
},
"current_entered": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "Date and time of current request.",
},
"pending": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "one of: new, validated, account-published, ibm-published, public-published.",
},
"pending_requested": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "Date and time of pending request.",
},
"previous": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "one of: new, validated, account-published, ibm-published, public-published.",
},
},
},
},
"catalog_name": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The name of the catalog.",
},
"data": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Stringified map of data values for this object.",
},
"rev": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "Cloudant revision.",
},
"object_id": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The ID of the object.",
},
},
}
}
func resourceIBMCmObjectCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
catalogManagementClient, err := meta.(conns.ClientSession).CatalogManagementV1()
if err != nil {
return diag.FromErr(err)
}
createObjectOptions := &catalogmanagementv1.CreateObjectOptions{}
createObjectOptions.SetCatalogIdentifier(d.Get("catalog_id").(string))
if _, ok := d.GetOk("name"); ok {
createObjectOptions.SetName(d.Get("name").(string))
}
if _, ok := d.GetOk("parent_id"); ok {
createObjectOptions.SetParentID(d.Get("parent_id").(string))
}
if _, ok := d.GetOk("label"); ok {
createObjectOptions.SetLabel(d.Get("label").(string))
}
if _, ok := d.GetOk("tags"); ok {
createObjectOptions.SetTags(SIToSS(d.Get("tags").([]interface{})))
}
if _, ok := d.GetOk("short_description"); ok {
createObjectOptions.SetShortDescription(d.Get("short_description").(string))
}
if _, ok := d.GetOk("kind"); ok {
createObjectOptions.SetKind(d.Get("kind").(string))
}
catalogObject, response, err := catalogManagementClient.CreateObjectWithContext(context, createObjectOptions)
if err != nil {
log.Printf("[DEBUG] CreateObjectWithContext failed %s\n%s", err, response)
return diag.FromErr(fmt.Errorf("CreateObjectWithContext failed %s\n%s", err, response))
}
d.SetId(*catalogObject.ID)
// update data here if provided in resource
if _, ok := d.GetOk("data"); ok {
replaceObjectOptions := &catalogmanagementv1.ReplaceObjectOptions{}
replaceObjectOptions.SetCatalogIdentifier(*catalogObject.CatalogID)
replaceObjectOptions.SetObjectIdentifier(*catalogObject.ID)
replaceObjectOptions.SetID(*catalogObject.ID)
replaceObjectOptions.SetCRN(*catalogObject.CRN)
replaceObjectOptions.SetURL(*catalogObject.URL)
replaceObjectOptions.SetCatalogName(*catalogObject.CatalogName)
replaceObjectOptions.SetCatalogID(*catalogObject.CatalogID)
replaceObjectOptions.SetKind(*catalogObject.Kind)
replaceObjectOptions.SetRev(*catalogObject.Rev)
replaceObjectOptions.SetCreated(*&catalogObject.Created)
replaceObjectOptions.SetUpdated(*&catalogObject.Updated)
replaceObjectOptions.SetPublish(*&catalogObject.Publish)
replaceObjectOptions.SetState(*&catalogObject.State)
if catalogObject.Label != nil {
replaceObjectOptions.SetLabel(*catalogObject.Label)
}
if catalogObject.Name != nil {
replaceObjectOptions.SetName(*catalogObject.Name)
}
if catalogObject.ParentID != nil {
replaceObjectOptions.SetParentID(*catalogObject.ParentID)
}
if catalogObject.ShortDescription != nil {
replaceObjectOptions.SetShortDescription(*catalogObject.ShortDescription)
}
if catalogObject.Tags != nil {
replaceObjectOptions.SetTags(catalogObject.Tags)
}
dataMap := make(map[string]interface{})
dataString, err := strconv.Unquote(d.Get("data").(string))
if err != nil {
dataString = d.Get("data").(string)
}
err = json.Unmarshal([]byte(dataString), &dataMap)
if err != nil {
return diag.FromErr(fmt.Errorf("error unmarshalling json %s", err))
}
replaceObjectOptions.SetData(dataMap)
catalogObject, response, err = catalogManagementClient.ReplaceObjectWithContext(context, replaceObjectOptions)
if err != nil {
log.Printf("[DEBUG] ReplaceObjectWithContext failed %s\n%s", err, response)
return diag.FromErr(fmt.Errorf("ReplaceObjectWithContext failed %s\n%s", err, response))
}
}
return resourceIBMCmObjectRead(context, d, meta)
}
func resourceIBMCmObjectRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
catalogManagementClient, err := meta.(conns.ClientSession).CatalogManagementV1()
if err != nil {
return diag.FromErr(err)
}
getObjectOptions := &catalogmanagementv1.GetObjectOptions{}
getObjectOptions.SetCatalogIdentifier(d.Get("catalog_id").(string))
getObjectOptions.SetObjectIdentifier(d.Id())
catalogObject, response, err := catalogManagementClient.GetObjectWithContext(context, getObjectOptions)
if err != nil {
if response != nil && response.StatusCode == 404 {
d.SetId("")
return nil
}
log.Printf("[DEBUG] GetObjectWithContext failed %s\n%s", err, response)
return diag.FromErr(fmt.Errorf("GetObjectWithContext failed %s\n%s", err, response))
}
if err = d.Set("catalog_id", getObjectOptions.CatalogIdentifier); err != nil {
return diag.FromErr(fmt.Errorf("Error setting catalog_id: %s", err))
}
if err = d.Set("name", catalogObject.Name); err != nil {
return diag.FromErr(fmt.Errorf("Error setting name: %s", err))
}
if err = d.Set("crn", catalogObject.CRN); err != nil {
return diag.FromErr(fmt.Errorf("Error setting crn: %s", err))
}
if err = d.Set("url", catalogObject.URL); err != nil {
return diag.FromErr(fmt.Errorf("Error setting url: %s", err))
}
if err = d.Set("parent_id", catalogObject.ParentID); err != nil {
return diag.FromErr(fmt.Errorf("Error setting parent_id: %s", err))
}
if err = d.Set("label", catalogObject.Label); err != nil {
return diag.FromErr(fmt.Errorf("Error setting label: %s", err))
}
if catalogObject.Tags != nil {
modifiedTags := []string{}
for _, tag := range catalogObject.Tags {
if !strings.HasPrefix(tag, "svc:") && !strings.HasPrefix(tag, "fqdn:") && tag != *catalogObject.ParentID {
modifiedTags = append(modifiedTags, tag)
}
}
if err = d.Set("tags", modifiedTags); err != nil {
return diag.FromErr(fmt.Errorf("Error setting tags: %s", err))
}
}
if err = d.Set("created", flex.DateTimeToString(catalogObject.Created)); err != nil {
return diag.FromErr(fmt.Errorf("Error setting created: %s", err))
}
if err = d.Set("updated", flex.DateTimeToString(catalogObject.Updated)); err != nil {
return diag.FromErr(fmt.Errorf("Error setting updated: %s", err))
}
if err = d.Set("short_description", catalogObject.ShortDescription); err != nil {
return diag.FromErr(fmt.Errorf("Error setting short_description: %s", err))
}
if err = d.Set("kind", catalogObject.Kind); err != nil {
return diag.FromErr(fmt.Errorf("Error setting kind: %s", err))
}
publishMap := map[string]interface{}{}
if catalogObject.Publish != nil {
publishMap, err = resourceIBMCmObjectPublishObjectToMap(catalogObject.Publish)
if err != nil {
return diag.FromErr(err)
}
}
if err = d.Set("publish", []map[string]interface{}{publishMap}); err != nil {
return diag.FromErr(fmt.Errorf("Error setting publish: %s", err))
}
if catalogObject.State != nil {
stateMap, err := resourceIBMCmObjectStateToMap(catalogObject.State)
if err != nil {
return diag.FromErr(err)
}
if err = d.Set("state", []map[string]interface{}{stateMap}); err != nil {
return diag.FromErr(fmt.Errorf("Error setting state: %s", err))
}
}
if err = d.Set("catalog_id", catalogObject.CatalogID); err != nil {
return diag.FromErr(fmt.Errorf("Error setting catalog_id: %s", err))
}
if err = d.Set("catalog_name", catalogObject.CatalogName); err != nil {
return diag.FromErr(fmt.Errorf("Error setting catalog_name: %s", err))
}
if catalogObject.Data != nil {
dataString, err := json.Marshal(catalogObject.Data)
if err != nil {
return diag.FromErr(fmt.Errorf("Error setting data, error with json marshal: %s", err))
}
if err = d.Set("data", string(dataString)); err != nil {
return diag.FromErr(fmt.Errorf("Error setting data: %s", err))
}
}
if err = d.Set("rev", catalogObject.Rev); err != nil {
return diag.FromErr(fmt.Errorf("Error setting rev: %s", err))
}
if err = d.Set("object_id", catalogObject.ID); err != nil {
return diag.FromErr(fmt.Errorf("Error setting object_id: %s", err))
}
return nil
}
func resourceIBMCmObjectUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
catalogManagementClient, err := meta.(conns.ClientSession).CatalogManagementV1()
if err != nil {
return diag.FromErr(err)
}
getObjectOptions := &catalogmanagementv1.GetObjectOptions{}
getObjectOptions.SetCatalogIdentifier(d.Get("catalog_id").(string))
getObjectOptions.SetObjectIdentifier(d.Id())
catalogObject, response, err := catalogManagementClient.GetObjectWithContext(context, getObjectOptions)
if err != nil {
if response != nil && response.StatusCode == 404 {
d.SetId("")
return nil
}
log.Printf("[DEBUG] GetObjectWithContext failed %s\n%s", err, response)
return diag.FromErr(fmt.Errorf("GetObjectWithContext failed %s\n%s", err, response))
}
replaceObjectOptions := &catalogmanagementv1.ReplaceObjectOptions{}
replaceObjectOptions.SetCatalogIdentifier(*catalogObject.CatalogID)
replaceObjectOptions.SetObjectIdentifier(*catalogObject.ID)
replaceObjectOptions.SetID(*catalogObject.ID)
replaceObjectOptions.SetRev(*catalogObject.Rev)
if catalogObject.State != nil {
replaceObjectOptions.SetState(catalogObject.State)
}
if catalogObject.Publish != nil {
replaceObjectOptions.SetPublish(catalogObject.Publish)
}
if _, ok := d.GetOk("name"); ok {
replaceObjectOptions.SetName(d.Get("name").(string))
} else if catalogObject.Name != nil {
replaceObjectOptions.SetName(*catalogObject.Name)
}
if _, ok := d.GetOk("crn"); ok {
replaceObjectOptions.SetCRN(d.Get("crn").(string))
} else if catalogObject.CRN != nil {
replaceObjectOptions.SetCRN(*catalogObject.CRN)
}
if _, ok := d.GetOk("url"); ok {
replaceObjectOptions.SetURL(d.Get("url").(string))
} else if catalogObject.URL != nil {
replaceObjectOptions.SetURL(*catalogObject.URL)
}
if _, ok := d.GetOk("parent_id"); ok {
replaceObjectOptions.SetParentID(d.Get("parent_id").(string))
} else if catalogObject.ParentID != nil {
replaceObjectOptions.SetParentID(*catalogObject.ParentID)
}
if _, ok := d.GetOk("label"); ok {
replaceObjectOptions.SetLabel(d.Get("label").(string))
} else if catalogObject.Label != nil {
replaceObjectOptions.SetLabel(*catalogObject.Label)
}
if _, ok := d.GetOk("tags"); ok {
replaceObjectOptions.SetTags(SIToSS(d.Get("tags").([]interface{})))
} else if catalogObject.Tags != nil {
replaceObjectOptions.SetTags(catalogObject.Tags)
}
if _, ok := d.GetOk("created"); ok {
fmtDateTimeCreated, err := core.ParseDateTime(d.Get("created").(string))
if err != nil {
return diag.FromErr(err)
}
replaceObjectOptions.SetCreated(&fmtDateTimeCreated)
} else if catalogObject.Created != nil {
replaceObjectOptions.SetCreated(catalogObject.Created)
}
if _, ok := d.GetOk("updated"); ok {
fmtDateTimeUpdated, err := core.ParseDateTime(d.Get("updated").(string))
if err != nil {
return diag.FromErr(err)
}
replaceObjectOptions.SetUpdated(&fmtDateTimeUpdated)
} else if catalogObject.Updated != nil {
replaceObjectOptions.SetUpdated(catalogObject.Updated)
}
if _, ok := d.GetOk("short_description"); ok {
replaceObjectOptions.SetShortDescription(d.Get("short_description").(string))
} else if catalogObject.ShortDescription != nil {
replaceObjectOptions.SetShortDescription(*catalogObject.ShortDescription)
}
if _, ok := d.GetOk("kind"); ok {
replaceObjectOptions.SetKind(d.Get("kind").(string))
} else if catalogObject.Kind != nil {
replaceObjectOptions.SetKind(*catalogObject.Kind)
}
if _, ok := d.GetOk("catalog_id"); ok {
replaceObjectOptions.SetCatalogID(d.Get("catalog_id").(string))
} else if catalogObject.CatalogID != nil {
replaceObjectOptions.SetCatalogID(*catalogObject.CatalogID)
}
if _, ok := d.GetOk("catalog_name"); ok {
replaceObjectOptions.SetCatalogName(d.Get("catalog_name").(string))
} else if catalogObject.CatalogName != nil {
replaceObjectOptions.SetCatalogName(*catalogObject.CatalogName)
}
if _, ok := d.GetOk("data"); ok {
dataMap := make(map[string]interface{})
dataString, err := strconv.Unquote(d.Get("data").(string))
if err != nil {
dataString = d.Get("data").(string)
}
err = json.Unmarshal([]byte(dataString), &dataMap)
if err != nil {
return diag.FromErr(fmt.Errorf("error unmarshalling json %s", err))
}
replaceObjectOptions.SetData(dataMap)
} else if catalogObject.Data != nil {
replaceObjectOptions.SetData(catalogObject.Data)
}
_, response, err = catalogManagementClient.ReplaceObjectWithContext(context, replaceObjectOptions)
if err != nil {
log.Printf("[DEBUG] ReplaceObjectWithContext failed %s\n%s", err, response)
return diag.FromErr(fmt.Errorf("ReplaceObjectWithContext failed %s\n%s", err, response))
}
return resourceIBMCmObjectRead(context, d, meta)
}
func resourceIBMCmObjectDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
catalogManagementClient, err := meta.(conns.ClientSession).CatalogManagementV1()
if err != nil {
return diag.FromErr(err)
}
deleteObjectOptions := &catalogmanagementv1.DeleteObjectOptions{}
deleteObjectOptions.SetCatalogIdentifier(d.Get("catalog_id").(string))
deleteObjectOptions.SetObjectIdentifier(d.Id())
response, err := catalogManagementClient.DeleteObjectWithContext(context, deleteObjectOptions)
if err != nil {
log.Printf("[DEBUG] DeleteObjectWithContext failed %s\n%s", err, response)
return diag.FromErr(fmt.Errorf("DeleteObjectWithContext failed %s\n%s", err, response))
}
d.SetId("")
return nil
}
func resourceIBMCmObjectMapToPublishObject(modelMap map[string]interface{}) (*catalogmanagementv1.PublishObject, error) {
model := &catalogmanagementv1.PublishObject{}
if modelMap["permit_ibm_public_publish"] != nil {
model.PermitIBMPublicPublish = core.BoolPtr(modelMap["permit_ibm_public_publish"].(bool))
}
if modelMap["ibm_approved"] != nil {
model.IBMApproved = core.BoolPtr(modelMap["ibm_approved"].(bool))
}
if modelMap["public_approved"] != nil {
model.PublicApproved = core.BoolPtr(modelMap["public_approved"].(bool))
}
return model, nil
}
func resourceIBMCmObjectMapToState(modelMap map[string]interface{}) (*catalogmanagementv1.State, error) {
model := &catalogmanagementv1.State{}
if modelMap["current"] != nil && modelMap["current"].(string) != "" {
model.Current = core.StringPtr(modelMap["current"].(string))
}
if modelMap["current_entered"] != nil {
}
if modelMap["pending"] != nil && modelMap["pending"].(string) != "" {
model.Pending = core.StringPtr(modelMap["pending"].(string))
}
if modelMap["pending_requested"] != nil {
}
if modelMap["previous"] != nil && modelMap["previous"].(string) != "" {
model.Previous = core.StringPtr(modelMap["previous"].(string))
}
return model, nil
}
func resourceIBMCmObjectPublishObjectToMap(model *catalogmanagementv1.PublishObject) (map[string]interface{}, error) {
modelMap := make(map[string]interface{})
if model.PermitIBMPublicPublish != nil {
modelMap["permit_ibm_public_publish"] = model.PermitIBMPublicPublish
}
if model.IBMApproved != nil {
modelMap["ibm_approved"] = model.IBMApproved
}
if model.PublicApproved != nil {
modelMap["public_approved"] = model.PublicApproved
}
return modelMap, nil
}
func resourceIBMCmObjectStateToMap(model *catalogmanagementv1.State) (map[string]interface{}, error) {
modelMap := make(map[string]interface{})
if model.Current != nil {
modelMap["current"] = model.Current
}
if model.CurrentEntered != nil {
modelMap["current_entered"] = model.CurrentEntered.String()
}
if model.Pending != nil {
modelMap["pending"] = model.Pending
}
if model.PendingRequested != nil {
modelMap["pending_requested"] = model.PendingRequested.String()
}
if model.Previous != nil {
modelMap["previous"] = model.Previous
}
return modelMap, nil
}