-
Notifications
You must be signed in to change notification settings - Fork 1
/
mcirapi.go
1527 lines (1240 loc) · 42.5 KB
/
mcirapi.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
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package request
import (
"encoding/json"
"errors"
"io"
"time"
gc "github.com/cloud-barista/poc-cicd-tumblebug/src/api/grpc/common"
"github.com/cloud-barista/poc-cicd-tumblebug/src/api/grpc/config"
"github.com/cloud-barista/poc-cicd-tumblebug/src/api/grpc/logger"
pb "github.com/cloud-barista/poc-cicd-tumblebug/src/api/grpc/protobuf/cbtumblebug"
"github.com/cloud-barista/poc-cicd-tumblebug/src/api/grpc/request/mcir"
core_mcir "github.com/cloud-barista/poc-cicd-tumblebug/src/core/mcir"
"google.golang.org/grpc"
)
// ===== [ Comtants and Variables ] =====
// ===== [ Types ] =====
// MCIRApi
type MCIRApi struct {
gConf *config.GrpcConfig
conn *grpc.ClientConn
jaegerCloser io.Closer
clientMCIR pb.MCIRClient
requestMCIR *mcir.MCIRRequest
inType string
outType string
}
// KeyValue
type KeyValue struct {
Key string `yaml:"Key" json:"Key"`
Value string `yaml:"Value" json:"Value"`
}
// IID - Defined by & used for CB-Spider
type IID struct {
NameId string `yaml:"NameId" json:"NameId"`
SystemId string `yaml:"SystemId" json:"SystemId"`
}
// TbImageCreateRequest - Wrapper struct
type TbImageCreateRequest struct {
NsId string `yaml:"nsId" json:"nsId"`
Item core_mcir.TbImageReq `yaml:"image" json:"image"`
}
// TbImageReq
// type TbImageReq struct {
// Name string `yaml:"name" json:"name"`
// ConnectionName string `yaml:"connectionName" json:"connectionName"`
// CspImageId string `yaml:"cspImageId" json:"cspImageId"`
// Description string `yaml:"description" json:"description"`
// }
// TbImageInfoRequest - Wrapper struct
type TbImageInfoRequest struct {
NsId string `yaml:"nsId" json:"nsId"`
Item core_mcir.TbImageInfo `yaml:"image" json:"image"`
}
// TbImageInfo
// type TbImageInfo struct {
// Id string `yaml:"id" json:"id"`
// Name string `yaml:"name" json:"name"`
// ConnectionName string `yaml:"connectionName" json:"connectionName"`
// CspImageId string `yaml:"cspImageId" json:"cspImageId"`
// CspImageName string `yaml:"cspImageName" json:"cspImageName"`
// Description string `yaml:"description" json:"description"`
// CreationDate string `yaml:"creationDate" json:"creationDate"`
// GuestOS string `yaml:"guestOS" json:"guestOS"`
// Status string `yaml:"status" json:"status"`
// KeyValueList []KeyValue `yaml:"keyValueList" json:"keyValueList"`
// AssociatedObjectList []string `yaml:"associatedObjectList" json:"associatedObjectList"`
// IsAutoGenerated bool `yaml:"isAutoGenerated" json:"isAutoGenerated"`
// }
// SearchImageQryRequest - Wrapper struct
type SearchImageQryRequest struct {
NsId string `yaml:"nsId" json:"nsId"`
Keywords []string `yaml:"keywords" json:"keywords"`
}
// TbSecurityGroupCreateRequest - Wrapper struct
type TbSecurityGroupCreateRequest struct {
NsId string `yaml:"nsId" json:"nsId"`
Item core_mcir.TbSecurityGroupReq `yaml:"securityGroup" json:"securityGroup"`
}
// TbSecurityGroupReq
// type TbSecurityGroupReq struct { // Tumblebug
// Name string `yaml:"name" json:"name"`
// ConnectionName string `yaml:"connectionName" json:"connectionName"`
// VNetId string `yaml:"vNetId" json:"vNetId"`
// Description string `yaml:"description" json:"description"`
// FirewallRules *[]SpiderSecurityRuleInfo `yaml:"firewallRules" json:"firewallRules"`
// }
// SpiderSecurityRuleInfo
// type SpiderSecurityRuleInfo struct { // Spider
// FromPort string `yaml:"fromPort" json:"fromPort"`
// ToPort string `yaml:"toPort" json:"toPort"`
// IPProtocol string `yaml:"ipProtocol" json:"ipProtocol"`
// Direction string `yaml:"direction" json:"direction"`
// CIDR string `yaml:"cidr" json:"cidr"`
// }
// TbSpecCreateRequest - Wrapper struct
type TbSpecCreateRequest struct {
NsId string `yaml:"nsId" json:"nsId"`
Item core_mcir.TbSpecReq `yaml:"spec" json:"spec"`
}
// TbSpecReq
// type TbSpecReq struct { // Tumblebug
// Name string `yaml:"name" json:"name"`
// ConnectionName string `yaml:"connectionName" json:"connectionName"`
// CspSpecName string `yaml:"cspSpecName" json:"cspSpecName"`
// Description string `yaml:"description" json:"description"`
// }
// TbSpecInfoRequest - Wrapper struct
type TbSpecInfoRequest struct {
NsId string `yaml:"nsId" json:"nsId"`
Item core_mcir.TbSpecInfo `yaml:"spec" json:"spec"`
}
// TbSpecInfo
// type TbSpecInfo struct { // Tumblebug
// Id string `yaml:"id" json:"id"`
// Name string `yaml:"name" json:"name"`
// ConnectionName string `yaml:"connectionName" json:"connectionName"`
// CspSpecName string `yaml:"cspSpecName" json:"cspSpecName"`
// Os_type string `yaml:"os_type" json:"os_type"`
// Num_vCPU uint16 `yaml:"num_vCPU" json:"num_vCPU"`
// Num_core uint16 `yaml:"num_core" json:"num_core"`
// Mem_GiB uint16 `yaml:"mem_GiB" json:"mem_GiB"`
// Storage_GiB uint32 `yaml:"storage_GiB" json:"storage_GiB"`
// Description string `yaml:"description" json:"description"`
// Cost_per_hour float32 `yaml:"cost_per_hour" json:"cost_per_hour"`
// Num_storage uint8 `yaml:"num_storage" json:"num_storage"`
// Max_num_storage uint8 `yaml:"max_num_storage" json:"max_num_storage"`
// Max_total_storage_TiB uint16 `yaml:"max_total_storage_TiB" json:"max_total_storage_TiB"`
// Net_bw_Gbps uint16 `yaml:"net_bw_Gbps" json:"net_bw_Gbps"`
// Ebs_bw_Mbps uint32 `yaml:"ebs_bw_Mbps" json:"ebs_bw_Mbps"`
// Gpu_model string `yaml:"gpu_model" json:"gpu_model"`
// Num_gpu uint8 `yaml:"num_gpu" json:"num_gpu"`
// Gpumem_GiB uint16 `yaml:"gpumem_GiB" json:"gpumem_GiB"`
// Gpu_p2p string `yaml:"gpu_p2p" json:"gpu_p2p"`
// OrderInFilteredResult uint16 `yaml:"orderInFilteredResult" json:"orderInFilteredResult"`
// EvaluationStatus string `yaml:"evaluationStatus" json:"evaluationStatus"`
// EvaluationScore_01 float32 `yaml:"evaluationScore_01" json:"evaluationScore_01"`
// EvaluationScore_02 float32 `yaml:"evaluationScore_02" json:"evaluationScore_02"`
// EvaluationScore_03 float32 `yaml:"evaluationScore_03" json:"evaluationScore_03"`
// EvaluationScore_04 float32 `yaml:"evaluationScore_04" json:"evaluationScore_04"`
// EvaluationScore_05 float32 `yaml:"evaluationScore_05" json:"evaluationScore_05"`
// EvaluationScore_06 float32 `yaml:"evaluationScore_06" json:"evaluationScore_06"`
// EvaluationScore_07 float32 `yaml:"evaluationScore_07" json:"evaluationScore_07"`
// EvaluationScore_08 float32 `yaml:"evaluationScore_08" json:"evaluationScore_08"`
// EvaluationScore_09 float32 `yaml:"evaluationScore_09" json:"evaluationScore_09"`
// EvaluationScore_10 float32 `yaml:"evaluationScore_10" json:"evaluationScore_10"`
// AssociatedObjectList []string `yaml:"associatedObjectList" json:"associatedObjectList"`
// IsAutoGenerated bool `yaml:"isAutoGenerated" json:"isAutoGenerated"`
// }
// TbSshKeyCreateRequest - Wrapper struct
type TbSshKeyCreateRequest struct {
NsId string `yaml:"nsId" json:"nsId"`
Item core_mcir.TbSshKeyReq `yaml:"sshKey" json:"sshKey"`
}
// TbSshKeyReq
// type TbSshKeyReq struct {
// Name string `yaml:"name" json:"name"`
// ConnectionName string `yaml:"connectionName" json:"connectionName"`
// Description string `yaml:"description" json:"description"`
// }
// TbVNetCreateRequest - Wrapper struct
type TbVNetCreateRequest struct {
NsId string `yaml:"nsId" json:"nsId"`
Item core_mcir.TbVNetReq `yaml:"vNet" json:"vNet"`
}
// TbVNetReq
// type TbVNetReq struct { // Tumblebug
// Name string `yaml:"name" json:"name"`
// ConnectionName string `yaml:"connectionName" json:"connectionName"`
// CidrBlock string `yaml:"cidrBlock" json:"cidrBlock"`
// SubnetInfoList []SpiderSubnetReqInfo `yaml:"subnetInfoList" json:"subnetInfoList"`
// Description string `yaml:"description" json:"description"`
// }
// SpiderSubnetReqInfo
// type SpiderSubnetReqInfo struct { // Spider
// Name string `yaml:"Name" json:"Name"`
// IPv4_CIDR string `yaml:"IPv4_CIDR" json:"IPv4_CIDR"`
// KeyValueList []KeyValue `yaml:"KeyValueList" json:"KeyValueList"`
// }
// ===== [ Implementatiom ] =====
// SetServerAddr - Set Tumblebug server address
func (m *MCIRApi) SetServerAddr(addr string) error {
if addr == "" {
return errors.New("parameter is empty")
}
m.gConf.GSL.TumblebugCli.ServerAddr = addr
return nil
}
// GetServerAddr - Get Tumblebug server address
func (m *MCIRApi) GetServerAddr() (string, error) {
return m.gConf.GSL.TumblebugCli.ServerAddr, nil
}
// SetTLSCA - Set TLS CA
func (m *MCIRApi) SetTLSCA(tlsCAFile string) error {
if tlsCAFile == "" {
return errors.New("parameter is empty")
}
if m.gConf.GSL.TumblebugCli.TLS == nil {
m.gConf.GSL.TumblebugCli.TLS = &config.TLSConfig{}
}
m.gConf.GSL.TumblebugCli.TLS.TLSCA = tlsCAFile
return nil
}
// GetTLSCA - Get TLS CA
func (m *MCIRApi) GetTLSCA() (string, error) {
if m.gConf.GSL.TumblebugCli.TLS == nil {
return "", nil
}
return m.gConf.GSL.TumblebugCli.TLS.TLSCA, nil
}
// SetTimeout
func (m *MCIRApi) SetTimeout(timeout time.Duration) error {
m.gConf.GSL.TumblebugCli.Timeout = timeout
return nil
}
// GetTimeout
func (m *MCIRApi) GetTimeout() (time.Duration, error) {
return m.gConf.GSL.TumblebugCli.Timeout, nil
}
// SetJWTToken - Set JWT auth token
func (m *MCIRApi) SetJWTToken(token string) error {
if token == "" {
return errors.New("parameter is empty")
}
if m.gConf.GSL.TumblebugCli.Interceptors == nil {
m.gConf.GSL.TumblebugCli.Interceptors = &config.InterceptorsConfig{}
m.gConf.GSL.TumblebugCli.Interceptors.AuthJWT = &config.AuthJWTConfig{}
}
if m.gConf.GSL.TumblebugCli.Interceptors.AuthJWT == nil {
m.gConf.GSL.TumblebugCli.Interceptors.AuthJWT = &config.AuthJWTConfig{}
}
m.gConf.GSL.TumblebugCli.Interceptors.AuthJWT.JWTToken = token
return nil
}
// GetJWTToken - Get JWT auth token
func (m *MCIRApi) GetJWTToken() (string, error) {
if m.gConf.GSL.TumblebugCli.Interceptors == nil {
return "", nil
}
if m.gConf.GSL.TumblebugCli.Interceptors.AuthJWT == nil {
return "", nil
}
return m.gConf.GSL.TumblebugCli.Interceptors.AuthJWT.JWTToken, nil
}
// SetConfigPath
func (m *MCIRApi) SetConfigPath(configFile string) error {
logger := logger.NewLogger()
// Make new config parser that uses Viper library
parser := config.MakeParser()
var (
gConf config.GrpcConfig
err error
)
if configFile == "" {
logger.Error("Please, provide the path to your configuration file")
return errors.New("configuration file are not specified")
}
logger.Debug("Parsing configuration file: ", configFile)
if gConf, err = parser.GrpcParse(configFile); err != nil {
logger.Error("ERROR - Parsing the configuration file.\n", err.Error())
return err
}
// Check input data
tumblebugcli := gConf.GSL.TumblebugCli
if tumblebugcli == nil {
return errors.New("tumblebugcli field are not specified")
}
if tumblebugcli.ServerAddr == "" {
return errors.New("tumblebugcli.server_addr field are not specified")
}
if tumblebugcli.Timeout == 0 {
tumblebugcli.Timeout = 90 * time.Second
}
if tumblebugcli.TLS != nil {
if tumblebugcli.TLS.TLSCA == "" {
return errors.New("tumblebugcli.tls.tls_ca field are not specified")
}
}
if tumblebugcli.Interceptors != nil {
if tumblebugcli.Interceptors.AuthJWT != nil {
if tumblebugcli.Interceptors.AuthJWT.JWTToken == "" {
return errors.New("tumblebugcli.interceptors.auth_jwt.jwt_token field are not specified")
}
}
if tumblebugcli.Interceptors.Opentracing != nil {
if tumblebugcli.Interceptors.Opentracing.Jaeger != nil {
if tumblebugcli.Interceptors.Opentracing.Jaeger.Endpoint == "" {
return errors.New("tumblebugcli.interceptors.opentracing.jaeger.endpoint field are not specified")
}
}
}
}
m.gConf = &gConf
return nil
}
// Open - Open new connection
func (m *MCIRApi) Open() error {
tumblebugcli := m.gConf.GSL.TumblebugCli
// grpc 커넥션 생성
cbconn, closer, err := gc.NewCBConnection(tumblebugcli)
if err != nil {
return err
}
if closer != nil {
m.jaegerCloser = closer
}
m.conn = cbconn.Conn
// grpc 클라이언트 생성
m.clientMCIR = pb.NewMCIRClient(m.conn)
// grpc 호출 Wrapper
m.requestMCIR = &mcir.MCIRRequest{Client: m.clientMCIR, Timeout: tumblebugcli.Timeout, InType: m.inType, OutType: m.outType}
return nil
}
// Close - Close connection
func (m *MCIRApi) Close() {
if m.conn != nil {
m.conn.Close()
}
if m.jaegerCloser != nil {
m.jaegerCloser.Close()
}
m.jaegerCloser = nil
m.conn = nil
m.clientMCIR = nil
m.requestMCIR = nil
}
// SetInType - Set input doc type (json/yaml)
func (m *MCIRApi) SetInType(in string) error {
if in == "json" {
m.inType = in
} else if in == "yaml" {
m.inType = in
} else {
return errors.New("input type is not supported")
}
if m.requestMCIR != nil {
m.requestMCIR.InType = m.inType
}
return nil
}
// GetInType - Get input doc type (json/yaml)
func (m *MCIRApi) GetInType() (string, error) {
return m.inType, nil
}
// SetOutType - Set output doc type (json/yaml)
func (m *MCIRApi) SetOutType(out string) error {
if out == "json" {
m.outType = out
} else if out == "yaml" {
m.outType = out
} else {
return errors.New("output type is not supported")
}
if m.requestMCIR != nil {
m.requestMCIR.OutType = m.outType
}
return nil
}
// GetOutType - Get output doc type (json/yaml)
func (m *MCIRApi) GetOutType() (string, error) {
return m.outType, nil
}
// CreateImageWithInfo
func (m *MCIRApi) CreateImageWithInfo(doc string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
m.requestMCIR.InData = doc
return m.requestMCIR.CreateImageWithInfo()
}
// CreateImageWithInfoByParam
func (m *MCIRApi) CreateImageWithInfoByParam(req *TbImageInfoRequest) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
holdType, _ := m.GetInType()
m.SetInType("json")
j, err := json.Marshal(req)
if err != nil {
return "", err
}
m.requestMCIR.InData = string(j)
result, err := m.requestMCIR.CreateImageWithInfo()
m.SetInType(holdType)
return result, err
}
// CreateImageWithID
func (m *MCIRApi) CreateImageWithID(doc string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
m.requestMCIR.InData = doc
return m.requestMCIR.CreateImageWithID()
}
// CreateImageWithIDByParam
func (m *MCIRApi) CreateImageWithIDByParam(req *TbImageCreateRequest) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
holdType, _ := m.GetInType()
m.SetInType("json")
j, err := json.Marshal(req)
if err != nil {
return "", err
}
m.requestMCIR.InData = string(j)
result, err := m.requestMCIR.CreateImageWithID()
m.SetInType(holdType)
return result, err
}
// ListImage
func (m *MCIRApi) ListImage(doc string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
m.requestMCIR.InData = doc
return m.requestMCIR.ListImage()
}
// ListImageByParam
func (m *MCIRApi) ListImageByParam(nameSpaceID string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
holdType, _ := m.GetInType()
m.SetInType("json")
m.requestMCIR.InData = `{"nsId":"` + nameSpaceID + `", "resourceType":"image"}`
result, err := m.requestMCIR.ListImage()
m.SetInType(holdType)
return result, err
}
// ListImageId
func (m *MCIRApi) ListImageId(doc string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
m.requestMCIR.InData = doc
return m.requestMCIR.ListImageId()
}
// ListImageIdByParam
func (m *MCIRApi) ListImageIdByParam(nameSpaceID string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
holdType, _ := m.GetInType()
m.SetInType("json")
m.requestMCIR.InData = `{"nsId":"` + nameSpaceID + `", "resourceType":"image"}`
result, err := m.requestMCIR.ListImageId()
m.SetInType(holdType)
return result, err
}
// GetImage
func (m *MCIRApi) GetImage(doc string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
m.requestMCIR.InData = doc
return m.requestMCIR.GetImage()
}
// GetImageByParam
func (m *MCIRApi) GetImageByParam(nameSpaceID string, resourceID string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
holdType, _ := m.GetInType()
m.SetInType("json")
m.requestMCIR.InData = `{"nsId":"` + nameSpaceID + `", "resourceType":"image", "resourceId":"` + resourceID + `"}`
result, err := m.requestMCIR.GetImage()
m.SetInType(holdType)
return result, err
}
// DeleteImage
func (m *MCIRApi) DeleteImage(doc string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
m.requestMCIR.InData = doc
return m.requestMCIR.DeleteImage()
}
// DeleteImageByParam
func (m *MCIRApi) DeleteImageByParam(nameSpaceID string, resourceID string, force string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
holdType, _ := m.GetInType()
m.SetInType("json")
m.requestMCIR.InData = `{"nsId":"` + nameSpaceID + `", "resourceType":"image", "resourceId":"` + resourceID + `", "force":"` + force + `"}`
result, err := m.requestMCIR.DeleteImage()
m.SetInType(holdType)
return result, err
}
// DeleteAllImage
func (m *MCIRApi) DeleteAllImage(doc string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
m.requestMCIR.InData = doc
return m.requestMCIR.DeleteAllImage()
}
// DeleteAllImageByParam
func (m *MCIRApi) DeleteAllImageByParam(nameSpaceID string, force string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
holdType, _ := m.GetInType()
m.SetInType("json")
m.requestMCIR.InData = `{"nsId":"` + nameSpaceID + `", "resourceType":"image", "force":"` + force + `"}`
result, err := m.requestMCIR.DeleteAllImage()
m.SetInType(holdType)
return result, err
}
// FetchImage
func (m *MCIRApi) FetchImage(doc string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
m.requestMCIR.InData = doc
return m.requestMCIR.FetchImage()
}
// FetchImageByParam
func (m *MCIRApi) FetchImageByParam(connConfigName string, nameSpaceID string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
holdType, _ := m.GetInType()
m.SetInType("json")
m.requestMCIR.InData = `{"ConnectionName":"` + connConfigName + `", "nsId":"` + nameSpaceID + `"}`
result, err := m.requestMCIR.FetchImage()
m.SetInType(holdType)
return result, err
}
// SearchImage
func (m *MCIRApi) SearchImage(doc string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
m.requestMCIR.InData = doc
return m.requestMCIR.SearchImage()
}
// SearchImageByParam
func (m *MCIRApi) SearchImageByParam(req *SearchImageQryRequest) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
holdType, _ := m.GetInType()
m.SetInType("json")
j, err := json.Marshal(req)
if err != nil {
return "", err
}
m.requestMCIR.InData = string(j)
result, err := m.requestMCIR.SearchImage()
m.SetInType(holdType)
return result, err
}
// ListLookupImage - LookupImages
func (m *MCIRApi) ListLookupImage(doc string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
m.requestMCIR.InData = doc
return m.requestMCIR.ListLookupImage()
}
// ListLookupImageByParam - LookupImages
func (m *MCIRApi) ListLookupImageByParam(connConfigName string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
holdType, _ := m.GetInType()
m.SetInType("json")
m.requestMCIR.InData = `{"ConnectionName":"` + connConfigName + `"}`
result, err := m.requestMCIR.ListLookupImage()
m.SetInType(holdType)
return result, err
}
// GetLookupImage - LookupImage
func (m *MCIRApi) GetLookupImage(doc string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
m.requestMCIR.InData = doc
return m.requestMCIR.GetLookupImage()
}
// GetLookupImageByParam - LookupImage
func (m *MCIRApi) GetLookupImageByParam(connConfigName string, cspImageId string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
holdType, _ := m.GetInType()
m.SetInType("json")
m.requestMCIR.InData = `{"ConnectionName":"` + connConfigName + `", "cspImageId": "` + cspImageId + `"}`
result, err := m.requestMCIR.GetLookupImage()
m.SetInType(holdType)
return result, err
}
// CreateSecurityGroup
func (m *MCIRApi) CreateSecurityGroup(doc string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
m.requestMCIR.InData = doc
return m.requestMCIR.CreateSecurityGroup()
}
// CreateSecurityGroupByParam
func (m *MCIRApi) CreateSecurityGroupByParam(req *TbSecurityGroupCreateRequest) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
holdType, _ := m.GetInType()
m.SetInType("json")
j, err := json.Marshal(req)
if err != nil {
return "", err
}
m.requestMCIR.InData = string(j)
result, err := m.requestMCIR.CreateSecurityGroup()
m.SetInType(holdType)
return result, err
}
// ListSecurityGroup
func (m *MCIRApi) ListSecurityGroup(doc string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
m.requestMCIR.InData = doc
return m.requestMCIR.ListSecurityGroup()
}
// ListSecurityGroupByParam
func (m *MCIRApi) ListSecurityGroupByParam(nameSpaceID string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
holdType, _ := m.GetInType()
m.SetInType("json")
m.requestMCIR.InData = `{"nsId":"` + nameSpaceID + `", "resourceType":"securityGroup"}`
result, err := m.requestMCIR.ListSecurityGroup()
m.SetInType(holdType)
return result, err
}
// ListSecurityGroupId
func (m *MCIRApi) ListSecurityGroupId(doc string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
m.requestMCIR.InData = doc
return m.requestMCIR.ListSecurityGroupId()
}
// ListSecurityGroupIdByParam
func (m *MCIRApi) ListSecurityGroupIdByParam(nameSpaceID string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
holdType, _ := m.GetInType()
m.SetInType("json")
m.requestMCIR.InData = `{"nsId":"` + nameSpaceID + `", "resourceType":"securityGroup"}`
result, err := m.requestMCIR.ListSecurityGroupId()
m.SetInType(holdType)
return result, err
}
// GetSecurityGroup
func (m *MCIRApi) GetSecurityGroup(doc string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
m.requestMCIR.InData = doc
return m.requestMCIR.GetSecurityGroup()
}
// GetSecurityGroupByParam
func (m *MCIRApi) GetSecurityGroupByParam(nameSpaceID string, resourceID string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
holdType, _ := m.GetInType()
m.SetInType("json")
m.requestMCIR.InData = `{"nsId":"` + nameSpaceID + `", "resourceType":"securityGroup", "resourceId":"` + resourceID + `"}`
result, err := m.requestMCIR.GetSecurityGroup()
m.SetInType(holdType)
return result, err
}
// DeleteSecurityGroup
func (m *MCIRApi) DeleteSecurityGroup(doc string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
m.requestMCIR.InData = doc
return m.requestMCIR.DeleteSecurityGroup()
}
// DeleteSecurityGroupByParam
func (m *MCIRApi) DeleteSecurityGroupByParam(nameSpaceID string, resourceID string, force string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
holdType, _ := m.GetInType()
m.SetInType("json")
m.requestMCIR.InData = `{"nsId":"` + nameSpaceID + `", "resourceType":"securityGroup", "resourceId":"` + resourceID + `", "force":"` + force + `"}`
result, err := m.requestMCIR.DeleteSecurityGroup()
m.SetInType(holdType)
return result, err
}
// DeleteAllSecurityGroup
func (m *MCIRApi) DeleteAllSecurityGroup(doc string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
m.requestMCIR.InData = doc
return m.requestMCIR.DeleteAllSecurityGroup()
}
// DeleteAllSecurityGroupByParam
func (m *MCIRApi) DeleteAllSecurityGroupByParam(nameSpaceID string, force string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
holdType, _ := m.GetInType()
m.SetInType("json")
m.requestMCIR.InData = `{"nsId":"` + nameSpaceID + `", "resourceType":"securityGroup", "force":"` + force + `"}`
result, err := m.requestMCIR.DeleteAllImage()
m.SetInType(holdType)
return result, err
}
// CreateSpecWithInfo
func (m *MCIRApi) CreateSpecWithInfo(doc string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
m.requestMCIR.InData = doc
return m.requestMCIR.CreateSpecWithInfo()
}
// CreateSpecWithInfoByParam
func (m *MCIRApi) CreateSpecWithInfoByParam(req *TbSpecInfoRequest) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
holdType, _ := m.GetInType()
m.SetInType("json")
j, err := json.Marshal(req)
if err != nil {
return "", err
}
m.requestMCIR.InData = string(j)
result, err := m.requestMCIR.CreateSpecWithInfo()
m.SetInType(holdType)
return result, err
}
// CreateSpecWithSpecName
func (m *MCIRApi) CreateSpecWithSpecName(doc string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
m.requestMCIR.InData = doc
return m.requestMCIR.CreateSpecWithSpecName()
}
// CreateSpecWithSpecNameByParam
func (m *MCIRApi) CreateSpecWithSpecNameByParam(req *TbSpecCreateRequest) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
holdType, _ := m.GetInType()
m.SetInType("json")
j, err := json.Marshal(req)
if err != nil {
return "", err
}
m.requestMCIR.InData = string(j)
result, err := m.requestMCIR.CreateSpecWithSpecName()
m.SetInType(holdType)
return result, err
}
// ListSpec
func (m *MCIRApi) ListSpec(doc string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
m.requestMCIR.InData = doc
return m.requestMCIR.ListSpec()
}
// ListSpecByParam
func (m *MCIRApi) ListSpecByParam(nameSpaceID string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
holdType, _ := m.GetInType()
m.SetInType("json")
m.requestMCIR.InData = `{"nsId":"` + nameSpaceID + `", "resourceType":"spec"}`
result, err := m.requestMCIR.ListSpec()
m.SetInType(holdType)
return result, err
}
// ListSpecId
func (m *MCIRApi) ListSpecId(doc string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
m.requestMCIR.InData = doc
return m.requestMCIR.ListSpecId()
}
// ListSpecIdByParam
func (m *MCIRApi) ListSpecIdByParam(nameSpaceID string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
holdType, _ := m.GetInType()
m.SetInType("json")
m.requestMCIR.InData = `{"nsId":"` + nameSpaceID + `", "resourceType":"spec"}`
result, err := m.requestMCIR.ListSpecId()
m.SetInType(holdType)
return result, err
}
// GetSpec
func (m *MCIRApi) GetSpec(doc string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
m.requestMCIR.InData = doc
return m.requestMCIR.GetSpec()
}
// GetSpecByParam
func (m *MCIRApi) GetSpecByParam(nameSpaceID string, resourceID string) (string, error) {
if m.requestMCIR == nil {
return "", errors.New("The Open() function must be called")
}
holdType, _ := m.GetInType()