Skip to content

Commit c780e1f

Browse files
committed
update sdk
1 parent 37c0d33 commit c780e1f

File tree

16 files changed

+97
-110
lines changed

16 files changed

+97
-110
lines changed

api/coralogix/v1alpha1/apikey_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ type ApiKeyList struct {
113113
}
114114

115115
func (s *ApiKeySpec) ExtractCreateApiKeyRequest() *apikeys.CreateApiKeyRequest {
116-
owner := apikeys.Owner{}
116+
owner := &apikeys.Owner{}
117117
if s.Owner.UserId != nil {
118118
owner.OwnerUserId = &apikeys.OwnerUserId{UserId: s.Owner.UserId}
119119
}
@@ -122,9 +122,9 @@ func (s *ApiKeySpec) ExtractCreateApiKeyRequest() *apikeys.CreateApiKeyRequest {
122122
}
123123

124124
return &apikeys.CreateApiKeyRequest{
125-
Name: s.Name,
125+
Name: apikeys.PtrString(s.Name),
126126
Owner: owner,
127-
KeyPermissions: apikeys.CreateApiKeyRequestKeyPermissions{
127+
KeyPermissions: &apikeys.CreateApiKeyRequestKeyPermissions{
128128
Presets: s.Presets,
129129
Permissions: s.Permissions,
130130
},

api/coralogix/v1alpha1/connector_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,15 @@ var (
117117

118118
func (c *Connector) ExtractConnector() (*connectors.Connector, error) {
119119
connector := &connectors.Connector{
120-
Name: c.Spec.Name,
120+
Name: connectors.PtrString(c.Spec.Name),
121121
Description: connectors.PtrString(c.Spec.Description),
122122
}
123123

124124
connectorType, ok := schemaToOpenApiConnectorType[c.Spec.Type]
125125
if !ok {
126126
return nil, fmt.Errorf("unsupported connector type: %s", c.Spec.Type)
127127
}
128-
connector.Type = connectorType
128+
connector.Type = connectorType.Ptr()
129129

130130
connector.ConnectorConfig = &connectors.ConnectorConfig{
131131
Fields: ExtractConnectorConfigFields(c.Spec.ConnectorConfig.Fields),

api/coralogix/v1alpha1/globalrouter_types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ func (g *GlobalRouter) ExtractGlobalRouter(ctx context.Context) (*globalrouters.
111111

112112
return &globalrouters.GlobalRouter{
113113
Id: ptr.To("router_default"),
114-
EntityType: schemaToOpenApiRoutersEntityType[g.Spec.EntityType],
115-
Name: g.Spec.Name,
114+
EntityType: schemaToOpenApiRoutersEntityType[g.Spec.EntityType].Ptr(),
115+
Name: globalrouters.PtrString(g.Spec.Name),
116116
Description: globalrouters.PtrString(g.Spec.Description),
117117
Fallback: fallback,
118118
Rules: rules,
@@ -146,7 +146,7 @@ func extractRoutingRule(ctx context.Context, namespace string, rule RoutingRule)
146146

147147
return &globalrouters.RoutingRule{
148148
Name: ptr.To(rule.Name),
149-
Condition: rule.Condition,
149+
Condition: globalrouters.PtrString(rule.Condition),
150150
Targets: targets,
151151
}, nil
152152
}
@@ -185,7 +185,7 @@ func extractRoutingTarget(ctx context.Context, namespace string, target RoutingT
185185
}
186186

187187
return &globalrouters.RoutingTarget{
188-
ConnectorId: connectorID,
188+
ConnectorId: globalrouters.PtrString(connectorID),
189189
PresetId: ptr.To(presetID),
190190
}, nil
191191
}

api/coralogix/v1alpha1/integration_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (s *IntegrationSpec) ExtractCreateIntegrationRequest() (*integrations.SaveI
4444
return nil, fmt.Errorf("failed to extract parameters: %w", err)
4545
}
4646
return &integrations.SaveIntegrationRequest{
47-
Metadata: integrations.IntegrationMetadata{
47+
Metadata: &integrations.IntegrationMetadata{
4848
IntegrationKey: integrations.PtrString(s.IntegrationKey),
4949
Version: integrations.PtrString(s.Version),
5050
IntegrationParameters: &integrations.GenericIntegrationParameters{
@@ -54,15 +54,15 @@ func (s *IntegrationSpec) ExtractCreateIntegrationRequest() (*integrations.SaveI
5454
}, nil
5555
}
5656

57-
func (s *IntegrationSpec) ExtractUpdateIntegrationRequest(id string) (*integrations.UpdateIntegrationRequest, error) {
57+
func (s *IntegrationSpec) ExtractUpdateIntegrationRequest(id *string) (*integrations.UpdateIntegrationRequest, error) {
5858
parameters, err := s.ExtractParameters()
5959
if err != nil {
6060
return nil, fmt.Errorf("failed to extract parameters: %w", err)
6161
}
6262

6363
return &integrations.UpdateIntegrationRequest{
6464
Id: id,
65-
Metadata: integrations.IntegrationMetadata{
65+
Metadata: &integrations.IntegrationMetadata{
6666
IntegrationKey: integrations.PtrString(s.IntegrationKey),
6767
Version: integrations.PtrString(s.Version),
6868
IntegrationParameters: &integrations.GenericIntegrationParameters{

api/coralogix/v1alpha1/ipaccess_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func ExtractIPAccessRules(specRules []IPAccessRule) []ipaccess.IpAccess {
8989
for i, rule := range specRules {
9090
ipAccess[i] = ipaccess.IpAccess{
9191
Name: rule.Name,
92-
IpRange: rule.IPRange,
92+
IpRange: ipaccess.PtrString(rule.IPRange),
9393
Enabled: rule.Enabled,
9494
}
9595
}

api/coralogix/v1alpha1/outboundwebhook_types.go

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ type GenericWebhook struct {
9898

9999
func (in *GenericWebhook) extractGenericWebhookConfig() *webhooks.GenericWebhookConfig {
100100
return &webhooks.GenericWebhookConfig{
101-
Uuid: gouuid.NewString(),
102-
Method: GenericWebhookMethodTypeToOpenAPI[in.Method],
101+
Uuid: webhooks.PtrString(gouuid.NewString()),
102+
Method: GenericWebhookMethodTypeToOpenAPI[in.Method].Ptr(),
103103
Headers: ptr.To(in.Headers),
104104
Payload: in.Payload,
105105
}
@@ -140,15 +140,15 @@ func (in *Slack) extractSlackConfig() *webhooks.SlackConfig {
140140
digests := make([]webhooks.Digest, 0)
141141
for _, digest := range in.Digests {
142142
digests = append(digests, webhooks.Digest{
143-
Type: SlackConfigDigestTypeToOpenAPI[digest.Type],
143+
Type: SlackConfigDigestTypeToOpenAPI[digest.Type].Ptr(),
144144
IsActive: webhooks.PtrBool(digest.IsActive),
145145
})
146146
}
147147

148148
attachments := make([]webhooks.Attachment, 0)
149149
for _, attachment := range in.Attachments {
150150
attachments = append(attachments, webhooks.Attachment{
151-
Type: SlackConfigAttachmentTypeToOpenAPI[attachment.Type],
151+
Type: SlackConfigAttachmentTypeToOpenAPI[attachment.Type].Ptr(),
152152
IsActive: webhooks.PtrBool(attachment.IsActive),
153153
})
154154
}
@@ -225,7 +225,7 @@ type PagerDuty struct {
225225

226226
func (in *PagerDuty) extractPagerDutyConfig() *webhooks.PagerDutyConfig {
227227
return &webhooks.PagerDutyConfig{
228-
ServiceKey: in.ServiceKey,
228+
ServiceKey: webhooks.PtrString(in.ServiceKey),
229229
}
230230
}
231231

@@ -250,8 +250,8 @@ type SendLogStatus struct {
250250

251251
func (in *SendLog) extractSendLogConfig() *webhooks.SendLogConfig {
252252
return &webhooks.SendLogConfig{
253-
Payload: in.Payload,
254-
Uuid: gouuid.NewString(),
253+
Payload: webhooks.PtrString(in.Payload),
254+
Uuid: webhooks.PtrString(gouuid.NewString()),
255255
}
256256
}
257257

@@ -290,9 +290,9 @@ type Jira struct {
290290

291291
func (in *Jira) extractJiraConfig() *webhooks.JiraConfig {
292292
return &webhooks.JiraConfig{
293-
ApiToken: in.ApiToken,
294-
Email: in.Email,
295-
ProjectKey: in.ProjectKey,
293+
ApiToken: webhooks.PtrString(in.ApiToken),
294+
Email: webhooks.PtrString(in.Email),
295+
ProjectKey: webhooks.PtrString(in.ProjectKey),
296296
}
297297
}
298298

@@ -308,8 +308,8 @@ type Demisto struct {
308308

309309
func (in *Demisto) extractDemistoConfig() *webhooks.DemistoConfig {
310310
return &webhooks.DemistoConfig{
311-
Uuid: in.Uuid,
312-
Payload: in.Payload,
311+
Uuid: webhooks.PtrString(in.Uuid),
312+
Payload: webhooks.PtrString(in.Payload),
313313
}
314314
}
315315

@@ -323,11 +323,11 @@ type AwsEventBridge struct {
323323

324324
func (in *AwsEventBridge) extractAwsEventBridgeConfig() *webhooks.AwsEventBridgeConfig {
325325
return &webhooks.AwsEventBridgeConfig{
326-
EventBusArn: in.EventBusArn,
327-
Detail: in.Detail,
328-
DetailType: in.DetailType,
329-
Source: in.Source,
330-
RoleName: in.RoleName,
326+
EventBusArn: webhooks.PtrString(in.EventBusArn),
327+
Detail: webhooks.PtrString(in.Detail),
328+
DetailType: webhooks.PtrString(in.DetailType),
329+
Source: webhooks.PtrString(in.Source),
330+
RoleName: webhooks.PtrString(in.RoleName),
331331
}
332332
}
333333

@@ -388,7 +388,7 @@ func (in *OutboundWebhook) ExtractCreateOutboundWebhookRequest() (*webhooks.Crea
388388
}
389389

390390
return &webhooks.CreateOutgoingWebhookRequest{
391-
Data: *webhookData,
391+
Data: webhookData,
392392
}, nil
393393
}
394394

@@ -403,72 +403,69 @@ func (in *OutboundWebhook) ExtractUpdateOutboundWebhookRequest() (*webhooks.Upda
403403
}
404404

405405
return &webhooks.UpdateOutgoingWebhookRequest{
406-
Id: *in.Status.ID,
407-
Data: *webhookData,
406+
Id: in.Status.ID,
407+
Data: webhookData,
408408
}, nil
409409
}
410410

411411
func (in *OutboundWebhookSpec) ExtractOutgoingWebhookInputData() (*webhooks.OutgoingWebhookInputData, error) {
412412
if genericWebhook := in.OutboundWebhookType.GenericWebhook; genericWebhook != nil {
413413
return &webhooks.OutgoingWebhookInputData{
414414
OutgoingWebhookInputDataGenericWebhook: &webhooks.OutgoingWebhookInputDataGenericWebhook{
415-
Name: in.Name,
416-
Type: webhooks.WEBHOOKTYPE_GENERIC,
415+
Name: webhooks.PtrString(in.Name),
416+
Type: webhooks.WEBHOOKTYPE_GENERIC.Ptr(),
417417
Url: webhooks.PtrString(genericWebhook.Url),
418418
GenericWebhook: genericWebhook.extractGenericWebhookConfig(),
419419
},
420420
}, nil
421421
} else if slack := in.OutboundWebhookType.Slack; slack != nil {
422422
return &webhooks.OutgoingWebhookInputData{
423423
OutgoingWebhookInputDataSlack: &webhooks.OutgoingWebhookInputDataSlack{
424-
Name: in.Name,
425-
Type: webhooks.WEBHOOKTYPE_SLACK,
424+
Name: webhooks.PtrString(in.Name),
425+
Type: webhooks.WEBHOOKTYPE_SLACK.Ptr(),
426426
Url: webhooks.PtrString(slack.Url),
427427
Slack: slack.extractSlackConfig(),
428428
},
429429
}, nil
430430
} else if pagerDuty := in.OutboundWebhookType.PagerDuty; pagerDuty != nil {
431431
return &webhooks.OutgoingWebhookInputData{
432432
OutgoingWebhookInputDataPagerDuty: &webhooks.OutgoingWebhookInputDataPagerDuty{
433-
Name: in.Name,
434-
Type: webhooks.WEBHOOKTYPE_PAGERDUTY,
433+
Name: webhooks.PtrString(in.Name),
434+
Type: webhooks.WEBHOOKTYPE_PAGERDUTY.Ptr(),
435435
PagerDuty: pagerDuty.extractPagerDutyConfig(),
436436
},
437437
}, nil
438438
} else if sendLog := in.OutboundWebhookType.SendLog; sendLog != nil {
439439
return &webhooks.OutgoingWebhookInputData{
440440
OutgoingWebhookInputDataSendLog: &webhooks.OutgoingWebhookInputDataSendLog{
441-
Name: in.Name,
442-
Type: webhooks.WEBHOOKTYPE_SEND_LOG,
441+
Name: webhooks.PtrString(in.Name),
442+
Type: webhooks.WEBHOOKTYPE_SEND_LOG.Ptr(),
443443
Url: webhooks.PtrString(sendLog.Url),
444444
SendLog: sendLog.extractSendLogConfig(),
445445
},
446446
}, nil
447447
} else if emailGroup := in.OutboundWebhookType.EmailGroup; emailGroup != nil {
448448
return &webhooks.OutgoingWebhookInputData{
449449
OutgoingWebhookInputDataEmailGroup: &webhooks.OutgoingWebhookInputDataEmailGroup{
450-
Name: in.Name,
451-
Type: webhooks.WEBHOOKTYPE_EMAIL_GROUP,
450+
Name: webhooks.PtrString(in.Name),
451+
Type: webhooks.WEBHOOKTYPE_EMAIL_GROUP.Ptr(),
452452
EmailGroup: emailGroup.extractEmailGroupConfig(),
453453
},
454454
}, nil
455455
} else if microsoftTeams := in.OutboundWebhookType.MicrosoftTeams; microsoftTeams != nil {
456-
//data.Config = microsoftTeams.extractMicrosoftTeamsConfig()
457-
//data.Url = microsoftTeams.Url)
458-
//data.Type = cxsdk.WebhookTypeMicrosoftTeams
459456
return &webhooks.OutgoingWebhookInputData{
460457
OutgoingWebhookInputDataMicrosoftTeams: &webhooks.OutgoingWebhookInputDataMicrosoftTeams{
461-
Name: in.Name,
462-
Type: webhooks.WEBHOOKTYPE_MICROSOFT_TEAMS,
458+
Name: webhooks.PtrString(in.Name),
459+
Type: webhooks.WEBHOOKTYPE_MICROSOFT_TEAMS.Ptr(),
463460
Url: webhooks.PtrString(microsoftTeams.Url),
464461
MicrosoftTeams: map[string]interface{}{},
465462
},
466463
}, nil
467464
} else if jira := in.OutboundWebhookType.Jira; jira != nil {
468465
return &webhooks.OutgoingWebhookInputData{
469466
OutgoingWebhookInputDataJira: &webhooks.OutgoingWebhookInputDataJira{
470-
Name: in.Name,
471-
Type: webhooks.WEBHOOKTYPE_JIRA,
467+
Name: webhooks.PtrString(in.Name),
468+
Type: webhooks.WEBHOOKTYPE_JIRA.Ptr(),
472469
Url: webhooks.PtrString(jira.Url),
473470
Jira: jira.extractJiraConfig(),
474471
},
@@ -479,26 +476,26 @@ func (in *OutboundWebhookSpec) ExtractOutgoingWebhookInputData() (*webhooks.Outg
479476
//data.Url = opsgenie.Url)
480477
return &webhooks.OutgoingWebhookInputData{
481478
OutgoingWebhookInputDataOpsgenie: &webhooks.OutgoingWebhookInputDataOpsgenie{
482-
Name: in.Name,
483-
Type: webhooks.WEBHOOKTYPE_OPSGENIE,
479+
Name: webhooks.PtrString(in.Name),
480+
Type: webhooks.WEBHOOKTYPE_OPSGENIE.Ptr(),
484481
Url: webhooks.PtrString(opsgenie.Url),
485482
Opsgenie: map[string]interface{}{},
486483
},
487484
}, nil
488485
} else if demisto := in.OutboundWebhookType.Demisto; demisto != nil {
489486
return &webhooks.OutgoingWebhookInputData{
490487
OutgoingWebhookInputDataDemisto: &webhooks.OutgoingWebhookInputDataDemisto{
491-
Name: in.Name,
492-
Type: webhooks.WEBHOOKTYPE_DEMISTO,
488+
Name: webhooks.PtrString(in.Name),
489+
Type: webhooks.WEBHOOKTYPE_DEMISTO.Ptr(),
493490
Url: webhooks.PtrString(demisto.Url),
494491
Demisto: demisto.extractDemistoConfig(),
495492
},
496493
}, nil
497494
} else if in.OutboundWebhookType.AwsEventBridge != nil {
498495
return &webhooks.OutgoingWebhookInputData{
499496
OutgoingWebhookInputDataAwsEventBridge: &webhooks.OutgoingWebhookInputDataAwsEventBridge{
500-
Name: in.Name,
501-
Type: webhooks.WEBHOOKTYPE_AWS_EVENT_BRIDGE,
497+
Name: webhooks.PtrString(in.Name),
498+
Type: webhooks.WEBHOOKTYPE_AWS_EVENT_BRIDGE.Ptr(),
502499
AwsEventBridge: in.OutboundWebhookType.AwsEventBridge.extractAwsEventBridgeConfig(),
503500
},
504501
}, nil

api/coralogix/v1alpha1/preset_types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ var (
137137

138138
func (p *Preset) ExtractPreset() (*presets.Preset, error) {
139139
preset := &presets.Preset{
140-
Name: p.Spec.Name,
140+
Name: presets.PtrString(p.Spec.Name),
141141
Description: presets.PtrString(p.Spec.Description),
142142
ParentId: p.Spec.ParentId,
143143
}
@@ -153,7 +153,7 @@ func (p *Preset) ExtractPreset() (*presets.Preset, error) {
153153
return nil, fmt.Errorf("invalid entity type %s", p.Spec.EntityType)
154154
}
155155

156-
preset.EntityType = entityType
156+
preset.EntityType = entityType.Ptr()
157157
preset.ConfigOverrides = ExtractConfigOverrides(p.Spec.ConfigOverrides)
158158
return preset, nil
159159
}
@@ -193,8 +193,8 @@ func ExtractMessageConfig(messageConfig MessageConfig) *presets.MessageConfig {
193193
var fields []presets.NotificationCenterMessageConfigField
194194
for _, field := range messageConfig.Fields {
195195
fields = append(fields, presets.NotificationCenterMessageConfigField{
196-
FieldName: field.FieldName,
197-
Template: field.Template,
196+
FieldName: presets.PtrString(field.FieldName),
197+
Template: presets.PtrString(field.Template),
198198
})
199199
}
200200

api/coralogix/v1alpha1/slo_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,22 +157,22 @@ type SLO struct {
157157
Status SLOStatus `json:"status,omitempty"`
158158
}
159159

160-
func (s *SLO) ExtractSLOCreateRequest() (*slos.SlosServiceCreateSloRequest, error) {
160+
func (s *SLO) ExtractSLOCreateRequest() (*slos.SlosServiceReplaceSloRequest, error) {
161161
if requestBasedMetricSli := s.Spec.SliType.RequestBasedMetricSli; requestBasedMetricSli != nil {
162162
requestBased, err := s.Spec.ExtractRequestBasedMetricSli()
163163
if err != nil {
164164
return nil, fmt.Errorf("error extracting request based metric SLI: %w", err)
165165
}
166166

167-
return &slos.SlosServiceCreateSloRequest{
167+
return &slos.SlosServiceReplaceSloRequest{
168168
SloRequestBasedMetricSli: requestBased,
169169
}, nil
170170
} else if windowBasedMetricSli := s.Spec.SliType.WindowBasedMetricSli; windowBasedMetricSli != nil {
171171
windowBased, err := s.Spec.ExtractWindowBasedMetricSli()
172172
if err != nil {
173173
return nil, fmt.Errorf("error extracting window based metric SLI: %w", err)
174174
}
175-
return &slos.SlosServiceCreateSloRequest{
175+
return &slos.SlosServiceReplaceSloRequest{
176176
SloWindowBasedMetricSli: windowBased,
177177
}, nil
178178
}

api/coralogix/v1beta1/alert_types.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1915,7 +1915,10 @@ func fillWebhookNameToId(properties *GetResourceRefProperties) error {
19151915

19161916
properties.WebhookNameToId = make(map[string]int64)
19171917
for _, webhook := range webhooks.Deployed {
1918-
properties.WebhookNameToId[webhook.Name] = webhook.ExternalId
1918+
if webhook.Name == nil || webhook.ExternalId == nil {
1919+
continue
1920+
}
1921+
properties.WebhookNameToId[*webhook.Name] = *webhook.ExternalId
19191922
}
19201923

19211924
return nil

0 commit comments

Comments
 (0)