From 742393860c45f46c7155d382479b41a47c35d7d3 Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Fri, 13 Dec 2024 05:07:26 +0530 Subject: [PATCH 1/4] feat(CIS): Logpush to cloud logs and generic destination --- logpushjobsapiv1/logpush_jobs_api_v1.go | 2024 +++++++++++------------ 1 file changed, 970 insertions(+), 1054 deletions(-) diff --git a/logpushjobsapiv1/logpush_jobs_api_v1.go b/logpushjobsapiv1/logpush_jobs_api_v1.go index 2f4a206..d7cf324 100644 --- a/logpushjobsapiv1/logpush_jobs_api_v1.go +++ b/logpushjobsapiv1/logpush_jobs_api_v1.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2022. + * (C) Copyright IBM Corp. 2024. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ /* - * IBM OpenAPI SDK Code Generator Version: 3.43.4-432d779b-20220119-173927 + * IBM OpenAPI SDK Code Generator Version: 3.98.0-8be2046a-20241205-162752 */ // Package logpushjobsapiv1 : Operations and models for the LogpushJobsApiV1 service @@ -24,7 +24,6 @@ package logpushjobsapiv1 import ( "context" "encoding/json" - "fmt" "net/http" "reflect" "time" @@ -33,18 +32,20 @@ import ( common "github.com/IBM/networking-go-sdk/common" ) -// LogpushJobsApiV1 : CIS Loupush Jobs +// LogpushJobsApiV1 : CIS Logpush Jobs +// +// API Version: 1.0.0 type LogpushJobsApiV1 struct { Service *core.BaseService - // Full url-encoded CRN of the service instance. + // Full URL-encoded CRN of the service instance. Crn *string - // The domain id. - ZoneID *string - // The dataset. Dataset *string + + // Zone identifier. + ZoneID *string } // DefaultServiceURL is the default URL to make service requests to. @@ -59,14 +60,14 @@ type LogpushJobsApiV1Options struct { URL string Authenticator core.Authenticator - // Full url-encoded CRN of the service instance. + // Full URL-encoded CRN of the service instance. Crn *string `validate:"required"` - // The domain id. - ZoneID *string `validate:"required"` - // The dataset. Dataset *string `validate:"required"` + + // Zone identifier. + ZoneID *string `validate:"required"` } // NewLogpushJobsApiV1UsingExternalConfig : constructs an instance of LogpushJobsApiV1 with passed in options and external configuration. @@ -78,22 +79,26 @@ func NewLogpushJobsApiV1UsingExternalConfig(options *LogpushJobsApiV1Options) (l if options.Authenticator == nil { options.Authenticator, err = core.GetAuthenticatorFromEnvironment(options.ServiceName) if err != nil { + err = core.SDKErrorf(err, "", "env-auth-error", common.GetComponentInfo()) return } } logpushJobsApi, err = NewLogpushJobsApiV1(options) + err = core.RepurposeSDKProblem(err, "new-client-error") if err != nil { return } err = logpushJobsApi.Service.ConfigureService(options.ServiceName) if err != nil { + err = core.SDKErrorf(err, "", "client-config-error", common.GetComponentInfo()) return } if options.URL != "" { err = logpushJobsApi.Service.SetServiceURL(options.URL) + err = core.RepurposeSDKProblem(err, "url-set-error") } return } @@ -107,26 +112,29 @@ func NewLogpushJobsApiV1(options *LogpushJobsApiV1Options) (service *LogpushJobs err = core.ValidateStruct(options, "options") if err != nil { + err = core.SDKErrorf(err, "", "invalid-global-options", common.GetComponentInfo()) return } baseService, err := core.NewBaseService(serviceOptions) if err != nil { + err = core.SDKErrorf(err, "", "new-base-error", common.GetComponentInfo()) return } if options.URL != "" { err = baseService.SetServiceURL(options.URL) if err != nil { + err = core.SDKErrorf(err, "", "set-url-error", common.GetComponentInfo()) return } } service = &LogpushJobsApiV1{ Service: baseService, - Crn: options.Crn, - ZoneID: options.ZoneID, + Crn: options.Crn, Dataset: options.Dataset, + ZoneID: options.ZoneID, } return @@ -134,7 +142,7 @@ func NewLogpushJobsApiV1(options *LogpushJobsApiV1Options) (service *LogpushJobs // GetServiceURLForRegion returns the service URL to be used for the specified region func GetServiceURLForRegion(region string) (string, error) { - return "", fmt.Errorf("service does not support regional URLs") + return "", core.SDKErrorf(nil, "service does not support regional URLs", "no-regional-support", common.GetComponentInfo()) } // Clone makes a copy of "logpushJobsApi" suitable for processing requests. @@ -149,7 +157,11 @@ func (logpushJobsApi *LogpushJobsApiV1) Clone() *LogpushJobsApiV1 { // SetServiceURL sets the service URL func (logpushJobsApi *LogpushJobsApiV1) SetServiceURL(url string) error { - return logpushJobsApi.Service.SetServiceURL(url) + err := logpushJobsApi.Service.SetServiceURL(url) + if err != nil { + err = core.SDKErrorf(err, "", "url-set-error", common.GetComponentInfo()) + } + return err } // GetServiceURL returns the service URL @@ -183,37 +195,41 @@ func (logpushJobsApi *LogpushJobsApiV1) DisableRetries() { logpushJobsApi.Service.DisableRetries() } -// GetLogpushJobs : List logpush jobs +// GetLogpushJobsV2 : List logpush jobs // List configured logpush jobs for your domain. -func (logpushJobsApi *LogpushJobsApiV1) GetLogpushJobs(getLogpushJobsOptions *GetLogpushJobsOptions) (result *ListLogpushJobsResp, response *core.DetailedResponse, err error) { - return logpushJobsApi.GetLogpushJobsWithContext(context.Background(), getLogpushJobsOptions) +func (logpushJobsApi *LogpushJobsApiV1) GetLogpushJobsV2(getLogpushJobsV2Options *GetLogpushJobsV2Options) (result *ListLogpushJobsResp, response *core.DetailedResponse, err error) { + result, response, err = logpushJobsApi.GetLogpushJobsV2WithContext(context.Background(), getLogpushJobsV2Options) + err = core.RepurposeSDKProblem(err, "") + return } -// GetLogpushJobsWithContext is an alternate form of the GetLogpushJobs method which supports a Context parameter -func (logpushJobsApi *LogpushJobsApiV1) GetLogpushJobsWithContext(ctx context.Context, getLogpushJobsOptions *GetLogpushJobsOptions) (result *ListLogpushJobsResp, response *core.DetailedResponse, err error) { - err = core.ValidateStruct(getLogpushJobsOptions, "getLogpushJobsOptions") +// GetLogpushJobsV2WithContext is an alternate form of the GetLogpushJobsV2 method which supports a Context parameter +func (logpushJobsApi *LogpushJobsApiV1) GetLogpushJobsV2WithContext(ctx context.Context, getLogpushJobsV2Options *GetLogpushJobsV2Options) (result *ListLogpushJobsResp, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(getLogpushJobsV2Options, "getLogpushJobsV2Options") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } pathParamsMap := map[string]string{ - "crn": *logpushJobsApi.Crn, + "crn": *logpushJobsApi.Crn, "zone_id": *logpushJobsApi.ZoneID, } builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = logpushJobsApi.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v1/{crn}/zones/{zone_id}/logpush/jobs`, pathParamsMap) + _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v2/{crn}/zones/{zone_id}/logpush/jobs`, pathParamsMap) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } - for headerName, headerValue := range getLogpushJobsOptions.Headers { + for headerName, headerValue := range getLogpushJobsV2Options.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "GetLogpushJobs") + sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "GetLogpushJobsV2") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -221,17 +237,21 @@ func (logpushJobsApi *LogpushJobsApiV1) GetLogpushJobsWithContext(ctx context.Co request, err := builder.Build() if err != nil { + err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo()) return } var rawResponse map[string]json.RawMessage response, err = logpushJobsApi.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "get_logpush_jobs_v2", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalListLogpushJobsResp) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -240,83 +260,72 @@ func (logpushJobsApi *LogpushJobsApiV1) GetLogpushJobsWithContext(ctx context.Co return } -// CreateLogpushJob : Create a logpush jobs +// CreateLogpushJobV2 : Create a logpush jobs // Create a new logpush job for the domain. -func (logpushJobsApi *LogpushJobsApiV1) CreateLogpushJob(createLogpushJobOptions *CreateLogpushJobOptions) (result *LogpushJobsResp, response *core.DetailedResponse, err error) { - return logpushJobsApi.CreateLogpushJobWithContext(context.Background(), createLogpushJobOptions) +func (logpushJobsApi *LogpushJobsApiV1) CreateLogpushJobV2(createLogpushJobV2Options *CreateLogpushJobV2Options) (result *LogpushJobsResp, response *core.DetailedResponse, err error) { + result, response, err = logpushJobsApi.CreateLogpushJobV2WithContext(context.Background(), createLogpushJobV2Options) + err = core.RepurposeSDKProblem(err, "") + return } -// CreateLogpushJobWithContext is an alternate form of the CreateLogpushJob method which supports a Context parameter -func (logpushJobsApi *LogpushJobsApiV1) CreateLogpushJobWithContext(ctx context.Context, createLogpushJobOptions *CreateLogpushJobOptions) (result *LogpushJobsResp, response *core.DetailedResponse, err error) { - err = core.ValidateStruct(createLogpushJobOptions, "createLogpushJobOptions") +// CreateLogpushJobV2WithContext is an alternate form of the CreateLogpushJobV2 method which supports a Context parameter +func (logpushJobsApi *LogpushJobsApiV1) CreateLogpushJobV2WithContext(ctx context.Context, createLogpushJobV2Options *CreateLogpushJobV2Options) (result *LogpushJobsResp, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(createLogpushJobV2Options, "createLogpushJobV2Options") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } pathParamsMap := map[string]string{ - "crn": *logpushJobsApi.Crn, + "crn": *logpushJobsApi.Crn, "zone_id": *logpushJobsApi.ZoneID, } builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = logpushJobsApi.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v1/{crn}/zones/{zone_id}/logpush/jobs`, pathParamsMap) + _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v2/{crn}/zones/{zone_id}/logpush/jobs`, pathParamsMap) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } - for headerName, headerValue := range createLogpushJobOptions.Headers { + for headerName, headerValue := range createLogpushJobV2Options.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "CreateLogpushJob") + sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "CreateLogpushJobV2") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") builder.AddHeader("Content-Type", "application/json") - body := make(map[string]interface{}) - if createLogpushJobOptions.Name != nil { - body["name"] = createLogpushJobOptions.Name - } - if createLogpushJobOptions.Enabled != nil { - body["enabled"] = createLogpushJobOptions.Enabled - } - if createLogpushJobOptions.LogpullOptions != nil { - body["logpull_options"] = createLogpushJobOptions.LogpullOptions - } - if createLogpushJobOptions.DestinationConf != nil { - body["destination_conf"] = createLogpushJobOptions.DestinationConf - } - if createLogpushJobOptions.OwnershipChallenge != nil { - body["ownership_challenge"] = createLogpushJobOptions.OwnershipChallenge - } - if createLogpushJobOptions.Dataset != nil { - body["dataset"] = createLogpushJobOptions.Dataset - } - if createLogpushJobOptions.Frequency != nil { - body["frequency"] = createLogpushJobOptions.Frequency - } - _, err = builder.SetBodyContentJSON(body) - if err != nil { - return + if createLogpushJobV2Options.CreateLogpushJobV2Request != nil { + _, err = builder.SetBodyContentJSON(createLogpushJobV2Options.CreateLogpushJobV2Request) + if err != nil { + err = core.SDKErrorf(err, "", "set-json-body-error", common.GetComponentInfo()) + return + } } request, err := builder.Build() if err != nil { + err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo()) return } var rawResponse map[string]json.RawMessage response, err = logpushJobsApi.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "create_logpush_job_v2", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalLogpushJobsResp) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -325,42 +334,47 @@ func (logpushJobsApi *LogpushJobsApiV1) CreateLogpushJobWithContext(ctx context. return } -// GetLogpushJob : Get a logpush job +// GetLogpushJobV2 : Get a logpush job // Get a logpush job for a given zone. -func (logpushJobsApi *LogpushJobsApiV1) GetLogpushJob(getLogpushJobOptions *GetLogpushJobOptions) (result *LogpushJobsResp, response *core.DetailedResponse, err error) { - return logpushJobsApi.GetLogpushJobWithContext(context.Background(), getLogpushJobOptions) +func (logpushJobsApi *LogpushJobsApiV1) GetLogpushJobV2(getLogpushJobV2Options *GetLogpushJobV2Options) (result *LogpushJobsResp, response *core.DetailedResponse, err error) { + result, response, err = logpushJobsApi.GetLogpushJobV2WithContext(context.Background(), getLogpushJobV2Options) + err = core.RepurposeSDKProblem(err, "") + return } -// GetLogpushJobWithContext is an alternate form of the GetLogpushJob method which supports a Context parameter -func (logpushJobsApi *LogpushJobsApiV1) GetLogpushJobWithContext(ctx context.Context, getLogpushJobOptions *GetLogpushJobOptions) (result *LogpushJobsResp, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getLogpushJobOptions, "getLogpushJobOptions cannot be nil") +// GetLogpushJobV2WithContext is an alternate form of the GetLogpushJobV2 method which supports a Context parameter +func (logpushJobsApi *LogpushJobsApiV1) GetLogpushJobV2WithContext(ctx context.Context, getLogpushJobV2Options *GetLogpushJobV2Options) (result *LogpushJobsResp, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getLogpushJobV2Options, "getLogpushJobV2Options cannot be nil") if err != nil { + err = core.SDKErrorf(err, "", "unexpected-nil-param", common.GetComponentInfo()) return } - err = core.ValidateStruct(getLogpushJobOptions, "getLogpushJobOptions") + err = core.ValidateStruct(getLogpushJobV2Options, "getLogpushJobV2Options") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } pathParamsMap := map[string]string{ - "crn": *logpushJobsApi.Crn, + "crn": *logpushJobsApi.Crn, "zone_id": *logpushJobsApi.ZoneID, - "job_id": fmt.Sprint(*getLogpushJobOptions.JobID), + "job_id": *getLogpushJobV2Options.JobID, } builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = logpushJobsApi.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v1/{crn}/zones/{zone_id}/logpush/jobs/{job_id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v2/{crn}/zones/{zone_id}/logpush/jobs/{job_id}`, pathParamsMap) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } - for headerName, headerValue := range getLogpushJobOptions.Headers { + for headerName, headerValue := range getLogpushJobV2Options.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "GetLogpushJob") + sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "GetLogpushJobV2") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -368,17 +382,21 @@ func (logpushJobsApi *LogpushJobsApiV1) GetLogpushJobWithContext(ctx context.Con request, err := builder.Build() if err != nil { + err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo()) return } var rawResponse map[string]json.RawMessage response, err = logpushJobsApi.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "get_logpush_job_v2", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalLogpushJobsResp) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -387,82 +405,78 @@ func (logpushJobsApi *LogpushJobsApiV1) GetLogpushJobWithContext(ctx context.Con return } -// UpdateLogpushJob : Update a logpush job +// UpdateLogpushJobV2 : Update a logpush job // Update an existing logpush job for a given zone. -func (logpushJobsApi *LogpushJobsApiV1) UpdateLogpushJob(updateLogpushJobOptions *UpdateLogpushJobOptions) (result *LogpushJobsResp, response *core.DetailedResponse, err error) { - return logpushJobsApi.UpdateLogpushJobWithContext(context.Background(), updateLogpushJobOptions) +func (logpushJobsApi *LogpushJobsApiV1) UpdateLogpushJobV2(updateLogpushJobV2Options *UpdateLogpushJobV2Options) (result *LogpushJobsResp, response *core.DetailedResponse, err error) { + result, response, err = logpushJobsApi.UpdateLogpushJobV2WithContext(context.Background(), updateLogpushJobV2Options) + err = core.RepurposeSDKProblem(err, "") + return } -// UpdateLogpushJobWithContext is an alternate form of the UpdateLogpushJob method which supports a Context parameter -func (logpushJobsApi *LogpushJobsApiV1) UpdateLogpushJobWithContext(ctx context.Context, updateLogpushJobOptions *UpdateLogpushJobOptions) (result *LogpushJobsResp, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(updateLogpushJobOptions, "updateLogpushJobOptions cannot be nil") +// UpdateLogpushJobV2WithContext is an alternate form of the UpdateLogpushJobV2 method which supports a Context parameter +func (logpushJobsApi *LogpushJobsApiV1) UpdateLogpushJobV2WithContext(ctx context.Context, updateLogpushJobV2Options *UpdateLogpushJobV2Options) (result *LogpushJobsResp, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(updateLogpushJobV2Options, "updateLogpushJobV2Options cannot be nil") if err != nil { + err = core.SDKErrorf(err, "", "unexpected-nil-param", common.GetComponentInfo()) return } - err = core.ValidateStruct(updateLogpushJobOptions, "updateLogpushJobOptions") + err = core.ValidateStruct(updateLogpushJobV2Options, "updateLogpushJobV2Options") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } pathParamsMap := map[string]string{ - "crn": *logpushJobsApi.Crn, + "crn": *logpushJobsApi.Crn, "zone_id": *logpushJobsApi.ZoneID, - "job_id": fmt.Sprint(*updateLogpushJobOptions.JobID), + "job_id": *updateLogpushJobV2Options.JobID, } builder := core.NewRequestBuilder(core.PUT) builder = builder.WithContext(ctx) builder.EnableGzipCompression = logpushJobsApi.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v1/{crn}/zones/{zone_id}/logpush/jobs/{job_id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v2/{crn}/zones/{zone_id}/logpush/jobs/{job_id}`, pathParamsMap) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } - for headerName, headerValue := range updateLogpushJobOptions.Headers { + for headerName, headerValue := range updateLogpushJobV2Options.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "UpdateLogpushJob") + sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "UpdateLogpushJobV2") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") builder.AddHeader("Content-Type", "application/json") - body := make(map[string]interface{}) - if updateLogpushJobOptions.Enabled != nil { - body["enabled"] = updateLogpushJobOptions.Enabled - } - if updateLogpushJobOptions.LogpullOptions != nil { - body["logpull_options"] = updateLogpushJobOptions.LogpullOptions - } - if updateLogpushJobOptions.DestinationConf != nil { - body["destination_conf"] = updateLogpushJobOptions.DestinationConf - } - if updateLogpushJobOptions.OwnershipChallenge != nil { - body["ownership_challenge"] = updateLogpushJobOptions.OwnershipChallenge - } - if updateLogpushJobOptions.Frequency != nil { - body["frequency"] = updateLogpushJobOptions.Frequency - } - _, err = builder.SetBodyContentJSON(body) - if err != nil { - return + if updateLogpushJobV2Options.UpdateLogpushJobV2Request != nil { + _, err = builder.SetBodyContentJSON(updateLogpushJobV2Options.UpdateLogpushJobV2Request) + if err != nil { + err = core.SDKErrorf(err, "", "set-json-body-error", common.GetComponentInfo()) + return + } } request, err := builder.Build() if err != nil { + err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo()) return } var rawResponse map[string]json.RawMessage response, err = logpushJobsApi.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "update_logpush_job_v2", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalLogpushJobsResp) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -471,42 +485,47 @@ func (logpushJobsApi *LogpushJobsApiV1) UpdateLogpushJobWithContext(ctx context. return } -// DeleteLogpushJob : Delete a logpush job +// DeleteLogpushJobV2 : Delete a logpush job // Delete a logpush job for a zone. -func (logpushJobsApi *LogpushJobsApiV1) DeleteLogpushJob(deleteLogpushJobOptions *DeleteLogpushJobOptions) (result *DeleteLogpushJobResp, response *core.DetailedResponse, err error) { - return logpushJobsApi.DeleteLogpushJobWithContext(context.Background(), deleteLogpushJobOptions) +func (logpushJobsApi *LogpushJobsApiV1) DeleteLogpushJobV2(deleteLogpushJobV2Options *DeleteLogpushJobV2Options) (result *DeleteLogpushJobResp, response *core.DetailedResponse, err error) { + result, response, err = logpushJobsApi.DeleteLogpushJobV2WithContext(context.Background(), deleteLogpushJobV2Options) + err = core.RepurposeSDKProblem(err, "") + return } -// DeleteLogpushJobWithContext is an alternate form of the DeleteLogpushJob method which supports a Context parameter -func (logpushJobsApi *LogpushJobsApiV1) DeleteLogpushJobWithContext(ctx context.Context, deleteLogpushJobOptions *DeleteLogpushJobOptions) (result *DeleteLogpushJobResp, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(deleteLogpushJobOptions, "deleteLogpushJobOptions cannot be nil") +// DeleteLogpushJobV2WithContext is an alternate form of the DeleteLogpushJobV2 method which supports a Context parameter +func (logpushJobsApi *LogpushJobsApiV1) DeleteLogpushJobV2WithContext(ctx context.Context, deleteLogpushJobV2Options *DeleteLogpushJobV2Options) (result *DeleteLogpushJobResp, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteLogpushJobV2Options, "deleteLogpushJobV2Options cannot be nil") if err != nil { + err = core.SDKErrorf(err, "", "unexpected-nil-param", common.GetComponentInfo()) return } - err = core.ValidateStruct(deleteLogpushJobOptions, "deleteLogpushJobOptions") + err = core.ValidateStruct(deleteLogpushJobV2Options, "deleteLogpushJobV2Options") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } pathParamsMap := map[string]string{ - "crn": *logpushJobsApi.Crn, + "crn": *logpushJobsApi.Crn, "zone_id": *logpushJobsApi.ZoneID, - "job_id": fmt.Sprint(*deleteLogpushJobOptions.JobID), + "job_id": *deleteLogpushJobV2Options.JobID, } builder := core.NewRequestBuilder(core.DELETE) builder = builder.WithContext(ctx) builder.EnableGzipCompression = logpushJobsApi.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v1/{crn}/zones/{zone_id}/logpush/jobs/{job_id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v2/{crn}/zones/{zone_id}/logpush/jobs/{job_id}`, pathParamsMap) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } - for headerName, headerValue := range deleteLogpushJobOptions.Headers { + for headerName, headerValue := range deleteLogpushJobV2Options.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "DeleteLogpushJob") + sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "DeleteLogpushJobV2") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -514,17 +533,21 @@ func (logpushJobsApi *LogpushJobsApiV1) DeleteLogpushJobWithContext(ctx context. request, err := builder.Build() if err != nil { + err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo()) return } var rawResponse map[string]json.RawMessage response, err = logpushJobsApi.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "delete_logpush_job_v2", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalDeleteLogpushJobResp) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -533,56 +556,74 @@ func (logpushJobsApi *LogpushJobsApiV1) DeleteLogpushJobWithContext(ctx context. return } -// ListFieldsForDataset : List all fields available for a dataset -// The list of all fields available for a given dataset. -func (logpushJobsApi *LogpushJobsApiV1) ListFieldsForDataset(listFieldsForDatasetOptions *ListFieldsForDatasetOptions) (result *ListFieldsResp, response *core.DetailedResponse, err error) { - return logpushJobsApi.ListFieldsForDatasetWithContext(context.Background(), listFieldsForDatasetOptions) +// GetLogpushOwnershipV2 : Get a new ownership challenge sent to your destination +// Get a new ownership challenge. +func (logpushJobsApi *LogpushJobsApiV1) GetLogpushOwnershipV2(getLogpushOwnershipV2Options *GetLogpushOwnershipV2Options) (result *OwnershipChallengeResp, response *core.DetailedResponse, err error) { + result, response, err = logpushJobsApi.GetLogpushOwnershipV2WithContext(context.Background(), getLogpushOwnershipV2Options) + err = core.RepurposeSDKProblem(err, "") + return } -// ListFieldsForDatasetWithContext is an alternate form of the ListFieldsForDataset method which supports a Context parameter -func (logpushJobsApi *LogpushJobsApiV1) ListFieldsForDatasetWithContext(ctx context.Context, listFieldsForDatasetOptions *ListFieldsForDatasetOptions) (result *ListFieldsResp, response *core.DetailedResponse, err error) { - err = core.ValidateStruct(listFieldsForDatasetOptions, "listFieldsForDatasetOptions") +// GetLogpushOwnershipV2WithContext is an alternate form of the GetLogpushOwnershipV2 method which supports a Context parameter +func (logpushJobsApi *LogpushJobsApiV1) GetLogpushOwnershipV2WithContext(ctx context.Context, getLogpushOwnershipV2Options *GetLogpushOwnershipV2Options) (result *OwnershipChallengeResp, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(getLogpushOwnershipV2Options, "getLogpushOwnershipV2Options") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } pathParamsMap := map[string]string{ - "crn": *logpushJobsApi.Crn, + "crn": *logpushJobsApi.Crn, "zone_id": *logpushJobsApi.ZoneID, - "dataset": *logpushJobsApi.Dataset, } - builder := core.NewRequestBuilder(core.GET) + builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = logpushJobsApi.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v1/{crn}/zones/{zone_id}/logpush/datasets/{dataset}/fields`, pathParamsMap) + _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v2/{crn}/zones/{zone_id}/logpush/ownership`, pathParamsMap) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } - for headerName, headerValue := range listFieldsForDatasetOptions.Headers { + for headerName, headerValue := range getLogpushOwnershipV2Options.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "ListFieldsForDataset") + sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "GetLogpushOwnershipV2") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") + + body := make(map[string]interface{}) + if getLogpushOwnershipV2Options.Cos != nil { + body["cos"] = getLogpushOwnershipV2Options.Cos + } + _, err = builder.SetBodyContentJSON(body) + if err != nil { + err = core.SDKErrorf(err, "", "set-json-body-error", common.GetComponentInfo()) + return + } request, err := builder.Build() if err != nil { + err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo()) return } var rawResponse map[string]json.RawMessage response, err = logpushJobsApi.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "get_logpush_ownership_v2", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalListFieldsResp) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalOwnershipChallengeResp) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -591,56 +632,77 @@ func (logpushJobsApi *LogpushJobsApiV1) ListFieldsForDatasetWithContext(ctx cont return } -// ListLogpushJobsForDataset : List logpush jobs for a dataset -// List configured logpush jobs for a dataset. -func (logpushJobsApi *LogpushJobsApiV1) ListLogpushJobsForDataset(listLogpushJobsForDatasetOptions *ListLogpushJobsForDatasetOptions) (result *LogpushJobsResp, response *core.DetailedResponse, err error) { - return logpushJobsApi.ListLogpushJobsForDatasetWithContext(context.Background(), listLogpushJobsForDatasetOptions) +// ValidateLogpushOwnershipChallengeV2 : Validate ownership challenge of the destination +// Validate ownership challenge of the destination. +func (logpushJobsApi *LogpushJobsApiV1) ValidateLogpushOwnershipChallengeV2(validateLogpushOwnershipChallengeV2Options *ValidateLogpushOwnershipChallengeV2Options) (result *OwnershipChallengeValidateResult, response *core.DetailedResponse, err error) { + result, response, err = logpushJobsApi.ValidateLogpushOwnershipChallengeV2WithContext(context.Background(), validateLogpushOwnershipChallengeV2Options) + err = core.RepurposeSDKProblem(err, "") + return } -// ListLogpushJobsForDatasetWithContext is an alternate form of the ListLogpushJobsForDataset method which supports a Context parameter -func (logpushJobsApi *LogpushJobsApiV1) ListLogpushJobsForDatasetWithContext(ctx context.Context, listLogpushJobsForDatasetOptions *ListLogpushJobsForDatasetOptions) (result *LogpushJobsResp, response *core.DetailedResponse, err error) { - err = core.ValidateStruct(listLogpushJobsForDatasetOptions, "listLogpushJobsForDatasetOptions") +// ValidateLogpushOwnershipChallengeV2WithContext is an alternate form of the ValidateLogpushOwnershipChallengeV2 method which supports a Context parameter +func (logpushJobsApi *LogpushJobsApiV1) ValidateLogpushOwnershipChallengeV2WithContext(ctx context.Context, validateLogpushOwnershipChallengeV2Options *ValidateLogpushOwnershipChallengeV2Options) (result *OwnershipChallengeValidateResult, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(validateLogpushOwnershipChallengeV2Options, "validateLogpushOwnershipChallengeV2Options") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } pathParamsMap := map[string]string{ - "crn": *logpushJobsApi.Crn, + "crn": *logpushJobsApi.Crn, "zone_id": *logpushJobsApi.ZoneID, - "dataset": *logpushJobsApi.Dataset, } - builder := core.NewRequestBuilder(core.GET) + builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = logpushJobsApi.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v1/{crn}/zones/{zone_id}/logpush/datasets/{dataset}/jobs`, pathParamsMap) + _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v2/{crn}/zones/{zone_id}/logpush/ownership/validate`, pathParamsMap) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } - for headerName, headerValue := range listLogpushJobsForDatasetOptions.Headers { + for headerName, headerValue := range validateLogpushOwnershipChallengeV2Options.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "ListLogpushJobsForDataset") + sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "ValidateLogpushOwnershipChallengeV2") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") + + body := make(map[string]interface{}) + if validateLogpushOwnershipChallengeV2Options.Cos != nil { + body["cos"] = validateLogpushOwnershipChallengeV2Options.Cos + } + if validateLogpushOwnershipChallengeV2Options.OwnershipChallenge != nil { + body["ownership_challenge"] = validateLogpushOwnershipChallengeV2Options.OwnershipChallenge + } + _, err = builder.SetBodyContentJSON(body) + if err != nil { + err = core.SDKErrorf(err, "", "set-json-body-error", common.GetComponentInfo()) + return + } request, err := builder.Build() if err != nil { + err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo()) return } var rawResponse map[string]json.RawMessage response, err = logpushJobsApi.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "validate_logpush_ownership_challenge_v2", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalLogpushJobsResp) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalOwnershipChallengeValidateResult) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -649,65 +711,64 @@ func (logpushJobsApi *LogpushJobsApiV1) ListLogpushJobsForDatasetWithContext(ctx return } -// GetLogpushOwnership : Get a new ownership challenge sent to your destination -// Get a new ownership challenge. -func (logpushJobsApi *LogpushJobsApiV1) GetLogpushOwnership(getLogpushOwnershipOptions *GetLogpushOwnershipOptions) (result *OwnershipChallengeResp, response *core.DetailedResponse, err error) { - return logpushJobsApi.GetLogpushOwnershipWithContext(context.Background(), getLogpushOwnershipOptions) +// ListFieldsForDatasetV2 : The list of all fields available for a dataset +// The list of all fields available for a dataset. +func (logpushJobsApi *LogpushJobsApiV1) ListFieldsForDatasetV2(listFieldsForDatasetV2Options *ListFieldsForDatasetV2Options) (result *ListFieldsResp, response *core.DetailedResponse, err error) { + result, response, err = logpushJobsApi.ListFieldsForDatasetV2WithContext(context.Background(), listFieldsForDatasetV2Options) + err = core.RepurposeSDKProblem(err, "") + return } -// GetLogpushOwnershipWithContext is an alternate form of the GetLogpushOwnership method which supports a Context parameter -func (logpushJobsApi *LogpushJobsApiV1) GetLogpushOwnershipWithContext(ctx context.Context, getLogpushOwnershipOptions *GetLogpushOwnershipOptions) (result *OwnershipChallengeResp, response *core.DetailedResponse, err error) { - err = core.ValidateStruct(getLogpushOwnershipOptions, "getLogpushOwnershipOptions") +// ListFieldsForDatasetV2WithContext is an alternate form of the ListFieldsForDatasetV2 method which supports a Context parameter +func (logpushJobsApi *LogpushJobsApiV1) ListFieldsForDatasetV2WithContext(ctx context.Context, listFieldsForDatasetV2Options *ListFieldsForDatasetV2Options) (result *ListFieldsResp, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(listFieldsForDatasetV2Options, "listFieldsForDatasetV2Options") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } pathParamsMap := map[string]string{ - "crn": *logpushJobsApi.Crn, + "crn": *logpushJobsApi.Crn, "zone_id": *logpushJobsApi.ZoneID, + "dataset": *logpushJobsApi.Dataset, } - builder := core.NewRequestBuilder(core.POST) + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = logpushJobsApi.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v1/{crn}/zones/{zone_id}/logpush/ownership`, pathParamsMap) + _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v2/{crn}/zones/{zone_id}/logpush/datasets/{dataset}/fields`, pathParamsMap) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } - for headerName, headerValue := range getLogpushOwnershipOptions.Headers { + for headerName, headerValue := range listFieldsForDatasetV2Options.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "GetLogpushOwnership") + sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "ListFieldsForDatasetV2") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/json") - - body := make(map[string]interface{}) - if getLogpushOwnershipOptions.DestinationConf != nil { - body["destination_conf"] = getLogpushOwnershipOptions.DestinationConf - } - _, err = builder.SetBodyContentJSON(body) - if err != nil { - return - } request, err := builder.Build() if err != nil { + err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo()) return } var rawResponse map[string]json.RawMessage response, err = logpushJobsApi.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "list_fields_for_dataset_v2", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalOwnershipChallengeResp) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalListFieldsResp) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -716,68 +777,64 @@ func (logpushJobsApi *LogpushJobsApiV1) GetLogpushOwnershipWithContext(ctx conte return } -// ValidateLogpushOwnershipChallenge : Validate ownership challenge of the destination -// Validate ownership challenge of the destination. -func (logpushJobsApi *LogpushJobsApiV1) ValidateLogpushOwnershipChallenge(validateLogpushOwnershipChallengeOptions *ValidateLogpushOwnershipChallengeOptions) (result *OwnershipChallengeValidateResult, response *core.DetailedResponse, err error) { - return logpushJobsApi.ValidateLogpushOwnershipChallengeWithContext(context.Background(), validateLogpushOwnershipChallengeOptions) +// ListLogpushJobsForDatasetV2 : List logpush jobs for dataset +// List configured logpush jobs for a dataset. +func (logpushJobsApi *LogpushJobsApiV1) ListLogpushJobsForDatasetV2(listLogpushJobsForDatasetV2Options *ListLogpushJobsForDatasetV2Options) (result *LogpushJobsResp, response *core.DetailedResponse, err error) { + result, response, err = logpushJobsApi.ListLogpushJobsForDatasetV2WithContext(context.Background(), listLogpushJobsForDatasetV2Options) + err = core.RepurposeSDKProblem(err, "") + return } -// ValidateLogpushOwnershipChallengeWithContext is an alternate form of the ValidateLogpushOwnershipChallenge method which supports a Context parameter -func (logpushJobsApi *LogpushJobsApiV1) ValidateLogpushOwnershipChallengeWithContext(ctx context.Context, validateLogpushOwnershipChallengeOptions *ValidateLogpushOwnershipChallengeOptions) (result *OwnershipChallengeValidateResult, response *core.DetailedResponse, err error) { - err = core.ValidateStruct(validateLogpushOwnershipChallengeOptions, "validateLogpushOwnershipChallengeOptions") +// ListLogpushJobsForDatasetV2WithContext is an alternate form of the ListLogpushJobsForDatasetV2 method which supports a Context parameter +func (logpushJobsApi *LogpushJobsApiV1) ListLogpushJobsForDatasetV2WithContext(ctx context.Context, listLogpushJobsForDatasetV2Options *ListLogpushJobsForDatasetV2Options) (result *LogpushJobsResp, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(listLogpushJobsForDatasetV2Options, "listLogpushJobsForDatasetV2Options") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } pathParamsMap := map[string]string{ - "crn": *logpushJobsApi.Crn, + "crn": *logpushJobsApi.Crn, "zone_id": *logpushJobsApi.ZoneID, + "dataset": *logpushJobsApi.Dataset, } - builder := core.NewRequestBuilder(core.POST) + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = logpushJobsApi.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v1/{crn}/zones/{zone_id}/logpush/ownership/validate`, pathParamsMap) + _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v2/{crn}/zones/{zone_id}/logpush/datasets/{dataset}/jobs`, pathParamsMap) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } - for headerName, headerValue := range validateLogpushOwnershipChallengeOptions.Headers { + for headerName, headerValue := range listLogpushJobsForDatasetV2Options.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "ValidateLogpushOwnershipChallenge") + sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "ListLogpushJobsForDatasetV2") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/json") - - body := make(map[string]interface{}) - if validateLogpushOwnershipChallengeOptions.DestinationConf != nil { - body["destination_conf"] = validateLogpushOwnershipChallengeOptions.DestinationConf - } - if validateLogpushOwnershipChallengeOptions.OwnershipChallenge != nil { - body["ownership_challenge"] = validateLogpushOwnershipChallengeOptions.OwnershipChallenge - } - _, err = builder.SetBodyContentJSON(body) - if err != nil { - return - } request, err := builder.Build() if err != nil { + err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo()) return } var rawResponse map[string]json.RawMessage response, err = logpushJobsApi.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "list_logpush_jobs_for_dataset_v2", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalOwnershipChallengeValidateResult) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalLogpushJobsResp) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -786,37 +843,41 @@ func (logpushJobsApi *LogpushJobsApiV1) ValidateLogpushOwnershipChallengeWithCon return } -// GetLogpushJobsV2 : List logpush jobs -// List configured logpush jobs for your domain. -func (logpushJobsApi *LogpushJobsApiV1) GetLogpushJobsV2(getLogpushJobsV2Options *GetLogpushJobsV2Options) (result *ListLogpushJobsResp, response *core.DetailedResponse, err error) { - return logpushJobsApi.GetLogpushJobsV2WithContext(context.Background(), getLogpushJobsV2Options) +// GetLogsRetention : Get log retention +// Get log retention setting for Logpull/Logpush on your domain. +func (logpushJobsApi *LogpushJobsApiV1) GetLogsRetention(getLogsRetentionOptions *GetLogsRetentionOptions) (result *LogRetentionResp, response *core.DetailedResponse, err error) { + result, response, err = logpushJobsApi.GetLogsRetentionWithContext(context.Background(), getLogsRetentionOptions) + err = core.RepurposeSDKProblem(err, "") + return } -// GetLogpushJobsV2WithContext is an alternate form of the GetLogpushJobsV2 method which supports a Context parameter -func (logpushJobsApi *LogpushJobsApiV1) GetLogpushJobsV2WithContext(ctx context.Context, getLogpushJobsV2Options *GetLogpushJobsV2Options) (result *ListLogpushJobsResp, response *core.DetailedResponse, err error) { - err = core.ValidateStruct(getLogpushJobsV2Options, "getLogpushJobsV2Options") +// GetLogsRetentionWithContext is an alternate form of the GetLogsRetention method which supports a Context parameter +func (logpushJobsApi *LogpushJobsApiV1) GetLogsRetentionWithContext(ctx context.Context, getLogsRetentionOptions *GetLogsRetentionOptions) (result *LogRetentionResp, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(getLogsRetentionOptions, "getLogsRetentionOptions") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } pathParamsMap := map[string]string{ - "crn": *logpushJobsApi.Crn, + "crn": *logpushJobsApi.Crn, "zone_id": *logpushJobsApi.ZoneID, } builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = logpushJobsApi.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v2/{crn}/zones/{zone_id}/logpush/jobs`, pathParamsMap) + _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v1/{crn}/zones/{zone_id}/logs/retention`, pathParamsMap) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } - for headerName, headerValue := range getLogpushJobsV2Options.Headers { + for headerName, headerValue := range getLogsRetentionOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "GetLogpushJobsV2") + sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "GetLogsRetention") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -824,17 +885,21 @@ func (logpushJobsApi *LogpushJobsApiV1) GetLogpushJobsV2WithContext(ctx context. request, err := builder.Build() if err != nil { + err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo()) return } var rawResponse map[string]json.RawMessage response, err = logpushJobsApi.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "get_logs_retention", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalListLogpushJobsResp) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalLogRetentionResp) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -843,63 +908,74 @@ func (logpushJobsApi *LogpushJobsApiV1) GetLogpushJobsV2WithContext(ctx context. return } -// CreateLogpushJobV2 : Create a logpush jobs -// Create a new logpush job for the domain. -func (logpushJobsApi *LogpushJobsApiV1) CreateLogpushJobV2(createLogpushJobV2Options *CreateLogpushJobV2Options) (result *LogpushJobsResp, response *core.DetailedResponse, err error) { - return logpushJobsApi.CreateLogpushJobV2WithContext(context.Background(), createLogpushJobV2Options) +// CreateLogRetention : Update log retention +// Update log retention flag for Logpull/Logpush. +func (logpushJobsApi *LogpushJobsApiV1) CreateLogRetention(createLogRetentionOptions *CreateLogRetentionOptions) (result *LogRetentionResp, response *core.DetailedResponse, err error) { + result, response, err = logpushJobsApi.CreateLogRetentionWithContext(context.Background(), createLogRetentionOptions) + err = core.RepurposeSDKProblem(err, "") + return } -// CreateLogpushJobV2WithContext is an alternate form of the CreateLogpushJobV2 method which supports a Context parameter -func (logpushJobsApi *LogpushJobsApiV1) CreateLogpushJobV2WithContext(ctx context.Context, createLogpushJobV2Options *CreateLogpushJobV2Options) (result *LogpushJobsResp, response *core.DetailedResponse, err error) { - err = core.ValidateStruct(createLogpushJobV2Options, "createLogpushJobV2Options") +// CreateLogRetentionWithContext is an alternate form of the CreateLogRetention method which supports a Context parameter +func (logpushJobsApi *LogpushJobsApiV1) CreateLogRetentionWithContext(ctx context.Context, createLogRetentionOptions *CreateLogRetentionOptions) (result *LogRetentionResp, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(createLogRetentionOptions, "createLogRetentionOptions") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } pathParamsMap := map[string]string{ - "crn": *logpushJobsApi.Crn, + "crn": *logpushJobsApi.Crn, "zone_id": *logpushJobsApi.ZoneID, } builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = logpushJobsApi.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v2/{crn}/zones/{zone_id}/logpush/jobs`, pathParamsMap) + _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v1/{crn}/zones/{zone_id}/logs/retention`, pathParamsMap) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } - for headerName, headerValue := range createLogpushJobV2Options.Headers { + for headerName, headerValue := range createLogRetentionOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "CreateLogpushJobV2") + sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "CreateLogRetention") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") builder.AddHeader("Content-Type", "application/json") - if createLogpushJobV2Options.CreateLogpushJobV2Request != nil { - _, err = builder.SetBodyContentJSON(createLogpushJobV2Options.CreateLogpushJobV2Request) - if err != nil { - return - } + body := make(map[string]interface{}) + if createLogRetentionOptions.Flag != nil { + body["flag"] = createLogRetentionOptions.Flag + } + _, err = builder.SetBodyContentJSON(body) + if err != nil { + err = core.SDKErrorf(err, "", "set-json-body-error", common.GetComponentInfo()) + return } request, err := builder.Build() if err != nil { + err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo()) return } var rawResponse map[string]json.RawMessage response, err = logpushJobsApi.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "create_log_retention", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalLogpushJobsResp) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalLogRetentionResp) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -907,545 +983,31 @@ func (logpushJobsApi *LogpushJobsApiV1) CreateLogpushJobV2WithContext(ctx contex return } - -// GetLogpushJobV2 : Get a logpush job -// Get a logpush job for a given zone. -func (logpushJobsApi *LogpushJobsApiV1) GetLogpushJobV2(getLogpushJobV2Options *GetLogpushJobV2Options) (result *LogpushJobsResp, response *core.DetailedResponse, err error) { - return logpushJobsApi.GetLogpushJobV2WithContext(context.Background(), getLogpushJobV2Options) +func getServiceComponentInfo() *core.ProblemComponent { + return core.NewProblemComponent(DefaultServiceName, "1.0.0") } -// GetLogpushJobV2WithContext is an alternate form of the GetLogpushJobV2 method which supports a Context parameter -func (logpushJobsApi *LogpushJobsApiV1) GetLogpushJobV2WithContext(ctx context.Context, getLogpushJobV2Options *GetLogpushJobV2Options) (result *LogpushJobsResp, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getLogpushJobV2Options, "getLogpushJobV2Options cannot be nil") - if err != nil { - return - } - err = core.ValidateStruct(getLogpushJobV2Options, "getLogpushJobV2Options") - if err != nil { - return - } +// CreateLogRetentionOptions : The CreateLogRetention options. +type CreateLogRetentionOptions struct { + Flag *bool `json:"flag,omitempty"` - pathParamsMap := map[string]string{ - "crn": *logpushJobsApi.Crn, - "zone_id": *logpushJobsApi.ZoneID, - "job_id": fmt.Sprint(*getLogpushJobV2Options.JobID), - } + // Allows users to set headers on API requests. + Headers map[string]string +} - builder := core.NewRequestBuilder(core.GET) - builder = builder.WithContext(ctx) - builder.EnableGzipCompression = logpushJobsApi.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v2/{crn}/zones/{zone_id}/logpush/jobs/{job_id}`, pathParamsMap) - if err != nil { - return - } +// NewCreateLogRetentionOptions : Instantiate CreateLogRetentionOptions +func (*LogpushJobsApiV1) NewCreateLogRetentionOptions() *CreateLogRetentionOptions { + return &CreateLogRetentionOptions{} +} - for headerName, headerValue := range getLogpushJobV2Options.Headers { - builder.AddHeader(headerName, headerValue) - } - - sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "GetLogpushJobV2") - for headerName, headerValue := range sdkHeaders { - builder.AddHeader(headerName, headerValue) - } - builder.AddHeader("Accept", "application/json") - - request, err := builder.Build() - if err != nil { - return - } - - var rawResponse map[string]json.RawMessage - response, err = logpushJobsApi.Service.Request(request, &rawResponse) - if err != nil { - return - } - if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalLogpushJobsResp) - if err != nil { - return - } - response.Result = result - } - - return -} - -// UpdateLogpushJobV2 : Update a logpush job -// Update an existing logpush job for a given zone. -func (logpushJobsApi *LogpushJobsApiV1) UpdateLogpushJobV2(updateLogpushJobV2Options *UpdateLogpushJobV2Options) (result *LogpushJobsResp, response *core.DetailedResponse, err error) { - return logpushJobsApi.UpdateLogpushJobV2WithContext(context.Background(), updateLogpushJobV2Options) -} - -// UpdateLogpushJobV2WithContext is an alternate form of the UpdateLogpushJobV2 method which supports a Context parameter -func (logpushJobsApi *LogpushJobsApiV1) UpdateLogpushJobV2WithContext(ctx context.Context, updateLogpushJobV2Options *UpdateLogpushJobV2Options) (result *LogpushJobsResp, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(updateLogpushJobV2Options, "updateLogpushJobV2Options cannot be nil") - if err != nil { - return - } - err = core.ValidateStruct(updateLogpushJobV2Options, "updateLogpushJobV2Options") - if err != nil { - return - } - - pathParamsMap := map[string]string{ - "crn": *logpushJobsApi.Crn, - "zone_id": *logpushJobsApi.ZoneID, - "job_id": fmt.Sprint(*updateLogpushJobV2Options.JobID), - } - - builder := core.NewRequestBuilder(core.PUT) - builder = builder.WithContext(ctx) - builder.EnableGzipCompression = logpushJobsApi.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v2/{crn}/zones/{zone_id}/logpush/jobs/{job_id}`, pathParamsMap) - if err != nil { - return - } - - for headerName, headerValue := range updateLogpushJobV2Options.Headers { - builder.AddHeader(headerName, headerValue) - } - - sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "UpdateLogpushJobV2") - for headerName, headerValue := range sdkHeaders { - builder.AddHeader(headerName, headerValue) - } - builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/json") - - if updateLogpushJobV2Options.UpdateLogpushJobV2Request != nil { - _, err = builder.SetBodyContentJSON(updateLogpushJobV2Options.UpdateLogpushJobV2Request) - if err != nil { - return - } - } - - request, err := builder.Build() - if err != nil { - return - } - - var rawResponse map[string]json.RawMessage - response, err = logpushJobsApi.Service.Request(request, &rawResponse) - if err != nil { - return - } - if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalLogpushJobsResp) - if err != nil { - return - } - response.Result = result - } - - return -} - -// DeleteLogpushJobV2 : Delete a logpush job -// Delete a logpush job for a zone. -func (logpushJobsApi *LogpushJobsApiV1) DeleteLogpushJobV2(deleteLogpushJobV2Options *DeleteLogpushJobV2Options) (result *DeleteLogpushJobResp, response *core.DetailedResponse, err error) { - return logpushJobsApi.DeleteLogpushJobV2WithContext(context.Background(), deleteLogpushJobV2Options) -} - -// DeleteLogpushJobV2WithContext is an alternate form of the DeleteLogpushJobV2 method which supports a Context parameter -func (logpushJobsApi *LogpushJobsApiV1) DeleteLogpushJobV2WithContext(ctx context.Context, deleteLogpushJobV2Options *DeleteLogpushJobV2Options) (result *DeleteLogpushJobResp, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(deleteLogpushJobV2Options, "deleteLogpushJobV2Options cannot be nil") - if err != nil { - return - } - err = core.ValidateStruct(deleteLogpushJobV2Options, "deleteLogpushJobV2Options") - if err != nil { - return - } - - pathParamsMap := map[string]string{ - "crn": *logpushJobsApi.Crn, - "zone_id": *logpushJobsApi.ZoneID, - "job_id": fmt.Sprint(*deleteLogpushJobV2Options.JobID), - } - - builder := core.NewRequestBuilder(core.DELETE) - builder = builder.WithContext(ctx) - builder.EnableGzipCompression = logpushJobsApi.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v2/{crn}/zones/{zone_id}/logpush/jobs/{job_id}`, pathParamsMap) - if err != nil { - return - } - - for headerName, headerValue := range deleteLogpushJobV2Options.Headers { - builder.AddHeader(headerName, headerValue) - } - - sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "DeleteLogpushJobV2") - for headerName, headerValue := range sdkHeaders { - builder.AddHeader(headerName, headerValue) - } - builder.AddHeader("Accept", "application/json") - - request, err := builder.Build() - if err != nil { - return - } - - var rawResponse map[string]json.RawMessage - response, err = logpushJobsApi.Service.Request(request, &rawResponse) - if err != nil { - return - } - if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalDeleteLogpushJobResp) - if err != nil { - return - } - response.Result = result - } - - return -} - -// GetLogpushOwnershipV2 : Get a new ownership challenge sent to your destination -// Get a new ownership challenge. -func (logpushJobsApi *LogpushJobsApiV1) GetLogpushOwnershipV2(getLogpushOwnershipV2Options *GetLogpushOwnershipV2Options) (result *OwnershipChallengeResp, response *core.DetailedResponse, err error) { - return logpushJobsApi.GetLogpushOwnershipV2WithContext(context.Background(), getLogpushOwnershipV2Options) -} - -// GetLogpushOwnershipV2WithContext is an alternate form of the GetLogpushOwnershipV2 method which supports a Context parameter -func (logpushJobsApi *LogpushJobsApiV1) GetLogpushOwnershipV2WithContext(ctx context.Context, getLogpushOwnershipV2Options *GetLogpushOwnershipV2Options) (result *OwnershipChallengeResp, response *core.DetailedResponse, err error) { - err = core.ValidateStruct(getLogpushOwnershipV2Options, "getLogpushOwnershipV2Options") - if err != nil { - return - } - - pathParamsMap := map[string]string{ - "crn": *logpushJobsApi.Crn, - "zone_id": *logpushJobsApi.ZoneID, - } - - builder := core.NewRequestBuilder(core.POST) - builder = builder.WithContext(ctx) - builder.EnableGzipCompression = logpushJobsApi.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v2/{crn}/zones/{zone_id}/logpush/ownership`, pathParamsMap) - if err != nil { - return - } - - for headerName, headerValue := range getLogpushOwnershipV2Options.Headers { - builder.AddHeader(headerName, headerValue) - } - - sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "GetLogpushOwnershipV2") - for headerName, headerValue := range sdkHeaders { - builder.AddHeader(headerName, headerValue) - } - builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/json") - - body := make(map[string]interface{}) - if getLogpushOwnershipV2Options.Cos != nil { - body["cos"] = getLogpushOwnershipV2Options.Cos - } - _, err = builder.SetBodyContentJSON(body) - if err != nil { - return - } - - request, err := builder.Build() - if err != nil { - return - } - - var rawResponse map[string]json.RawMessage - response, err = logpushJobsApi.Service.Request(request, &rawResponse) - if err != nil { - return - } - if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalOwnershipChallengeResp) - if err != nil { - return - } - response.Result = result - } - - return -} - -// ValidateLogpushOwnershipChallengeV2 : Validate ownership challenge of the destination -// Validate ownership challenge of the destination. -func (logpushJobsApi *LogpushJobsApiV1) ValidateLogpushOwnershipChallengeV2(validateLogpushOwnershipChallengeV2Options *ValidateLogpushOwnershipChallengeV2Options) (result *OwnershipChallengeValidateResult, response *core.DetailedResponse, err error) { - return logpushJobsApi.ValidateLogpushOwnershipChallengeV2WithContext(context.Background(), validateLogpushOwnershipChallengeV2Options) -} - -// ValidateLogpushOwnershipChallengeV2WithContext is an alternate form of the ValidateLogpushOwnershipChallengeV2 method which supports a Context parameter -func (logpushJobsApi *LogpushJobsApiV1) ValidateLogpushOwnershipChallengeV2WithContext(ctx context.Context, validateLogpushOwnershipChallengeV2Options *ValidateLogpushOwnershipChallengeV2Options) (result *OwnershipChallengeValidateResult, response *core.DetailedResponse, err error) { - err = core.ValidateStruct(validateLogpushOwnershipChallengeV2Options, "validateLogpushOwnershipChallengeV2Options") - if err != nil { - return - } - - pathParamsMap := map[string]string{ - "crn": *logpushJobsApi.Crn, - "zone_id": *logpushJobsApi.ZoneID, - } - - builder := core.NewRequestBuilder(core.POST) - builder = builder.WithContext(ctx) - builder.EnableGzipCompression = logpushJobsApi.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v2/{crn}/zones/{zone_id}/logpush/ownership/validate`, pathParamsMap) - if err != nil { - return - } - - for headerName, headerValue := range validateLogpushOwnershipChallengeV2Options.Headers { - builder.AddHeader(headerName, headerValue) - } - - sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "ValidateLogpushOwnershipChallengeV2") - for headerName, headerValue := range sdkHeaders { - builder.AddHeader(headerName, headerValue) - } - builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/json") - - body := make(map[string]interface{}) - if validateLogpushOwnershipChallengeV2Options.Cos != nil { - body["cos"] = validateLogpushOwnershipChallengeV2Options.Cos - } - if validateLogpushOwnershipChallengeV2Options.OwnershipChallenge != nil { - body["ownership_challenge"] = validateLogpushOwnershipChallengeV2Options.OwnershipChallenge - } - _, err = builder.SetBodyContentJSON(body) - if err != nil { - return - } - - request, err := builder.Build() - if err != nil { - return - } - - var rawResponse map[string]json.RawMessage - response, err = logpushJobsApi.Service.Request(request, &rawResponse) - if err != nil { - return - } - if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalOwnershipChallengeValidateResult) - if err != nil { - return - } - response.Result = result - } - - return -} - -// ListFieldsForDatasetV2 : The list of all fields available for a dataset -// The list of all fields available for a dataset. -func (logpushJobsApi *LogpushJobsApiV1) ListFieldsForDatasetV2(listFieldsForDatasetV2Options *ListFieldsForDatasetV2Options) (result *ListFieldsResp, response *core.DetailedResponse, err error) { - return logpushJobsApi.ListFieldsForDatasetV2WithContext(context.Background(), listFieldsForDatasetV2Options) -} - -// ListFieldsForDatasetV2WithContext is an alternate form of the ListFieldsForDatasetV2 method which supports a Context parameter -func (logpushJobsApi *LogpushJobsApiV1) ListFieldsForDatasetV2WithContext(ctx context.Context, listFieldsForDatasetV2Options *ListFieldsForDatasetV2Options) (result *ListFieldsResp, response *core.DetailedResponse, err error) { - err = core.ValidateStruct(listFieldsForDatasetV2Options, "listFieldsForDatasetV2Options") - if err != nil { - return - } - - pathParamsMap := map[string]string{ - "crn": *logpushJobsApi.Crn, - "zone_id": *logpushJobsApi.ZoneID, - "dataset": *logpushJobsApi.Dataset, - } - - builder := core.NewRequestBuilder(core.GET) - builder = builder.WithContext(ctx) - builder.EnableGzipCompression = logpushJobsApi.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v2/{crn}/zones/{zone_id}/logpush/datasets/{dataset}/fields`, pathParamsMap) - if err != nil { - return - } - - for headerName, headerValue := range listFieldsForDatasetV2Options.Headers { - builder.AddHeader(headerName, headerValue) - } - - sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "ListFieldsForDatasetV2") - for headerName, headerValue := range sdkHeaders { - builder.AddHeader(headerName, headerValue) - } - builder.AddHeader("Accept", "application/json") - - request, err := builder.Build() - if err != nil { - return - } - - var rawResponse map[string]json.RawMessage - response, err = logpushJobsApi.Service.Request(request, &rawResponse) - if err != nil { - return - } - if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalListFieldsResp) - if err != nil { - return - } - response.Result = result - } - - return -} - -// ListLogpushJobsForDatasetV2 : List logpush jobs for dataset -// List configured logpush jobs for a dataset. -func (logpushJobsApi *LogpushJobsApiV1) ListLogpushJobsForDatasetV2(listLogpushJobsForDatasetV2Options *ListLogpushJobsForDatasetV2Options) (result *LogpushJobsResp, response *core.DetailedResponse, err error) { - return logpushJobsApi.ListLogpushJobsForDatasetV2WithContext(context.Background(), listLogpushJobsForDatasetV2Options) -} - -// ListLogpushJobsForDatasetV2WithContext is an alternate form of the ListLogpushJobsForDatasetV2 method which supports a Context parameter -func (logpushJobsApi *LogpushJobsApiV1) ListLogpushJobsForDatasetV2WithContext(ctx context.Context, listLogpushJobsForDatasetV2Options *ListLogpushJobsForDatasetV2Options) (result *LogpushJobsResp, response *core.DetailedResponse, err error) { - err = core.ValidateStruct(listLogpushJobsForDatasetV2Options, "listLogpushJobsForDatasetV2Options") - if err != nil { - return - } - - pathParamsMap := map[string]string{ - "crn": *logpushJobsApi.Crn, - "zone_id": *logpushJobsApi.ZoneID, - "dataset": *logpushJobsApi.Dataset, - } - - builder := core.NewRequestBuilder(core.GET) - builder = builder.WithContext(ctx) - builder.EnableGzipCompression = logpushJobsApi.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(logpushJobsApi.Service.Options.URL, `/v2/{crn}/zones/{zone_id}/logpush/datasets/{dataset}/jobs`, pathParamsMap) - if err != nil { - return - } - - for headerName, headerValue := range listLogpushJobsForDatasetV2Options.Headers { - builder.AddHeader(headerName, headerValue) - } - - sdkHeaders := common.GetSdkHeaders("logpush_jobs_api", "V1", "ListLogpushJobsForDatasetV2") - for headerName, headerValue := range sdkHeaders { - builder.AddHeader(headerName, headerValue) - } - builder.AddHeader("Accept", "application/json") - - request, err := builder.Build() - if err != nil { - return - } - - var rawResponse map[string]json.RawMessage - response, err = logpushJobsApi.Service.Request(request, &rawResponse) - if err != nil { - return - } - if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalLogpushJobsResp) - if err != nil { - return - } - response.Result = result - } - - return -} - -// CreateLogpushJobOptions : The CreateLogpushJob options. -type CreateLogpushJobOptions struct { - // Logpush Job Name. - Name *string `json:"name,omitempty"` - - // Whether the logpush job enabled or not. - Enabled *bool `json:"enabled,omitempty"` - - // Configuration string. - LogpullOptions *string `json:"logpull_options,omitempty"` - - // Uniquely identifies a resource (such as an s3 bucket) where data will be pushed. - DestinationConf *string `json:"destination_conf,omitempty"` - - // Ownership challenge token to prove destination ownership. - OwnershipChallenge *string `json:"ownership_challenge,omitempty"` - - // Dataset to be pulled. - Dataset *string `json:"dataset,omitempty"` - - // The frequency at which CIS sends batches of logs to your destination. - Frequency *string `json:"frequency,omitempty"` - - // Allows users to set headers on API requests - Headers map[string]string -} - -// Constants associated with the CreateLogpushJobOptions.Dataset property. -// Dataset to be pulled. -const ( - CreateLogpushJobOptions_Dataset_FirewallEvents = "firewall_events" - CreateLogpushJobOptions_Dataset_HttpRequests = "http_requests" - CreateLogpushJobOptions_Dataset_RangeEvents = "range_events" -) - -// Constants associated with the CreateLogpushJobOptions.Frequency property. -// The frequency at which CIS sends batches of logs to your destination. -const ( - CreateLogpushJobOptions_Frequency_High = "high" - CreateLogpushJobOptions_Frequency_Low = "low" -) - -// NewCreateLogpushJobOptions : Instantiate CreateLogpushJobOptions -func (*LogpushJobsApiV1) NewCreateLogpushJobOptions() *CreateLogpushJobOptions { - return &CreateLogpushJobOptions{} -} - -// SetName : Allow user to set Name -func (_options *CreateLogpushJobOptions) SetName(name string) *CreateLogpushJobOptions { - _options.Name = core.StringPtr(name) - return _options -} - -// SetEnabled : Allow user to set Enabled -func (_options *CreateLogpushJobOptions) SetEnabled(enabled bool) *CreateLogpushJobOptions { - _options.Enabled = core.BoolPtr(enabled) - return _options -} - -// SetLogpullOptions : Allow user to set LogpullOptions -func (_options *CreateLogpushJobOptions) SetLogpullOptions(logpullOptions string) *CreateLogpushJobOptions { - _options.LogpullOptions = core.StringPtr(logpullOptions) - return _options -} - -// SetDestinationConf : Allow user to set DestinationConf -func (_options *CreateLogpushJobOptions) SetDestinationConf(destinationConf string) *CreateLogpushJobOptions { - _options.DestinationConf = core.StringPtr(destinationConf) - return _options -} - -// SetOwnershipChallenge : Allow user to set OwnershipChallenge -func (_options *CreateLogpushJobOptions) SetOwnershipChallenge(ownershipChallenge string) *CreateLogpushJobOptions { - _options.OwnershipChallenge = core.StringPtr(ownershipChallenge) - return _options -} - -// SetDataset : Allow user to set Dataset -func (_options *CreateLogpushJobOptions) SetDataset(dataset string) *CreateLogpushJobOptions { - _options.Dataset = core.StringPtr(dataset) - return _options -} - -// SetFrequency : Allow user to set Frequency -func (_options *CreateLogpushJobOptions) SetFrequency(frequency string) *CreateLogpushJobOptions { - _options.Frequency = core.StringPtr(frequency) - return _options -} +// SetFlag : Allow user to set Flag +func (_options *CreateLogRetentionOptions) SetFlag(flag bool) *CreateLogRetentionOptions { + _options.Flag = core.BoolPtr(flag) + return _options +} // SetHeaders : Allow user to set Headers -func (options *CreateLogpushJobOptions) SetHeaders(param map[string]string) *CreateLogpushJobOptions { +func (options *CreateLogRetentionOptions) SetHeaders(param map[string]string) *CreateLogRetentionOptions { options.Headers = param return options } @@ -1455,7 +1017,7 @@ type CreateLogpushJobV2Options struct { // Create logpush job body. CreateLogpushJobV2Request CreateLogpushJobV2RequestIntf `json:"CreateLogpushJobV2Request,omitempty"` - // Allows users to set headers on API requests + // Allows users to set headers on API requests. Headers map[string]string } @@ -1480,6 +1042,8 @@ func (options *CreateLogpushJobV2Options) SetHeaders(param map[string]string) *C // Models which "extend" this model: // - CreateLogpushJobV2RequestLogpushJobCosReq // - CreateLogpushJobV2RequestLogpushJobLogdnaReq +// - CreateLogpushJobV2RequestLogpushJobIbmclReq +// - CreateLogpushJobV2RequestLogpushJobGenericReq type CreateLogpushJobV2Request struct { // Logpush Job Name. Name *string `json:"name,omitempty"` @@ -1491,7 +1055,7 @@ type CreateLogpushJobV2Request struct { LogpullOptions *string `json:"logpull_options,omitempty"` // Information to identify the COS bucket where the data will be pushed. - Cos interface{} `json:"cos,omitempty"` + Cos map[string]interface{} `json:"cos,omitempty"` // Ownership challenge token to prove destination ownership. OwnershipChallenge *string `json:"ownership_challenge,omitempty"` @@ -1503,23 +1067,31 @@ type CreateLogpushJobV2Request struct { Frequency *string `json:"frequency,omitempty"` // Information to identify the LogDNA instance the data will be pushed. - Logdna interface{} `json:"logdna,omitempty"` + Logdna map[string]interface{} `json:"logdna,omitempty"` + + // Required information to push logs to your Cloud Logs instance. + Ibmcl *LogpushJobIbmclReqIbmcl `json:"ibmcl,omitempty"` + + // Uniquely identifies a resource where data will be pushed. Additional configuration parameters supported by the + // destination may be included. + DestinationConf *string `json:"destination_conf,omitempty"` } // Constants associated with the CreateLogpushJobV2Request.Dataset property. // Dataset to be pulled. const ( CreateLogpushJobV2Request_Dataset_FirewallEvents = "firewall_events" - CreateLogpushJobV2Request_Dataset_HttpRequests = "http_requests" - CreateLogpushJobV2Request_Dataset_RangeEvents = "range_events" + CreateLogpushJobV2Request_Dataset_HttpRequests = "http_requests" + CreateLogpushJobV2Request_Dataset_RangeEvents = "range_events" ) // Constants associated with the CreateLogpushJobV2Request.Frequency property. // The frequency at which CIS sends batches of logs to your destination. const ( CreateLogpushJobV2Request_Frequency_High = "high" - CreateLogpushJobV2Request_Frequency_Low = "low" + CreateLogpushJobV2Request_Frequency_Low = "low" ) + func (*CreateLogpushJobV2Request) isaCreateLogpushJobV2Request() bool { return true } @@ -1533,87 +1105,77 @@ func UnmarshalCreateLogpushJobV2Request(m map[string]json.RawMessage, result int obj := new(CreateLogpushJobV2Request) err = core.UnmarshalPrimitive(m, "name", &obj.Name) if err != nil { + err = core.SDKErrorf(err, "", "name-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "enabled", &obj.Enabled) if err != nil { + err = core.SDKErrorf(err, "", "enabled-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "logpull_options", &obj.LogpullOptions) if err != nil { + err = core.SDKErrorf(err, "", "logpull_options-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "cos", &obj.Cos) if err != nil { + err = core.SDKErrorf(err, "", "cos-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "ownership_challenge", &obj.OwnershipChallenge) if err != nil { + err = core.SDKErrorf(err, "", "ownership_challenge-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "dataset", &obj.Dataset) if err != nil { + err = core.SDKErrorf(err, "", "dataset-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "frequency", &obj.Frequency) if err != nil { + err = core.SDKErrorf(err, "", "frequency-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "logdna", &obj.Logdna) if err != nil { + err = core.SDKErrorf(err, "", "logdna-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalModel(m, "ibmcl", &obj.Ibmcl, UnmarshalLogpushJobIbmclReqIbmcl) + if err != nil { + err = core.SDKErrorf(err, "", "ibmcl-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "destination_conf", &obj.DestinationConf) + if err != nil { + err = core.SDKErrorf(err, "", "destination_conf-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) return } -// DeleteLogpushJobOptions : The DeleteLogpushJob options. -type DeleteLogpushJobOptions struct { - // logpush job identifier. - JobID *int64 `json:"job_id" validate:"required"` - - // Allows users to set headers on API requests - Headers map[string]string -} - -// NewDeleteLogpushJobOptions : Instantiate DeleteLogpushJobOptions -func (*LogpushJobsApiV1) NewDeleteLogpushJobOptions(jobID int64) *DeleteLogpushJobOptions { - return &DeleteLogpushJobOptions{ - JobID: core.Int64Ptr(jobID), - } -} - -// SetJobID : Allow user to set JobID -func (_options *DeleteLogpushJobOptions) SetJobID(jobID int64) *DeleteLogpushJobOptions { - _options.JobID = core.Int64Ptr(jobID) - return _options -} - -// SetHeaders : Allow user to set Headers -func (options *DeleteLogpushJobOptions) SetHeaders(param map[string]string) *DeleteLogpushJobOptions { - options.Headers = param - return options -} - // DeleteLogpushJobV2Options : The DeleteLogpushJobV2 options. type DeleteLogpushJobV2Options struct { // logpush job identifier. - JobID *int64 `json:"job_id" validate:"required"` + JobID *string `json:"job_id" validate:"required,ne="` - // Allows users to set headers on API requests + // Allows users to set headers on API requests. Headers map[string]string } // NewDeleteLogpushJobV2Options : Instantiate DeleteLogpushJobV2Options -func (*LogpushJobsApiV1) NewDeleteLogpushJobV2Options(jobID int64) *DeleteLogpushJobV2Options { +func (*LogpushJobsApiV1) NewDeleteLogpushJobV2Options(jobID string) *DeleteLogpushJobV2Options { return &DeleteLogpushJobV2Options{ - JobID: core.Int64Ptr(jobID), + JobID: core.StringPtr(jobID), } } // SetJobID : Allow user to set JobID -func (_options *DeleteLogpushJobV2Options) SetJobID(jobID int64) *DeleteLogpushJobV2Options { - _options.JobID = core.Int64Ptr(jobID) +func (_options *DeleteLogpushJobV2Options) SetJobID(jobID string) *DeleteLogpushJobV2Options { + _options.JobID = core.StringPtr(jobID) return _options } @@ -1623,53 +1185,25 @@ func (options *DeleteLogpushJobV2Options) SetHeaders(param map[string]string) *D return options } -// GetLogpushJobOptions : The GetLogpushJob options. -type GetLogpushJobOptions struct { - // logpush job identifier. - JobID *int64 `json:"job_id" validate:"required"` - - // Allows users to set headers on API requests - Headers map[string]string -} - -// NewGetLogpushJobOptions : Instantiate GetLogpushJobOptions -func (*LogpushJobsApiV1) NewGetLogpushJobOptions(jobID int64) *GetLogpushJobOptions { - return &GetLogpushJobOptions{ - JobID: core.Int64Ptr(jobID), - } -} - -// SetJobID : Allow user to set JobID -func (_options *GetLogpushJobOptions) SetJobID(jobID int64) *GetLogpushJobOptions { - _options.JobID = core.Int64Ptr(jobID) - return _options -} - -// SetHeaders : Allow user to set Headers -func (options *GetLogpushJobOptions) SetHeaders(param map[string]string) *GetLogpushJobOptions { - options.Headers = param - return options -} - // GetLogpushJobV2Options : The GetLogpushJobV2 options. type GetLogpushJobV2Options struct { // logpush job identifier. - JobID *int64 `json:"job_id" validate:"required"` + JobID *string `json:"job_id" validate:"required,ne="` - // Allows users to set headers on API requests + // Allows users to set headers on API requests. Headers map[string]string } // NewGetLogpushJobV2Options : Instantiate GetLogpushJobV2Options -func (*LogpushJobsApiV1) NewGetLogpushJobV2Options(jobID int64) *GetLogpushJobV2Options { +func (*LogpushJobsApiV1) NewGetLogpushJobV2Options(jobID string) *GetLogpushJobV2Options { return &GetLogpushJobV2Options{ - JobID: core.Int64Ptr(jobID), + JobID: core.StringPtr(jobID), } } // SetJobID : Allow user to set JobID -func (_options *GetLogpushJobV2Options) SetJobID(jobID int64) *GetLogpushJobV2Options { - _options.JobID = core.Int64Ptr(jobID) +func (_options *GetLogpushJobV2Options) SetJobID(jobID string) *GetLogpushJobV2Options { + _options.JobID = core.StringPtr(jobID) return _options } @@ -1679,28 +1213,10 @@ func (options *GetLogpushJobV2Options) SetHeaders(param map[string]string) *GetL return options } -// GetLogpushJobsOptions : The GetLogpushJobs options. -type GetLogpushJobsOptions struct { - - // Allows users to set headers on API requests - Headers map[string]string -} - -// NewGetLogpushJobsOptions : Instantiate GetLogpushJobsOptions -func (*LogpushJobsApiV1) NewGetLogpushJobsOptions() *GetLogpushJobsOptions { - return &GetLogpushJobsOptions{} -} - -// SetHeaders : Allow user to set Headers -func (options *GetLogpushJobsOptions) SetHeaders(param map[string]string) *GetLogpushJobsOptions { - options.Headers = param - return options -} - // GetLogpushJobsV2Options : The GetLogpushJobsV2 options. type GetLogpushJobsV2Options struct { - // Allows users to set headers on API requests + // Allows users to set headers on API requests. Headers map[string]string } @@ -1715,38 +1231,12 @@ func (options *GetLogpushJobsV2Options) SetHeaders(param map[string]string) *Get return options } -// GetLogpushOwnershipOptions : The GetLogpushOwnership options. -type GetLogpushOwnershipOptions struct { - // Uniquely identifies a resource (such as an s3 bucket) where data will be pushed. - DestinationConf *string `json:"destination_conf,omitempty"` - - // Allows users to set headers on API requests - Headers map[string]string -} - -// NewGetLogpushOwnershipOptions : Instantiate GetLogpushOwnershipOptions -func (*LogpushJobsApiV1) NewGetLogpushOwnershipOptions() *GetLogpushOwnershipOptions { - return &GetLogpushOwnershipOptions{} -} - -// SetDestinationConf : Allow user to set DestinationConf -func (_options *GetLogpushOwnershipOptions) SetDestinationConf(destinationConf string) *GetLogpushOwnershipOptions { - _options.DestinationConf = core.StringPtr(destinationConf) - return _options -} - -// SetHeaders : Allow user to set Headers -func (options *GetLogpushOwnershipOptions) SetHeaders(param map[string]string) *GetLogpushOwnershipOptions { - options.Headers = param - return options -} - // GetLogpushOwnershipV2Options : The GetLogpushOwnershipV2 options. type GetLogpushOwnershipV2Options struct { // Information to identify the COS bucket where the data will be pushed. - Cos interface{} `json:"cos,omitempty"` + Cos map[string]interface{} `json:"cos,omitempty"` - // Allows users to set headers on API requests + // Allows users to set headers on API requests. Headers map[string]string } @@ -1756,7 +1246,7 @@ func (*LogpushJobsApiV1) NewGetLogpushOwnershipV2Options() *GetLogpushOwnershipV } // SetCos : Allow user to set Cos -func (_options *GetLogpushOwnershipV2Options) SetCos(cos interface{}) *GetLogpushOwnershipV2Options { +func (_options *GetLogpushOwnershipV2Options) SetCos(cos map[string]interface{}) *GetLogpushOwnershipV2Options { _options.Cos = cos return _options } @@ -1767,20 +1257,20 @@ func (options *GetLogpushOwnershipV2Options) SetHeaders(param map[string]string) return options } -// ListFieldsForDatasetOptions : The ListFieldsForDataset options. -type ListFieldsForDatasetOptions struct { +// GetLogsRetentionOptions : The GetLogsRetention options. +type GetLogsRetentionOptions struct { - // Allows users to set headers on API requests + // Allows users to set headers on API requests. Headers map[string]string } -// NewListFieldsForDatasetOptions : Instantiate ListFieldsForDatasetOptions -func (*LogpushJobsApiV1) NewListFieldsForDatasetOptions() *ListFieldsForDatasetOptions { - return &ListFieldsForDatasetOptions{} +// NewGetLogsRetentionOptions : Instantiate GetLogsRetentionOptions +func (*LogpushJobsApiV1) NewGetLogsRetentionOptions() *GetLogsRetentionOptions { + return &GetLogsRetentionOptions{} } // SetHeaders : Allow user to set Headers -func (options *ListFieldsForDatasetOptions) SetHeaders(param map[string]string) *ListFieldsForDatasetOptions { +func (options *GetLogsRetentionOptions) SetHeaders(param map[string]string) *GetLogsRetentionOptions { options.Headers = param return options } @@ -1788,7 +1278,7 @@ func (options *ListFieldsForDatasetOptions) SetHeaders(param map[string]string) // ListFieldsForDatasetV2Options : The ListFieldsForDatasetV2 options. type ListFieldsForDatasetV2Options struct { - // Allows users to set headers on API requests + // Allows users to set headers on API requests. Headers map[string]string } @@ -1803,28 +1293,10 @@ func (options *ListFieldsForDatasetV2Options) SetHeaders(param map[string]string return options } -// ListLogpushJobsForDatasetOptions : The ListLogpushJobsForDataset options. -type ListLogpushJobsForDatasetOptions struct { - - // Allows users to set headers on API requests - Headers map[string]string -} - -// NewListLogpushJobsForDatasetOptions : Instantiate ListLogpushJobsForDatasetOptions -func (*LogpushJobsApiV1) NewListLogpushJobsForDatasetOptions() *ListLogpushJobsForDatasetOptions { - return &ListLogpushJobsForDatasetOptions{} -} - -// SetHeaders : Allow user to set Headers -func (options *ListLogpushJobsForDatasetOptions) SetHeaders(param map[string]string) *ListLogpushJobsForDatasetOptions { - options.Headers = param - return options -} - // ListLogpushJobsForDatasetV2Options : The ListLogpushJobsForDatasetV2 options. type ListLogpushJobsForDatasetV2Options struct { - // Allows users to set headers on API requests + // Allows users to set headers on API requests. Headers map[string]string } @@ -1839,108 +1311,127 @@ func (options *ListLogpushJobsForDatasetV2Options) SetHeaders(param map[string]s return options } -// UpdateLogpushJobOptions : The UpdateLogpushJob options. -type UpdateLogpushJobOptions struct { - // logpush job identifier. - JobID *int64 `json:"job_id" validate:"required"` - - // Whether the logpush job enabled or not. - Enabled *bool `json:"enabled,omitempty"` - - // Configuration string. - LogpullOptions *string `json:"logpull_options,omitempty"` - - // Uniquely identifies a resource (such as an s3 bucket) where data will be pushed. - DestinationConf *string `json:"destination_conf,omitempty"` - - // Ownership challenge token to prove destination ownership. - OwnershipChallenge *string `json:"ownership_challenge,omitempty"` - - // The frequency at which CIS sends batches of logs to your destination. - Frequency *string `json:"frequency,omitempty"` - - // Allows users to set headers on API requests - Headers map[string]string +// LogRetentionRespResult : LogRetentionRespResult struct +type LogRetentionRespResult struct { + Flag *bool `json:"flag,omitempty"` } -// Constants associated with the UpdateLogpushJobOptions.Frequency property. -// The frequency at which CIS sends batches of logs to your destination. -const ( - UpdateLogpushJobOptions_Frequency_High = "high" - UpdateLogpushJobOptions_Frequency_Low = "low" -) - -// NewUpdateLogpushJobOptions : Instantiate UpdateLogpushJobOptions -func (*LogpushJobsApiV1) NewUpdateLogpushJobOptions(jobID int64) *UpdateLogpushJobOptions { - return &UpdateLogpushJobOptions{ - JobID: core.Int64Ptr(jobID), +// UnmarshalLogRetentionRespResult unmarshals an instance of LogRetentionRespResult from the specified map of raw messages. +func UnmarshalLogRetentionRespResult(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(LogRetentionRespResult) + err = core.UnmarshalPrimitive(m, "flag", &obj.Flag) + if err != nil { + err = core.SDKErrorf(err, "", "flag-error", common.GetComponentInfo()) + return } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } -// SetJobID : Allow user to set JobID -func (_options *UpdateLogpushJobOptions) SetJobID(jobID int64) *UpdateLogpushJobOptions { - _options.JobID = core.Int64Ptr(jobID) - return _options -} +// LogpushJobIbmclReqIbmcl : Required information to push logs to your Cloud Logs instance. +type LogpushJobIbmclReqIbmcl struct { + // GUID of the IBM Cloud Logs instance where you want to send logs. + InstanceID *string `json:"instance_id" validate:"required"` -// SetEnabled : Allow user to set Enabled -func (_options *UpdateLogpushJobOptions) SetEnabled(enabled bool) *UpdateLogpushJobOptions { - _options.Enabled = core.BoolPtr(enabled) - return _options -} + // Region where the IBM Cloud Logs instance is located. + Region *string `json:"region" validate:"required"` -// SetLogpullOptions : Allow user to set LogpullOptions -func (_options *UpdateLogpushJobOptions) SetLogpullOptions(logpullOptions string) *UpdateLogpushJobOptions { - _options.LogpullOptions = core.StringPtr(logpullOptions) - return _options + // IBM Cloud API key used to generate a token for pushing to your Cloud Logs instance. + ApiKey *string `json:"api_key" validate:"required"` } -// SetDestinationConf : Allow user to set DestinationConf -func (_options *UpdateLogpushJobOptions) SetDestinationConf(destinationConf string) *UpdateLogpushJobOptions { - _options.DestinationConf = core.StringPtr(destinationConf) - return _options +// NewLogpushJobIbmclReqIbmcl : Instantiate LogpushJobIbmclReqIbmcl (Generic Model Constructor) +func (*LogpushJobsApiV1) NewLogpushJobIbmclReqIbmcl(instanceID string, region string, apiKey string) (_model *LogpushJobIbmclReqIbmcl, err error) { + _model = &LogpushJobIbmclReqIbmcl{ + InstanceID: core.StringPtr(instanceID), + Region: core.StringPtr(region), + ApiKey: core.StringPtr(apiKey), + } + err = core.ValidateStruct(_model, "required parameters") + if err != nil { + err = core.SDKErrorf(err, "", "model-missing-required", common.GetComponentInfo()) + } + return } -// SetOwnershipChallenge : Allow user to set OwnershipChallenge -func (_options *UpdateLogpushJobOptions) SetOwnershipChallenge(ownershipChallenge string) *UpdateLogpushJobOptions { - _options.OwnershipChallenge = core.StringPtr(ownershipChallenge) - return _options +// UnmarshalLogpushJobIbmclReqIbmcl unmarshals an instance of LogpushJobIbmclReqIbmcl from the specified map of raw messages. +func UnmarshalLogpushJobIbmclReqIbmcl(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(LogpushJobIbmclReqIbmcl) + err = core.UnmarshalPrimitive(m, "instance_id", &obj.InstanceID) + if err != nil { + err = core.SDKErrorf(err, "", "instance_id-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "region", &obj.Region) + if err != nil { + err = core.SDKErrorf(err, "", "region-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "api_key", &obj.ApiKey) + if err != nil { + err = core.SDKErrorf(err, "", "api_key-error", common.GetComponentInfo()) + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } -// SetFrequency : Allow user to set Frequency -func (_options *UpdateLogpushJobOptions) SetFrequency(frequency string) *UpdateLogpushJobOptions { - _options.Frequency = core.StringPtr(frequency) - return _options +// LogpushJobsUpdateIbmclReqIbmcl : Required information to push logs to your Cloud Logs instance. +type LogpushJobsUpdateIbmclReqIbmcl struct { + // GUID of the IBM Cloud Logs instance where you want to send logs. + InstanceID *string `json:"instance_id,omitempty"` + + // Region where the IBM Cloud Logs instance is located. + Region *string `json:"region,omitempty"` + + // IBM Cloud API key used to generate a token for pushing to your Cloud Logs instance. + ApiKey *string `json:"api_key,omitempty"` } -// SetHeaders : Allow user to set Headers -func (options *UpdateLogpushJobOptions) SetHeaders(param map[string]string) *UpdateLogpushJobOptions { - options.Headers = param - return options +// UnmarshalLogpushJobsUpdateIbmclReqIbmcl unmarshals an instance of LogpushJobsUpdateIbmclReqIbmcl from the specified map of raw messages. +func UnmarshalLogpushJobsUpdateIbmclReqIbmcl(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(LogpushJobsUpdateIbmclReqIbmcl) + err = core.UnmarshalPrimitive(m, "instance_id", &obj.InstanceID) + if err != nil { + err = core.SDKErrorf(err, "", "instance_id-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "region", &obj.Region) + if err != nil { + err = core.SDKErrorf(err, "", "region-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "api_key", &obj.ApiKey) + if err != nil { + err = core.SDKErrorf(err, "", "api_key-error", common.GetComponentInfo()) + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } // UpdateLogpushJobV2Options : The UpdateLogpushJobV2 options. type UpdateLogpushJobV2Options struct { // logpush job identifier. - JobID *int64 `json:"job_id" validate:"required"` + JobID *string `json:"job_id" validate:"required,ne="` // Update logpush job. UpdateLogpushJobV2Request UpdateLogpushJobV2RequestIntf `json:"UpdateLogpushJobV2Request,omitempty"` - // Allows users to set headers on API requests + // Allows users to set headers on API requests. Headers map[string]string } // NewUpdateLogpushJobV2Options : Instantiate UpdateLogpushJobV2Options -func (*LogpushJobsApiV1) NewUpdateLogpushJobV2Options(jobID int64) *UpdateLogpushJobV2Options { +func (*LogpushJobsApiV1) NewUpdateLogpushJobV2Options(jobID string) *UpdateLogpushJobV2Options { return &UpdateLogpushJobV2Options{ - JobID: core.Int64Ptr(jobID), + JobID: core.StringPtr(jobID), } } // SetJobID : Allow user to set JobID -func (_options *UpdateLogpushJobV2Options) SetJobID(jobID int64) *UpdateLogpushJobV2Options { - _options.JobID = core.Int64Ptr(jobID) +func (_options *UpdateLogpushJobV2Options) SetJobID(jobID string) *UpdateLogpushJobV2Options { + _options.JobID = core.StringPtr(jobID) return _options } @@ -1960,6 +1451,8 @@ func (options *UpdateLogpushJobV2Options) SetHeaders(param map[string]string) *U // Models which "extend" this model: // - UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq // - UpdateLogpushJobV2RequestLogpushJobsUpdateLogdnaReq +// - UpdateLogpushJobV2RequestLogpushJobsUpdateIbmclReq +// - UpdateLogpushJobV2RequestLogpushJobsUpdateGenericReq type UpdateLogpushJobV2Request struct { // Whether the logpush job enabled or not. Enabled *bool `json:"enabled,omitempty"` @@ -1968,7 +1461,7 @@ type UpdateLogpushJobV2Request struct { LogpullOptions *string `json:"logpull_options,omitempty"` // Information to identify the COS bucket where the data will be pushed. - Cos interface{} `json:"cos,omitempty"` + Cos map[string]interface{} `json:"cos,omitempty"` // Ownership challenge token to prove destination ownership. OwnershipChallenge *string `json:"ownership_challenge,omitempty"` @@ -1977,15 +1470,37 @@ type UpdateLogpushJobV2Request struct { Frequency *string `json:"frequency,omitempty"` // Information to identify the LogDNA instance the data will be pushed. - Logdna interface{} `json:"logdna,omitempty"` + Logdna map[string]interface{} `json:"logdna,omitempty"` + + // Required information to push logs to your Cloud Logs instance. + Ibmcl *LogpushJobsUpdateIbmclReqIbmcl `json:"ibmcl,omitempty"` + + // Logpush Job Name. + Name *string `json:"name,omitempty"` + + // Uniquely identifies a resource where data will be pushed. Additional configuration parameters supported by the + // destination may be included. + DestinationConf *string `json:"destination_conf,omitempty"` + + // Dataset to be pulled. + Dataset *string `json:"dataset,omitempty"` } // Constants associated with the UpdateLogpushJobV2Request.Frequency property. // The frequency at which CIS sends batches of logs to your destination. const ( UpdateLogpushJobV2Request_Frequency_High = "high" - UpdateLogpushJobV2Request_Frequency_Low = "low" + UpdateLogpushJobV2Request_Frequency_Low = "low" ) + +// Constants associated with the UpdateLogpushJobV2Request.Dataset property. +// Dataset to be pulled. +const ( + UpdateLogpushJobV2Request_Dataset_FirewallEvents = "firewall_events" + UpdateLogpushJobV2Request_Dataset_HttpRequests = "http_requests" + UpdateLogpushJobV2Request_Dataset_RangeEvents = "range_events" +) + func (*UpdateLogpushJobV2Request) isaUpdateLogpushJobV2Request() bool { return true } @@ -1999,76 +1514,67 @@ func UnmarshalUpdateLogpushJobV2Request(m map[string]json.RawMessage, result int obj := new(UpdateLogpushJobV2Request) err = core.UnmarshalPrimitive(m, "enabled", &obj.Enabled) if err != nil { + err = core.SDKErrorf(err, "", "enabled-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "logpull_options", &obj.LogpullOptions) if err != nil { + err = core.SDKErrorf(err, "", "logpull_options-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "cos", &obj.Cos) if err != nil { + err = core.SDKErrorf(err, "", "cos-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "ownership_challenge", &obj.OwnershipChallenge) if err != nil { + err = core.SDKErrorf(err, "", "ownership_challenge-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "frequency", &obj.Frequency) if err != nil { + err = core.SDKErrorf(err, "", "frequency-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "logdna", &obj.Logdna) if err != nil { + err = core.SDKErrorf(err, "", "logdna-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalModel(m, "ibmcl", &obj.Ibmcl, UnmarshalLogpushJobsUpdateIbmclReqIbmcl) + if err != nil { + err = core.SDKErrorf(err, "", "ibmcl-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + err = core.SDKErrorf(err, "", "name-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "destination_conf", &obj.DestinationConf) + if err != nil { + err = core.SDKErrorf(err, "", "destination_conf-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "dataset", &obj.Dataset) + if err != nil { + err = core.SDKErrorf(err, "", "dataset-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) return } -// ValidateLogpushOwnershipChallengeOptions : The ValidateLogpushOwnershipChallenge options. -type ValidateLogpushOwnershipChallengeOptions struct { - // Uniquely identifies a resource (such as an s3 bucket) where data will be pushed. - DestinationConf *string `json:"destination_conf,omitempty"` - - // Ownership challenge token to prove destination ownership. - OwnershipChallenge *string `json:"ownership_challenge,omitempty"` - - // Allows users to set headers on API requests - Headers map[string]string -} - -// NewValidateLogpushOwnershipChallengeOptions : Instantiate ValidateLogpushOwnershipChallengeOptions -func (*LogpushJobsApiV1) NewValidateLogpushOwnershipChallengeOptions() *ValidateLogpushOwnershipChallengeOptions { - return &ValidateLogpushOwnershipChallengeOptions{} -} - -// SetDestinationConf : Allow user to set DestinationConf -func (_options *ValidateLogpushOwnershipChallengeOptions) SetDestinationConf(destinationConf string) *ValidateLogpushOwnershipChallengeOptions { - _options.DestinationConf = core.StringPtr(destinationConf) - return _options -} - -// SetOwnershipChallenge : Allow user to set OwnershipChallenge -func (_options *ValidateLogpushOwnershipChallengeOptions) SetOwnershipChallenge(ownershipChallenge string) *ValidateLogpushOwnershipChallengeOptions { - _options.OwnershipChallenge = core.StringPtr(ownershipChallenge) - return _options -} - -// SetHeaders : Allow user to set Headers -func (options *ValidateLogpushOwnershipChallengeOptions) SetHeaders(param map[string]string) *ValidateLogpushOwnershipChallengeOptions { - options.Headers = param - return options -} - // ValidateLogpushOwnershipChallengeV2Options : The ValidateLogpushOwnershipChallengeV2 options. type ValidateLogpushOwnershipChallengeV2Options struct { // Information to identify the COS bucket where the data will be pushed. - Cos interface{} `json:"cos,omitempty"` + Cos map[string]interface{} `json:"cos,omitempty"` // Ownership challenge token to prove destination ownership. OwnershipChallenge *string `json:"ownership_challenge,omitempty"` - // Allows users to set headers on API requests + // Allows users to set headers on API requests. Headers map[string]string } @@ -2078,7 +1584,7 @@ func (*LogpushJobsApiV1) NewValidateLogpushOwnershipChallengeV2Options() *Valida } // SetCos : Allow user to set Cos -func (_options *ValidateLogpushOwnershipChallengeV2Options) SetCos(cos interface{}) *ValidateLogpushOwnershipChallengeV2Options { +func (_options *ValidateLogpushOwnershipChallengeV2Options) SetCos(cos map[string]interface{}) *ValidateLogpushOwnershipChallengeV2Options { _options.Cos = cos return _options } @@ -2097,7 +1603,7 @@ func (options *ValidateLogpushOwnershipChallengeV2Options) SetHeaders(param map[ // DeleteLogpushJobResp : delete logpush job response. type DeleteLogpushJobResp struct { - // success respose. + // success response. Success *bool `json:"success" validate:"required"` // errors. @@ -2107,7 +1613,7 @@ type DeleteLogpushJobResp struct { Messages [][]string `json:"messages" validate:"required"` // result. - Result interface{} `json:"result" validate:"required"` + Result map[string]interface{} `json:"result" validate:"required"` } // UnmarshalDeleteLogpushJobResp unmarshals an instance of DeleteLogpushJobResp from the specified map of raw messages. @@ -2115,18 +1621,22 @@ func UnmarshalDeleteLogpushJobResp(m map[string]json.RawMessage, result interfac obj := new(DeleteLogpushJobResp) err = core.UnmarshalPrimitive(m, "success", &obj.Success) if err != nil { + err = core.SDKErrorf(err, "", "success-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "errors", &obj.Errors) if err != nil { + err = core.SDKErrorf(err, "", "errors-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "messages", &obj.Messages) if err != nil { + err = core.SDKErrorf(err, "", "messages-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "result", &obj.Result) if err != nil { + err = core.SDKErrorf(err, "", "result-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -2145,7 +1655,7 @@ type ListFieldsResp struct { Messages [][]string `json:"messages" validate:"required"` // result. - Result interface{} `json:"result,omitempty"` + Result map[string]interface{} `json:"result,omitempty"` } // UnmarshalListFieldsResp unmarshals an instance of ListFieldsResp from the specified map of raw messages. @@ -2153,56 +1663,105 @@ func UnmarshalListFieldsResp(m map[string]json.RawMessage, result interface{}) ( obj := new(ListFieldsResp) err = core.UnmarshalPrimitive(m, "success", &obj.Success) if err != nil { + err = core.SDKErrorf(err, "", "success-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "errors", &obj.Errors) + if err != nil { + err = core.SDKErrorf(err, "", "errors-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "messages", &obj.Messages) + if err != nil { + err = core.SDKErrorf(err, "", "messages-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "result", &obj.Result) + if err != nil { + err = core.SDKErrorf(err, "", "result-error", common.GetComponentInfo()) + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// ListLogpushJobsResp : List Logpush Jobs Response. +type ListLogpushJobsResp struct { + // success response. + Success *bool `json:"success" validate:"required"` + + // errors. + Errors [][]string `json:"errors" validate:"required"` + + // messages. + Messages [][]string `json:"messages" validate:"required"` + + // result. + Result []LogpushJobPack `json:"result" validate:"required"` +} + +// UnmarshalListLogpushJobsResp unmarshals an instance of ListLogpushJobsResp from the specified map of raw messages. +func UnmarshalListLogpushJobsResp(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(ListLogpushJobsResp) + err = core.UnmarshalPrimitive(m, "success", &obj.Success) + if err != nil { + err = core.SDKErrorf(err, "", "success-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "errors", &obj.Errors) if err != nil { + err = core.SDKErrorf(err, "", "errors-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "messages", &obj.Messages) if err != nil { + err = core.SDKErrorf(err, "", "messages-error", common.GetComponentInfo()) return } - err = core.UnmarshalPrimitive(m, "result", &obj.Result) + err = core.UnmarshalModel(m, "result", &obj.Result, UnmarshalLogpushJobPack) if err != nil { + err = core.SDKErrorf(err, "", "result-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) return } -// ListLogpushJobsResp : List Logpush Jobs Response. -type ListLogpushJobsResp struct { +// LogRetentionResp : log retention result. +type LogRetentionResp struct { + Result *LogRetentionRespResult `json:"result,omitempty"` + // success response. - Success *bool `json:"success" validate:"required"` + Success *bool `json:"success,omitempty"` // errors. - Errors [][]string `json:"errors" validate:"required"` + Errors [][]string `json:"errors,omitempty"` // messages. - Messages [][]string `json:"messages" validate:"required"` - - // result. - Result []LogpushJobPack `json:"result" validate:"required"` + Messages [][]string `json:"messages,omitempty"` } -// UnmarshalListLogpushJobsResp unmarshals an instance of ListLogpushJobsResp from the specified map of raw messages. -func UnmarshalListLogpushJobsResp(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(ListLogpushJobsResp) - err = core.UnmarshalPrimitive(m, "success", &obj.Success) +// UnmarshalLogRetentionResp unmarshals an instance of LogRetentionResp from the specified map of raw messages. +func UnmarshalLogRetentionResp(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(LogRetentionResp) + err = core.UnmarshalModel(m, "result", &obj.Result, UnmarshalLogRetentionRespResult) if err != nil { + err = core.SDKErrorf(err, "", "result-error", common.GetComponentInfo()) return } - err = core.UnmarshalPrimitive(m, "errors", &obj.Errors) + err = core.UnmarshalPrimitive(m, "success", &obj.Success) if err != nil { + err = core.SDKErrorf(err, "", "success-error", common.GetComponentInfo()) return } - err = core.UnmarshalPrimitive(m, "messages", &obj.Messages) + err = core.UnmarshalPrimitive(m, "errors", &obj.Errors) if err != nil { + err = core.SDKErrorf(err, "", "errors-error", common.GetComponentInfo()) return } - err = core.UnmarshalModel(m, "result", &obj.Result, UnmarshalLogpushJobPack) + err = core.UnmarshalPrimitive(m, "messages", &obj.Messages) if err != nil { + err = core.SDKErrorf(err, "", "messages-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -2247,42 +1806,52 @@ func UnmarshalLogpushJobPack(m map[string]json.RawMessage, result interface{}) ( obj := new(LogpushJobPack) err = core.UnmarshalPrimitive(m, "id", &obj.ID) if err != nil { + err = core.SDKErrorf(err, "", "id-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "name", &obj.Name) if err != nil { + err = core.SDKErrorf(err, "", "name-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "enabled", &obj.Enabled) if err != nil { + err = core.SDKErrorf(err, "", "enabled-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "dataset", &obj.Dataset) if err != nil { + err = core.SDKErrorf(err, "", "dataset-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "frequency", &obj.Frequency) if err != nil { + err = core.SDKErrorf(err, "", "frequency-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "logpull_options", &obj.LogpullOptions) if err != nil { + err = core.SDKErrorf(err, "", "logpull_options-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "destination_conf", &obj.DestinationConf) if err != nil { + err = core.SDKErrorf(err, "", "destination_conf-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "last_complete", &obj.LastComplete) if err != nil { + err = core.SDKErrorf(err, "", "last_complete-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "last_error", &obj.LastError) if err != nil { + err = core.SDKErrorf(err, "", "last_error-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "error_message", &obj.ErrorMessage) if err != nil { + err = core.SDKErrorf(err, "", "error_message-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -2309,18 +1878,22 @@ func UnmarshalLogpushJobsResp(m map[string]json.RawMessage, result interface{}) obj := new(LogpushJobsResp) err = core.UnmarshalPrimitive(m, "success", &obj.Success) if err != nil { + err = core.SDKErrorf(err, "", "success-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "errors", &obj.Errors) if err != nil { + err = core.SDKErrorf(err, "", "errors-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "messages", &obj.Messages) if err != nil { + err = core.SDKErrorf(err, "", "messages-error", common.GetComponentInfo()) return } err = core.UnmarshalModel(m, "result", &obj.Result, UnmarshalLogpushJobPack) if err != nil { + err = core.SDKErrorf(err, "", "result-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -2347,18 +1920,22 @@ func UnmarshalOwnershipChallengeResp(m map[string]json.RawMessage, result interf obj := new(OwnershipChallengeResp) err = core.UnmarshalPrimitive(m, "success", &obj.Success) if err != nil { + err = core.SDKErrorf(err, "", "success-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "errors", &obj.Errors) if err != nil { + err = core.SDKErrorf(err, "", "errors-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "messages", &obj.Messages) if err != nil { + err = core.SDKErrorf(err, "", "messages-error", common.GetComponentInfo()) return } err = core.UnmarshalModel(m, "result", &obj.Result, UnmarshalOwnershipChallengeResult) if err != nil { + err = core.SDKErrorf(err, "", "result-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -2382,14 +1959,17 @@ func UnmarshalOwnershipChallengeResult(m map[string]json.RawMessage, result inte obj := new(OwnershipChallengeResult) err = core.UnmarshalPrimitive(m, "filename", &obj.Filename) if err != nil { + err = core.SDKErrorf(err, "", "filename-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "valid", &obj.Valid) if err != nil { + err = core.SDKErrorf(err, "", "valid-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "messages", &obj.Messages) if err != nil { + err = core.SDKErrorf(err, "", "messages-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -2407,6 +1987,7 @@ func UnmarshalOwnershipChallengeValidateResult(m map[string]json.RawMessage, res obj := new(OwnershipChallengeValidateResult) err = core.UnmarshalPrimitive(m, "valid", &obj.Valid) if err != nil { + err = core.SDKErrorf(err, "", "valid-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -2426,7 +2007,7 @@ type CreateLogpushJobV2RequestLogpushJobCosReq struct { LogpullOptions *string `json:"logpull_options,omitempty"` // Information to identify the COS bucket where the data will be pushed. - Cos interface{} `json:"cos" validate:"required"` + Cos map[string]interface{} `json:"cos" validate:"required"` // Ownership challenge token to prove destination ownership. OwnershipChallenge *string `json:"ownership_challenge" validate:"required"` @@ -2442,24 +2023,27 @@ type CreateLogpushJobV2RequestLogpushJobCosReq struct { // Dataset to be pulled. const ( CreateLogpushJobV2RequestLogpushJobCosReq_Dataset_FirewallEvents = "firewall_events" - CreateLogpushJobV2RequestLogpushJobCosReq_Dataset_HttpRequests = "http_requests" - CreateLogpushJobV2RequestLogpushJobCosReq_Dataset_RangeEvents = "range_events" + CreateLogpushJobV2RequestLogpushJobCosReq_Dataset_HttpRequests = "http_requests" + CreateLogpushJobV2RequestLogpushJobCosReq_Dataset_RangeEvents = "range_events" ) // Constants associated with the CreateLogpushJobV2RequestLogpushJobCosReq.Frequency property. // The frequency at which CIS sends batches of logs to your destination. const ( CreateLogpushJobV2RequestLogpushJobCosReq_Frequency_High = "high" - CreateLogpushJobV2RequestLogpushJobCosReq_Frequency_Low = "low" + CreateLogpushJobV2RequestLogpushJobCosReq_Frequency_Low = "low" ) // NewCreateLogpushJobV2RequestLogpushJobCosReq : Instantiate CreateLogpushJobV2RequestLogpushJobCosReq (Generic Model Constructor) -func (*LogpushJobsApiV1) NewCreateLogpushJobV2RequestLogpushJobCosReq(cos interface{}, ownershipChallenge string) (_model *CreateLogpushJobV2RequestLogpushJobCosReq, err error) { +func (*LogpushJobsApiV1) NewCreateLogpushJobV2RequestLogpushJobCosReq(cos map[string]interface{}, ownershipChallenge string) (_model *CreateLogpushJobV2RequestLogpushJobCosReq, err error) { _model = &CreateLogpushJobV2RequestLogpushJobCosReq{ - Cos: cos, + Cos: cos, OwnershipChallenge: core.StringPtr(ownershipChallenge), } err = core.ValidateStruct(_model, "required parameters") + if err != nil { + err = core.SDKErrorf(err, "", "model-missing-required", common.GetComponentInfo()) + } return } @@ -2472,30 +2056,218 @@ func UnmarshalCreateLogpushJobV2RequestLogpushJobCosReq(m map[string]json.RawMes obj := new(CreateLogpushJobV2RequestLogpushJobCosReq) err = core.UnmarshalPrimitive(m, "name", &obj.Name) if err != nil { + err = core.SDKErrorf(err, "", "name-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "enabled", &obj.Enabled) if err != nil { + err = core.SDKErrorf(err, "", "enabled-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "logpull_options", &obj.LogpullOptions) if err != nil { + err = core.SDKErrorf(err, "", "logpull_options-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "cos", &obj.Cos) if err != nil { + err = core.SDKErrorf(err, "", "cos-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "ownership_challenge", &obj.OwnershipChallenge) if err != nil { + err = core.SDKErrorf(err, "", "ownership_challenge-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "dataset", &obj.Dataset) + if err != nil { + err = core.SDKErrorf(err, "", "dataset-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "frequency", &obj.Frequency) + if err != nil { + err = core.SDKErrorf(err, "", "frequency-error", common.GetComponentInfo()) + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// CreateLogpushJobV2RequestLogpushJobGenericReq : Create logpush job for a generic destination. +// This model "extends" CreateLogpushJobV2Request +type CreateLogpushJobV2RequestLogpushJobGenericReq struct { + // Logpush Job Name. + Name *string `json:"name,omitempty"` + + // Whether the logpush job is enabled or not. + Enabled *bool `json:"enabled,omitempty"` + + // Configuration string. + LogpullOptions *string `json:"logpull_options,omitempty"` + + // Uniquely identifies a resource where data will be pushed. Additional configuration parameters supported by the + // destination may be included. + DestinationConf *string `json:"destination_conf" validate:"required"` + + // Dataset to be pulled. + Dataset *string `json:"dataset,omitempty"` + + // The frequency at which CIS sends batches of logs to your destination. + Frequency *string `json:"frequency,omitempty"` +} + +// Constants associated with the CreateLogpushJobV2RequestLogpushJobGenericReq.Dataset property. +// Dataset to be pulled. +const ( + CreateLogpushJobV2RequestLogpushJobGenericReq_Dataset_FirewallEvents = "firewall_events" + CreateLogpushJobV2RequestLogpushJobGenericReq_Dataset_HttpRequests = "http_requests" + CreateLogpushJobV2RequestLogpushJobGenericReq_Dataset_RangeEvents = "range_events" +) + +// Constants associated with the CreateLogpushJobV2RequestLogpushJobGenericReq.Frequency property. +// The frequency at which CIS sends batches of logs to your destination. +const ( + CreateLogpushJobV2RequestLogpushJobGenericReq_Frequency_High = "high" + CreateLogpushJobV2RequestLogpushJobGenericReq_Frequency_Low = "low" +) + +// NewCreateLogpushJobV2RequestLogpushJobGenericReq : Instantiate CreateLogpushJobV2RequestLogpushJobGenericReq (Generic Model Constructor) +func (*LogpushJobsApiV1) NewCreateLogpushJobV2RequestLogpushJobGenericReq(destinationConf string) (_model *CreateLogpushJobV2RequestLogpushJobGenericReq, err error) { + _model = &CreateLogpushJobV2RequestLogpushJobGenericReq{ + DestinationConf: core.StringPtr(destinationConf), + } + err = core.ValidateStruct(_model, "required parameters") + if err != nil { + err = core.SDKErrorf(err, "", "model-missing-required", common.GetComponentInfo()) + } + return +} + +func (*CreateLogpushJobV2RequestLogpushJobGenericReq) isaCreateLogpushJobV2Request() bool { + return true +} + +// UnmarshalCreateLogpushJobV2RequestLogpushJobGenericReq unmarshals an instance of CreateLogpushJobV2RequestLogpushJobGenericReq from the specified map of raw messages. +func UnmarshalCreateLogpushJobV2RequestLogpushJobGenericReq(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(CreateLogpushJobV2RequestLogpushJobGenericReq) + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + err = core.SDKErrorf(err, "", "name-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "enabled", &obj.Enabled) + if err != nil { + err = core.SDKErrorf(err, "", "enabled-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "logpull_options", &obj.LogpullOptions) + if err != nil { + err = core.SDKErrorf(err, "", "logpull_options-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "destination_conf", &obj.DestinationConf) + if err != nil { + err = core.SDKErrorf(err, "", "destination_conf-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "dataset", &obj.Dataset) + if err != nil { + err = core.SDKErrorf(err, "", "dataset-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "frequency", &obj.Frequency) + if err != nil { + err = core.SDKErrorf(err, "", "frequency-error", common.GetComponentInfo()) + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// CreateLogpushJobV2RequestLogpushJobIbmclReq : Create IBM Cloud Logs logpush job input. +// This model "extends" CreateLogpushJobV2Request +type CreateLogpushJobV2RequestLogpushJobIbmclReq struct { + // Logpush Job Name. + Name *string `json:"name,omitempty"` + + // Whether the logpush job is enabled or not. + Enabled *bool `json:"enabled,omitempty"` + + // Configuration string. + LogpullOptions *string `json:"logpull_options,omitempty"` + + // Required information to push logs to your Cloud Logs instance. + Ibmcl *LogpushJobIbmclReqIbmcl `json:"ibmcl" validate:"required"` + + // Dataset to be pulled. + Dataset *string `json:"dataset,omitempty"` + + // The frequency at which CIS sends batches of logs to your destination. + Frequency *string `json:"frequency,omitempty"` +} + +// Constants associated with the CreateLogpushJobV2RequestLogpushJobIbmclReq.Dataset property. +// Dataset to be pulled. +const ( + CreateLogpushJobV2RequestLogpushJobIbmclReq_Dataset_FirewallEvents = "firewall_events" + CreateLogpushJobV2RequestLogpushJobIbmclReq_Dataset_HttpRequests = "http_requests" + CreateLogpushJobV2RequestLogpushJobIbmclReq_Dataset_RangeEvents = "range_events" +) + +// Constants associated with the CreateLogpushJobV2RequestLogpushJobIbmclReq.Frequency property. +// The frequency at which CIS sends batches of logs to your destination. +const ( + CreateLogpushJobV2RequestLogpushJobIbmclReq_Frequency_High = "high" + CreateLogpushJobV2RequestLogpushJobIbmclReq_Frequency_Low = "low" +) + +// NewCreateLogpushJobV2RequestLogpushJobIbmclReq : Instantiate CreateLogpushJobV2RequestLogpushJobIbmclReq (Generic Model Constructor) +func (*LogpushJobsApiV1) NewCreateLogpushJobV2RequestLogpushJobIbmclReq(ibmcl *LogpushJobIbmclReqIbmcl) (_model *CreateLogpushJobV2RequestLogpushJobIbmclReq, err error) { + _model = &CreateLogpushJobV2RequestLogpushJobIbmclReq{ + Ibmcl: ibmcl, + } + err = core.ValidateStruct(_model, "required parameters") + if err != nil { + err = core.SDKErrorf(err, "", "model-missing-required", common.GetComponentInfo()) + } + return +} + +func (*CreateLogpushJobV2RequestLogpushJobIbmclReq) isaCreateLogpushJobV2Request() bool { + return true +} + +// UnmarshalCreateLogpushJobV2RequestLogpushJobIbmclReq unmarshals an instance of CreateLogpushJobV2RequestLogpushJobIbmclReq from the specified map of raw messages. +func UnmarshalCreateLogpushJobV2RequestLogpushJobIbmclReq(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(CreateLogpushJobV2RequestLogpushJobIbmclReq) + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + err = core.SDKErrorf(err, "", "name-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "enabled", &obj.Enabled) + if err != nil { + err = core.SDKErrorf(err, "", "enabled-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "logpull_options", &obj.LogpullOptions) + if err != nil { + err = core.SDKErrorf(err, "", "logpull_options-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalModel(m, "ibmcl", &obj.Ibmcl, UnmarshalLogpushJobIbmclReqIbmcl) + if err != nil { + err = core.SDKErrorf(err, "", "ibmcl-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "dataset", &obj.Dataset) if err != nil { + err = core.SDKErrorf(err, "", "dataset-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "frequency", &obj.Frequency) if err != nil { + err = core.SDKErrorf(err, "", "frequency-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -2515,10 +2287,7 @@ type CreateLogpushJobV2RequestLogpushJobLogdnaReq struct { LogpullOptions *string `json:"logpull_options,omitempty"` // Information to identify the LogDNA instance the data will be pushed. - Logdna interface{} `json:"logdna" validate:"required"` - - // Ownership challenge token to prove destination ownership. - OwnershipChallenge *string `json:"ownership_challenge,omitempty"` + Logdna map[string]interface{} `json:"logdna" validate:"required"` // Dataset to be pulled. Dataset *string `json:"dataset,omitempty"` @@ -2531,23 +2300,26 @@ type CreateLogpushJobV2RequestLogpushJobLogdnaReq struct { // Dataset to be pulled. const ( CreateLogpushJobV2RequestLogpushJobLogdnaReq_Dataset_FirewallEvents = "firewall_events" - CreateLogpushJobV2RequestLogpushJobLogdnaReq_Dataset_HttpRequests = "http_requests" - CreateLogpushJobV2RequestLogpushJobLogdnaReq_Dataset_RangeEvents = "range_events" + CreateLogpushJobV2RequestLogpushJobLogdnaReq_Dataset_HttpRequests = "http_requests" + CreateLogpushJobV2RequestLogpushJobLogdnaReq_Dataset_RangeEvents = "range_events" ) // Constants associated with the CreateLogpushJobV2RequestLogpushJobLogdnaReq.Frequency property. // The frequency at which CIS sends batches of logs to your destination. const ( CreateLogpushJobV2RequestLogpushJobLogdnaReq_Frequency_High = "high" - CreateLogpushJobV2RequestLogpushJobLogdnaReq_Frequency_Low = "low" + CreateLogpushJobV2RequestLogpushJobLogdnaReq_Frequency_Low = "low" ) // NewCreateLogpushJobV2RequestLogpushJobLogdnaReq : Instantiate CreateLogpushJobV2RequestLogpushJobLogdnaReq (Generic Model Constructor) -func (*LogpushJobsApiV1) NewCreateLogpushJobV2RequestLogpushJobLogdnaReq(logdna interface{}) (_model *CreateLogpushJobV2RequestLogpushJobLogdnaReq, err error) { +func (*LogpushJobsApiV1) NewCreateLogpushJobV2RequestLogpushJobLogdnaReq(logdna map[string]interface{}) (_model *CreateLogpushJobV2RequestLogpushJobLogdnaReq, err error) { _model = &CreateLogpushJobV2RequestLogpushJobLogdnaReq{ Logdna: logdna, } err = core.ValidateStruct(_model, "required parameters") + if err != nil { + err = core.SDKErrorf(err, "", "model-missing-required", common.GetComponentInfo()) + } return } @@ -2560,30 +2332,32 @@ func UnmarshalCreateLogpushJobV2RequestLogpushJobLogdnaReq(m map[string]json.Raw obj := new(CreateLogpushJobV2RequestLogpushJobLogdnaReq) err = core.UnmarshalPrimitive(m, "name", &obj.Name) if err != nil { + err = core.SDKErrorf(err, "", "name-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "enabled", &obj.Enabled) if err != nil { + err = core.SDKErrorf(err, "", "enabled-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "logpull_options", &obj.LogpullOptions) if err != nil { + err = core.SDKErrorf(err, "", "logpull_options-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "logdna", &obj.Logdna) if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "ownership_challenge", &obj.OwnershipChallenge) - if err != nil { + err = core.SDKErrorf(err, "", "logdna-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "dataset", &obj.Dataset) if err != nil { + err = core.SDKErrorf(err, "", "dataset-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "frequency", &obj.Frequency) if err != nil { + err = core.SDKErrorf(err, "", "frequency-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -2600,7 +2374,7 @@ type UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq struct { LogpullOptions *string `json:"logpull_options,omitempty"` // Information to identify the COS bucket where the data will be pushed. - Cos interface{} `json:"cos,omitempty"` + Cos map[string]interface{} `json:"cos,omitempty"` // Ownership challenge token to prove destination ownership. OwnershipChallenge *string `json:"ownership_challenge,omitempty"` @@ -2613,7 +2387,7 @@ type UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq struct { // The frequency at which CIS sends batches of logs to your destination. const ( UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq_Frequency_High = "high" - UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq_Frequency_Low = "low" + UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq_Frequency_Low = "low" ) func (*UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq) isaUpdateLogpushJobV2Request() bool { @@ -2625,22 +2399,160 @@ func UnmarshalUpdateLogpushJobV2RequestLogpushJobsUpdateCosReq(m map[string]json obj := new(UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq) err = core.UnmarshalPrimitive(m, "enabled", &obj.Enabled) if err != nil { + err = core.SDKErrorf(err, "", "enabled-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "logpull_options", &obj.LogpullOptions) if err != nil { + err = core.SDKErrorf(err, "", "logpull_options-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "cos", &obj.Cos) if err != nil { + err = core.SDKErrorf(err, "", "cos-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "ownership_challenge", &obj.OwnershipChallenge) if err != nil { + err = core.SDKErrorf(err, "", "ownership_challenge-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "frequency", &obj.Frequency) + if err != nil { + err = core.SDKErrorf(err, "", "frequency-error", common.GetComponentInfo()) + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// UpdateLogpushJobV2RequestLogpushJobsUpdateGenericReq : Create logpush job for a generic destination. +// This model "extends" UpdateLogpushJobV2Request +type UpdateLogpushJobV2RequestLogpushJobsUpdateGenericReq struct { + // Logpush Job Name. + Name *string `json:"name,omitempty"` + + // Whether the logpush job is enabled or not. + Enabled *bool `json:"enabled,omitempty"` + + // Configuration string. + LogpullOptions *string `json:"logpull_options,omitempty"` + + // Uniquely identifies a resource where data will be pushed. Additional configuration parameters supported by the + // destination may be included. + DestinationConf *string `json:"destination_conf,omitempty"` + + // Dataset to be pulled. + Dataset *string `json:"dataset,omitempty"` + + // The frequency at which CIS sends batches of logs to your destination. + Frequency *string `json:"frequency,omitempty"` +} + +// Constants associated with the UpdateLogpushJobV2RequestLogpushJobsUpdateGenericReq.Dataset property. +// Dataset to be pulled. +const ( + UpdateLogpushJobV2RequestLogpushJobsUpdateGenericReq_Dataset_FirewallEvents = "firewall_events" + UpdateLogpushJobV2RequestLogpushJobsUpdateGenericReq_Dataset_HttpRequests = "http_requests" + UpdateLogpushJobV2RequestLogpushJobsUpdateGenericReq_Dataset_RangeEvents = "range_events" +) + +// Constants associated with the UpdateLogpushJobV2RequestLogpushJobsUpdateGenericReq.Frequency property. +// The frequency at which CIS sends batches of logs to your destination. +const ( + UpdateLogpushJobV2RequestLogpushJobsUpdateGenericReq_Frequency_High = "high" + UpdateLogpushJobV2RequestLogpushJobsUpdateGenericReq_Frequency_Low = "low" +) + +func (*UpdateLogpushJobV2RequestLogpushJobsUpdateGenericReq) isaUpdateLogpushJobV2Request() bool { + return true +} + +// UnmarshalUpdateLogpushJobV2RequestLogpushJobsUpdateGenericReq unmarshals an instance of UpdateLogpushJobV2RequestLogpushJobsUpdateGenericReq from the specified map of raw messages. +func UnmarshalUpdateLogpushJobV2RequestLogpushJobsUpdateGenericReq(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(UpdateLogpushJobV2RequestLogpushJobsUpdateGenericReq) + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + err = core.SDKErrorf(err, "", "name-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "enabled", &obj.Enabled) + if err != nil { + err = core.SDKErrorf(err, "", "enabled-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "logpull_options", &obj.LogpullOptions) + if err != nil { + err = core.SDKErrorf(err, "", "logpull_options-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "destination_conf", &obj.DestinationConf) + if err != nil { + err = core.SDKErrorf(err, "", "destination_conf-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "dataset", &obj.Dataset) + if err != nil { + err = core.SDKErrorf(err, "", "dataset-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "frequency", &obj.Frequency) + if err != nil { + err = core.SDKErrorf(err, "", "frequency-error", common.GetComponentInfo()) + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// UpdateLogpushJobV2RequestLogpushJobsUpdateIbmclReq : Update IBM Cloud Logs logpush job input. +// This model "extends" UpdateLogpushJobV2Request +type UpdateLogpushJobV2RequestLogpushJobsUpdateIbmclReq struct { + // Whether the logpush job enabled or not. + Enabled *bool `json:"enabled,omitempty"` + + // Configuration string. + LogpullOptions *string `json:"logpull_options,omitempty"` + + // Required information to push logs to your Cloud Logs instance. + Ibmcl *LogpushJobsUpdateIbmclReqIbmcl `json:"ibmcl,omitempty"` + + // The frequency at which CIS sends batches of logs to your destination. + Frequency *string `json:"frequency,omitempty"` +} + +// Constants associated with the UpdateLogpushJobV2RequestLogpushJobsUpdateIbmclReq.Frequency property. +// The frequency at which CIS sends batches of logs to your destination. +const ( + UpdateLogpushJobV2RequestLogpushJobsUpdateIbmclReq_Frequency_High = "high" + UpdateLogpushJobV2RequestLogpushJobsUpdateIbmclReq_Frequency_Low = "low" +) + +func (*UpdateLogpushJobV2RequestLogpushJobsUpdateIbmclReq) isaUpdateLogpushJobV2Request() bool { + return true +} + +// UnmarshalUpdateLogpushJobV2RequestLogpushJobsUpdateIbmclReq unmarshals an instance of UpdateLogpushJobV2RequestLogpushJobsUpdateIbmclReq from the specified map of raw messages. +func UnmarshalUpdateLogpushJobV2RequestLogpushJobsUpdateIbmclReq(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(UpdateLogpushJobV2RequestLogpushJobsUpdateIbmclReq) + err = core.UnmarshalPrimitive(m, "enabled", &obj.Enabled) + if err != nil { + err = core.SDKErrorf(err, "", "enabled-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "logpull_options", &obj.LogpullOptions) + if err != nil { + err = core.SDKErrorf(err, "", "logpull_options-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalModel(m, "ibmcl", &obj.Ibmcl, UnmarshalLogpushJobsUpdateIbmclReqIbmcl) + if err != nil { + err = core.SDKErrorf(err, "", "ibmcl-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "frequency", &obj.Frequency) if err != nil { + err = core.SDKErrorf(err, "", "frequency-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -2657,7 +2569,7 @@ type UpdateLogpushJobV2RequestLogpushJobsUpdateLogdnaReq struct { LogpullOptions *string `json:"logpull_options,omitempty"` // Information to identify the LogDNA instance the data will be pushed. - Logdna interface{} `json:"logdna,omitempty"` + Logdna map[string]interface{} `json:"logdna,omitempty"` // The frequency at which CIS sends batches of logs to your destination. Frequency *string `json:"frequency,omitempty"` @@ -2667,7 +2579,7 @@ type UpdateLogpushJobV2RequestLogpushJobsUpdateLogdnaReq struct { // The frequency at which CIS sends batches of logs to your destination. const ( UpdateLogpushJobV2RequestLogpushJobsUpdateLogdnaReq_Frequency_High = "high" - UpdateLogpushJobV2RequestLogpushJobsUpdateLogdnaReq_Frequency_Low = "low" + UpdateLogpushJobV2RequestLogpushJobsUpdateLogdnaReq_Frequency_Low = "low" ) func (*UpdateLogpushJobV2RequestLogpushJobsUpdateLogdnaReq) isaUpdateLogpushJobV2Request() bool { @@ -2679,18 +2591,22 @@ func UnmarshalUpdateLogpushJobV2RequestLogpushJobsUpdateLogdnaReq(m map[string]j obj := new(UpdateLogpushJobV2RequestLogpushJobsUpdateLogdnaReq) err = core.UnmarshalPrimitive(m, "enabled", &obj.Enabled) if err != nil { + err = core.SDKErrorf(err, "", "enabled-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "logpull_options", &obj.LogpullOptions) if err != nil { + err = core.SDKErrorf(err, "", "logpull_options-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "logdna", &obj.Logdna) if err != nil { + err = core.SDKErrorf(err, "", "logdna-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "frequency", &obj.Frequency) if err != nil { + err = core.SDKErrorf(err, "", "frequency-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) From 9efbadf7b50358a97f5ecaf75b1142865ac58a6b Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Fri, 13 Dec 2024 05:07:53 +0530 Subject: [PATCH 2/4] add unit test --- logpushjobsapiv1/logpush_jobs_api_v1_test.go | 3714 +++++------------- 1 file changed, 1089 insertions(+), 2625 deletions(-) diff --git a/logpushjobsapiv1/logpush_jobs_api_v1_test.go b/logpushjobsapiv1/logpush_jobs_api_v1_test.go index 77c0892..378c9d7 100644 --- a/logpushjobsapiv1/logpush_jobs_api_v1_test.go +++ b/logpushjobsapiv1/logpush_jobs_api_v1_test.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2022. + * (C) Copyright IBM Corp. 2024. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,8 @@ package logpushjobsapiv1_test import ( "bytes" "context" + "encoding/base64" + "encoding/json" "fmt" "io" "net/http" @@ -37,14 +39,14 @@ var _ = Describe(`LogpushJobsApiV1`, func() { var testServer *httptest.Server Describe(`Service constructor tests`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" It(`Instantiate service client`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(logpushJobsApiService).ToNot(BeNil()) Expect(serviceErr).To(BeNil()) @@ -53,8 +55,8 @@ var _ = Describe(`LogpushJobsApiV1`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: "{BAD_URL_STRING", Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(logpushJobsApiService).To(BeNil()) Expect(serviceErr).ToNot(BeNil()) @@ -63,8 +65,8 @@ var _ = Describe(`LogpushJobsApiV1`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: "https://logpushjobsapiv1/api", Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), Authenticator: &core.BasicAuthenticator{ Username: "", Password: "", @@ -81,8 +83,8 @@ var _ = Describe(`LogpushJobsApiV1`, func() { }) Describe(`Service constructor tests using external config`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" Context(`Using external config, construct service client instances`, func() { // Map containing environment variables used in testing. var testEnvironment = map[string]string{ @@ -94,8 +96,8 @@ var _ = Describe(`LogpushJobsApiV1`, func() { SetTestEnvironment(testEnvironment) logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1UsingExternalConfig(&logpushjobsapiv1.LogpushJobsApiV1Options{ Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(logpushJobsApiService).ToNot(BeNil()) Expect(serviceErr).To(BeNil()) @@ -112,8 +114,8 @@ var _ = Describe(`LogpushJobsApiV1`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1UsingExternalConfig(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: "https://testService/api", Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(logpushJobsApiService).ToNot(BeNil()) Expect(serviceErr).To(BeNil()) @@ -130,8 +132,8 @@ var _ = Describe(`LogpushJobsApiV1`, func() { SetTestEnvironment(testEnvironment) logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1UsingExternalConfig(&logpushjobsapiv1.LogpushJobsApiV1Options{ Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) err := logpushJobsApiService.SetServiceURL("https://testService/api") Expect(err).To(BeNil()) @@ -157,8 +159,8 @@ var _ = Describe(`LogpushJobsApiV1`, func() { SetTestEnvironment(testEnvironment) logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1UsingExternalConfig(&logpushjobsapiv1.LogpushJobsApiV1Options{ Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) It(`Instantiate service client with error`, func() { @@ -177,8 +179,8 @@ var _ = Describe(`LogpushJobsApiV1`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1UsingExternalConfig(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: "{BAD_URL_STRING", Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) It(`Instantiate service client with error`, func() { @@ -198,47 +200,47 @@ var _ = Describe(`LogpushJobsApiV1`, func() { fmt.Fprintf(GinkgoWriter, "Expected error: %s\n", err.Error()) }) }) - Describe(`GetLogpushJobs(getLogpushJobsOptions *GetLogpushJobsOptions) - Operation response error`, func() { + Describe(`GetLogpushJobsV2(getLogpushJobsV2Options *GetLogpushJobsV2Options) - Operation response error`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" - getLogpushJobsPath := "/v1/testString/zones/testString/logpush/jobs" + getLogpushJobsV2Path := "/v2/testString/zones/testString/logpush/jobs" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getLogpushJobsPath)) + Expect(req.URL.EscapedPath()).To(Equal(getLogpushJobsV2Path)) Expect(req.Method).To(Equal("GET")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) + fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke GetLogpushJobs with error: Operation response processing error`, func() { + It(`Invoke GetLogpushJobsV2 with error: Operation response processing error`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the GetLogpushJobsOptions model - getLogpushJobsOptionsModel := new(logpushjobsapiv1.GetLogpushJobsOptions) - getLogpushJobsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetLogpushJobsV2Options model + getLogpushJobsV2OptionsModel := new(logpushjobsapiv1.GetLogpushJobsV2Options) + getLogpushJobsV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := logpushJobsApiService.GetLogpushJobs(getLogpushJobsOptionsModel) + result, response, operationErr := logpushJobsApiService.GetLogpushJobsV2(getLogpushJobsV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again logpushJobsApiService.EnableRetries(0, 0) - result, response, operationErr = logpushJobsApiService.GetLogpushJobs(getLogpushJobsOptionsModel) + result, response, operationErr = logpushJobsApiService.GetLogpushJobsV2(getLogpushJobsV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -248,18 +250,18 @@ var _ = Describe(`LogpushJobsApiV1`, func() { }) }) }) - Describe(`GetLogpushJobs(getLogpushJobsOptions *GetLogpushJobsOptions)`, func() { + Describe(`GetLogpushJobsV2(getLogpushJobsV2Options *GetLogpushJobsV2Options)`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" - getLogpushJobsPath := "/v1/testString/zones/testString/logpush/jobs" + getLogpushJobsV2Path := "/v2/testString/zones/testString/logpush/jobs" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getLogpushJobsPath)) + Expect(req.URL.EscapedPath()).To(Equal(getLogpushJobsV2Path)) Expect(req.Method).To(Equal("GET")) // Sleep a short time to support a timeout test @@ -271,32 +273,32 @@ var _ = Describe(`LogpushJobsApiV1`, func() { fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": [{"id": 5850, "name": "My log push job", "enabled": false, "dataset": "firewall_events", "frequency": "high", "logpull_options": "timestamps=rfc3339×tamps=rfc3339", "destination_conf": "cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea", "last_complete": "2022-01-15T16:33:31.834209Z", "last_error": "2022-01-15T16:33:31.834209Z", "error_message": "ErrorMessage"}]}`) })) }) - It(`Invoke GetLogpushJobs successfully with retries`, func() { + It(`Invoke GetLogpushJobsV2 successfully with retries`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) logpushJobsApiService.EnableRetries(0, 0) - // Construct an instance of the GetLogpushJobsOptions model - getLogpushJobsOptionsModel := new(logpushjobsapiv1.GetLogpushJobsOptions) - getLogpushJobsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetLogpushJobsV2Options model + getLogpushJobsV2OptionsModel := new(logpushjobsapiv1.GetLogpushJobsV2Options) + getLogpushJobsV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := logpushJobsApiService.GetLogpushJobsWithContext(ctx, getLogpushJobsOptionsModel) + _, _, operationErr := logpushJobsApiService.GetLogpushJobsV2WithContext(ctx, getLogpushJobsV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again logpushJobsApiService.DisableRetries() - result, response, operationErr := logpushJobsApiService.GetLogpushJobs(getLogpushJobsOptionsModel) + result, response, operationErr := logpushJobsApiService.GetLogpushJobsV2(getLogpushJobsV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -304,7 +306,7 @@ var _ = Describe(`LogpushJobsApiV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = logpushJobsApiService.GetLogpushJobsWithContext(ctx, getLogpushJobsOptionsModel) + _, _, operationErr = logpushJobsApiService.GetLogpushJobsV2WithContext(ctx, getLogpushJobsV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -318,7 +320,7 @@ var _ = Describe(`LogpushJobsApiV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getLogpushJobsPath)) + Expect(req.URL.EscapedPath()).To(Equal(getLogpushJobsV2Path)) Expect(req.Method).To(Equal("GET")) // Set mock response @@ -327,52 +329,52 @@ var _ = Describe(`LogpushJobsApiV1`, func() { fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": [{"id": 5850, "name": "My log push job", "enabled": false, "dataset": "firewall_events", "frequency": "high", "logpull_options": "timestamps=rfc3339×tamps=rfc3339", "destination_conf": "cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea", "last_complete": "2022-01-15T16:33:31.834209Z", "last_error": "2022-01-15T16:33:31.834209Z", "error_message": "ErrorMessage"}]}`) })) }) - It(`Invoke GetLogpushJobs successfully`, func() { + It(`Invoke GetLogpushJobsV2 successfully`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := logpushJobsApiService.GetLogpushJobs(nil) + result, response, operationErr := logpushJobsApiService.GetLogpushJobsV2(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetLogpushJobsOptions model - getLogpushJobsOptionsModel := new(logpushjobsapiv1.GetLogpushJobsOptions) - getLogpushJobsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetLogpushJobsV2Options model + getLogpushJobsV2OptionsModel := new(logpushjobsapiv1.GetLogpushJobsV2Options) + getLogpushJobsV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = logpushJobsApiService.GetLogpushJobs(getLogpushJobsOptionsModel) + result, response, operationErr = logpushJobsApiService.GetLogpushJobsV2(getLogpushJobsV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetLogpushJobs with error: Operation request error`, func() { + It(`Invoke GetLogpushJobsV2 with error: Operation request error`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the GetLogpushJobsOptions model - getLogpushJobsOptionsModel := new(logpushjobsapiv1.GetLogpushJobsOptions) - getLogpushJobsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetLogpushJobsV2Options model + getLogpushJobsV2OptionsModel := new(logpushjobsapiv1.GetLogpushJobsV2Options) + getLogpushJobsV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := logpushJobsApiService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := logpushJobsApiService.GetLogpushJobs(getLogpushJobsOptionsModel) + result, response, operationErr := logpushJobsApiService.GetLogpushJobsV2(getLogpushJobsV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) @@ -391,23 +393,23 @@ var _ = Describe(`LogpushJobsApiV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke GetLogpushJobs successfully`, func() { + It(`Invoke GetLogpushJobsV2 successfully`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the GetLogpushJobsOptions model - getLogpushJobsOptionsModel := new(logpushjobsapiv1.GetLogpushJobsOptions) - getLogpushJobsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetLogpushJobsV2Options model + getLogpushJobsV2OptionsModel := new(logpushjobsapiv1.GetLogpushJobsV2Options) + getLogpushJobsV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := logpushJobsApiService.GetLogpushJobs(getLogpushJobsOptionsModel) + result, response, operationErr := logpushJobsApiService.GetLogpushJobsV2(getLogpushJobsV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -419,54 +421,58 @@ var _ = Describe(`LogpushJobsApiV1`, func() { }) }) }) - Describe(`CreateLogpushJob(createLogpushJobOptions *CreateLogpushJobOptions) - Operation response error`, func() { + Describe(`CreateLogpushJobV2(createLogpushJobV2Options *CreateLogpushJobV2Options) - Operation response error`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" - createLogpushJobPath := "/v1/testString/zones/testString/logpush/jobs" + createLogpushJobV2Path := "/v2/testString/zones/testString/logpush/jobs" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createLogpushJobPath)) + Expect(req.URL.EscapedPath()).To(Equal(createLogpushJobV2Path)) Expect(req.Method).To(Equal("POST")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) + fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke CreateLogpushJob with error: Operation response processing error`, func() { + It(`Invoke CreateLogpushJobV2 with error: Operation response processing error`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the CreateLogpushJobOptions model - createLogpushJobOptionsModel := new(logpushjobsapiv1.CreateLogpushJobOptions) - createLogpushJobOptionsModel.Name = core.StringPtr("My log push job") - createLogpushJobOptionsModel.Enabled = core.BoolPtr(false) - createLogpushJobOptionsModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") - createLogpushJobOptionsModel.DestinationConf = core.StringPtr("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea") - createLogpushJobOptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") - createLogpushJobOptionsModel.Dataset = core.StringPtr("firewall_events") - createLogpushJobOptionsModel.Frequency = core.StringPtr("high") - createLogpushJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateLogpushJobV2RequestLogpushJobCosReq model + createLogpushJobV2RequestModel := new(logpushjobsapiv1.CreateLogpushJobV2RequestLogpushJobCosReq) + createLogpushJobV2RequestModel.Name = core.StringPtr("My log push job") + createLogpushJobV2RequestModel.Enabled = core.BoolPtr(false) + createLogpushJobV2RequestModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") + createLogpushJobV2RequestModel.Cos = map[string]interface{}{"anyKey": "anyValue"} + createLogpushJobV2RequestModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") + createLogpushJobV2RequestModel.Dataset = core.StringPtr("http_requests") + createLogpushJobV2RequestModel.Frequency = core.StringPtr("high") + + // Construct an instance of the CreateLogpushJobV2Options model + createLogpushJobV2OptionsModel := new(logpushjobsapiv1.CreateLogpushJobV2Options) + createLogpushJobV2OptionsModel.CreateLogpushJobV2Request = createLogpushJobV2RequestModel + createLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := logpushJobsApiService.CreateLogpushJob(createLogpushJobOptionsModel) + result, response, operationErr := logpushJobsApiService.CreateLogpushJobV2(createLogpushJobV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again logpushJobsApiService.EnableRetries(0, 0) - result, response, operationErr = logpushJobsApiService.CreateLogpushJob(createLogpushJobOptionsModel) + result, response, operationErr = logpushJobsApiService.CreateLogpushJobV2(createLogpushJobV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -476,18 +482,18 @@ var _ = Describe(`LogpushJobsApiV1`, func() { }) }) }) - Describe(`CreateLogpushJob(createLogpushJobOptions *CreateLogpushJobOptions)`, func() { + Describe(`CreateLogpushJobV2(createLogpushJobV2Options *CreateLogpushJobV2Options)`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" - createLogpushJobPath := "/v1/testString/zones/testString/logpush/jobs" + createLogpushJobV2Path := "/v2/testString/zones/testString/logpush/jobs" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createLogpushJobPath)) + Expect(req.URL.EscapedPath()).To(Equal(createLogpushJobV2Path)) Expect(req.Method).To(Equal("POST")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -515,39 +521,43 @@ var _ = Describe(`LogpushJobsApiV1`, func() { fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"id": 5850, "name": "My log push job", "enabled": false, "dataset": "firewall_events", "frequency": "high", "logpull_options": "timestamps=rfc3339×tamps=rfc3339", "destination_conf": "cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea", "last_complete": "2022-01-15T16:33:31.834209Z", "last_error": "2022-01-15T16:33:31.834209Z", "error_message": "ErrorMessage"}}`) })) }) - It(`Invoke CreateLogpushJob successfully with retries`, func() { + It(`Invoke CreateLogpushJobV2 successfully with retries`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) logpushJobsApiService.EnableRetries(0, 0) - // Construct an instance of the CreateLogpushJobOptions model - createLogpushJobOptionsModel := new(logpushjobsapiv1.CreateLogpushJobOptions) - createLogpushJobOptionsModel.Name = core.StringPtr("My log push job") - createLogpushJobOptionsModel.Enabled = core.BoolPtr(false) - createLogpushJobOptionsModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") - createLogpushJobOptionsModel.DestinationConf = core.StringPtr("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea") - createLogpushJobOptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") - createLogpushJobOptionsModel.Dataset = core.StringPtr("firewall_events") - createLogpushJobOptionsModel.Frequency = core.StringPtr("high") - createLogpushJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateLogpushJobV2RequestLogpushJobCosReq model + createLogpushJobV2RequestModel := new(logpushjobsapiv1.CreateLogpushJobV2RequestLogpushJobCosReq) + createLogpushJobV2RequestModel.Name = core.StringPtr("My log push job") + createLogpushJobV2RequestModel.Enabled = core.BoolPtr(false) + createLogpushJobV2RequestModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") + createLogpushJobV2RequestModel.Cos = map[string]interface{}{"anyKey": "anyValue"} + createLogpushJobV2RequestModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") + createLogpushJobV2RequestModel.Dataset = core.StringPtr("http_requests") + createLogpushJobV2RequestModel.Frequency = core.StringPtr("high") + + // Construct an instance of the CreateLogpushJobV2Options model + createLogpushJobV2OptionsModel := new(logpushjobsapiv1.CreateLogpushJobV2Options) + createLogpushJobV2OptionsModel.CreateLogpushJobV2Request = createLogpushJobV2RequestModel + createLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := logpushJobsApiService.CreateLogpushJobWithContext(ctx, createLogpushJobOptionsModel) + _, _, operationErr := logpushJobsApiService.CreateLogpushJobV2WithContext(ctx, createLogpushJobV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again logpushJobsApiService.DisableRetries() - result, response, operationErr := logpushJobsApiService.CreateLogpushJob(createLogpushJobOptionsModel) + result, response, operationErr := logpushJobsApiService.CreateLogpushJobV2(createLogpushJobV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -555,7 +565,7 @@ var _ = Describe(`LogpushJobsApiV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = logpushJobsApiService.CreateLogpushJobWithContext(ctx, createLogpushJobOptionsModel) + _, _, operationErr = logpushJobsApiService.CreateLogpushJobV2WithContext(ctx, createLogpushJobV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -569,7 +579,7 @@ var _ = Describe(`LogpushJobsApiV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createLogpushJobPath)) + Expect(req.URL.EscapedPath()).To(Equal(createLogpushJobV2Path)) Expect(req.Method).To(Equal("POST")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -594,66 +604,74 @@ var _ = Describe(`LogpushJobsApiV1`, func() { fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"id": 5850, "name": "My log push job", "enabled": false, "dataset": "firewall_events", "frequency": "high", "logpull_options": "timestamps=rfc3339×tamps=rfc3339", "destination_conf": "cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea", "last_complete": "2022-01-15T16:33:31.834209Z", "last_error": "2022-01-15T16:33:31.834209Z", "error_message": "ErrorMessage"}}`) })) }) - It(`Invoke CreateLogpushJob successfully`, func() { + It(`Invoke CreateLogpushJobV2 successfully`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := logpushJobsApiService.CreateLogpushJob(nil) + result, response, operationErr := logpushJobsApiService.CreateLogpushJobV2(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the CreateLogpushJobOptions model - createLogpushJobOptionsModel := new(logpushjobsapiv1.CreateLogpushJobOptions) - createLogpushJobOptionsModel.Name = core.StringPtr("My log push job") - createLogpushJobOptionsModel.Enabled = core.BoolPtr(false) - createLogpushJobOptionsModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") - createLogpushJobOptionsModel.DestinationConf = core.StringPtr("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea") - createLogpushJobOptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") - createLogpushJobOptionsModel.Dataset = core.StringPtr("firewall_events") - createLogpushJobOptionsModel.Frequency = core.StringPtr("high") - createLogpushJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateLogpushJobV2RequestLogpushJobCosReq model + createLogpushJobV2RequestModel := new(logpushjobsapiv1.CreateLogpushJobV2RequestLogpushJobCosReq) + createLogpushJobV2RequestModel.Name = core.StringPtr("My log push job") + createLogpushJobV2RequestModel.Enabled = core.BoolPtr(false) + createLogpushJobV2RequestModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") + createLogpushJobV2RequestModel.Cos = map[string]interface{}{"anyKey": "anyValue"} + createLogpushJobV2RequestModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") + createLogpushJobV2RequestModel.Dataset = core.StringPtr("http_requests") + createLogpushJobV2RequestModel.Frequency = core.StringPtr("high") + + // Construct an instance of the CreateLogpushJobV2Options model + createLogpushJobV2OptionsModel := new(logpushjobsapiv1.CreateLogpushJobV2Options) + createLogpushJobV2OptionsModel.CreateLogpushJobV2Request = createLogpushJobV2RequestModel + createLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = logpushJobsApiService.CreateLogpushJob(createLogpushJobOptionsModel) + result, response, operationErr = logpushJobsApiService.CreateLogpushJobV2(createLogpushJobV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke CreateLogpushJob with error: Operation request error`, func() { + It(`Invoke CreateLogpushJobV2 with error: Operation request error`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the CreateLogpushJobOptions model - createLogpushJobOptionsModel := new(logpushjobsapiv1.CreateLogpushJobOptions) - createLogpushJobOptionsModel.Name = core.StringPtr("My log push job") - createLogpushJobOptionsModel.Enabled = core.BoolPtr(false) - createLogpushJobOptionsModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") - createLogpushJobOptionsModel.DestinationConf = core.StringPtr("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea") - createLogpushJobOptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") - createLogpushJobOptionsModel.Dataset = core.StringPtr("firewall_events") - createLogpushJobOptionsModel.Frequency = core.StringPtr("high") - createLogpushJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateLogpushJobV2RequestLogpushJobCosReq model + createLogpushJobV2RequestModel := new(logpushjobsapiv1.CreateLogpushJobV2RequestLogpushJobCosReq) + createLogpushJobV2RequestModel.Name = core.StringPtr("My log push job") + createLogpushJobV2RequestModel.Enabled = core.BoolPtr(false) + createLogpushJobV2RequestModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") + createLogpushJobV2RequestModel.Cos = map[string]interface{}{"anyKey": "anyValue"} + createLogpushJobV2RequestModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") + createLogpushJobV2RequestModel.Dataset = core.StringPtr("http_requests") + createLogpushJobV2RequestModel.Frequency = core.StringPtr("high") + + // Construct an instance of the CreateLogpushJobV2Options model + createLogpushJobV2OptionsModel := new(logpushjobsapiv1.CreateLogpushJobV2Options) + createLogpushJobV2OptionsModel.CreateLogpushJobV2Request = createLogpushJobV2RequestModel + createLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := logpushJobsApiService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := logpushJobsApiService.CreateLogpushJob(createLogpushJobOptionsModel) + result, response, operationErr := logpushJobsApiService.CreateLogpushJobV2(createLogpushJobV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) @@ -672,30 +690,34 @@ var _ = Describe(`LogpushJobsApiV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke CreateLogpushJob successfully`, func() { + It(`Invoke CreateLogpushJobV2 successfully`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the CreateLogpushJobOptions model - createLogpushJobOptionsModel := new(logpushjobsapiv1.CreateLogpushJobOptions) - createLogpushJobOptionsModel.Name = core.StringPtr("My log push job") - createLogpushJobOptionsModel.Enabled = core.BoolPtr(false) - createLogpushJobOptionsModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") - createLogpushJobOptionsModel.DestinationConf = core.StringPtr("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea") - createLogpushJobOptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") - createLogpushJobOptionsModel.Dataset = core.StringPtr("firewall_events") - createLogpushJobOptionsModel.Frequency = core.StringPtr("high") - createLogpushJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateLogpushJobV2RequestLogpushJobCosReq model + createLogpushJobV2RequestModel := new(logpushjobsapiv1.CreateLogpushJobV2RequestLogpushJobCosReq) + createLogpushJobV2RequestModel.Name = core.StringPtr("My log push job") + createLogpushJobV2RequestModel.Enabled = core.BoolPtr(false) + createLogpushJobV2RequestModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") + createLogpushJobV2RequestModel.Cos = map[string]interface{}{"anyKey": "anyValue"} + createLogpushJobV2RequestModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") + createLogpushJobV2RequestModel.Dataset = core.StringPtr("http_requests") + createLogpushJobV2RequestModel.Frequency = core.StringPtr("high") + + // Construct an instance of the CreateLogpushJobV2Options model + createLogpushJobV2OptionsModel := new(logpushjobsapiv1.CreateLogpushJobV2Options) + createLogpushJobV2OptionsModel.CreateLogpushJobV2Request = createLogpushJobV2RequestModel + createLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := logpushJobsApiService.CreateLogpushJob(createLogpushJobOptionsModel) + result, response, operationErr := logpushJobsApiService.CreateLogpushJobV2(createLogpushJobV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -707,48 +729,48 @@ var _ = Describe(`LogpushJobsApiV1`, func() { }) }) }) - Describe(`GetLogpushJob(getLogpushJobOptions *GetLogpushJobOptions) - Operation response error`, func() { + Describe(`GetLogpushJobV2(getLogpushJobV2Options *GetLogpushJobV2Options) - Operation response error`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" - getLogpushJobPath := "/v1/testString/zones/testString/logpush/jobs/38" + getLogpushJobV2Path := "/v2/testString/zones/testString/logpush/jobs/testString" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getLogpushJobPath)) + Expect(req.URL.EscapedPath()).To(Equal(getLogpushJobV2Path)) Expect(req.Method).To(Equal("GET")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) + fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke GetLogpushJob with error: Operation response processing error`, func() { + It(`Invoke GetLogpushJobV2 with error: Operation response processing error`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the GetLogpushJobOptions model - getLogpushJobOptionsModel := new(logpushjobsapiv1.GetLogpushJobOptions) - getLogpushJobOptionsModel.JobID = core.Int64Ptr(int64(38)) - getLogpushJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetLogpushJobV2Options model + getLogpushJobV2OptionsModel := new(logpushjobsapiv1.GetLogpushJobV2Options) + getLogpushJobV2OptionsModel.JobID = core.StringPtr("testString") + getLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := logpushJobsApiService.GetLogpushJob(getLogpushJobOptionsModel) + result, response, operationErr := logpushJobsApiService.GetLogpushJobV2(getLogpushJobV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again logpushJobsApiService.EnableRetries(0, 0) - result, response, operationErr = logpushJobsApiService.GetLogpushJob(getLogpushJobOptionsModel) + result, response, operationErr = logpushJobsApiService.GetLogpushJobV2(getLogpushJobV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -758,18 +780,18 @@ var _ = Describe(`LogpushJobsApiV1`, func() { }) }) }) - Describe(`GetLogpushJob(getLogpushJobOptions *GetLogpushJobOptions)`, func() { + Describe(`GetLogpushJobV2(getLogpushJobV2Options *GetLogpushJobV2Options)`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" - getLogpushJobPath := "/v1/testString/zones/testString/logpush/jobs/38" + getLogpushJobV2Path := "/v2/testString/zones/testString/logpush/jobs/testString" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getLogpushJobPath)) + Expect(req.URL.EscapedPath()).To(Equal(getLogpushJobV2Path)) Expect(req.Method).To(Equal("GET")) // Sleep a short time to support a timeout test @@ -781,33 +803,33 @@ var _ = Describe(`LogpushJobsApiV1`, func() { fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"id": 5850, "name": "My log push job", "enabled": false, "dataset": "firewall_events", "frequency": "high", "logpull_options": "timestamps=rfc3339×tamps=rfc3339", "destination_conf": "cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea", "last_complete": "2022-01-15T16:33:31.834209Z", "last_error": "2022-01-15T16:33:31.834209Z", "error_message": "ErrorMessage"}}`) })) }) - It(`Invoke GetLogpushJob successfully with retries`, func() { + It(`Invoke GetLogpushJobV2 successfully with retries`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) logpushJobsApiService.EnableRetries(0, 0) - // Construct an instance of the GetLogpushJobOptions model - getLogpushJobOptionsModel := new(logpushjobsapiv1.GetLogpushJobOptions) - getLogpushJobOptionsModel.JobID = core.Int64Ptr(int64(38)) - getLogpushJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetLogpushJobV2Options model + getLogpushJobV2OptionsModel := new(logpushjobsapiv1.GetLogpushJobV2Options) + getLogpushJobV2OptionsModel.JobID = core.StringPtr("testString") + getLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := logpushJobsApiService.GetLogpushJobWithContext(ctx, getLogpushJobOptionsModel) + _, _, operationErr := logpushJobsApiService.GetLogpushJobV2WithContext(ctx, getLogpushJobV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again logpushJobsApiService.DisableRetries() - result, response, operationErr := logpushJobsApiService.GetLogpushJob(getLogpushJobOptionsModel) + result, response, operationErr := logpushJobsApiService.GetLogpushJobV2(getLogpushJobV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -815,7 +837,7 @@ var _ = Describe(`LogpushJobsApiV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = logpushJobsApiService.GetLogpushJobWithContext(ctx, getLogpushJobOptionsModel) + _, _, operationErr = logpushJobsApiService.GetLogpushJobV2WithContext(ctx, getLogpushJobV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -829,7 +851,7 @@ var _ = Describe(`LogpushJobsApiV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getLogpushJobPath)) + Expect(req.URL.EscapedPath()).To(Equal(getLogpushJobV2Path)) Expect(req.Method).To(Equal("GET")) // Set mock response @@ -838,62 +860,62 @@ var _ = Describe(`LogpushJobsApiV1`, func() { fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"id": 5850, "name": "My log push job", "enabled": false, "dataset": "firewall_events", "frequency": "high", "logpull_options": "timestamps=rfc3339×tamps=rfc3339", "destination_conf": "cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea", "last_complete": "2022-01-15T16:33:31.834209Z", "last_error": "2022-01-15T16:33:31.834209Z", "error_message": "ErrorMessage"}}`) })) }) - It(`Invoke GetLogpushJob successfully`, func() { + It(`Invoke GetLogpushJobV2 successfully`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := logpushJobsApiService.GetLogpushJob(nil) + result, response, operationErr := logpushJobsApiService.GetLogpushJobV2(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetLogpushJobOptions model - getLogpushJobOptionsModel := new(logpushjobsapiv1.GetLogpushJobOptions) - getLogpushJobOptionsModel.JobID = core.Int64Ptr(int64(38)) - getLogpushJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetLogpushJobV2Options model + getLogpushJobV2OptionsModel := new(logpushjobsapiv1.GetLogpushJobV2Options) + getLogpushJobV2OptionsModel.JobID = core.StringPtr("testString") + getLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = logpushJobsApiService.GetLogpushJob(getLogpushJobOptionsModel) + result, response, operationErr = logpushJobsApiService.GetLogpushJobV2(getLogpushJobV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetLogpushJob with error: Operation validation and request error`, func() { + It(`Invoke GetLogpushJobV2 with error: Operation validation and request error`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the GetLogpushJobOptions model - getLogpushJobOptionsModel := new(logpushjobsapiv1.GetLogpushJobOptions) - getLogpushJobOptionsModel.JobID = core.Int64Ptr(int64(38)) - getLogpushJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetLogpushJobV2Options model + getLogpushJobV2OptionsModel := new(logpushjobsapiv1.GetLogpushJobV2Options) + getLogpushJobV2OptionsModel.JobID = core.StringPtr("testString") + getLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := logpushJobsApiService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := logpushJobsApiService.GetLogpushJob(getLogpushJobOptionsModel) + result, response, operationErr := logpushJobsApiService.GetLogpushJobV2(getLogpushJobV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the GetLogpushJobOptions model with no property values - getLogpushJobOptionsModelNew := new(logpushjobsapiv1.GetLogpushJobOptions) + // Construct a second instance of the GetLogpushJobV2Options model with no property values + getLogpushJobV2OptionsModelNew := new(logpushjobsapiv1.GetLogpushJobV2Options) // Invoke operation with invalid model (negative test) - result, response, operationErr = logpushJobsApiService.GetLogpushJob(getLogpushJobOptionsModelNew) + result, response, operationErr = logpushJobsApiService.GetLogpushJobV2(getLogpushJobV2OptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -911,24 +933,24 @@ var _ = Describe(`LogpushJobsApiV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke GetLogpushJob successfully`, func() { + It(`Invoke GetLogpushJobV2 successfully`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the GetLogpushJobOptions model - getLogpushJobOptionsModel := new(logpushjobsapiv1.GetLogpushJobOptions) - getLogpushJobOptionsModel.JobID = core.Int64Ptr(int64(38)) - getLogpushJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetLogpushJobV2Options model + getLogpushJobV2OptionsModel := new(logpushjobsapiv1.GetLogpushJobV2Options) + getLogpushJobV2OptionsModel.JobID = core.StringPtr("testString") + getLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := logpushJobsApiService.GetLogpushJob(getLogpushJobOptionsModel) + result, response, operationErr := logpushJobsApiService.GetLogpushJobV2(getLogpushJobV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -940,53 +962,57 @@ var _ = Describe(`LogpushJobsApiV1`, func() { }) }) }) - Describe(`UpdateLogpushJob(updateLogpushJobOptions *UpdateLogpushJobOptions) - Operation response error`, func() { + Describe(`UpdateLogpushJobV2(updateLogpushJobV2Options *UpdateLogpushJobV2Options) - Operation response error`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" - updateLogpushJobPath := "/v1/testString/zones/testString/logpush/jobs/38" + updateLogpushJobV2Path := "/v2/testString/zones/testString/logpush/jobs/testString" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateLogpushJobPath)) + Expect(req.URL.EscapedPath()).To(Equal(updateLogpushJobV2Path)) Expect(req.Method).To(Equal("PUT")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) + fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke UpdateLogpushJob with error: Operation response processing error`, func() { + It(`Invoke UpdateLogpushJobV2 with error: Operation response processing error`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the UpdateLogpushJobOptions model - updateLogpushJobOptionsModel := new(logpushjobsapiv1.UpdateLogpushJobOptions) - updateLogpushJobOptionsModel.JobID = core.Int64Ptr(int64(38)) - updateLogpushJobOptionsModel.Enabled = core.BoolPtr(false) - updateLogpushJobOptionsModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") - updateLogpushJobOptionsModel.DestinationConf = core.StringPtr("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea") - updateLogpushJobOptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") - updateLogpushJobOptionsModel.Frequency = core.StringPtr("high") - updateLogpushJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq model + updateLogpushJobV2RequestModel := new(logpushjobsapiv1.UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq) + updateLogpushJobV2RequestModel.Enabled = core.BoolPtr(false) + updateLogpushJobV2RequestModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") + updateLogpushJobV2RequestModel.Cos = map[string]interface{}{"anyKey": "anyValue"} + updateLogpushJobV2RequestModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") + updateLogpushJobV2RequestModel.Frequency = core.StringPtr("high") + + // Construct an instance of the UpdateLogpushJobV2Options model + updateLogpushJobV2OptionsModel := new(logpushjobsapiv1.UpdateLogpushJobV2Options) + updateLogpushJobV2OptionsModel.JobID = core.StringPtr("testString") + updateLogpushJobV2OptionsModel.UpdateLogpushJobV2Request = updateLogpushJobV2RequestModel + updateLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := logpushJobsApiService.UpdateLogpushJob(updateLogpushJobOptionsModel) + result, response, operationErr := logpushJobsApiService.UpdateLogpushJobV2(updateLogpushJobV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again logpushJobsApiService.EnableRetries(0, 0) - result, response, operationErr = logpushJobsApiService.UpdateLogpushJob(updateLogpushJobOptionsModel) + result, response, operationErr = logpushJobsApiService.UpdateLogpushJobV2(updateLogpushJobV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -996,18 +1022,18 @@ var _ = Describe(`LogpushJobsApiV1`, func() { }) }) }) - Describe(`UpdateLogpushJob(updateLogpushJobOptions *UpdateLogpushJobOptions)`, func() { + Describe(`UpdateLogpushJobV2(updateLogpushJobV2Options *UpdateLogpushJobV2Options)`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" - updateLogpushJobPath := "/v1/testString/zones/testString/logpush/jobs/38" + updateLogpushJobV2Path := "/v2/testString/zones/testString/logpush/jobs/testString" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateLogpushJobPath)) + Expect(req.URL.EscapedPath()).To(Equal(updateLogpushJobV2Path)) Expect(req.Method).To(Equal("PUT")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -1035,38 +1061,42 @@ var _ = Describe(`LogpushJobsApiV1`, func() { fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"id": 5850, "name": "My log push job", "enabled": false, "dataset": "firewall_events", "frequency": "high", "logpull_options": "timestamps=rfc3339×tamps=rfc3339", "destination_conf": "cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea", "last_complete": "2022-01-15T16:33:31.834209Z", "last_error": "2022-01-15T16:33:31.834209Z", "error_message": "ErrorMessage"}}`) })) }) - It(`Invoke UpdateLogpushJob successfully with retries`, func() { + It(`Invoke UpdateLogpushJobV2 successfully with retries`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) logpushJobsApiService.EnableRetries(0, 0) - // Construct an instance of the UpdateLogpushJobOptions model - updateLogpushJobOptionsModel := new(logpushjobsapiv1.UpdateLogpushJobOptions) - updateLogpushJobOptionsModel.JobID = core.Int64Ptr(int64(38)) - updateLogpushJobOptionsModel.Enabled = core.BoolPtr(false) - updateLogpushJobOptionsModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") - updateLogpushJobOptionsModel.DestinationConf = core.StringPtr("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea") - updateLogpushJobOptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") - updateLogpushJobOptionsModel.Frequency = core.StringPtr("high") - updateLogpushJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq model + updateLogpushJobV2RequestModel := new(logpushjobsapiv1.UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq) + updateLogpushJobV2RequestModel.Enabled = core.BoolPtr(false) + updateLogpushJobV2RequestModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") + updateLogpushJobV2RequestModel.Cos = map[string]interface{}{"anyKey": "anyValue"} + updateLogpushJobV2RequestModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") + updateLogpushJobV2RequestModel.Frequency = core.StringPtr("high") + + // Construct an instance of the UpdateLogpushJobV2Options model + updateLogpushJobV2OptionsModel := new(logpushjobsapiv1.UpdateLogpushJobV2Options) + updateLogpushJobV2OptionsModel.JobID = core.StringPtr("testString") + updateLogpushJobV2OptionsModel.UpdateLogpushJobV2Request = updateLogpushJobV2RequestModel + updateLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := logpushJobsApiService.UpdateLogpushJobWithContext(ctx, updateLogpushJobOptionsModel) + _, _, operationErr := logpushJobsApiService.UpdateLogpushJobV2WithContext(ctx, updateLogpushJobV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again logpushJobsApiService.DisableRetries() - result, response, operationErr := logpushJobsApiService.UpdateLogpushJob(updateLogpushJobOptionsModel) + result, response, operationErr := logpushJobsApiService.UpdateLogpushJobV2(updateLogpushJobV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -1074,7 +1104,7 @@ var _ = Describe(`LogpushJobsApiV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = logpushJobsApiService.UpdateLogpushJobWithContext(ctx, updateLogpushJobOptionsModel) + _, _, operationErr = logpushJobsApiService.UpdateLogpushJobV2WithContext(ctx, updateLogpushJobV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -1088,7 +1118,7 @@ var _ = Describe(`LogpushJobsApiV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateLogpushJobPath)) + Expect(req.URL.EscapedPath()).To(Equal(updateLogpushJobV2Path)) Expect(req.Method).To(Equal("PUT")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -1113,72 +1143,80 @@ var _ = Describe(`LogpushJobsApiV1`, func() { fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"id": 5850, "name": "My log push job", "enabled": false, "dataset": "firewall_events", "frequency": "high", "logpull_options": "timestamps=rfc3339×tamps=rfc3339", "destination_conf": "cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea", "last_complete": "2022-01-15T16:33:31.834209Z", "last_error": "2022-01-15T16:33:31.834209Z", "error_message": "ErrorMessage"}}`) })) }) - It(`Invoke UpdateLogpushJob successfully`, func() { + It(`Invoke UpdateLogpushJobV2 successfully`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := logpushJobsApiService.UpdateLogpushJob(nil) + result, response, operationErr := logpushJobsApiService.UpdateLogpushJobV2(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the UpdateLogpushJobOptions model - updateLogpushJobOptionsModel := new(logpushjobsapiv1.UpdateLogpushJobOptions) - updateLogpushJobOptionsModel.JobID = core.Int64Ptr(int64(38)) - updateLogpushJobOptionsModel.Enabled = core.BoolPtr(false) - updateLogpushJobOptionsModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") - updateLogpushJobOptionsModel.DestinationConf = core.StringPtr("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea") - updateLogpushJobOptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") - updateLogpushJobOptionsModel.Frequency = core.StringPtr("high") - updateLogpushJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with valid options model (positive test) - result, response, operationErr = logpushJobsApiService.UpdateLogpushJob(updateLogpushJobOptionsModel) + // Construct an instance of the UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq model + updateLogpushJobV2RequestModel := new(logpushjobsapiv1.UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq) + updateLogpushJobV2RequestModel.Enabled = core.BoolPtr(false) + updateLogpushJobV2RequestModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") + updateLogpushJobV2RequestModel.Cos = map[string]interface{}{"anyKey": "anyValue"} + updateLogpushJobV2RequestModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") + updateLogpushJobV2RequestModel.Frequency = core.StringPtr("high") + + // Construct an instance of the UpdateLogpushJobV2Options model + updateLogpushJobV2OptionsModel := new(logpushjobsapiv1.UpdateLogpushJobV2Options) + updateLogpushJobV2OptionsModel.JobID = core.StringPtr("testString") + updateLogpushJobV2OptionsModel.UpdateLogpushJobV2Request = updateLogpushJobV2RequestModel + updateLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = logpushJobsApiService.UpdateLogpushJobV2(updateLogpushJobV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke UpdateLogpushJob with error: Operation validation and request error`, func() { + It(`Invoke UpdateLogpushJobV2 with error: Operation validation and request error`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the UpdateLogpushJobOptions model - updateLogpushJobOptionsModel := new(logpushjobsapiv1.UpdateLogpushJobOptions) - updateLogpushJobOptionsModel.JobID = core.Int64Ptr(int64(38)) - updateLogpushJobOptionsModel.Enabled = core.BoolPtr(false) - updateLogpushJobOptionsModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") - updateLogpushJobOptionsModel.DestinationConf = core.StringPtr("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea") - updateLogpushJobOptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") - updateLogpushJobOptionsModel.Frequency = core.StringPtr("high") - updateLogpushJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq model + updateLogpushJobV2RequestModel := new(logpushjobsapiv1.UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq) + updateLogpushJobV2RequestModel.Enabled = core.BoolPtr(false) + updateLogpushJobV2RequestModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") + updateLogpushJobV2RequestModel.Cos = map[string]interface{}{"anyKey": "anyValue"} + updateLogpushJobV2RequestModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") + updateLogpushJobV2RequestModel.Frequency = core.StringPtr("high") + + // Construct an instance of the UpdateLogpushJobV2Options model + updateLogpushJobV2OptionsModel := new(logpushjobsapiv1.UpdateLogpushJobV2Options) + updateLogpushJobV2OptionsModel.JobID = core.StringPtr("testString") + updateLogpushJobV2OptionsModel.UpdateLogpushJobV2Request = updateLogpushJobV2RequestModel + updateLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := logpushJobsApiService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := logpushJobsApiService.UpdateLogpushJob(updateLogpushJobOptionsModel) + result, response, operationErr := logpushJobsApiService.UpdateLogpushJobV2(updateLogpushJobV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the UpdateLogpushJobOptions model with no property values - updateLogpushJobOptionsModelNew := new(logpushjobsapiv1.UpdateLogpushJobOptions) + // Construct a second instance of the UpdateLogpushJobV2Options model with no property values + updateLogpushJobV2OptionsModelNew := new(logpushjobsapiv1.UpdateLogpushJobV2Options) // Invoke operation with invalid model (negative test) - result, response, operationErr = logpushJobsApiService.UpdateLogpushJob(updateLogpushJobOptionsModelNew) + result, response, operationErr = logpushJobsApiService.UpdateLogpushJobV2(updateLogpushJobV2OptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -1196,29 +1234,33 @@ var _ = Describe(`LogpushJobsApiV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke UpdateLogpushJob successfully`, func() { + It(`Invoke UpdateLogpushJobV2 successfully`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the UpdateLogpushJobOptions model - updateLogpushJobOptionsModel := new(logpushjobsapiv1.UpdateLogpushJobOptions) - updateLogpushJobOptionsModel.JobID = core.Int64Ptr(int64(38)) - updateLogpushJobOptionsModel.Enabled = core.BoolPtr(false) - updateLogpushJobOptionsModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") - updateLogpushJobOptionsModel.DestinationConf = core.StringPtr("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea") - updateLogpushJobOptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") - updateLogpushJobOptionsModel.Frequency = core.StringPtr("high") - updateLogpushJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq model + updateLogpushJobV2RequestModel := new(logpushjobsapiv1.UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq) + updateLogpushJobV2RequestModel.Enabled = core.BoolPtr(false) + updateLogpushJobV2RequestModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") + updateLogpushJobV2RequestModel.Cos = map[string]interface{}{"anyKey": "anyValue"} + updateLogpushJobV2RequestModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") + updateLogpushJobV2RequestModel.Frequency = core.StringPtr("high") + + // Construct an instance of the UpdateLogpushJobV2Options model + updateLogpushJobV2OptionsModel := new(logpushjobsapiv1.UpdateLogpushJobV2Options) + updateLogpushJobV2OptionsModel.JobID = core.StringPtr("testString") + updateLogpushJobV2OptionsModel.UpdateLogpushJobV2Request = updateLogpushJobV2RequestModel + updateLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := logpushJobsApiService.UpdateLogpushJob(updateLogpushJobOptionsModel) + result, response, operationErr := logpushJobsApiService.UpdateLogpushJobV2(updateLogpushJobV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -1230,48 +1272,48 @@ var _ = Describe(`LogpushJobsApiV1`, func() { }) }) }) - Describe(`DeleteLogpushJob(deleteLogpushJobOptions *DeleteLogpushJobOptions) - Operation response error`, func() { + Describe(`DeleteLogpushJobV2(deleteLogpushJobV2Options *DeleteLogpushJobV2Options) - Operation response error`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" - deleteLogpushJobPath := "/v1/testString/zones/testString/logpush/jobs/38" + deleteLogpushJobV2Path := "/v2/testString/zones/testString/logpush/jobs/testString" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(deleteLogpushJobPath)) + Expect(req.URL.EscapedPath()).To(Equal(deleteLogpushJobV2Path)) Expect(req.Method).To(Equal("DELETE")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) + fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke DeleteLogpushJob with error: Operation response processing error`, func() { + It(`Invoke DeleteLogpushJobV2 with error: Operation response processing error`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the DeleteLogpushJobOptions model - deleteLogpushJobOptionsModel := new(logpushjobsapiv1.DeleteLogpushJobOptions) - deleteLogpushJobOptionsModel.JobID = core.Int64Ptr(int64(38)) - deleteLogpushJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteLogpushJobV2Options model + deleteLogpushJobV2OptionsModel := new(logpushjobsapiv1.DeleteLogpushJobV2Options) + deleteLogpushJobV2OptionsModel.JobID = core.StringPtr("testString") + deleteLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := logpushJobsApiService.DeleteLogpushJob(deleteLogpushJobOptionsModel) + result, response, operationErr := logpushJobsApiService.DeleteLogpushJobV2(deleteLogpushJobV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again logpushJobsApiService.EnableRetries(0, 0) - result, response, operationErr = logpushJobsApiService.DeleteLogpushJob(deleteLogpushJobOptionsModel) + result, response, operationErr = logpushJobsApiService.DeleteLogpushJobV2(deleteLogpushJobV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -1281,18 +1323,18 @@ var _ = Describe(`LogpushJobsApiV1`, func() { }) }) }) - Describe(`DeleteLogpushJob(deleteLogpushJobOptions *DeleteLogpushJobOptions)`, func() { + Describe(`DeleteLogpushJobV2(deleteLogpushJobV2Options *DeleteLogpushJobV2Options)`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" - deleteLogpushJobPath := "/v1/testString/zones/testString/logpush/jobs/38" + deleteLogpushJobV2Path := "/v2/testString/zones/testString/logpush/jobs/testString" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(deleteLogpushJobPath)) + Expect(req.URL.EscapedPath()).To(Equal(deleteLogpushJobV2Path)) Expect(req.Method).To(Equal("DELETE")) // Sleep a short time to support a timeout test @@ -1304,33 +1346,33 @@ var _ = Describe(`LogpushJobsApiV1`, func() { fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"anyKey": "anyValue"}}`) })) }) - It(`Invoke DeleteLogpushJob successfully with retries`, func() { + It(`Invoke DeleteLogpushJobV2 successfully with retries`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) logpushJobsApiService.EnableRetries(0, 0) - // Construct an instance of the DeleteLogpushJobOptions model - deleteLogpushJobOptionsModel := new(logpushjobsapiv1.DeleteLogpushJobOptions) - deleteLogpushJobOptionsModel.JobID = core.Int64Ptr(int64(38)) - deleteLogpushJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteLogpushJobV2Options model + deleteLogpushJobV2OptionsModel := new(logpushjobsapiv1.DeleteLogpushJobV2Options) + deleteLogpushJobV2OptionsModel.JobID = core.StringPtr("testString") + deleteLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := logpushJobsApiService.DeleteLogpushJobWithContext(ctx, deleteLogpushJobOptionsModel) + _, _, operationErr := logpushJobsApiService.DeleteLogpushJobV2WithContext(ctx, deleteLogpushJobV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again logpushJobsApiService.DisableRetries() - result, response, operationErr := logpushJobsApiService.DeleteLogpushJob(deleteLogpushJobOptionsModel) + result, response, operationErr := logpushJobsApiService.DeleteLogpushJobV2(deleteLogpushJobV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -1338,7 +1380,7 @@ var _ = Describe(`LogpushJobsApiV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = logpushJobsApiService.DeleteLogpushJobWithContext(ctx, deleteLogpushJobOptionsModel) + _, _, operationErr = logpushJobsApiService.DeleteLogpushJobV2WithContext(ctx, deleteLogpushJobV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -1352,7 +1394,7 @@ var _ = Describe(`LogpushJobsApiV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(deleteLogpushJobPath)) + Expect(req.URL.EscapedPath()).To(Equal(deleteLogpushJobV2Path)) Expect(req.Method).To(Equal("DELETE")) // Set mock response @@ -1361,62 +1403,62 @@ var _ = Describe(`LogpushJobsApiV1`, func() { fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"anyKey": "anyValue"}}`) })) }) - It(`Invoke DeleteLogpushJob successfully`, func() { + It(`Invoke DeleteLogpushJobV2 successfully`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := logpushJobsApiService.DeleteLogpushJob(nil) + result, response, operationErr := logpushJobsApiService.DeleteLogpushJobV2(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the DeleteLogpushJobOptions model - deleteLogpushJobOptionsModel := new(logpushjobsapiv1.DeleteLogpushJobOptions) - deleteLogpushJobOptionsModel.JobID = core.Int64Ptr(int64(38)) - deleteLogpushJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteLogpushJobV2Options model + deleteLogpushJobV2OptionsModel := new(logpushjobsapiv1.DeleteLogpushJobV2Options) + deleteLogpushJobV2OptionsModel.JobID = core.StringPtr("testString") + deleteLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = logpushJobsApiService.DeleteLogpushJob(deleteLogpushJobOptionsModel) + result, response, operationErr = logpushJobsApiService.DeleteLogpushJobV2(deleteLogpushJobV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke DeleteLogpushJob with error: Operation validation and request error`, func() { + It(`Invoke DeleteLogpushJobV2 with error: Operation validation and request error`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the DeleteLogpushJobOptions model - deleteLogpushJobOptionsModel := new(logpushjobsapiv1.DeleteLogpushJobOptions) - deleteLogpushJobOptionsModel.JobID = core.Int64Ptr(int64(38)) - deleteLogpushJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteLogpushJobV2Options model + deleteLogpushJobV2OptionsModel := new(logpushjobsapiv1.DeleteLogpushJobV2Options) + deleteLogpushJobV2OptionsModel.JobID = core.StringPtr("testString") + deleteLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := logpushJobsApiService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := logpushJobsApiService.DeleteLogpushJob(deleteLogpushJobOptionsModel) + result, response, operationErr := logpushJobsApiService.DeleteLogpushJobV2(deleteLogpushJobV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the DeleteLogpushJobOptions model with no property values - deleteLogpushJobOptionsModelNew := new(logpushjobsapiv1.DeleteLogpushJobOptions) + // Construct a second instance of the DeleteLogpushJobV2Options model with no property values + deleteLogpushJobV2OptionsModelNew := new(logpushjobsapiv1.DeleteLogpushJobV2Options) // Invoke operation with invalid model (negative test) - result, response, operationErr = logpushJobsApiService.DeleteLogpushJob(deleteLogpushJobOptionsModelNew) + result, response, operationErr = logpushJobsApiService.DeleteLogpushJobV2(deleteLogpushJobV2OptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -1434,24 +1476,24 @@ var _ = Describe(`LogpushJobsApiV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke DeleteLogpushJob successfully`, func() { + It(`Invoke DeleteLogpushJobV2 successfully`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the DeleteLogpushJobOptions model - deleteLogpushJobOptionsModel := new(logpushjobsapiv1.DeleteLogpushJobOptions) - deleteLogpushJobOptionsModel.JobID = core.Int64Ptr(int64(38)) - deleteLogpushJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteLogpushJobV2Options model + deleteLogpushJobV2OptionsModel := new(logpushjobsapiv1.DeleteLogpushJobV2Options) + deleteLogpushJobV2OptionsModel.JobID = core.StringPtr("testString") + deleteLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := logpushJobsApiService.DeleteLogpushJob(deleteLogpushJobOptionsModel) + result, response, operationErr := logpushJobsApiService.DeleteLogpushJobV2(deleteLogpushJobV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -1463,47 +1505,48 @@ var _ = Describe(`LogpushJobsApiV1`, func() { }) }) }) - Describe(`ListFieldsForDataset(listFieldsForDatasetOptions *ListFieldsForDatasetOptions) - Operation response error`, func() { + Describe(`GetLogpushOwnershipV2(getLogpushOwnershipV2Options *GetLogpushOwnershipV2Options) - Operation response error`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" - listFieldsForDatasetPath := "/v1/testString/zones/testString/logpush/datasets/http_requests/fields" + getLogpushOwnershipV2Path := "/v2/testString/zones/testString/logpush/ownership" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listFieldsForDatasetPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(getLogpushOwnershipV2Path)) + Expect(req.Method).To(Equal("POST")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) + fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListFieldsForDataset with error: Operation response processing error`, func() { + It(`Invoke GetLogpushOwnershipV2 with error: Operation response processing error`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the ListFieldsForDatasetOptions model - listFieldsForDatasetOptionsModel := new(logpushjobsapiv1.ListFieldsForDatasetOptions) - listFieldsForDatasetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetLogpushOwnershipV2Options model + getLogpushOwnershipV2OptionsModel := new(logpushjobsapiv1.GetLogpushOwnershipV2Options) + getLogpushOwnershipV2OptionsModel.Cos = map[string]interface{}{"anyKey": "anyValue"} + getLogpushOwnershipV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := logpushJobsApiService.ListFieldsForDataset(listFieldsForDatasetOptionsModel) + result, response, operationErr := logpushJobsApiService.GetLogpushOwnershipV2(getLogpushOwnershipV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again logpushJobsApiService.EnableRetries(0, 0) - result, response, operationErr = logpushJobsApiService.ListFieldsForDataset(listFieldsForDatasetOptionsModel) + result, response, operationErr = logpushJobsApiService.GetLogpushOwnershipV2(getLogpushOwnershipV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -1513,19 +1556,35 @@ var _ = Describe(`LogpushJobsApiV1`, func() { }) }) }) - Describe(`ListFieldsForDataset(listFieldsForDatasetOptions *ListFieldsForDatasetOptions)`, func() { + Describe(`GetLogpushOwnershipV2(getLogpushOwnershipV2Options *GetLogpushOwnershipV2Options)`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" - listFieldsForDatasetPath := "/v1/testString/zones/testString/logpush/datasets/http_requests/fields" + getLogpushOwnershipV2Path := "/v2/testString/zones/testString/logpush/ownership" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listFieldsForDatasetPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(getLogpushOwnershipV2Path)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) @@ -1533,35 +1592,36 @@ var _ = Describe(`LogpushJobsApiV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"anyKey": "anyValue"}}`) + fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"filename": "logs/challenge-filename.txt", "valid": true, "messages": "Messages"}}`) })) }) - It(`Invoke ListFieldsForDataset successfully with retries`, func() { + It(`Invoke GetLogpushOwnershipV2 successfully with retries`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) logpushJobsApiService.EnableRetries(0, 0) - // Construct an instance of the ListFieldsForDatasetOptions model - listFieldsForDatasetOptionsModel := new(logpushjobsapiv1.ListFieldsForDatasetOptions) - listFieldsForDatasetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetLogpushOwnershipV2Options model + getLogpushOwnershipV2OptionsModel := new(logpushjobsapiv1.GetLogpushOwnershipV2Options) + getLogpushOwnershipV2OptionsModel.Cos = map[string]interface{}{"anyKey": "anyValue"} + getLogpushOwnershipV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := logpushJobsApiService.ListFieldsForDatasetWithContext(ctx, listFieldsForDatasetOptionsModel) + _, _, operationErr := logpushJobsApiService.GetLogpushOwnershipV2WithContext(ctx, getLogpushOwnershipV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again logpushJobsApiService.DisableRetries() - result, response, operationErr := logpushJobsApiService.ListFieldsForDataset(listFieldsForDatasetOptionsModel) + result, response, operationErr := logpushJobsApiService.GetLogpushOwnershipV2(getLogpushOwnershipV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -1569,7 +1629,7 @@ var _ = Describe(`LogpushJobsApiV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = logpushJobsApiService.ListFieldsForDatasetWithContext(ctx, listFieldsForDatasetOptionsModel) + _, _, operationErr = logpushJobsApiService.GetLogpushOwnershipV2WithContext(ctx, getLogpushOwnershipV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -1583,61 +1643,79 @@ var _ = Describe(`LogpushJobsApiV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listFieldsForDatasetPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(getLogpushOwnershipV2Path)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"anyKey": "anyValue"}}`) + fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"filename": "logs/challenge-filename.txt", "valid": true, "messages": "Messages"}}`) })) }) - It(`Invoke ListFieldsForDataset successfully`, func() { + It(`Invoke GetLogpushOwnershipV2 successfully`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := logpushJobsApiService.ListFieldsForDataset(nil) + result, response, operationErr := logpushJobsApiService.GetLogpushOwnershipV2(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListFieldsForDatasetOptions model - listFieldsForDatasetOptionsModel := new(logpushjobsapiv1.ListFieldsForDatasetOptions) - listFieldsForDatasetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetLogpushOwnershipV2Options model + getLogpushOwnershipV2OptionsModel := new(logpushjobsapiv1.GetLogpushOwnershipV2Options) + getLogpushOwnershipV2OptionsModel.Cos = map[string]interface{}{"anyKey": "anyValue"} + getLogpushOwnershipV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = logpushJobsApiService.ListFieldsForDataset(listFieldsForDatasetOptionsModel) + result, response, operationErr = logpushJobsApiService.GetLogpushOwnershipV2(getLogpushOwnershipV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListFieldsForDataset with error: Operation request error`, func() { + It(`Invoke GetLogpushOwnershipV2 with error: Operation request error`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the ListFieldsForDatasetOptions model - listFieldsForDatasetOptionsModel := new(logpushjobsapiv1.ListFieldsForDatasetOptions) - listFieldsForDatasetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetLogpushOwnershipV2Options model + getLogpushOwnershipV2OptionsModel := new(logpushjobsapiv1.GetLogpushOwnershipV2Options) + getLogpushOwnershipV2OptionsModel.Cos = map[string]interface{}{"anyKey": "anyValue"} + getLogpushOwnershipV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := logpushJobsApiService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := logpushJobsApiService.ListFieldsForDataset(listFieldsForDatasetOptionsModel) + result, response, operationErr := logpushJobsApiService.GetLogpushOwnershipV2(getLogpushOwnershipV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) @@ -1656,23 +1734,24 @@ var _ = Describe(`LogpushJobsApiV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListFieldsForDataset successfully`, func() { + It(`Invoke GetLogpushOwnershipV2 successfully`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the ListFieldsForDatasetOptions model - listFieldsForDatasetOptionsModel := new(logpushjobsapiv1.ListFieldsForDatasetOptions) - listFieldsForDatasetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetLogpushOwnershipV2Options model + getLogpushOwnershipV2OptionsModel := new(logpushjobsapiv1.GetLogpushOwnershipV2Options) + getLogpushOwnershipV2OptionsModel.Cos = map[string]interface{}{"anyKey": "anyValue"} + getLogpushOwnershipV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := logpushJobsApiService.ListFieldsForDataset(listFieldsForDatasetOptionsModel) + result, response, operationErr := logpushJobsApiService.GetLogpushOwnershipV2(getLogpushOwnershipV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -1684,47 +1763,49 @@ var _ = Describe(`LogpushJobsApiV1`, func() { }) }) }) - Describe(`ListLogpushJobsForDataset(listLogpushJobsForDatasetOptions *ListLogpushJobsForDatasetOptions) - Operation response error`, func() { + Describe(`ValidateLogpushOwnershipChallengeV2(validateLogpushOwnershipChallengeV2Options *ValidateLogpushOwnershipChallengeV2Options) - Operation response error`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" - listLogpushJobsForDatasetPath := "/v1/testString/zones/testString/logpush/datasets/http_requests/jobs" + validateLogpushOwnershipChallengeV2Path := "/v2/testString/zones/testString/logpush/ownership/validate" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listLogpushJobsForDatasetPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(validateLogpushOwnershipChallengeV2Path)) + Expect(req.Method).To(Equal("POST")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) + fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListLogpushJobsForDataset with error: Operation response processing error`, func() { + It(`Invoke ValidateLogpushOwnershipChallengeV2 with error: Operation response processing error`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the ListLogpushJobsForDatasetOptions model - listLogpushJobsForDatasetOptionsModel := new(logpushjobsapiv1.ListLogpushJobsForDatasetOptions) - listLogpushJobsForDatasetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ValidateLogpushOwnershipChallengeV2Options model + validateLogpushOwnershipChallengeV2OptionsModel := new(logpushjobsapiv1.ValidateLogpushOwnershipChallengeV2Options) + validateLogpushOwnershipChallengeV2OptionsModel.Cos = map[string]interface{}{"anyKey": "anyValue"} + validateLogpushOwnershipChallengeV2OptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000") + validateLogpushOwnershipChallengeV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := logpushJobsApiService.ListLogpushJobsForDataset(listLogpushJobsForDatasetOptionsModel) + result, response, operationErr := logpushJobsApiService.ValidateLogpushOwnershipChallengeV2(validateLogpushOwnershipChallengeV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again logpushJobsApiService.EnableRetries(0, 0) - result, response, operationErr = logpushJobsApiService.ListLogpushJobsForDataset(listLogpushJobsForDatasetOptionsModel) + result, response, operationErr = logpushJobsApiService.ValidateLogpushOwnershipChallengeV2(validateLogpushOwnershipChallengeV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -1734,19 +1815,35 @@ var _ = Describe(`LogpushJobsApiV1`, func() { }) }) }) - Describe(`ListLogpushJobsForDataset(listLogpushJobsForDatasetOptions *ListLogpushJobsForDatasetOptions)`, func() { + Describe(`ValidateLogpushOwnershipChallengeV2(validateLogpushOwnershipChallengeV2Options *ValidateLogpushOwnershipChallengeV2Options)`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" - listLogpushJobsForDatasetPath := "/v1/testString/zones/testString/logpush/datasets/http_requests/jobs" + validateLogpushOwnershipChallengeV2Path := "/v2/testString/zones/testString/logpush/ownership/validate" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listLogpushJobsForDatasetPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(validateLogpushOwnershipChallengeV2Path)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) @@ -1754,35 +1851,37 @@ var _ = Describe(`LogpushJobsApiV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"id": 5850, "name": "My log push job", "enabled": false, "dataset": "firewall_events", "frequency": "high", "logpull_options": "timestamps=rfc3339×tamps=rfc3339", "destination_conf": "cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea", "last_complete": "2022-01-15T16:33:31.834209Z", "last_error": "2022-01-15T16:33:31.834209Z", "error_message": "ErrorMessage"}}`) + fmt.Fprintf(res, "%s", `{"valid": true}`) })) }) - It(`Invoke ListLogpushJobsForDataset successfully with retries`, func() { + It(`Invoke ValidateLogpushOwnershipChallengeV2 successfully with retries`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) logpushJobsApiService.EnableRetries(0, 0) - // Construct an instance of the ListLogpushJobsForDatasetOptions model - listLogpushJobsForDatasetOptionsModel := new(logpushjobsapiv1.ListLogpushJobsForDatasetOptions) - listLogpushJobsForDatasetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ValidateLogpushOwnershipChallengeV2Options model + validateLogpushOwnershipChallengeV2OptionsModel := new(logpushjobsapiv1.ValidateLogpushOwnershipChallengeV2Options) + validateLogpushOwnershipChallengeV2OptionsModel.Cos = map[string]interface{}{"anyKey": "anyValue"} + validateLogpushOwnershipChallengeV2OptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000") + validateLogpushOwnershipChallengeV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := logpushJobsApiService.ListLogpushJobsForDatasetWithContext(ctx, listLogpushJobsForDatasetOptionsModel) + _, _, operationErr := logpushJobsApiService.ValidateLogpushOwnershipChallengeV2WithContext(ctx, validateLogpushOwnershipChallengeV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again logpushJobsApiService.DisableRetries() - result, response, operationErr := logpushJobsApiService.ListLogpushJobsForDataset(listLogpushJobsForDatasetOptionsModel) + result, response, operationErr := logpushJobsApiService.ValidateLogpushOwnershipChallengeV2(validateLogpushOwnershipChallengeV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -1790,7 +1889,7 @@ var _ = Describe(`LogpushJobsApiV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = logpushJobsApiService.ListLogpushJobsForDatasetWithContext(ctx, listLogpushJobsForDatasetOptionsModel) + _, _, operationErr = logpushJobsApiService.ValidateLogpushOwnershipChallengeV2WithContext(ctx, validateLogpushOwnershipChallengeV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -1804,1890 +1903,85 @@ var _ = Describe(`LogpushJobsApiV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listLogpushJobsForDatasetPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(validateLogpushOwnershipChallengeV2Path)) + Expect(req.Method).To(Equal("POST")) - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"id": 5850, "name": "My log push job", "enabled": false, "dataset": "firewall_events", "frequency": "high", "logpull_options": "timestamps=rfc3339×tamps=rfc3339", "destination_conf": "cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea", "last_complete": "2022-01-15T16:33:31.834209Z", "last_error": "2022-01-15T16:33:31.834209Z", "error_message": "ErrorMessage"}}`) - })) - }) - It(`Invoke ListLogpushJobsForDataset successfully`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Invoke operation with nil options model (negative test) - result, response, operationErr := logpushJobsApiService.ListLogpushJobsForDataset(nil) - Expect(operationErr).NotTo(BeNil()) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) - - // Construct an instance of the ListLogpushJobsForDatasetOptions model - listLogpushJobsForDatasetOptionsModel := new(logpushjobsapiv1.ListLogpushJobsForDatasetOptions) - listLogpushJobsForDatasetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with valid options model (positive test) - result, response, operationErr = logpushJobsApiService.ListLogpushJobsForDataset(listLogpushJobsForDatasetOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).ToNot(BeNil()) - - }) - It(`Invoke ListLogpushJobsForDataset with error: Operation request error`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Construct an instance of the ListLogpushJobsForDatasetOptions model - listLogpushJobsForDatasetOptionsModel := new(logpushjobsapiv1.ListLogpushJobsForDatasetOptions) - listLogpushJobsForDatasetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Invoke operation with empty URL (negative test) - err := logpushJobsApiService.SetServiceURL("") - Expect(err).To(BeNil()) - result, response, operationErr := logpushJobsApiService.ListLogpushJobsForDataset(listLogpushJobsForDatasetOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - Context(`Using mock server endpoint with missing response body`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Set success status code with no respoonse body - res.WriteHeader(200) - })) - }) - It(`Invoke ListLogpushJobsForDataset successfully`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Construct an instance of the ListLogpushJobsForDatasetOptions model - listLogpushJobsForDatasetOptionsModel := new(logpushjobsapiv1.ListLogpushJobsForDatasetOptions) - listLogpushJobsForDatasetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation - result, response, operationErr := logpushJobsApiService.ListLogpushJobsForDataset(listLogpushJobsForDatasetOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - - // Verify a nil result - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`GetLogpushOwnership(getLogpushOwnershipOptions *GetLogpushOwnershipOptions) - Operation response error`, func() { - crn := "testString" - zoneID := "testString" - dataset := "http_requests" - getLogpushOwnershipPath := "/v1/testString/zones/testString/logpush/ownership" - Context(`Using mock server endpoint with invalid JSON response`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getLogpushOwnershipPath)) - Expect(req.Method).To(Equal("POST")) - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) - })) - }) - It(`Invoke GetLogpushOwnership with error: Operation response processing error`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Construct an instance of the GetLogpushOwnershipOptions model - getLogpushOwnershipOptionsModel := new(logpushjobsapiv1.GetLogpushOwnershipOptions) - getLogpushOwnershipOptionsModel.DestinationConf = core.StringPtr("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea") - getLogpushOwnershipOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := logpushJobsApiService.GetLogpushOwnership(getLogpushOwnershipOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).To(BeNil()) - - // Enable retries and test again - logpushJobsApiService.EnableRetries(0, 0) - result, response, operationErr = logpushJobsApiService.GetLogpushOwnership(getLogpushOwnershipOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`GetLogpushOwnership(getLogpushOwnershipOptions *GetLogpushOwnershipOptions)`, func() { - crn := "testString" - zoneID := "testString" - dataset := "http_requests" - getLogpushOwnershipPath := "/v1/testString/zones/testString/logpush/ownership" - Context(`Using mock server endpoint with timeout`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getLogpushOwnershipPath)) - Expect(req.Method).To(Equal("POST")) - - // For gzip-disabled operation, verify Content-Encoding is not set. - Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) - - // If there is a body, then make sure we can read it - bodyBuf := new(bytes.Buffer) - if req.Header.Get("Content-Encoding") == "gzip" { - body, err := core.NewGzipDecompressionReader(req.Body) - Expect(err).To(BeNil()) - _, err = bodyBuf.ReadFrom(body) - Expect(err).To(BeNil()) - } else { - _, err := bodyBuf.ReadFrom(req.Body) - Expect(err).To(BeNil()) - } - fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) - - // Sleep a short time to support a timeout test - time.Sleep(100 * time.Millisecond) - - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"filename": "logs/challenge-filename.txt", "valid": true, "messages": "Messages"}}`) - })) - }) - It(`Invoke GetLogpushOwnership successfully with retries`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - logpushJobsApiService.EnableRetries(0, 0) - - // Construct an instance of the GetLogpushOwnershipOptions model - getLogpushOwnershipOptionsModel := new(logpushjobsapiv1.GetLogpushOwnershipOptions) - getLogpushOwnershipOptionsModel.DestinationConf = core.StringPtr("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea") - getLogpushOwnershipOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with a Context to test a timeout error - ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) - defer cancelFunc() - _, _, operationErr := logpushJobsApiService.GetLogpushOwnershipWithContext(ctx, getLogpushOwnershipOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) - - // Disable retries and test again - logpushJobsApiService.DisableRetries() - result, response, operationErr := logpushJobsApiService.GetLogpushOwnership(getLogpushOwnershipOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).ToNot(BeNil()) - - // Re-test the timeout error with retries disabled - ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) - defer cancelFunc2() - _, _, operationErr = logpushJobsApiService.GetLogpushOwnershipWithContext(ctx, getLogpushOwnershipOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) - }) - AfterEach(func() { - testServer.Close() - }) - }) - Context(`Using mock server endpoint`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getLogpushOwnershipPath)) - Expect(req.Method).To(Equal("POST")) - - // For gzip-disabled operation, verify Content-Encoding is not set. - Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) - - // If there is a body, then make sure we can read it - bodyBuf := new(bytes.Buffer) - if req.Header.Get("Content-Encoding") == "gzip" { - body, err := core.NewGzipDecompressionReader(req.Body) - Expect(err).To(BeNil()) - _, err = bodyBuf.ReadFrom(body) - Expect(err).To(BeNil()) - } else { - _, err := bodyBuf.ReadFrom(req.Body) - Expect(err).To(BeNil()) - } - fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) - - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"filename": "logs/challenge-filename.txt", "valid": true, "messages": "Messages"}}`) - })) - }) - It(`Invoke GetLogpushOwnership successfully`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Invoke operation with nil options model (negative test) - result, response, operationErr := logpushJobsApiService.GetLogpushOwnership(nil) - Expect(operationErr).NotTo(BeNil()) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) - - // Construct an instance of the GetLogpushOwnershipOptions model - getLogpushOwnershipOptionsModel := new(logpushjobsapiv1.GetLogpushOwnershipOptions) - getLogpushOwnershipOptionsModel.DestinationConf = core.StringPtr("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea") - getLogpushOwnershipOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with valid options model (positive test) - result, response, operationErr = logpushJobsApiService.GetLogpushOwnership(getLogpushOwnershipOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).ToNot(BeNil()) - - }) - It(`Invoke GetLogpushOwnership with error: Operation request error`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Construct an instance of the GetLogpushOwnershipOptions model - getLogpushOwnershipOptionsModel := new(logpushjobsapiv1.GetLogpushOwnershipOptions) - getLogpushOwnershipOptionsModel.DestinationConf = core.StringPtr("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea") - getLogpushOwnershipOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Invoke operation with empty URL (negative test) - err := logpushJobsApiService.SetServiceURL("") - Expect(err).To(BeNil()) - result, response, operationErr := logpushJobsApiService.GetLogpushOwnership(getLogpushOwnershipOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - Context(`Using mock server endpoint with missing response body`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Set success status code with no respoonse body - res.WriteHeader(200) - })) - }) - It(`Invoke GetLogpushOwnership successfully`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Construct an instance of the GetLogpushOwnershipOptions model - getLogpushOwnershipOptionsModel := new(logpushjobsapiv1.GetLogpushOwnershipOptions) - getLogpushOwnershipOptionsModel.DestinationConf = core.StringPtr("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea") - getLogpushOwnershipOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation - result, response, operationErr := logpushJobsApiService.GetLogpushOwnership(getLogpushOwnershipOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - - // Verify a nil result - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`ValidateLogpushOwnershipChallenge(validateLogpushOwnershipChallengeOptions *ValidateLogpushOwnershipChallengeOptions) - Operation response error`, func() { - crn := "testString" - zoneID := "testString" - dataset := "http_requests" - validateLogpushOwnershipChallengePath := "/v1/testString/zones/testString/logpush/ownership/validate" - Context(`Using mock server endpoint with invalid JSON response`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(validateLogpushOwnershipChallengePath)) - Expect(req.Method).To(Equal("POST")) - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) - })) - }) - It(`Invoke ValidateLogpushOwnershipChallenge with error: Operation response processing error`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Construct an instance of the ValidateLogpushOwnershipChallengeOptions model - validateLogpushOwnershipChallengeOptionsModel := new(logpushjobsapiv1.ValidateLogpushOwnershipChallengeOptions) - validateLogpushOwnershipChallengeOptionsModel.DestinationConf = core.StringPtr("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea") - validateLogpushOwnershipChallengeOptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000") - validateLogpushOwnershipChallengeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := logpushJobsApiService.ValidateLogpushOwnershipChallenge(validateLogpushOwnershipChallengeOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).To(BeNil()) - - // Enable retries and test again - logpushJobsApiService.EnableRetries(0, 0) - result, response, operationErr = logpushJobsApiService.ValidateLogpushOwnershipChallenge(validateLogpushOwnershipChallengeOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`ValidateLogpushOwnershipChallenge(validateLogpushOwnershipChallengeOptions *ValidateLogpushOwnershipChallengeOptions)`, func() { - crn := "testString" - zoneID := "testString" - dataset := "http_requests" - validateLogpushOwnershipChallengePath := "/v1/testString/zones/testString/logpush/ownership/validate" - Context(`Using mock server endpoint with timeout`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(validateLogpushOwnershipChallengePath)) - Expect(req.Method).To(Equal("POST")) - - // For gzip-disabled operation, verify Content-Encoding is not set. - Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) - - // If there is a body, then make sure we can read it - bodyBuf := new(bytes.Buffer) - if req.Header.Get("Content-Encoding") == "gzip" { - body, err := core.NewGzipDecompressionReader(req.Body) - Expect(err).To(BeNil()) - _, err = bodyBuf.ReadFrom(body) - Expect(err).To(BeNil()) - } else { - _, err := bodyBuf.ReadFrom(req.Body) - Expect(err).To(BeNil()) - } - fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) - - // Sleep a short time to support a timeout test - time.Sleep(100 * time.Millisecond) - - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"valid": true}`) - })) - }) - It(`Invoke ValidateLogpushOwnershipChallenge successfully with retries`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - logpushJobsApiService.EnableRetries(0, 0) - - // Construct an instance of the ValidateLogpushOwnershipChallengeOptions model - validateLogpushOwnershipChallengeOptionsModel := new(logpushjobsapiv1.ValidateLogpushOwnershipChallengeOptions) - validateLogpushOwnershipChallengeOptionsModel.DestinationConf = core.StringPtr("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea") - validateLogpushOwnershipChallengeOptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000") - validateLogpushOwnershipChallengeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with a Context to test a timeout error - ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) - defer cancelFunc() - _, _, operationErr := logpushJobsApiService.ValidateLogpushOwnershipChallengeWithContext(ctx, validateLogpushOwnershipChallengeOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) - - // Disable retries and test again - logpushJobsApiService.DisableRetries() - result, response, operationErr := logpushJobsApiService.ValidateLogpushOwnershipChallenge(validateLogpushOwnershipChallengeOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).ToNot(BeNil()) - - // Re-test the timeout error with retries disabled - ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) - defer cancelFunc2() - _, _, operationErr = logpushJobsApiService.ValidateLogpushOwnershipChallengeWithContext(ctx, validateLogpushOwnershipChallengeOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) - }) - AfterEach(func() { - testServer.Close() - }) - }) - Context(`Using mock server endpoint`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(validateLogpushOwnershipChallengePath)) - Expect(req.Method).To(Equal("POST")) - - // For gzip-disabled operation, verify Content-Encoding is not set. - Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) - - // If there is a body, then make sure we can read it - bodyBuf := new(bytes.Buffer) - if req.Header.Get("Content-Encoding") == "gzip" { - body, err := core.NewGzipDecompressionReader(req.Body) - Expect(err).To(BeNil()) - _, err = bodyBuf.ReadFrom(body) - Expect(err).To(BeNil()) - } else { - _, err := bodyBuf.ReadFrom(req.Body) - Expect(err).To(BeNil()) - } - fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) - - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"valid": true}`) - })) - }) - It(`Invoke ValidateLogpushOwnershipChallenge successfully`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Invoke operation with nil options model (negative test) - result, response, operationErr := logpushJobsApiService.ValidateLogpushOwnershipChallenge(nil) - Expect(operationErr).NotTo(BeNil()) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) - - // Construct an instance of the ValidateLogpushOwnershipChallengeOptions model - validateLogpushOwnershipChallengeOptionsModel := new(logpushjobsapiv1.ValidateLogpushOwnershipChallengeOptions) - validateLogpushOwnershipChallengeOptionsModel.DestinationConf = core.StringPtr("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea") - validateLogpushOwnershipChallengeOptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000") - validateLogpushOwnershipChallengeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with valid options model (positive test) - result, response, operationErr = logpushJobsApiService.ValidateLogpushOwnershipChallenge(validateLogpushOwnershipChallengeOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).ToNot(BeNil()) - - }) - It(`Invoke ValidateLogpushOwnershipChallenge with error: Operation request error`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Construct an instance of the ValidateLogpushOwnershipChallengeOptions model - validateLogpushOwnershipChallengeOptionsModel := new(logpushjobsapiv1.ValidateLogpushOwnershipChallengeOptions) - validateLogpushOwnershipChallengeOptionsModel.DestinationConf = core.StringPtr("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea") - validateLogpushOwnershipChallengeOptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000") - validateLogpushOwnershipChallengeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Invoke operation with empty URL (negative test) - err := logpushJobsApiService.SetServiceURL("") - Expect(err).To(BeNil()) - result, response, operationErr := logpushJobsApiService.ValidateLogpushOwnershipChallenge(validateLogpushOwnershipChallengeOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - Context(`Using mock server endpoint with missing response body`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Set success status code with no respoonse body - res.WriteHeader(200) - })) - }) - It(`Invoke ValidateLogpushOwnershipChallenge successfully`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Construct an instance of the ValidateLogpushOwnershipChallengeOptions model - validateLogpushOwnershipChallengeOptionsModel := new(logpushjobsapiv1.ValidateLogpushOwnershipChallengeOptions) - validateLogpushOwnershipChallengeOptionsModel.DestinationConf = core.StringPtr("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea") - validateLogpushOwnershipChallengeOptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000") - validateLogpushOwnershipChallengeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation - result, response, operationErr := logpushJobsApiService.ValidateLogpushOwnershipChallenge(validateLogpushOwnershipChallengeOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - - // Verify a nil result - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`GetLogpushJobsV2(getLogpushJobsV2Options *GetLogpushJobsV2Options) - Operation response error`, func() { - crn := "testString" - zoneID := "testString" - dataset := "http_requests" - getLogpushJobsV2Path := "/v2/testString/zones/testString/logpush/jobs" - Context(`Using mock server endpoint with invalid JSON response`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getLogpushJobsV2Path)) - Expect(req.Method).To(Equal("GET")) - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) - })) - }) - It(`Invoke GetLogpushJobsV2 with error: Operation response processing error`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Construct an instance of the GetLogpushJobsV2Options model - getLogpushJobsV2OptionsModel := new(logpushjobsapiv1.GetLogpushJobsV2Options) - getLogpushJobsV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := logpushJobsApiService.GetLogpushJobsV2(getLogpushJobsV2OptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).To(BeNil()) - - // Enable retries and test again - logpushJobsApiService.EnableRetries(0, 0) - result, response, operationErr = logpushJobsApiService.GetLogpushJobsV2(getLogpushJobsV2OptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`GetLogpushJobsV2(getLogpushJobsV2Options *GetLogpushJobsV2Options)`, func() { - crn := "testString" - zoneID := "testString" - dataset := "http_requests" - getLogpushJobsV2Path := "/v2/testString/zones/testString/logpush/jobs" - Context(`Using mock server endpoint with timeout`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getLogpushJobsV2Path)) - Expect(req.Method).To(Equal("GET")) - - // Sleep a short time to support a timeout test - time.Sleep(100 * time.Millisecond) - - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": [{"id": 5850, "name": "My log push job", "enabled": false, "dataset": "firewall_events", "frequency": "high", "logpull_options": "timestamps=rfc3339×tamps=rfc3339", "destination_conf": "cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea", "last_complete": "2022-01-15T16:33:31.834209Z", "last_error": "2022-01-15T16:33:31.834209Z", "error_message": "ErrorMessage"}]}`) - })) - }) - It(`Invoke GetLogpushJobsV2 successfully with retries`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - logpushJobsApiService.EnableRetries(0, 0) - - // Construct an instance of the GetLogpushJobsV2Options model - getLogpushJobsV2OptionsModel := new(logpushjobsapiv1.GetLogpushJobsV2Options) - getLogpushJobsV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with a Context to test a timeout error - ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) - defer cancelFunc() - _, _, operationErr := logpushJobsApiService.GetLogpushJobsV2WithContext(ctx, getLogpushJobsV2OptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) - - // Disable retries and test again - logpushJobsApiService.DisableRetries() - result, response, operationErr := logpushJobsApiService.GetLogpushJobsV2(getLogpushJobsV2OptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).ToNot(BeNil()) - - // Re-test the timeout error with retries disabled - ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) - defer cancelFunc2() - _, _, operationErr = logpushJobsApiService.GetLogpushJobsV2WithContext(ctx, getLogpushJobsV2OptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) - }) - AfterEach(func() { - testServer.Close() - }) - }) - Context(`Using mock server endpoint`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getLogpushJobsV2Path)) - Expect(req.Method).To(Equal("GET")) - - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": [{"id": 5850, "name": "My log push job", "enabled": false, "dataset": "firewall_events", "frequency": "high", "logpull_options": "timestamps=rfc3339×tamps=rfc3339", "destination_conf": "cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea", "last_complete": "2022-01-15T16:33:31.834209Z", "last_error": "2022-01-15T16:33:31.834209Z", "error_message": "ErrorMessage"}]}`) - })) - }) - It(`Invoke GetLogpushJobsV2 successfully`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Invoke operation with nil options model (negative test) - result, response, operationErr := logpushJobsApiService.GetLogpushJobsV2(nil) - Expect(operationErr).NotTo(BeNil()) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) - - // Construct an instance of the GetLogpushJobsV2Options model - getLogpushJobsV2OptionsModel := new(logpushjobsapiv1.GetLogpushJobsV2Options) - getLogpushJobsV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with valid options model (positive test) - result, response, operationErr = logpushJobsApiService.GetLogpushJobsV2(getLogpushJobsV2OptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).ToNot(BeNil()) - - }) - It(`Invoke GetLogpushJobsV2 with error: Operation request error`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Construct an instance of the GetLogpushJobsV2Options model - getLogpushJobsV2OptionsModel := new(logpushjobsapiv1.GetLogpushJobsV2Options) - getLogpushJobsV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Invoke operation with empty URL (negative test) - err := logpushJobsApiService.SetServiceURL("") - Expect(err).To(BeNil()) - result, response, operationErr := logpushJobsApiService.GetLogpushJobsV2(getLogpushJobsV2OptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - Context(`Using mock server endpoint with missing response body`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Set success status code with no respoonse body - res.WriteHeader(200) - })) - }) - It(`Invoke GetLogpushJobsV2 successfully`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Construct an instance of the GetLogpushJobsV2Options model - getLogpushJobsV2OptionsModel := new(logpushjobsapiv1.GetLogpushJobsV2Options) - getLogpushJobsV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation - result, response, operationErr := logpushJobsApiService.GetLogpushJobsV2(getLogpushJobsV2OptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - - // Verify a nil result - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`CreateLogpushJobV2(createLogpushJobV2Options *CreateLogpushJobV2Options) - Operation response error`, func() { - crn := "testString" - zoneID := "testString" - dataset := "http_requests" - createLogpushJobV2Path := "/v2/testString/zones/testString/logpush/jobs" - Context(`Using mock server endpoint with invalid JSON response`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createLogpushJobV2Path)) - Expect(req.Method).To(Equal("POST")) - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) - })) - }) - It(`Invoke CreateLogpushJobV2 with error: Operation response processing error`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Construct an instance of the CreateLogpushJobV2RequestLogpushJobCosReq model - createLogpushJobV2RequestModel := new(logpushjobsapiv1.CreateLogpushJobV2RequestLogpushJobCosReq) - createLogpushJobV2RequestModel.Name = core.StringPtr("My log push job") - createLogpushJobV2RequestModel.Enabled = core.BoolPtr(false) - createLogpushJobV2RequestModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") - createLogpushJobV2RequestModel.Cos = map[string]interface{}{"anyKey": "anyValue"} - createLogpushJobV2RequestModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") - createLogpushJobV2RequestModel.Dataset = core.StringPtr("http_requests") - createLogpushJobV2RequestModel.Frequency = core.StringPtr("high") - - // Construct an instance of the CreateLogpushJobV2Options model - createLogpushJobV2OptionsModel := new(logpushjobsapiv1.CreateLogpushJobV2Options) - createLogpushJobV2OptionsModel.CreateLogpushJobV2Request = createLogpushJobV2RequestModel - createLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := logpushJobsApiService.CreateLogpushJobV2(createLogpushJobV2OptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).To(BeNil()) - - // Enable retries and test again - logpushJobsApiService.EnableRetries(0, 0) - result, response, operationErr = logpushJobsApiService.CreateLogpushJobV2(createLogpushJobV2OptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`CreateLogpushJobV2(createLogpushJobV2Options *CreateLogpushJobV2Options)`, func() { - crn := "testString" - zoneID := "testString" - dataset := "http_requests" - createLogpushJobV2Path := "/v2/testString/zones/testString/logpush/jobs" - Context(`Using mock server endpoint with timeout`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createLogpushJobV2Path)) - Expect(req.Method).To(Equal("POST")) - - // For gzip-disabled operation, verify Content-Encoding is not set. - Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) - - // If there is a body, then make sure we can read it - bodyBuf := new(bytes.Buffer) - if req.Header.Get("Content-Encoding") == "gzip" { - body, err := core.NewGzipDecompressionReader(req.Body) - Expect(err).To(BeNil()) - _, err = bodyBuf.ReadFrom(body) - Expect(err).To(BeNil()) - } else { - _, err := bodyBuf.ReadFrom(req.Body) - Expect(err).To(BeNil()) - } - fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) - - // Sleep a short time to support a timeout test - time.Sleep(100 * time.Millisecond) - - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"id": 5850, "name": "My log push job", "enabled": false, "dataset": "firewall_events", "frequency": "high", "logpull_options": "timestamps=rfc3339×tamps=rfc3339", "destination_conf": "cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea", "last_complete": "2022-01-15T16:33:31.834209Z", "last_error": "2022-01-15T16:33:31.834209Z", "error_message": "ErrorMessage"}}`) - })) - }) - It(`Invoke CreateLogpushJobV2 successfully with retries`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - logpushJobsApiService.EnableRetries(0, 0) - - // Construct an instance of the CreateLogpushJobV2RequestLogpushJobCosReq model - createLogpushJobV2RequestModel := new(logpushjobsapiv1.CreateLogpushJobV2RequestLogpushJobCosReq) - createLogpushJobV2RequestModel.Name = core.StringPtr("My log push job") - createLogpushJobV2RequestModel.Enabled = core.BoolPtr(false) - createLogpushJobV2RequestModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") - createLogpushJobV2RequestModel.Cos = map[string]interface{}{"anyKey": "anyValue"} - createLogpushJobV2RequestModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") - createLogpushJobV2RequestModel.Dataset = core.StringPtr("http_requests") - createLogpushJobV2RequestModel.Frequency = core.StringPtr("high") - - // Construct an instance of the CreateLogpushJobV2Options model - createLogpushJobV2OptionsModel := new(logpushjobsapiv1.CreateLogpushJobV2Options) - createLogpushJobV2OptionsModel.CreateLogpushJobV2Request = createLogpushJobV2RequestModel - createLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with a Context to test a timeout error - ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) - defer cancelFunc() - _, _, operationErr := logpushJobsApiService.CreateLogpushJobV2WithContext(ctx, createLogpushJobV2OptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) - - // Disable retries and test again - logpushJobsApiService.DisableRetries() - result, response, operationErr := logpushJobsApiService.CreateLogpushJobV2(createLogpushJobV2OptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).ToNot(BeNil()) - - // Re-test the timeout error with retries disabled - ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) - defer cancelFunc2() - _, _, operationErr = logpushJobsApiService.CreateLogpushJobV2WithContext(ctx, createLogpushJobV2OptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) - }) - AfterEach(func() { - testServer.Close() - }) - }) - Context(`Using mock server endpoint`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createLogpushJobV2Path)) - Expect(req.Method).To(Equal("POST")) - - // For gzip-disabled operation, verify Content-Encoding is not set. - Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) - - // If there is a body, then make sure we can read it - bodyBuf := new(bytes.Buffer) - if req.Header.Get("Content-Encoding") == "gzip" { - body, err := core.NewGzipDecompressionReader(req.Body) - Expect(err).To(BeNil()) - _, err = bodyBuf.ReadFrom(body) - Expect(err).To(BeNil()) - } else { - _, err := bodyBuf.ReadFrom(req.Body) - Expect(err).To(BeNil()) - } - fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) - - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"id": 5850, "name": "My log push job", "enabled": false, "dataset": "firewall_events", "frequency": "high", "logpull_options": "timestamps=rfc3339×tamps=rfc3339", "destination_conf": "cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea", "last_complete": "2022-01-15T16:33:31.834209Z", "last_error": "2022-01-15T16:33:31.834209Z", "error_message": "ErrorMessage"}}`) - })) - }) - It(`Invoke CreateLogpushJobV2 successfully`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Invoke operation with nil options model (negative test) - result, response, operationErr := logpushJobsApiService.CreateLogpushJobV2(nil) - Expect(operationErr).NotTo(BeNil()) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) - - // Construct an instance of the CreateLogpushJobV2RequestLogpushJobCosReq model - createLogpushJobV2RequestModel := new(logpushjobsapiv1.CreateLogpushJobV2RequestLogpushJobCosReq) - createLogpushJobV2RequestModel.Name = core.StringPtr("My log push job") - createLogpushJobV2RequestModel.Enabled = core.BoolPtr(false) - createLogpushJobV2RequestModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") - createLogpushJobV2RequestModel.Cos = map[string]interface{}{"anyKey": "anyValue"} - createLogpushJobV2RequestModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") - createLogpushJobV2RequestModel.Dataset = core.StringPtr("http_requests") - createLogpushJobV2RequestModel.Frequency = core.StringPtr("high") - - // Construct an instance of the CreateLogpushJobV2Options model - createLogpushJobV2OptionsModel := new(logpushjobsapiv1.CreateLogpushJobV2Options) - createLogpushJobV2OptionsModel.CreateLogpushJobV2Request = createLogpushJobV2RequestModel - createLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with valid options model (positive test) - result, response, operationErr = logpushJobsApiService.CreateLogpushJobV2(createLogpushJobV2OptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).ToNot(BeNil()) - - }) - It(`Invoke CreateLogpushJobV2 with error: Operation request error`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Construct an instance of the CreateLogpushJobV2RequestLogpushJobCosReq model - createLogpushJobV2RequestModel := new(logpushjobsapiv1.CreateLogpushJobV2RequestLogpushJobCosReq) - createLogpushJobV2RequestModel.Name = core.StringPtr("My log push job") - createLogpushJobV2RequestModel.Enabled = core.BoolPtr(false) - createLogpushJobV2RequestModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") - createLogpushJobV2RequestModel.Cos = map[string]interface{}{"anyKey": "anyValue"} - createLogpushJobV2RequestModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") - createLogpushJobV2RequestModel.Dataset = core.StringPtr("http_requests") - createLogpushJobV2RequestModel.Frequency = core.StringPtr("high") - - // Construct an instance of the CreateLogpushJobV2Options model - createLogpushJobV2OptionsModel := new(logpushjobsapiv1.CreateLogpushJobV2Options) - createLogpushJobV2OptionsModel.CreateLogpushJobV2Request = createLogpushJobV2RequestModel - createLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Invoke operation with empty URL (negative test) - err := logpushJobsApiService.SetServiceURL("") - Expect(err).To(BeNil()) - result, response, operationErr := logpushJobsApiService.CreateLogpushJobV2(createLogpushJobV2OptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - Context(`Using mock server endpoint with missing response body`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Set success status code with no respoonse body - res.WriteHeader(200) - })) - }) - It(`Invoke CreateLogpushJobV2 successfully`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Construct an instance of the CreateLogpushJobV2RequestLogpushJobCosReq model - createLogpushJobV2RequestModel := new(logpushjobsapiv1.CreateLogpushJobV2RequestLogpushJobCosReq) - createLogpushJobV2RequestModel.Name = core.StringPtr("My log push job") - createLogpushJobV2RequestModel.Enabled = core.BoolPtr(false) - createLogpushJobV2RequestModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") - createLogpushJobV2RequestModel.Cos = map[string]interface{}{"anyKey": "anyValue"} - createLogpushJobV2RequestModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") - createLogpushJobV2RequestModel.Dataset = core.StringPtr("http_requests") - createLogpushJobV2RequestModel.Frequency = core.StringPtr("high") - - // Construct an instance of the CreateLogpushJobV2Options model - createLogpushJobV2OptionsModel := new(logpushjobsapiv1.CreateLogpushJobV2Options) - createLogpushJobV2OptionsModel.CreateLogpushJobV2Request = createLogpushJobV2RequestModel - createLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation - result, response, operationErr := logpushJobsApiService.CreateLogpushJobV2(createLogpushJobV2OptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - - // Verify a nil result - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`GetLogpushJobV2(getLogpushJobV2Options *GetLogpushJobV2Options) - Operation response error`, func() { - crn := "testString" - zoneID := "testString" - dataset := "http_requests" - getLogpushJobV2Path := "/v2/testString/zones/testString/logpush/jobs/38" - Context(`Using mock server endpoint with invalid JSON response`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getLogpushJobV2Path)) - Expect(req.Method).To(Equal("GET")) - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) - })) - }) - It(`Invoke GetLogpushJobV2 with error: Operation response processing error`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Construct an instance of the GetLogpushJobV2Options model - getLogpushJobV2OptionsModel := new(logpushjobsapiv1.GetLogpushJobV2Options) - getLogpushJobV2OptionsModel.JobID = core.Int64Ptr(int64(38)) - getLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := logpushJobsApiService.GetLogpushJobV2(getLogpushJobV2OptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).To(BeNil()) - - // Enable retries and test again - logpushJobsApiService.EnableRetries(0, 0) - result, response, operationErr = logpushJobsApiService.GetLogpushJobV2(getLogpushJobV2OptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`GetLogpushJobV2(getLogpushJobV2Options *GetLogpushJobV2Options)`, func() { - crn := "testString" - zoneID := "testString" - dataset := "http_requests" - getLogpushJobV2Path := "/v2/testString/zones/testString/logpush/jobs/38" - Context(`Using mock server endpoint with timeout`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getLogpushJobV2Path)) - Expect(req.Method).To(Equal("GET")) - - // Sleep a short time to support a timeout test - time.Sleep(100 * time.Millisecond) - - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"id": 5850, "name": "My log push job", "enabled": false, "dataset": "firewall_events", "frequency": "high", "logpull_options": "timestamps=rfc3339×tamps=rfc3339", "destination_conf": "cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea", "last_complete": "2022-01-15T16:33:31.834209Z", "last_error": "2022-01-15T16:33:31.834209Z", "error_message": "ErrorMessage"}}`) - })) - }) - It(`Invoke GetLogpushJobV2 successfully with retries`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - logpushJobsApiService.EnableRetries(0, 0) - - // Construct an instance of the GetLogpushJobV2Options model - getLogpushJobV2OptionsModel := new(logpushjobsapiv1.GetLogpushJobV2Options) - getLogpushJobV2OptionsModel.JobID = core.Int64Ptr(int64(38)) - getLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with a Context to test a timeout error - ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) - defer cancelFunc() - _, _, operationErr := logpushJobsApiService.GetLogpushJobV2WithContext(ctx, getLogpushJobV2OptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) - - // Disable retries and test again - logpushJobsApiService.DisableRetries() - result, response, operationErr := logpushJobsApiService.GetLogpushJobV2(getLogpushJobV2OptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).ToNot(BeNil()) - - // Re-test the timeout error with retries disabled - ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) - defer cancelFunc2() - _, _, operationErr = logpushJobsApiService.GetLogpushJobV2WithContext(ctx, getLogpushJobV2OptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) - }) - AfterEach(func() { - testServer.Close() - }) - }) - Context(`Using mock server endpoint`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getLogpushJobV2Path)) - Expect(req.Method).To(Equal("GET")) - - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"id": 5850, "name": "My log push job", "enabled": false, "dataset": "firewall_events", "frequency": "high", "logpull_options": "timestamps=rfc3339×tamps=rfc3339", "destination_conf": "cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea", "last_complete": "2022-01-15T16:33:31.834209Z", "last_error": "2022-01-15T16:33:31.834209Z", "error_message": "ErrorMessage"}}`) - })) - }) - It(`Invoke GetLogpushJobV2 successfully`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Invoke operation with nil options model (negative test) - result, response, operationErr := logpushJobsApiService.GetLogpushJobV2(nil) - Expect(operationErr).NotTo(BeNil()) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) - - // Construct an instance of the GetLogpushJobV2Options model - getLogpushJobV2OptionsModel := new(logpushjobsapiv1.GetLogpushJobV2Options) - getLogpushJobV2OptionsModel.JobID = core.Int64Ptr(int64(38)) - getLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with valid options model (positive test) - result, response, operationErr = logpushJobsApiService.GetLogpushJobV2(getLogpushJobV2OptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).ToNot(BeNil()) - - }) - It(`Invoke GetLogpushJobV2 with error: Operation validation and request error`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Construct an instance of the GetLogpushJobV2Options model - getLogpushJobV2OptionsModel := new(logpushjobsapiv1.GetLogpushJobV2Options) - getLogpushJobV2OptionsModel.JobID = core.Int64Ptr(int64(38)) - getLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Invoke operation with empty URL (negative test) - err := logpushJobsApiService.SetServiceURL("") - Expect(err).To(BeNil()) - result, response, operationErr := logpushJobsApiService.GetLogpushJobV2(getLogpushJobV2OptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) - // Construct a second instance of the GetLogpushJobV2Options model with no property values - getLogpushJobV2OptionsModelNew := new(logpushjobsapiv1.GetLogpushJobV2Options) - // Invoke operation with invalid model (negative test) - result, response, operationErr = logpushJobsApiService.GetLogpushJobV2(getLogpushJobV2OptionsModelNew) - Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - Context(`Using mock server endpoint with missing response body`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Set success status code with no respoonse body - res.WriteHeader(200) - })) - }) - It(`Invoke GetLogpushJobV2 successfully`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Construct an instance of the GetLogpushJobV2Options model - getLogpushJobV2OptionsModel := new(logpushjobsapiv1.GetLogpushJobV2Options) - getLogpushJobV2OptionsModel.JobID = core.Int64Ptr(int64(38)) - getLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation - result, response, operationErr := logpushJobsApiService.GetLogpushJobV2(getLogpushJobV2OptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - - // Verify a nil result - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`UpdateLogpushJobV2(updateLogpushJobV2Options *UpdateLogpushJobV2Options) - Operation response error`, func() { - crn := "testString" - zoneID := "testString" - dataset := "http_requests" - updateLogpushJobV2Path := "/v2/testString/zones/testString/logpush/jobs/38" - Context(`Using mock server endpoint with invalid JSON response`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateLogpushJobV2Path)) - Expect(req.Method).To(Equal("PUT")) - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) - })) - }) - It(`Invoke UpdateLogpushJobV2 with error: Operation response processing error`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Construct an instance of the UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq model - updateLogpushJobV2RequestModel := new(logpushjobsapiv1.UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq) - updateLogpushJobV2RequestModel.Enabled = core.BoolPtr(false) - updateLogpushJobV2RequestModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") - updateLogpushJobV2RequestModel.Cos = map[string]interface{}{"anyKey": "anyValue"} - updateLogpushJobV2RequestModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") - updateLogpushJobV2RequestModel.Frequency = core.StringPtr("high") - - // Construct an instance of the UpdateLogpushJobV2Options model - updateLogpushJobV2OptionsModel := new(logpushjobsapiv1.UpdateLogpushJobV2Options) - updateLogpushJobV2OptionsModel.JobID = core.Int64Ptr(int64(38)) - updateLogpushJobV2OptionsModel.UpdateLogpushJobV2Request = updateLogpushJobV2RequestModel - updateLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := logpushJobsApiService.UpdateLogpushJobV2(updateLogpushJobV2OptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).To(BeNil()) - - // Enable retries and test again - logpushJobsApiService.EnableRetries(0, 0) - result, response, operationErr = logpushJobsApiService.UpdateLogpushJobV2(updateLogpushJobV2OptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`UpdateLogpushJobV2(updateLogpushJobV2Options *UpdateLogpushJobV2Options)`, func() { - crn := "testString" - zoneID := "testString" - dataset := "http_requests" - updateLogpushJobV2Path := "/v2/testString/zones/testString/logpush/jobs/38" - Context(`Using mock server endpoint with timeout`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateLogpushJobV2Path)) - Expect(req.Method).To(Equal("PUT")) - - // For gzip-disabled operation, verify Content-Encoding is not set. - Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) - - // If there is a body, then make sure we can read it - bodyBuf := new(bytes.Buffer) - if req.Header.Get("Content-Encoding") == "gzip" { - body, err := core.NewGzipDecompressionReader(req.Body) - Expect(err).To(BeNil()) - _, err = bodyBuf.ReadFrom(body) - Expect(err).To(BeNil()) - } else { - _, err := bodyBuf.ReadFrom(req.Body) - Expect(err).To(BeNil()) - } - fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) - - // Sleep a short time to support a timeout test - time.Sleep(100 * time.Millisecond) - - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"id": 5850, "name": "My log push job", "enabled": false, "dataset": "firewall_events", "frequency": "high", "logpull_options": "timestamps=rfc3339×tamps=rfc3339", "destination_conf": "cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea", "last_complete": "2022-01-15T16:33:31.834209Z", "last_error": "2022-01-15T16:33:31.834209Z", "error_message": "ErrorMessage"}}`) - })) - }) - It(`Invoke UpdateLogpushJobV2 successfully with retries`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - logpushJobsApiService.EnableRetries(0, 0) - - // Construct an instance of the UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq model - updateLogpushJobV2RequestModel := new(logpushjobsapiv1.UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq) - updateLogpushJobV2RequestModel.Enabled = core.BoolPtr(false) - updateLogpushJobV2RequestModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") - updateLogpushJobV2RequestModel.Cos = map[string]interface{}{"anyKey": "anyValue"} - updateLogpushJobV2RequestModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") - updateLogpushJobV2RequestModel.Frequency = core.StringPtr("high") - - // Construct an instance of the UpdateLogpushJobV2Options model - updateLogpushJobV2OptionsModel := new(logpushjobsapiv1.UpdateLogpushJobV2Options) - updateLogpushJobV2OptionsModel.JobID = core.Int64Ptr(int64(38)) - updateLogpushJobV2OptionsModel.UpdateLogpushJobV2Request = updateLogpushJobV2RequestModel - updateLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with a Context to test a timeout error - ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) - defer cancelFunc() - _, _, operationErr := logpushJobsApiService.UpdateLogpushJobV2WithContext(ctx, updateLogpushJobV2OptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) - - // Disable retries and test again - logpushJobsApiService.DisableRetries() - result, response, operationErr := logpushJobsApiService.UpdateLogpushJobV2(updateLogpushJobV2OptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).ToNot(BeNil()) - - // Re-test the timeout error with retries disabled - ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) - defer cancelFunc2() - _, _, operationErr = logpushJobsApiService.UpdateLogpushJobV2WithContext(ctx, updateLogpushJobV2OptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) - }) - AfterEach(func() { - testServer.Close() - }) - }) - Context(`Using mock server endpoint`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateLogpushJobV2Path)) - Expect(req.Method).To(Equal("PUT")) - - // For gzip-disabled operation, verify Content-Encoding is not set. - Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) - - // If there is a body, then make sure we can read it - bodyBuf := new(bytes.Buffer) - if req.Header.Get("Content-Encoding") == "gzip" { - body, err := core.NewGzipDecompressionReader(req.Body) - Expect(err).To(BeNil()) - _, err = bodyBuf.ReadFrom(body) - Expect(err).To(BeNil()) - } else { - _, err := bodyBuf.ReadFrom(req.Body) - Expect(err).To(BeNil()) - } - fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) - - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"id": 5850, "name": "My log push job", "enabled": false, "dataset": "firewall_events", "frequency": "high", "logpull_options": "timestamps=rfc3339×tamps=rfc3339", "destination_conf": "cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea", "last_complete": "2022-01-15T16:33:31.834209Z", "last_error": "2022-01-15T16:33:31.834209Z", "error_message": "ErrorMessage"}}`) - })) - }) - It(`Invoke UpdateLogpushJobV2 successfully`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Invoke operation with nil options model (negative test) - result, response, operationErr := logpushJobsApiService.UpdateLogpushJobV2(nil) - Expect(operationErr).NotTo(BeNil()) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) - - // Construct an instance of the UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq model - updateLogpushJobV2RequestModel := new(logpushjobsapiv1.UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq) - updateLogpushJobV2RequestModel.Enabled = core.BoolPtr(false) - updateLogpushJobV2RequestModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") - updateLogpushJobV2RequestModel.Cos = map[string]interface{}{"anyKey": "anyValue"} - updateLogpushJobV2RequestModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") - updateLogpushJobV2RequestModel.Frequency = core.StringPtr("high") - - // Construct an instance of the UpdateLogpushJobV2Options model - updateLogpushJobV2OptionsModel := new(logpushjobsapiv1.UpdateLogpushJobV2Options) - updateLogpushJobV2OptionsModel.JobID = core.Int64Ptr(int64(38)) - updateLogpushJobV2OptionsModel.UpdateLogpushJobV2Request = updateLogpushJobV2RequestModel - updateLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with valid options model (positive test) - result, response, operationErr = logpushJobsApiService.UpdateLogpushJobV2(updateLogpushJobV2OptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).ToNot(BeNil()) - - }) - It(`Invoke UpdateLogpushJobV2 with error: Operation validation and request error`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Construct an instance of the UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq model - updateLogpushJobV2RequestModel := new(logpushjobsapiv1.UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq) - updateLogpushJobV2RequestModel.Enabled = core.BoolPtr(false) - updateLogpushJobV2RequestModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") - updateLogpushJobV2RequestModel.Cos = map[string]interface{}{"anyKey": "anyValue"} - updateLogpushJobV2RequestModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") - updateLogpushJobV2RequestModel.Frequency = core.StringPtr("high") - - // Construct an instance of the UpdateLogpushJobV2Options model - updateLogpushJobV2OptionsModel := new(logpushjobsapiv1.UpdateLogpushJobV2Options) - updateLogpushJobV2OptionsModel.JobID = core.Int64Ptr(int64(38)) - updateLogpushJobV2OptionsModel.UpdateLogpushJobV2Request = updateLogpushJobV2RequestModel - updateLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Invoke operation with empty URL (negative test) - err := logpushJobsApiService.SetServiceURL("") - Expect(err).To(BeNil()) - result, response, operationErr := logpushJobsApiService.UpdateLogpushJobV2(updateLogpushJobV2OptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) - // Construct a second instance of the UpdateLogpushJobV2Options model with no property values - updateLogpushJobV2OptionsModelNew := new(logpushjobsapiv1.UpdateLogpushJobV2Options) - // Invoke operation with invalid model (negative test) - result, response, operationErr = logpushJobsApiService.UpdateLogpushJobV2(updateLogpushJobV2OptionsModelNew) - Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - Context(`Using mock server endpoint with missing response body`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Set success status code with no respoonse body - res.WriteHeader(200) - })) - }) - It(`Invoke UpdateLogpushJobV2 successfully`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Construct an instance of the UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq model - updateLogpushJobV2RequestModel := new(logpushjobsapiv1.UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq) - updateLogpushJobV2RequestModel.Enabled = core.BoolPtr(false) - updateLogpushJobV2RequestModel.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") - updateLogpushJobV2RequestModel.Cos = map[string]interface{}{"anyKey": "anyValue"} - updateLogpushJobV2RequestModel.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") - updateLogpushJobV2RequestModel.Frequency = core.StringPtr("high") - - // Construct an instance of the UpdateLogpushJobV2Options model - updateLogpushJobV2OptionsModel := new(logpushjobsapiv1.UpdateLogpushJobV2Options) - updateLogpushJobV2OptionsModel.JobID = core.Int64Ptr(int64(38)) - updateLogpushJobV2OptionsModel.UpdateLogpushJobV2Request = updateLogpushJobV2RequestModel - updateLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation - result, response, operationErr := logpushJobsApiService.UpdateLogpushJobV2(updateLogpushJobV2OptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - - // Verify a nil result - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`DeleteLogpushJobV2(deleteLogpushJobV2Options *DeleteLogpushJobV2Options) - Operation response error`, func() { - crn := "testString" - zoneID := "testString" - dataset := "http_requests" - deleteLogpushJobV2Path := "/v2/testString/zones/testString/logpush/jobs/38" - Context(`Using mock server endpoint with invalid JSON response`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(deleteLogpushJobV2Path)) - Expect(req.Method).To(Equal("DELETE")) - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) - })) - }) - It(`Invoke DeleteLogpushJobV2 with error: Operation response processing error`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - - // Construct an instance of the DeleteLogpushJobV2Options model - deleteLogpushJobV2OptionsModel := new(logpushjobsapiv1.DeleteLogpushJobV2Options) - deleteLogpushJobV2OptionsModel.JobID = core.Int64Ptr(int64(38)) - deleteLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := logpushJobsApiService.DeleteLogpushJobV2(deleteLogpushJobV2OptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).To(BeNil()) - - // Enable retries and test again - logpushJobsApiService.EnableRetries(0, 0) - result, response, operationErr = logpushJobsApiService.DeleteLogpushJobV2(deleteLogpushJobV2OptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`DeleteLogpushJobV2(deleteLogpushJobV2Options *DeleteLogpushJobV2Options)`, func() { - crn := "testString" - zoneID := "testString" - dataset := "http_requests" - deleteLogpushJobV2Path := "/v2/testString/zones/testString/logpush/jobs/38" - Context(`Using mock server endpoint with timeout`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(deleteLogpushJobV2Path)) - Expect(req.Method).To(Equal("DELETE")) - - // Sleep a short time to support a timeout test - time.Sleep(100 * time.Millisecond) - - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"anyKey": "anyValue"}}`) - })) - }) - It(`Invoke DeleteLogpushJobV2 successfully with retries`, func() { - logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), - Dataset: core.StringPtr(dataset), - }) - Expect(serviceErr).To(BeNil()) - Expect(logpushJobsApiService).ToNot(BeNil()) - logpushJobsApiService.EnableRetries(0, 0) - - // Construct an instance of the DeleteLogpushJobV2Options model - deleteLogpushJobV2OptionsModel := new(logpushjobsapiv1.DeleteLogpushJobV2Options) - deleteLogpushJobV2OptionsModel.JobID = core.Int64Ptr(int64(38)) - deleteLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with a Context to test a timeout error - ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) - defer cancelFunc() - _, _, operationErr := logpushJobsApiService.DeleteLogpushJobV2WithContext(ctx, deleteLogpushJobV2OptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) - - // Disable retries and test again - logpushJobsApiService.DisableRetries() - result, response, operationErr := logpushJobsApiService.DeleteLogpushJobV2(deleteLogpushJobV2OptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).ToNot(BeNil()) - - // Re-test the timeout error with retries disabled - ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) - defer cancelFunc2() - _, _, operationErr = logpushJobsApiService.DeleteLogpushJobV2WithContext(ctx, deleteLogpushJobV2OptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) - }) - AfterEach(func() { - testServer.Close() - }) - }) - Context(`Using mock server endpoint`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(deleteLogpushJobV2Path)) - Expect(req.Method).To(Equal("DELETE")) + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"anyKey": "anyValue"}}`) + fmt.Fprintf(res, "%s", `{"valid": true}`) })) }) - It(`Invoke DeleteLogpushJobV2 successfully`, func() { + It(`Invoke ValidateLogpushOwnershipChallengeV2 successfully`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := logpushJobsApiService.DeleteLogpushJobV2(nil) + result, response, operationErr := logpushJobsApiService.ValidateLogpushOwnershipChallengeV2(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the DeleteLogpushJobV2Options model - deleteLogpushJobV2OptionsModel := new(logpushjobsapiv1.DeleteLogpushJobV2Options) - deleteLogpushJobV2OptionsModel.JobID = core.Int64Ptr(int64(38)) - deleteLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ValidateLogpushOwnershipChallengeV2Options model + validateLogpushOwnershipChallengeV2OptionsModel := new(logpushjobsapiv1.ValidateLogpushOwnershipChallengeV2Options) + validateLogpushOwnershipChallengeV2OptionsModel.Cos = map[string]interface{}{"anyKey": "anyValue"} + validateLogpushOwnershipChallengeV2OptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000") + validateLogpushOwnershipChallengeV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = logpushJobsApiService.DeleteLogpushJobV2(deleteLogpushJobV2OptionsModel) + result, response, operationErr = logpushJobsApiService.ValidateLogpushOwnershipChallengeV2(validateLogpushOwnershipChallengeV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke DeleteLogpushJobV2 with error: Operation validation and request error`, func() { + It(`Invoke ValidateLogpushOwnershipChallengeV2 with error: Operation request error`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the DeleteLogpushJobV2Options model - deleteLogpushJobV2OptionsModel := new(logpushjobsapiv1.DeleteLogpushJobV2Options) - deleteLogpushJobV2OptionsModel.JobID = core.Int64Ptr(int64(38)) - deleteLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ValidateLogpushOwnershipChallengeV2Options model + validateLogpushOwnershipChallengeV2OptionsModel := new(logpushjobsapiv1.ValidateLogpushOwnershipChallengeV2Options) + validateLogpushOwnershipChallengeV2OptionsModel.Cos = map[string]interface{}{"anyKey": "anyValue"} + validateLogpushOwnershipChallengeV2OptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000") + validateLogpushOwnershipChallengeV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := logpushJobsApiService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := logpushJobsApiService.DeleteLogpushJobV2(deleteLogpushJobV2OptionsModel) + result, response, operationErr := logpushJobsApiService.ValidateLogpushOwnershipChallengeV2(validateLogpushOwnershipChallengeV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the DeleteLogpushJobV2Options model with no property values - deleteLogpushJobV2OptionsModelNew := new(logpushjobsapiv1.DeleteLogpushJobV2Options) - // Invoke operation with invalid model (negative test) - result, response, operationErr = logpushJobsApiService.DeleteLogpushJobV2(deleteLogpushJobV2OptionsModelNew) - Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() @@ -3702,24 +1996,25 @@ var _ = Describe(`LogpushJobsApiV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke DeleteLogpushJobV2 successfully`, func() { + It(`Invoke ValidateLogpushOwnershipChallengeV2 successfully`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the DeleteLogpushJobV2Options model - deleteLogpushJobV2OptionsModel := new(logpushjobsapiv1.DeleteLogpushJobV2Options) - deleteLogpushJobV2OptionsModel.JobID = core.Int64Ptr(int64(38)) - deleteLogpushJobV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ValidateLogpushOwnershipChallengeV2Options model + validateLogpushOwnershipChallengeV2OptionsModel := new(logpushjobsapiv1.ValidateLogpushOwnershipChallengeV2Options) + validateLogpushOwnershipChallengeV2OptionsModel.Cos = map[string]interface{}{"anyKey": "anyValue"} + validateLogpushOwnershipChallengeV2OptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000") + validateLogpushOwnershipChallengeV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := logpushJobsApiService.DeleteLogpushJobV2(deleteLogpushJobV2OptionsModel) + result, response, operationErr := logpushJobsApiService.ValidateLogpushOwnershipChallengeV2(validateLogpushOwnershipChallengeV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -3731,48 +2026,47 @@ var _ = Describe(`LogpushJobsApiV1`, func() { }) }) }) - Describe(`GetLogpushOwnershipV2(getLogpushOwnershipV2Options *GetLogpushOwnershipV2Options) - Operation response error`, func() { + Describe(`ListFieldsForDatasetV2(listFieldsForDatasetV2Options *ListFieldsForDatasetV2Options) - Operation response error`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" - getLogpushOwnershipV2Path := "/v2/testString/zones/testString/logpush/ownership" + listFieldsForDatasetV2Path := "/v2/testString/zones/testString/logpush/datasets/testString/fields" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getLogpushOwnershipV2Path)) - Expect(req.Method).To(Equal("POST")) + Expect(req.URL.EscapedPath()).To(Equal(listFieldsForDatasetV2Path)) + Expect(req.Method).To(Equal("GET")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) + fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke GetLogpushOwnershipV2 with error: Operation response processing error`, func() { + It(`Invoke ListFieldsForDatasetV2 with error: Operation response processing error`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the GetLogpushOwnershipV2Options model - getLogpushOwnershipV2OptionsModel := new(logpushjobsapiv1.GetLogpushOwnershipV2Options) - getLogpushOwnershipV2OptionsModel.Cos = map[string]interface{}{"anyKey": "anyValue"} - getLogpushOwnershipV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListFieldsForDatasetV2Options model + listFieldsForDatasetV2OptionsModel := new(logpushjobsapiv1.ListFieldsForDatasetV2Options) + listFieldsForDatasetV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := logpushJobsApiService.GetLogpushOwnershipV2(getLogpushOwnershipV2OptionsModel) + result, response, operationErr := logpushJobsApiService.ListFieldsForDatasetV2(listFieldsForDatasetV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again logpushJobsApiService.EnableRetries(0, 0) - result, response, operationErr = logpushJobsApiService.GetLogpushOwnershipV2(getLogpushOwnershipV2OptionsModel) + result, response, operationErr = logpushJobsApiService.ListFieldsForDatasetV2(listFieldsForDatasetV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -3782,35 +2076,19 @@ var _ = Describe(`LogpushJobsApiV1`, func() { }) }) }) - Describe(`GetLogpushOwnershipV2(getLogpushOwnershipV2Options *GetLogpushOwnershipV2Options)`, func() { + Describe(`ListFieldsForDatasetV2(listFieldsForDatasetV2Options *ListFieldsForDatasetV2Options)`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" - getLogpushOwnershipV2Path := "/v2/testString/zones/testString/logpush/ownership" + listFieldsForDatasetV2Path := "/v2/testString/zones/testString/logpush/datasets/testString/fields" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getLogpushOwnershipV2Path)) - Expect(req.Method).To(Equal("POST")) - - // For gzip-disabled operation, verify Content-Encoding is not set. - Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) - - // If there is a body, then make sure we can read it - bodyBuf := new(bytes.Buffer) - if req.Header.Get("Content-Encoding") == "gzip" { - body, err := core.NewGzipDecompressionReader(req.Body) - Expect(err).To(BeNil()) - _, err = bodyBuf.ReadFrom(body) - Expect(err).To(BeNil()) - } else { - _, err := bodyBuf.ReadFrom(req.Body) - Expect(err).To(BeNil()) - } - fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + Expect(req.URL.EscapedPath()).To(Equal(listFieldsForDatasetV2Path)) + Expect(req.Method).To(Equal("GET")) // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) @@ -3818,36 +2096,35 @@ var _ = Describe(`LogpushJobsApiV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"filename": "logs/challenge-filename.txt", "valid": true, "messages": "Messages"}}`) + fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"anyKey": "anyValue"}}`) })) }) - It(`Invoke GetLogpushOwnershipV2 successfully with retries`, func() { + It(`Invoke ListFieldsForDatasetV2 successfully with retries`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) logpushJobsApiService.EnableRetries(0, 0) - // Construct an instance of the GetLogpushOwnershipV2Options model - getLogpushOwnershipV2OptionsModel := new(logpushjobsapiv1.GetLogpushOwnershipV2Options) - getLogpushOwnershipV2OptionsModel.Cos = map[string]interface{}{"anyKey": "anyValue"} - getLogpushOwnershipV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListFieldsForDatasetV2Options model + listFieldsForDatasetV2OptionsModel := new(logpushjobsapiv1.ListFieldsForDatasetV2Options) + listFieldsForDatasetV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := logpushJobsApiService.GetLogpushOwnershipV2WithContext(ctx, getLogpushOwnershipV2OptionsModel) + _, _, operationErr := logpushJobsApiService.ListFieldsForDatasetV2WithContext(ctx, listFieldsForDatasetV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again logpushJobsApiService.DisableRetries() - result, response, operationErr := logpushJobsApiService.GetLogpushOwnershipV2(getLogpushOwnershipV2OptionsModel) + result, response, operationErr := logpushJobsApiService.ListFieldsForDatasetV2(listFieldsForDatasetV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -3855,7 +2132,7 @@ var _ = Describe(`LogpushJobsApiV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = logpushJobsApiService.GetLogpushOwnershipV2WithContext(ctx, getLogpushOwnershipV2OptionsModel) + _, _, operationErr = logpushJobsApiService.ListFieldsForDatasetV2WithContext(ctx, listFieldsForDatasetV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -3869,79 +2146,61 @@ var _ = Describe(`LogpushJobsApiV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getLogpushOwnershipV2Path)) - Expect(req.Method).To(Equal("POST")) - - // For gzip-disabled operation, verify Content-Encoding is not set. - Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) - - // If there is a body, then make sure we can read it - bodyBuf := new(bytes.Buffer) - if req.Header.Get("Content-Encoding") == "gzip" { - body, err := core.NewGzipDecompressionReader(req.Body) - Expect(err).To(BeNil()) - _, err = bodyBuf.ReadFrom(body) - Expect(err).To(BeNil()) - } else { - _, err := bodyBuf.ReadFrom(req.Body) - Expect(err).To(BeNil()) - } - fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + Expect(req.URL.EscapedPath()).To(Equal(listFieldsForDatasetV2Path)) + Expect(req.Method).To(Equal("GET")) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"filename": "logs/challenge-filename.txt", "valid": true, "messages": "Messages"}}`) + fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"anyKey": "anyValue"}}`) })) }) - It(`Invoke GetLogpushOwnershipV2 successfully`, func() { + It(`Invoke ListFieldsForDatasetV2 successfully`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := logpushJobsApiService.GetLogpushOwnershipV2(nil) + result, response, operationErr := logpushJobsApiService.ListFieldsForDatasetV2(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetLogpushOwnershipV2Options model - getLogpushOwnershipV2OptionsModel := new(logpushjobsapiv1.GetLogpushOwnershipV2Options) - getLogpushOwnershipV2OptionsModel.Cos = map[string]interface{}{"anyKey": "anyValue"} - getLogpushOwnershipV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListFieldsForDatasetV2Options model + listFieldsForDatasetV2OptionsModel := new(logpushjobsapiv1.ListFieldsForDatasetV2Options) + listFieldsForDatasetV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = logpushJobsApiService.GetLogpushOwnershipV2(getLogpushOwnershipV2OptionsModel) + result, response, operationErr = logpushJobsApiService.ListFieldsForDatasetV2(listFieldsForDatasetV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetLogpushOwnershipV2 with error: Operation request error`, func() { + It(`Invoke ListFieldsForDatasetV2 with error: Operation request error`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the GetLogpushOwnershipV2Options model - getLogpushOwnershipV2OptionsModel := new(logpushjobsapiv1.GetLogpushOwnershipV2Options) - getLogpushOwnershipV2OptionsModel.Cos = map[string]interface{}{"anyKey": "anyValue"} - getLogpushOwnershipV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListFieldsForDatasetV2Options model + listFieldsForDatasetV2OptionsModel := new(logpushjobsapiv1.ListFieldsForDatasetV2Options) + listFieldsForDatasetV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := logpushJobsApiService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := logpushJobsApiService.GetLogpushOwnershipV2(getLogpushOwnershipV2OptionsModel) + result, response, operationErr := logpushJobsApiService.ListFieldsForDatasetV2(listFieldsForDatasetV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) @@ -3960,24 +2219,23 @@ var _ = Describe(`LogpushJobsApiV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke GetLogpushOwnershipV2 successfully`, func() { + It(`Invoke ListFieldsForDatasetV2 successfully`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the GetLogpushOwnershipV2Options model - getLogpushOwnershipV2OptionsModel := new(logpushjobsapiv1.GetLogpushOwnershipV2Options) - getLogpushOwnershipV2OptionsModel.Cos = map[string]interface{}{"anyKey": "anyValue"} - getLogpushOwnershipV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListFieldsForDatasetV2Options model + listFieldsForDatasetV2OptionsModel := new(logpushjobsapiv1.ListFieldsForDatasetV2Options) + listFieldsForDatasetV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := logpushJobsApiService.GetLogpushOwnershipV2(getLogpushOwnershipV2OptionsModel) + result, response, operationErr := logpushJobsApiService.ListFieldsForDatasetV2(listFieldsForDatasetV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -3989,49 +2247,47 @@ var _ = Describe(`LogpushJobsApiV1`, func() { }) }) }) - Describe(`ValidateLogpushOwnershipChallengeV2(validateLogpushOwnershipChallengeV2Options *ValidateLogpushOwnershipChallengeV2Options) - Operation response error`, func() { + Describe(`ListLogpushJobsForDatasetV2(listLogpushJobsForDatasetV2Options *ListLogpushJobsForDatasetV2Options) - Operation response error`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" - validateLogpushOwnershipChallengeV2Path := "/v2/testString/zones/testString/logpush/ownership/validate" + listLogpushJobsForDatasetV2Path := "/v2/testString/zones/testString/logpush/datasets/testString/jobs" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(validateLogpushOwnershipChallengeV2Path)) - Expect(req.Method).To(Equal("POST")) + Expect(req.URL.EscapedPath()).To(Equal(listLogpushJobsForDatasetV2Path)) + Expect(req.Method).To(Equal("GET")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) + fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ValidateLogpushOwnershipChallengeV2 with error: Operation response processing error`, func() { + It(`Invoke ListLogpushJobsForDatasetV2 with error: Operation response processing error`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the ValidateLogpushOwnershipChallengeV2Options model - validateLogpushOwnershipChallengeV2OptionsModel := new(logpushjobsapiv1.ValidateLogpushOwnershipChallengeV2Options) - validateLogpushOwnershipChallengeV2OptionsModel.Cos = map[string]interface{}{"anyKey": "anyValue"} - validateLogpushOwnershipChallengeV2OptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000") - validateLogpushOwnershipChallengeV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListLogpushJobsForDatasetV2Options model + listLogpushJobsForDatasetV2OptionsModel := new(logpushjobsapiv1.ListLogpushJobsForDatasetV2Options) + listLogpushJobsForDatasetV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := logpushJobsApiService.ValidateLogpushOwnershipChallengeV2(validateLogpushOwnershipChallengeV2OptionsModel) + result, response, operationErr := logpushJobsApiService.ListLogpushJobsForDatasetV2(listLogpushJobsForDatasetV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again logpushJobsApiService.EnableRetries(0, 0) - result, response, operationErr = logpushJobsApiService.ValidateLogpushOwnershipChallengeV2(validateLogpushOwnershipChallengeV2OptionsModel) + result, response, operationErr = logpushJobsApiService.ListLogpushJobsForDatasetV2(listLogpushJobsForDatasetV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -4041,35 +2297,19 @@ var _ = Describe(`LogpushJobsApiV1`, func() { }) }) }) - Describe(`ValidateLogpushOwnershipChallengeV2(validateLogpushOwnershipChallengeV2Options *ValidateLogpushOwnershipChallengeV2Options)`, func() { + Describe(`ListLogpushJobsForDatasetV2(listLogpushJobsForDatasetV2Options *ListLogpushJobsForDatasetV2Options)`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" - validateLogpushOwnershipChallengeV2Path := "/v2/testString/zones/testString/logpush/ownership/validate" + listLogpushJobsForDatasetV2Path := "/v2/testString/zones/testString/logpush/datasets/testString/jobs" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(validateLogpushOwnershipChallengeV2Path)) - Expect(req.Method).To(Equal("POST")) - - // For gzip-disabled operation, verify Content-Encoding is not set. - Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) - - // If there is a body, then make sure we can read it - bodyBuf := new(bytes.Buffer) - if req.Header.Get("Content-Encoding") == "gzip" { - body, err := core.NewGzipDecompressionReader(req.Body) - Expect(err).To(BeNil()) - _, err = bodyBuf.ReadFrom(body) - Expect(err).To(BeNil()) - } else { - _, err := bodyBuf.ReadFrom(req.Body) - Expect(err).To(BeNil()) - } - fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + Expect(req.URL.EscapedPath()).To(Equal(listLogpushJobsForDatasetV2Path)) + Expect(req.Method).To(Equal("GET")) // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) @@ -4077,37 +2317,35 @@ var _ = Describe(`LogpushJobsApiV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"valid": true}`) + fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"id": 5850, "name": "My log push job", "enabled": false, "dataset": "firewall_events", "frequency": "high", "logpull_options": "timestamps=rfc3339×tamps=rfc3339", "destination_conf": "cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea", "last_complete": "2022-01-15T16:33:31.834209Z", "last_error": "2022-01-15T16:33:31.834209Z", "error_message": "ErrorMessage"}}`) })) }) - It(`Invoke ValidateLogpushOwnershipChallengeV2 successfully with retries`, func() { + It(`Invoke ListLogpushJobsForDatasetV2 successfully with retries`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) logpushJobsApiService.EnableRetries(0, 0) - // Construct an instance of the ValidateLogpushOwnershipChallengeV2Options model - validateLogpushOwnershipChallengeV2OptionsModel := new(logpushjobsapiv1.ValidateLogpushOwnershipChallengeV2Options) - validateLogpushOwnershipChallengeV2OptionsModel.Cos = map[string]interface{}{"anyKey": "anyValue"} - validateLogpushOwnershipChallengeV2OptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000") - validateLogpushOwnershipChallengeV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListLogpushJobsForDatasetV2Options model + listLogpushJobsForDatasetV2OptionsModel := new(logpushjobsapiv1.ListLogpushJobsForDatasetV2Options) + listLogpushJobsForDatasetV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := logpushJobsApiService.ValidateLogpushOwnershipChallengeV2WithContext(ctx, validateLogpushOwnershipChallengeV2OptionsModel) + _, _, operationErr := logpushJobsApiService.ListLogpushJobsForDatasetV2WithContext(ctx, listLogpushJobsForDatasetV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again logpushJobsApiService.DisableRetries() - result, response, operationErr := logpushJobsApiService.ValidateLogpushOwnershipChallengeV2(validateLogpushOwnershipChallengeV2OptionsModel) + result, response, operationErr := logpushJobsApiService.ListLogpushJobsForDatasetV2(listLogpushJobsForDatasetV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -4115,7 +2353,7 @@ var _ = Describe(`LogpushJobsApiV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = logpushJobsApiService.ValidateLogpushOwnershipChallengeV2WithContext(ctx, validateLogpushOwnershipChallengeV2OptionsModel) + _, _, operationErr = logpushJobsApiService.ListLogpushJobsForDatasetV2WithContext(ctx, listLogpushJobsForDatasetV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -4129,81 +2367,61 @@ var _ = Describe(`LogpushJobsApiV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(validateLogpushOwnershipChallengeV2Path)) - Expect(req.Method).To(Equal("POST")) - - // For gzip-disabled operation, verify Content-Encoding is not set. - Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) - - // If there is a body, then make sure we can read it - bodyBuf := new(bytes.Buffer) - if req.Header.Get("Content-Encoding") == "gzip" { - body, err := core.NewGzipDecompressionReader(req.Body) - Expect(err).To(BeNil()) - _, err = bodyBuf.ReadFrom(body) - Expect(err).To(BeNil()) - } else { - _, err := bodyBuf.ReadFrom(req.Body) - Expect(err).To(BeNil()) - } - fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + Expect(req.URL.EscapedPath()).To(Equal(listLogpushJobsForDatasetV2Path)) + Expect(req.Method).To(Equal("GET")) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"valid": true}`) + fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"id": 5850, "name": "My log push job", "enabled": false, "dataset": "firewall_events", "frequency": "high", "logpull_options": "timestamps=rfc3339×tamps=rfc3339", "destination_conf": "cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea", "last_complete": "2022-01-15T16:33:31.834209Z", "last_error": "2022-01-15T16:33:31.834209Z", "error_message": "ErrorMessage"}}`) })) }) - It(`Invoke ValidateLogpushOwnershipChallengeV2 successfully`, func() { + It(`Invoke ListLogpushJobsForDatasetV2 successfully`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := logpushJobsApiService.ValidateLogpushOwnershipChallengeV2(nil) + result, response, operationErr := logpushJobsApiService.ListLogpushJobsForDatasetV2(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ValidateLogpushOwnershipChallengeV2Options model - validateLogpushOwnershipChallengeV2OptionsModel := new(logpushjobsapiv1.ValidateLogpushOwnershipChallengeV2Options) - validateLogpushOwnershipChallengeV2OptionsModel.Cos = map[string]interface{}{"anyKey": "anyValue"} - validateLogpushOwnershipChallengeV2OptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000") - validateLogpushOwnershipChallengeV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListLogpushJobsForDatasetV2Options model + listLogpushJobsForDatasetV2OptionsModel := new(logpushjobsapiv1.ListLogpushJobsForDatasetV2Options) + listLogpushJobsForDatasetV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = logpushJobsApiService.ValidateLogpushOwnershipChallengeV2(validateLogpushOwnershipChallengeV2OptionsModel) + result, response, operationErr = logpushJobsApiService.ListLogpushJobsForDatasetV2(listLogpushJobsForDatasetV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ValidateLogpushOwnershipChallengeV2 with error: Operation request error`, func() { + It(`Invoke ListLogpushJobsForDatasetV2 with error: Operation request error`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the ValidateLogpushOwnershipChallengeV2Options model - validateLogpushOwnershipChallengeV2OptionsModel := new(logpushjobsapiv1.ValidateLogpushOwnershipChallengeV2Options) - validateLogpushOwnershipChallengeV2OptionsModel.Cos = map[string]interface{}{"anyKey": "anyValue"} - validateLogpushOwnershipChallengeV2OptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000") - validateLogpushOwnershipChallengeV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListLogpushJobsForDatasetV2Options model + listLogpushJobsForDatasetV2OptionsModel := new(logpushjobsapiv1.ListLogpushJobsForDatasetV2Options) + listLogpushJobsForDatasetV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := logpushJobsApiService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := logpushJobsApiService.ValidateLogpushOwnershipChallengeV2(validateLogpushOwnershipChallengeV2OptionsModel) + result, response, operationErr := logpushJobsApiService.ListLogpushJobsForDatasetV2(listLogpushJobsForDatasetV2OptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) @@ -4222,25 +2440,23 @@ var _ = Describe(`LogpushJobsApiV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke ValidateLogpushOwnershipChallengeV2 successfully`, func() { + It(`Invoke ListLogpushJobsForDatasetV2 successfully`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the ValidateLogpushOwnershipChallengeV2Options model - validateLogpushOwnershipChallengeV2OptionsModel := new(logpushjobsapiv1.ValidateLogpushOwnershipChallengeV2Options) - validateLogpushOwnershipChallengeV2OptionsModel.Cos = map[string]interface{}{"anyKey": "anyValue"} - validateLogpushOwnershipChallengeV2OptionsModel.OwnershipChallenge = core.StringPtr("00000000000000000000") - validateLogpushOwnershipChallengeV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListLogpushJobsForDatasetV2Options model + listLogpushJobsForDatasetV2OptionsModel := new(logpushjobsapiv1.ListLogpushJobsForDatasetV2Options) + listLogpushJobsForDatasetV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := logpushJobsApiService.ValidateLogpushOwnershipChallengeV2(validateLogpushOwnershipChallengeV2OptionsModel) + result, response, operationErr := logpushJobsApiService.ListLogpushJobsForDatasetV2(listLogpushJobsForDatasetV2OptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -4252,47 +2468,47 @@ var _ = Describe(`LogpushJobsApiV1`, func() { }) }) }) - Describe(`ListFieldsForDatasetV2(listFieldsForDatasetV2Options *ListFieldsForDatasetV2Options) - Operation response error`, func() { + Describe(`GetLogsRetention(getLogsRetentionOptions *GetLogsRetentionOptions) - Operation response error`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" - listFieldsForDatasetV2Path := "/v2/testString/zones/testString/logpush/datasets/http_requests/fields" + getLogsRetentionPath := "/v1/testString/zones/testString/logs/retention" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listFieldsForDatasetV2Path)) + Expect(req.URL.EscapedPath()).To(Equal(getLogsRetentionPath)) Expect(req.Method).To(Equal("GET")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) + fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListFieldsForDatasetV2 with error: Operation response processing error`, func() { + It(`Invoke GetLogsRetention with error: Operation response processing error`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the ListFieldsForDatasetV2Options model - listFieldsForDatasetV2OptionsModel := new(logpushjobsapiv1.ListFieldsForDatasetV2Options) - listFieldsForDatasetV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetLogsRetentionOptions model + getLogsRetentionOptionsModel := new(logpushjobsapiv1.GetLogsRetentionOptions) + getLogsRetentionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := logpushJobsApiService.ListFieldsForDatasetV2(listFieldsForDatasetV2OptionsModel) + result, response, operationErr := logpushJobsApiService.GetLogsRetention(getLogsRetentionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again logpushJobsApiService.EnableRetries(0, 0) - result, response, operationErr = logpushJobsApiService.ListFieldsForDatasetV2(listFieldsForDatasetV2OptionsModel) + result, response, operationErr = logpushJobsApiService.GetLogsRetention(getLogsRetentionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -4302,18 +2518,18 @@ var _ = Describe(`LogpushJobsApiV1`, func() { }) }) }) - Describe(`ListFieldsForDatasetV2(listFieldsForDatasetV2Options *ListFieldsForDatasetV2Options)`, func() { + Describe(`GetLogsRetention(getLogsRetentionOptions *GetLogsRetentionOptions)`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" - listFieldsForDatasetV2Path := "/v2/testString/zones/testString/logpush/datasets/http_requests/fields" + getLogsRetentionPath := "/v1/testString/zones/testString/logs/retention" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listFieldsForDatasetV2Path)) + Expect(req.URL.EscapedPath()).To(Equal(getLogsRetentionPath)) Expect(req.Method).To(Equal("GET")) // Sleep a short time to support a timeout test @@ -4322,35 +2538,35 @@ var _ = Describe(`LogpushJobsApiV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"anyKey": "anyValue"}}`) + fmt.Fprintf(res, "%s", `{"result": {"flag": true}, "success": true, "errors": [["Errors"]], "messages": [["Messages"]]}`) })) }) - It(`Invoke ListFieldsForDatasetV2 successfully with retries`, func() { + It(`Invoke GetLogsRetention successfully with retries`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) logpushJobsApiService.EnableRetries(0, 0) - // Construct an instance of the ListFieldsForDatasetV2Options model - listFieldsForDatasetV2OptionsModel := new(logpushjobsapiv1.ListFieldsForDatasetV2Options) - listFieldsForDatasetV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetLogsRetentionOptions model + getLogsRetentionOptionsModel := new(logpushjobsapiv1.GetLogsRetentionOptions) + getLogsRetentionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := logpushJobsApiService.ListFieldsForDatasetV2WithContext(ctx, listFieldsForDatasetV2OptionsModel) + _, _, operationErr := logpushJobsApiService.GetLogsRetentionWithContext(ctx, getLogsRetentionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again logpushJobsApiService.DisableRetries() - result, response, operationErr := logpushJobsApiService.ListFieldsForDatasetV2(listFieldsForDatasetV2OptionsModel) + result, response, operationErr := logpushJobsApiService.GetLogsRetention(getLogsRetentionOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -4358,7 +2574,7 @@ var _ = Describe(`LogpushJobsApiV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = logpushJobsApiService.ListFieldsForDatasetV2WithContext(ctx, listFieldsForDatasetV2OptionsModel) + _, _, operationErr = logpushJobsApiService.GetLogsRetentionWithContext(ctx, getLogsRetentionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -4372,61 +2588,61 @@ var _ = Describe(`LogpushJobsApiV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listFieldsForDatasetV2Path)) + Expect(req.URL.EscapedPath()).To(Equal(getLogsRetentionPath)) Expect(req.Method).To(Equal("GET")) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"anyKey": "anyValue"}}`) + fmt.Fprintf(res, "%s", `{"result": {"flag": true}, "success": true, "errors": [["Errors"]], "messages": [["Messages"]]}`) })) }) - It(`Invoke ListFieldsForDatasetV2 successfully`, func() { + It(`Invoke GetLogsRetention successfully`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := logpushJobsApiService.ListFieldsForDatasetV2(nil) + result, response, operationErr := logpushJobsApiService.GetLogsRetention(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListFieldsForDatasetV2Options model - listFieldsForDatasetV2OptionsModel := new(logpushjobsapiv1.ListFieldsForDatasetV2Options) - listFieldsForDatasetV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetLogsRetentionOptions model + getLogsRetentionOptionsModel := new(logpushjobsapiv1.GetLogsRetentionOptions) + getLogsRetentionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = logpushJobsApiService.ListFieldsForDatasetV2(listFieldsForDatasetV2OptionsModel) + result, response, operationErr = logpushJobsApiService.GetLogsRetention(getLogsRetentionOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListFieldsForDatasetV2 with error: Operation request error`, func() { + It(`Invoke GetLogsRetention with error: Operation request error`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the ListFieldsForDatasetV2Options model - listFieldsForDatasetV2OptionsModel := new(logpushjobsapiv1.ListFieldsForDatasetV2Options) - listFieldsForDatasetV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetLogsRetentionOptions model + getLogsRetentionOptionsModel := new(logpushjobsapiv1.GetLogsRetentionOptions) + getLogsRetentionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := logpushJobsApiService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := logpushJobsApiService.ListFieldsForDatasetV2(listFieldsForDatasetV2OptionsModel) + result, response, operationErr := logpushJobsApiService.GetLogsRetention(getLogsRetentionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) @@ -4445,23 +2661,23 @@ var _ = Describe(`LogpushJobsApiV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListFieldsForDatasetV2 successfully`, func() { + It(`Invoke GetLogsRetention successfully`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the ListFieldsForDatasetV2Options model - listFieldsForDatasetV2OptionsModel := new(logpushjobsapiv1.ListFieldsForDatasetV2Options) - listFieldsForDatasetV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetLogsRetentionOptions model + getLogsRetentionOptionsModel := new(logpushjobsapiv1.GetLogsRetentionOptions) + getLogsRetentionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := logpushJobsApiService.ListFieldsForDatasetV2(listFieldsForDatasetV2OptionsModel) + result, response, operationErr := logpushJobsApiService.GetLogsRetention(getLogsRetentionOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -4473,47 +2689,48 @@ var _ = Describe(`LogpushJobsApiV1`, func() { }) }) }) - Describe(`ListLogpushJobsForDatasetV2(listLogpushJobsForDatasetV2Options *ListLogpushJobsForDatasetV2Options) - Operation response error`, func() { + Describe(`CreateLogRetention(createLogRetentionOptions *CreateLogRetentionOptions) - Operation response error`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" - listLogpushJobsForDatasetV2Path := "/v2/testString/zones/testString/logpush/datasets/http_requests/jobs" + createLogRetentionPath := "/v1/testString/zones/testString/logs/retention" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listLogpushJobsForDatasetV2Path)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(createLogRetentionPath)) + Expect(req.Method).To(Equal("POST")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) + fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListLogpushJobsForDatasetV2 with error: Operation response processing error`, func() { + It(`Invoke CreateLogRetention with error: Operation response processing error`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the ListLogpushJobsForDatasetV2Options model - listLogpushJobsForDatasetV2OptionsModel := new(logpushjobsapiv1.ListLogpushJobsForDatasetV2Options) - listLogpushJobsForDatasetV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateLogRetentionOptions model + createLogRetentionOptionsModel := new(logpushjobsapiv1.CreateLogRetentionOptions) + createLogRetentionOptionsModel.Flag = core.BoolPtr(false) + createLogRetentionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := logpushJobsApiService.ListLogpushJobsForDatasetV2(listLogpushJobsForDatasetV2OptionsModel) + result, response, operationErr := logpushJobsApiService.CreateLogRetention(createLogRetentionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again logpushJobsApiService.EnableRetries(0, 0) - result, response, operationErr = logpushJobsApiService.ListLogpushJobsForDatasetV2(listLogpushJobsForDatasetV2OptionsModel) + result, response, operationErr = logpushJobsApiService.CreateLogRetention(createLogRetentionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -4523,19 +2740,35 @@ var _ = Describe(`LogpushJobsApiV1`, func() { }) }) }) - Describe(`ListLogpushJobsForDatasetV2(listLogpushJobsForDatasetV2Options *ListLogpushJobsForDatasetV2Options)`, func() { + Describe(`CreateLogRetention(createLogRetentionOptions *CreateLogRetentionOptions)`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" - listLogpushJobsForDatasetV2Path := "/v2/testString/zones/testString/logpush/datasets/http_requests/jobs" + createLogRetentionPath := "/v1/testString/zones/testString/logs/retention" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listLogpushJobsForDatasetV2Path)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(createLogRetentionPath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) @@ -4543,35 +2776,36 @@ var _ = Describe(`LogpushJobsApiV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"id": 5850, "name": "My log push job", "enabled": false, "dataset": "firewall_events", "frequency": "high", "logpull_options": "timestamps=rfc3339×tamps=rfc3339", "destination_conf": "cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea", "last_complete": "2022-01-15T16:33:31.834209Z", "last_error": "2022-01-15T16:33:31.834209Z", "error_message": "ErrorMessage"}}`) + fmt.Fprintf(res, "%s", `{"result": {"flag": true}, "success": true, "errors": [["Errors"]], "messages": [["Messages"]]}`) })) }) - It(`Invoke ListLogpushJobsForDatasetV2 successfully with retries`, func() { + It(`Invoke CreateLogRetention successfully with retries`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) logpushJobsApiService.EnableRetries(0, 0) - // Construct an instance of the ListLogpushJobsForDatasetV2Options model - listLogpushJobsForDatasetV2OptionsModel := new(logpushjobsapiv1.ListLogpushJobsForDatasetV2Options) - listLogpushJobsForDatasetV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateLogRetentionOptions model + createLogRetentionOptionsModel := new(logpushjobsapiv1.CreateLogRetentionOptions) + createLogRetentionOptionsModel.Flag = core.BoolPtr(false) + createLogRetentionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := logpushJobsApiService.ListLogpushJobsForDatasetV2WithContext(ctx, listLogpushJobsForDatasetV2OptionsModel) + _, _, operationErr := logpushJobsApiService.CreateLogRetentionWithContext(ctx, createLogRetentionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again logpushJobsApiService.DisableRetries() - result, response, operationErr := logpushJobsApiService.ListLogpushJobsForDatasetV2(listLogpushJobsForDatasetV2OptionsModel) + result, response, operationErr := logpushJobsApiService.CreateLogRetention(createLogRetentionOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -4579,7 +2813,7 @@ var _ = Describe(`LogpushJobsApiV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = logpushJobsApiService.ListLogpushJobsForDatasetV2WithContext(ctx, listLogpushJobsForDatasetV2OptionsModel) + _, _, operationErr = logpushJobsApiService.CreateLogRetentionWithContext(ctx, createLogRetentionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -4593,61 +2827,79 @@ var _ = Describe(`LogpushJobsApiV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listLogpushJobsForDatasetV2Path)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(createLogRetentionPath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"success": true, "errors": [["Errors"]], "messages": [["Messages"]], "result": {"id": 5850, "name": "My log push job", "enabled": false, "dataset": "firewall_events", "frequency": "high", "logpull_options": "timestamps=rfc3339×tamps=rfc3339", "destination_conf": "cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea", "last_complete": "2022-01-15T16:33:31.834209Z", "last_error": "2022-01-15T16:33:31.834209Z", "error_message": "ErrorMessage"}}`) + fmt.Fprintf(res, "%s", `{"result": {"flag": true}, "success": true, "errors": [["Errors"]], "messages": [["Messages"]]}`) })) }) - It(`Invoke ListLogpushJobsForDatasetV2 successfully`, func() { + It(`Invoke CreateLogRetention successfully`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := logpushJobsApiService.ListLogpushJobsForDatasetV2(nil) + result, response, operationErr := logpushJobsApiService.CreateLogRetention(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListLogpushJobsForDatasetV2Options model - listLogpushJobsForDatasetV2OptionsModel := new(logpushjobsapiv1.ListLogpushJobsForDatasetV2Options) - listLogpushJobsForDatasetV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateLogRetentionOptions model + createLogRetentionOptionsModel := new(logpushjobsapiv1.CreateLogRetentionOptions) + createLogRetentionOptionsModel.Flag = core.BoolPtr(false) + createLogRetentionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = logpushJobsApiService.ListLogpushJobsForDatasetV2(listLogpushJobsForDatasetV2OptionsModel) + result, response, operationErr = logpushJobsApiService.CreateLogRetention(createLogRetentionOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListLogpushJobsForDatasetV2 with error: Operation request error`, func() { + It(`Invoke CreateLogRetention with error: Operation request error`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the ListLogpushJobsForDatasetV2Options model - listLogpushJobsForDatasetV2OptionsModel := new(logpushjobsapiv1.ListLogpushJobsForDatasetV2Options) - listLogpushJobsForDatasetV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateLogRetentionOptions model + createLogRetentionOptionsModel := new(logpushjobsapiv1.CreateLogRetentionOptions) + createLogRetentionOptionsModel.Flag = core.BoolPtr(false) + createLogRetentionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := logpushJobsApiService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := logpushJobsApiService.ListLogpushJobsForDatasetV2(listLogpushJobsForDatasetV2OptionsModel) + result, response, operationErr := logpushJobsApiService.CreateLogRetention(createLogRetentionOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) @@ -4666,23 +2918,24 @@ var _ = Describe(`LogpushJobsApiV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListLogpushJobsForDatasetV2 successfully`, func() { + It(`Invoke CreateLogRetention successfully`, func() { logpushJobsApiService, serviceErr := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) Expect(serviceErr).To(BeNil()) Expect(logpushJobsApiService).ToNot(BeNil()) - // Construct an instance of the ListLogpushJobsForDatasetV2Options model - listLogpushJobsForDatasetV2OptionsModel := new(logpushjobsapiv1.ListLogpushJobsForDatasetV2Options) - listLogpushJobsForDatasetV2OptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateLogRetentionOptions model + createLogRetentionOptionsModel := new(logpushjobsapiv1.CreateLogRetentionOptions) + createLogRetentionOptionsModel.Flag = core.BoolPtr(false) + createLogRetentionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := logpushJobsApiService.ListLogpushJobsForDatasetV2(listLogpushJobsForDatasetV2OptionsModel) + result, response, operationErr := logpushJobsApiService.CreateLogRetention(createLogRetentionOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -4697,35 +2950,23 @@ var _ = Describe(`LogpushJobsApiV1`, func() { Describe(`Model constructor tests`, func() { Context(`Using a service client instance`, func() { crn := "testString" + dataset := "testString" zoneID := "testString" - dataset := "http_requests" logpushJobsApiService, _ := logpushjobsapiv1.NewLogpushJobsApiV1(&logpushjobsapiv1.LogpushJobsApiV1Options{ URL: "http://logpushjobsapiv1modelgenerator.com", Authenticator: &core.NoAuthAuthenticator{}, Crn: core.StringPtr(crn), - ZoneID: core.StringPtr(zoneID), Dataset: core.StringPtr(dataset), + ZoneID: core.StringPtr(zoneID), }) - It(`Invoke NewCreateLogpushJobOptions successfully`, func() { - // Construct an instance of the CreateLogpushJobOptions model - createLogpushJobOptionsModel := logpushJobsApiService.NewCreateLogpushJobOptions() - createLogpushJobOptionsModel.SetName("My log push job") - createLogpushJobOptionsModel.SetEnabled(false) - createLogpushJobOptionsModel.SetLogpullOptions("timestamps=rfc3339×tamps=rfc3339") - createLogpushJobOptionsModel.SetDestinationConf("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea") - createLogpushJobOptionsModel.SetOwnershipChallenge("00000000000000000000000000000000") - createLogpushJobOptionsModel.SetDataset("firewall_events") - createLogpushJobOptionsModel.SetFrequency("high") - createLogpushJobOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) - Expect(createLogpushJobOptionsModel).ToNot(BeNil()) - Expect(createLogpushJobOptionsModel.Name).To(Equal(core.StringPtr("My log push job"))) - Expect(createLogpushJobOptionsModel.Enabled).To(Equal(core.BoolPtr(false))) - Expect(createLogpushJobOptionsModel.LogpullOptions).To(Equal(core.StringPtr("timestamps=rfc3339×tamps=rfc3339"))) - Expect(createLogpushJobOptionsModel.DestinationConf).To(Equal(core.StringPtr("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea"))) - Expect(createLogpushJobOptionsModel.OwnershipChallenge).To(Equal(core.StringPtr("00000000000000000000000000000000"))) - Expect(createLogpushJobOptionsModel.Dataset).To(Equal(core.StringPtr("firewall_events"))) - Expect(createLogpushJobOptionsModel.Frequency).To(Equal(core.StringPtr("high"))) - Expect(createLogpushJobOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + It(`Invoke NewCreateLogRetentionOptions successfully`, func() { + // Construct an instance of the CreateLogRetentionOptions model + createLogRetentionOptionsModel := logpushJobsApiService.NewCreateLogRetentionOptions() + createLogRetentionOptionsModel.SetFlag(false) + createLogRetentionOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(createLogRetentionOptionsModel).ToNot(BeNil()) + Expect(createLogRetentionOptionsModel.Flag).To(Equal(core.BoolPtr(false))) + Expect(createLogRetentionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewCreateLogpushJobV2Options successfully`, func() { // Construct an instance of the CreateLogpushJobV2RequestLogpushJobCosReq model @@ -4754,53 +2995,26 @@ var _ = Describe(`LogpushJobsApiV1`, func() { Expect(createLogpushJobV2OptionsModel.CreateLogpushJobV2Request).To(Equal(createLogpushJobV2RequestModel)) Expect(createLogpushJobV2OptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) - It(`Invoke NewDeleteLogpushJobOptions successfully`, func() { - // Construct an instance of the DeleteLogpushJobOptions model - jobID := int64(38) - deleteLogpushJobOptionsModel := logpushJobsApiService.NewDeleteLogpushJobOptions(jobID) - deleteLogpushJobOptionsModel.SetJobID(int64(38)) - deleteLogpushJobOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) - Expect(deleteLogpushJobOptionsModel).ToNot(BeNil()) - Expect(deleteLogpushJobOptionsModel.JobID).To(Equal(core.Int64Ptr(int64(38)))) - Expect(deleteLogpushJobOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) - }) It(`Invoke NewDeleteLogpushJobV2Options successfully`, func() { // Construct an instance of the DeleteLogpushJobV2Options model - jobID := int64(38) + jobID := "testString" deleteLogpushJobV2OptionsModel := logpushJobsApiService.NewDeleteLogpushJobV2Options(jobID) - deleteLogpushJobV2OptionsModel.SetJobID(int64(38)) + deleteLogpushJobV2OptionsModel.SetJobID("testString") deleteLogpushJobV2OptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(deleteLogpushJobV2OptionsModel).ToNot(BeNil()) - Expect(deleteLogpushJobV2OptionsModel.JobID).To(Equal(core.Int64Ptr(int64(38)))) + Expect(deleteLogpushJobV2OptionsModel.JobID).To(Equal(core.StringPtr("testString"))) Expect(deleteLogpushJobV2OptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) - It(`Invoke NewGetLogpushJobOptions successfully`, func() { - // Construct an instance of the GetLogpushJobOptions model - jobID := int64(38) - getLogpushJobOptionsModel := logpushJobsApiService.NewGetLogpushJobOptions(jobID) - getLogpushJobOptionsModel.SetJobID(int64(38)) - getLogpushJobOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) - Expect(getLogpushJobOptionsModel).ToNot(BeNil()) - Expect(getLogpushJobOptionsModel.JobID).To(Equal(core.Int64Ptr(int64(38)))) - Expect(getLogpushJobOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) - }) It(`Invoke NewGetLogpushJobV2Options successfully`, func() { // Construct an instance of the GetLogpushJobV2Options model - jobID := int64(38) + jobID := "testString" getLogpushJobV2OptionsModel := logpushJobsApiService.NewGetLogpushJobV2Options(jobID) - getLogpushJobV2OptionsModel.SetJobID(int64(38)) + getLogpushJobV2OptionsModel.SetJobID("testString") getLogpushJobV2OptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(getLogpushJobV2OptionsModel).ToNot(BeNil()) - Expect(getLogpushJobV2OptionsModel.JobID).To(Equal(core.Int64Ptr(int64(38)))) + Expect(getLogpushJobV2OptionsModel.JobID).To(Equal(core.StringPtr("testString"))) Expect(getLogpushJobV2OptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) - It(`Invoke NewGetLogpushJobsOptions successfully`, func() { - // Construct an instance of the GetLogpushJobsOptions model - getLogpushJobsOptionsModel := logpushJobsApiService.NewGetLogpushJobsOptions() - getLogpushJobsOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) - Expect(getLogpushJobsOptionsModel).ToNot(BeNil()) - Expect(getLogpushJobsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) - }) It(`Invoke NewGetLogpushJobsV2Options successfully`, func() { // Construct an instance of the GetLogpushJobsV2Options model getLogpushJobsV2OptionsModel := logpushJobsApiService.NewGetLogpushJobsV2Options() @@ -4808,15 +3022,6 @@ var _ = Describe(`LogpushJobsApiV1`, func() { Expect(getLogpushJobsV2OptionsModel).ToNot(BeNil()) Expect(getLogpushJobsV2OptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) - It(`Invoke NewGetLogpushOwnershipOptions successfully`, func() { - // Construct an instance of the GetLogpushOwnershipOptions model - getLogpushOwnershipOptionsModel := logpushJobsApiService.NewGetLogpushOwnershipOptions() - getLogpushOwnershipOptionsModel.SetDestinationConf("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea") - getLogpushOwnershipOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) - Expect(getLogpushOwnershipOptionsModel).ToNot(BeNil()) - Expect(getLogpushOwnershipOptionsModel.DestinationConf).To(Equal(core.StringPtr("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea"))) - Expect(getLogpushOwnershipOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) - }) It(`Invoke NewGetLogpushOwnershipV2Options successfully`, func() { // Construct an instance of the GetLogpushOwnershipV2Options model getLogpushOwnershipV2OptionsModel := logpushJobsApiService.NewGetLogpushOwnershipV2Options() @@ -4826,12 +3031,12 @@ var _ = Describe(`LogpushJobsApiV1`, func() { Expect(getLogpushOwnershipV2OptionsModel.Cos).To(Equal(map[string]interface{}{"anyKey": "anyValue"})) Expect(getLogpushOwnershipV2OptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) - It(`Invoke NewListFieldsForDatasetOptions successfully`, func() { - // Construct an instance of the ListFieldsForDatasetOptions model - listFieldsForDatasetOptionsModel := logpushJobsApiService.NewListFieldsForDatasetOptions() - listFieldsForDatasetOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) - Expect(listFieldsForDatasetOptionsModel).ToNot(BeNil()) - Expect(listFieldsForDatasetOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + It(`Invoke NewGetLogsRetentionOptions successfully`, func() { + // Construct an instance of the GetLogsRetentionOptions model + getLogsRetentionOptionsModel := logpushJobsApiService.NewGetLogsRetentionOptions() + getLogsRetentionOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(getLogsRetentionOptionsModel).ToNot(BeNil()) + Expect(getLogsRetentionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewListFieldsForDatasetV2Options successfully`, func() { // Construct an instance of the ListFieldsForDatasetV2Options model @@ -4840,13 +3045,6 @@ var _ = Describe(`LogpushJobsApiV1`, func() { Expect(listFieldsForDatasetV2OptionsModel).ToNot(BeNil()) Expect(listFieldsForDatasetV2OptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) - It(`Invoke NewListLogpushJobsForDatasetOptions successfully`, func() { - // Construct an instance of the ListLogpushJobsForDatasetOptions model - listLogpushJobsForDatasetOptionsModel := logpushJobsApiService.NewListLogpushJobsForDatasetOptions() - listLogpushJobsForDatasetOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) - Expect(listLogpushJobsForDatasetOptionsModel).ToNot(BeNil()) - Expect(listLogpushJobsForDatasetOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) - }) It(`Invoke NewListLogpushJobsForDatasetV2Options successfully`, func() { // Construct an instance of the ListLogpushJobsForDatasetV2Options model listLogpushJobsForDatasetV2OptionsModel := logpushJobsApiService.NewListLogpushJobsForDatasetV2Options() @@ -4854,25 +3052,13 @@ var _ = Describe(`LogpushJobsApiV1`, func() { Expect(listLogpushJobsForDatasetV2OptionsModel).ToNot(BeNil()) Expect(listLogpushJobsForDatasetV2OptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) - It(`Invoke NewUpdateLogpushJobOptions successfully`, func() { - // Construct an instance of the UpdateLogpushJobOptions model - jobID := int64(38) - updateLogpushJobOptionsModel := logpushJobsApiService.NewUpdateLogpushJobOptions(jobID) - updateLogpushJobOptionsModel.SetJobID(int64(38)) - updateLogpushJobOptionsModel.SetEnabled(false) - updateLogpushJobOptionsModel.SetLogpullOptions("timestamps=rfc3339×tamps=rfc3339") - updateLogpushJobOptionsModel.SetDestinationConf("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea") - updateLogpushJobOptionsModel.SetOwnershipChallenge("00000000000000000000000000000000") - updateLogpushJobOptionsModel.SetFrequency("high") - updateLogpushJobOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) - Expect(updateLogpushJobOptionsModel).ToNot(BeNil()) - Expect(updateLogpushJobOptionsModel.JobID).To(Equal(core.Int64Ptr(int64(38)))) - Expect(updateLogpushJobOptionsModel.Enabled).To(Equal(core.BoolPtr(false))) - Expect(updateLogpushJobOptionsModel.LogpullOptions).To(Equal(core.StringPtr("timestamps=rfc3339×tamps=rfc3339"))) - Expect(updateLogpushJobOptionsModel.DestinationConf).To(Equal(core.StringPtr("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea"))) - Expect(updateLogpushJobOptionsModel.OwnershipChallenge).To(Equal(core.StringPtr("00000000000000000000000000000000"))) - Expect(updateLogpushJobOptionsModel.Frequency).To(Equal(core.StringPtr("high"))) - Expect(updateLogpushJobOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + It(`Invoke NewLogpushJobIbmclReqIbmcl successfully`, func() { + instanceID := "90d208cc-e1dd-4fb2-a938-358e5996f056" + region := "eu-es" + apiKey := "XXXXXXXXXXXXXX" + _model, err := logpushJobsApiService.NewLogpushJobIbmclReqIbmcl(instanceID, region, apiKey) + Expect(_model).ToNot(BeNil()) + Expect(err).To(BeNil()) }) It(`Invoke NewUpdateLogpushJobV2Options successfully`, func() { // Construct an instance of the UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq model @@ -4890,27 +3076,16 @@ var _ = Describe(`LogpushJobsApiV1`, func() { Expect(updateLogpushJobV2RequestModel.Frequency).To(Equal(core.StringPtr("high"))) // Construct an instance of the UpdateLogpushJobV2Options model - jobID := int64(38) + jobID := "testString" updateLogpushJobV2OptionsModel := logpushJobsApiService.NewUpdateLogpushJobV2Options(jobID) - updateLogpushJobV2OptionsModel.SetJobID(int64(38)) + updateLogpushJobV2OptionsModel.SetJobID("testString") updateLogpushJobV2OptionsModel.SetUpdateLogpushJobV2Request(updateLogpushJobV2RequestModel) updateLogpushJobV2OptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(updateLogpushJobV2OptionsModel).ToNot(BeNil()) - Expect(updateLogpushJobV2OptionsModel.JobID).To(Equal(core.Int64Ptr(int64(38)))) + Expect(updateLogpushJobV2OptionsModel.JobID).To(Equal(core.StringPtr("testString"))) Expect(updateLogpushJobV2OptionsModel.UpdateLogpushJobV2Request).To(Equal(updateLogpushJobV2RequestModel)) Expect(updateLogpushJobV2OptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) - It(`Invoke NewValidateLogpushOwnershipChallengeOptions successfully`, func() { - // Construct an instance of the ValidateLogpushOwnershipChallengeOptions model - validateLogpushOwnershipChallengeOptionsModel := logpushJobsApiService.NewValidateLogpushOwnershipChallengeOptions() - validateLogpushOwnershipChallengeOptionsModel.SetDestinationConf("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea") - validateLogpushOwnershipChallengeOptionsModel.SetOwnershipChallenge("00000000000000000000") - validateLogpushOwnershipChallengeOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) - Expect(validateLogpushOwnershipChallengeOptionsModel).ToNot(BeNil()) - Expect(validateLogpushOwnershipChallengeOptionsModel.DestinationConf).To(Equal(core.StringPtr("cos://cos-bucket001?region=us-south&instance-id=231f5467-3072-4cb9-9e39-a906fa3032ea"))) - Expect(validateLogpushOwnershipChallengeOptionsModel.OwnershipChallenge).To(Equal(core.StringPtr("00000000000000000000"))) - Expect(validateLogpushOwnershipChallengeOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) - }) It(`Invoke NewValidateLogpushOwnershipChallengeV2Options successfully`, func() { // Construct an instance of the ValidateLogpushOwnershipChallengeV2Options model validateLogpushOwnershipChallengeV2OptionsModel := logpushJobsApiService.NewValidateLogpushOwnershipChallengeV2Options() @@ -4929,6 +3104,17 @@ var _ = Describe(`LogpushJobsApiV1`, func() { Expect(_model).ToNot(BeNil()) Expect(err).To(BeNil()) }) + It(`Invoke NewCreateLogpushJobV2RequestLogpushJobGenericReq successfully`, func() { + destinationConf := "s3://mybucket/logs?region=us-west-2" + _model, err := logpushJobsApiService.NewCreateLogpushJobV2RequestLogpushJobGenericReq(destinationConf) + Expect(_model).ToNot(BeNil()) + Expect(err).To(BeNil()) + }) + It(`Invoke NewCreateLogpushJobV2RequestLogpushJobIbmclReq successfully`, func() { + var ibmcl *logpushjobsapiv1.LogpushJobIbmclReqIbmcl = nil + _, err := logpushJobsApiService.NewCreateLogpushJobV2RequestLogpushJobIbmclReq(ibmcl) + Expect(err).ToNot(BeNil()) + }) It(`Invoke NewCreateLogpushJobV2RequestLogpushJobLogdnaReq successfully`, func() { logdna := map[string]interface{}{"anyKey": "anyValue"} _model, err := logpushJobsApiService.NewCreateLogpushJobV2RequestLogpushJobLogdnaReq(logdna) @@ -4937,9 +3123,285 @@ var _ = Describe(`LogpushJobsApiV1`, func() { }) }) }) + Describe(`Model unmarshaling tests`, func() { + It(`Invoke UnmarshalCreateLogpushJobV2Request successfully`, func() { + // Construct an instance of the model. + model := new(logpushjobsapiv1.CreateLogpushJobV2Request) + model.Name = core.StringPtr("My log push job") + model.Enabled = core.BoolPtr(false) + model.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") + model.Cos = map[string]interface{}{"anyKey": "anyValue"} + model.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") + model.Dataset = core.StringPtr("http_requests") + model.Frequency = core.StringPtr("high") + model.Logdna = map[string]interface{}{"anyKey": "anyValue"} + model.Ibmcl = nil + model.DestinationConf = core.StringPtr("s3://mybucket/logs?region=us-west-2") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *logpushjobsapiv1.CreateLogpushJobV2Request + err = logpushjobsapiv1.UnmarshalCreateLogpushJobV2Request(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalLogpushJobIbmclReqIbmcl successfully`, func() { + // Construct an instance of the model. + model := new(logpushjobsapiv1.LogpushJobIbmclReqIbmcl) + model.InstanceID = core.StringPtr("90d208cc-e1dd-4fb2-a938-358e5996f056") + model.Region = core.StringPtr("eu-es") + model.ApiKey = core.StringPtr("XXXXXXXXXXXXXX") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *logpushjobsapiv1.LogpushJobIbmclReqIbmcl + err = logpushjobsapiv1.UnmarshalLogpushJobIbmclReqIbmcl(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalLogpushJobsUpdateIbmclReqIbmcl successfully`, func() { + // Construct an instance of the model. + model := new(logpushjobsapiv1.LogpushJobsUpdateIbmclReqIbmcl) + model.InstanceID = core.StringPtr("90d208cc-e1dd-4fb2-a938-358e5996f056") + model.Region = core.StringPtr("eu-es") + model.ApiKey = core.StringPtr("XXXXXXXXXXXXXX") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *logpushjobsapiv1.LogpushJobsUpdateIbmclReqIbmcl + err = logpushjobsapiv1.UnmarshalLogpushJobsUpdateIbmclReqIbmcl(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalUpdateLogpushJobV2Request successfully`, func() { + // Construct an instance of the model. + model := new(logpushjobsapiv1.UpdateLogpushJobV2Request) + model.Enabled = core.BoolPtr(false) + model.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") + model.Cos = map[string]interface{}{"anyKey": "anyValue"} + model.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") + model.Frequency = core.StringPtr("high") + model.Logdna = map[string]interface{}{"anyKey": "anyValue"} + model.Ibmcl = nil + model.Name = core.StringPtr("My log push job") + model.DestinationConf = core.StringPtr("s3://mybucket/logs?region=us-west-2") + model.Dataset = core.StringPtr("http_requests") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *logpushjobsapiv1.UpdateLogpushJobV2Request + err = logpushjobsapiv1.UnmarshalUpdateLogpushJobV2Request(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalCreateLogpushJobV2RequestLogpushJobCosReq successfully`, func() { + // Construct an instance of the model. + model := new(logpushjobsapiv1.CreateLogpushJobV2RequestLogpushJobCosReq) + model.Name = core.StringPtr("My log push job") + model.Enabled = core.BoolPtr(false) + model.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") + model.Cos = map[string]interface{}{"anyKey": "anyValue"} + model.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") + model.Dataset = core.StringPtr("http_requests") + model.Frequency = core.StringPtr("high") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *logpushjobsapiv1.CreateLogpushJobV2RequestLogpushJobCosReq + err = logpushjobsapiv1.UnmarshalCreateLogpushJobV2RequestLogpushJobCosReq(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalCreateLogpushJobV2RequestLogpushJobGenericReq successfully`, func() { + // Construct an instance of the model. + model := new(logpushjobsapiv1.CreateLogpushJobV2RequestLogpushJobGenericReq) + model.Name = core.StringPtr("My log push job") + model.Enabled = core.BoolPtr(false) + model.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") + model.DestinationConf = core.StringPtr("s3://mybucket/logs?region=us-west-2") + model.Dataset = core.StringPtr("http_requests") + model.Frequency = core.StringPtr("high") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *logpushjobsapiv1.CreateLogpushJobV2RequestLogpushJobGenericReq + err = logpushjobsapiv1.UnmarshalCreateLogpushJobV2RequestLogpushJobGenericReq(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalCreateLogpushJobV2RequestLogpushJobIbmclReq successfully`, func() { + // Construct an instance of the model. + model := new(logpushjobsapiv1.CreateLogpushJobV2RequestLogpushJobIbmclReq) + model.Name = core.StringPtr("My log push job") + model.Enabled = core.BoolPtr(false) + model.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") + model.Ibmcl = nil + model.Dataset = core.StringPtr("http_requests") + model.Frequency = core.StringPtr("high") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *logpushjobsapiv1.CreateLogpushJobV2RequestLogpushJobIbmclReq + err = logpushjobsapiv1.UnmarshalCreateLogpushJobV2RequestLogpushJobIbmclReq(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalCreateLogpushJobV2RequestLogpushJobLogdnaReq successfully`, func() { + // Construct an instance of the model. + model := new(logpushjobsapiv1.CreateLogpushJobV2RequestLogpushJobLogdnaReq) + model.Name = core.StringPtr("My log push job") + model.Enabled = core.BoolPtr(false) + model.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") + model.Logdna = map[string]interface{}{"anyKey": "anyValue"} + model.Dataset = core.StringPtr("http_requests") + model.Frequency = core.StringPtr("high") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *logpushjobsapiv1.CreateLogpushJobV2RequestLogpushJobLogdnaReq + err = logpushjobsapiv1.UnmarshalCreateLogpushJobV2RequestLogpushJobLogdnaReq(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalUpdateLogpushJobV2RequestLogpushJobsUpdateCosReq successfully`, func() { + // Construct an instance of the model. + model := new(logpushjobsapiv1.UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq) + model.Enabled = core.BoolPtr(false) + model.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") + model.Cos = map[string]interface{}{"anyKey": "anyValue"} + model.OwnershipChallenge = core.StringPtr("00000000000000000000000000000000") + model.Frequency = core.StringPtr("high") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *logpushjobsapiv1.UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq + err = logpushjobsapiv1.UnmarshalUpdateLogpushJobV2RequestLogpushJobsUpdateCosReq(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalUpdateLogpushJobV2RequestLogpushJobsUpdateGenericReq successfully`, func() { + // Construct an instance of the model. + model := new(logpushjobsapiv1.UpdateLogpushJobV2RequestLogpushJobsUpdateGenericReq) + model.Name = core.StringPtr("My log push job") + model.Enabled = core.BoolPtr(false) + model.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") + model.DestinationConf = core.StringPtr("s3://mybucket/logs?region=us-west-2") + model.Dataset = core.StringPtr("http_requests") + model.Frequency = core.StringPtr("high") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *logpushjobsapiv1.UpdateLogpushJobV2RequestLogpushJobsUpdateGenericReq + err = logpushjobsapiv1.UnmarshalUpdateLogpushJobV2RequestLogpushJobsUpdateGenericReq(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalUpdateLogpushJobV2RequestLogpushJobsUpdateIbmclReq successfully`, func() { + // Construct an instance of the model. + model := new(logpushjobsapiv1.UpdateLogpushJobV2RequestLogpushJobsUpdateIbmclReq) + model.Enabled = core.BoolPtr(false) + model.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") + model.Ibmcl = nil + model.Frequency = core.StringPtr("high") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *logpushjobsapiv1.UpdateLogpushJobV2RequestLogpushJobsUpdateIbmclReq + err = logpushjobsapiv1.UnmarshalUpdateLogpushJobV2RequestLogpushJobsUpdateIbmclReq(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + It(`Invoke UnmarshalUpdateLogpushJobV2RequestLogpushJobsUpdateLogdnaReq successfully`, func() { + // Construct an instance of the model. + model := new(logpushjobsapiv1.UpdateLogpushJobV2RequestLogpushJobsUpdateLogdnaReq) + model.Enabled = core.BoolPtr(false) + model.LogpullOptions = core.StringPtr("timestamps=rfc3339×tamps=rfc3339") + model.Logdna = map[string]interface{}{"anyKey": "anyValue"} + model.Frequency = core.StringPtr("high") + + b, err := json.Marshal(model) + Expect(err).To(BeNil()) + + var raw map[string]json.RawMessage + err = json.Unmarshal(b, &raw) + Expect(err).To(BeNil()) + + var result *logpushjobsapiv1.UpdateLogpushJobV2RequestLogpushJobsUpdateLogdnaReq + err = logpushjobsapiv1.UnmarshalUpdateLogpushJobV2RequestLogpushJobsUpdateLogdnaReq(raw, &result) + Expect(err).To(BeNil()) + Expect(result).ToNot(BeNil()) + Expect(result).To(Equal(model)) + }) + }) Describe(`Utility function tests`, func() { It(`Invoke CreateMockByteArray() successfully`, func() { - mockByteArray := CreateMockByteArray("This is a test") + mockByteArray := CreateMockByteArray("VGhpcyBpcyBhIHRlc3Qgb2YgdGhlIGVtZXJnZW5jeSBicm9hZGNhc3Qgc3lzdGVt") Expect(mockByteArray).ToNot(BeNil()) }) It(`Invoke CreateMockUUID() successfully`, func() { @@ -4965,9 +3427,11 @@ var _ = Describe(`LogpushJobsApiV1`, func() { // Utility functions used by the generated test code // -func CreateMockByteArray(mockData string) *[]byte { - ba := make([]byte, 0) - ba = append(ba, mockData...) +func CreateMockByteArray(encodedString string) *[]byte { + ba, err := base64.StdEncoding.DecodeString(encodedString) + if err != nil { + panic(err) + } return &ba } From 5653debc0c5255f7c6bcd580787bca2690a6899f Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Fri, 13 Dec 2024 05:08:13 +0530 Subject: [PATCH 3/4] add integration test --- .../logpush_jobs_api_v1_integration_test.go | 229 ++++++++++++++++-- 1 file changed, 214 insertions(+), 15 deletions(-) diff --git a/logpushjobsapiv1/logpush_jobs_api_v1_integration_test.go b/logpushjobsapiv1/logpush_jobs_api_v1_integration_test.go index c26c83c..7554e75 100644 --- a/logpushjobsapiv1/logpush_jobs_api_v1_integration_test.go +++ b/logpushjobsapiv1/logpush_jobs_api_v1_integration_test.go @@ -19,16 +19,16 @@ package logpushjobsapiv1_test import ( "fmt" "os" + "strconv" "github.com/IBM/go-sdk-core/v5/core" "github.com/IBM/networking-go-sdk/logpushjobsapiv1" - . "github.com/IBM/networking-go-sdk/logpushjobsapiv1" "github.com/joho/godotenv" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) -const configFile = "../cislog.env" +const configFile = "../cis.env" var configLoaded bool = true @@ -41,6 +41,7 @@ func shouldSkipTest() { var _ = Describe(`LogpushJobsApiV1`, func() { defer GinkgoRecover() + //Skip("Skipping") if _, err := os.Stat(configFile); err != nil { configLoaded = false } @@ -52,7 +53,8 @@ var _ = Describe(`LogpushJobsApiV1`, func() { authenticator := &core.IamAuthenticator{ ApiKey: os.Getenv("CIS_SERVICES_APIKEY"), - URL: os.Getenv("CIS_SERVICES_AUTH_URL"), + + URL: os.Getenv("CIS_SERVICES_AUTH_URL"), } crn := os.Getenv("CRN") zoneId := os.Getenv("ZONE_ID") @@ -67,7 +69,7 @@ var _ = Describe(`LogpushJobsApiV1`, func() { dataset := "http_requests" globalOptions := &logpushjobsapiv1.LogpushJobsApiV1Options{ - ServiceName: DefaultServiceName, + ServiceName: logpushjobsapiv1.DefaultServiceName, Crn: &crn, ZoneID: &zoneId, URL: serviceURL, @@ -80,7 +82,6 @@ var _ = Describe(`LogpushJobsApiV1`, func() { Describe(`LogpushJobsApiV1_test`, func() { Context(`LogpushJobsApiV1 All Jobs`, func() { - BeforeEach(func() { shouldSkipTest() //List Logpush Jobs @@ -92,7 +93,7 @@ var _ = Describe(`LogpushJobsApiV1`, func() { //Delete Logpush Jobs for _, job := range result.Result { - delOptions := testService.NewDeleteLogpushJobV2Options(*job.ID) + delOptions := testService.NewDeleteLogpushJobV2Options(strconv.FormatInt(*job.ID, 10)) result, response, deleteErr := testService.DeleteLogpushJobV2(delOptions) Expect(deleteErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -110,7 +111,7 @@ var _ = Describe(`LogpushJobsApiV1`, func() { //Delete all Logpush Jobs for _, job := range result.Result { - delOptions := testService.NewDeleteLogpushJobV2Options(*job.ID) + delOptions := testService.NewDeleteLogpushJobV2Options(strconv.FormatInt(*job.ID, 10)) result, response, deleteErr := testService.DeleteLogpushJobV2(delOptions) Expect(deleteErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -118,11 +119,12 @@ var _ = Describe(`LogpushJobsApiV1`, func() { } }) - It(`create/update/delete/get logpush jobs`, func() { + It(`create/update/delete/get logpush jobs for logdna`, func() { + Skip("skipping") shouldSkipTest() options := testService.NewCreateLogpushJobV2Options() - createLogpushJobV2RequestModel := &CreateLogpushJobV2RequestLogpushJobLogdnaReq{ + createLogpushJobV2RequestModel := &logpushjobsapiv1.CreateLogpushJobV2RequestLogpushJobLogdnaReq{ Name: core.StringPtr("Test123"), Enabled: core.BoolPtr(false), @@ -151,15 +153,15 @@ var _ = Describe(`LogpushJobsApiV1`, func() { // Get Logpush Job by jobID getJob := allJobs[0] - getOptions := testService.NewGetLogpushJobV2Options(*getJob.ID) + getOptions := testService.NewGetLogpushJobV2Options(strconv.FormatInt(*getJob.ID, 10)) result, response, operationErr = testService.GetLogpushJobV2(getOptions) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) //Update Logpush Jobs - updateOptions := testService.NewUpdateLogpushJobV2Options(*job.ID) - updateLogpushJobV2RequestModel := &UpdateLogpushJobV2RequestLogpushJobsUpdateLogdnaReq{ + updateOptions := testService.NewUpdateLogpushJobV2Options(strconv.FormatInt(*job.ID, 10)) + updateLogpushJobV2RequestModel := &logpushjobsapiv1.UpdateLogpushJobV2RequestLogpushJobsUpdateLogdnaReq{ Enabled: core.BoolPtr(false), LogpullOptions: core.StringPtr("timestamps=rfc3339×tamps=rfc3339"), Logdna: map[string]interface{}{"ingress_key": IngressKey, "region": LogdnaRegion, "hostname": LogdnaDomain}, @@ -175,9 +177,205 @@ var _ = Describe(`LogpushJobsApiV1`, func() { //Delete Logpush Jobs for _, thisJob := range allJobs { - delOptions := testService.NewDeleteLogpushJobV2Options(*thisJob.ID) - delResult, delResponse, delReleteErr := testService.DeleteLogpushJobV2(delOptions) - Expect(delReleteErr).To(BeNil()) + delOptions := testService.NewDeleteLogpushJobV2Options(strconv.FormatInt(*thisJob.ID, 10)) + delResult, delResponse, delErr := testService.DeleteLogpushJobV2(delOptions) + Expect(delErr).To(BeNil()) + Expect(delResponse).ToNot(BeNil()) + Expect(delResult).ToNot(BeNil()) + } + }) + + It(`create/update/delete/get logpush jobs for general`, func() { + Skip("skipping") + shouldSkipTest() + + options := testService.NewCreateLogpushJobV2Options() + createLogpushJobV2RequestGenericModel := &logpushjobsapiv1.CreateLogpushJobV2RequestLogpushJobGenericReq{ + + Name: core.StringPtr("Test123"), + Enabled: core.BoolPtr(false), + LogpullOptions: core.StringPtr("timestamps=rfc3339×tamps=rfc3339"), + DestinationConf: core.StringPtr("s3://mybucket/logs?region=us-west-2"), + Dataset: core.StringPtr("http_requests"), + Frequency: core.StringPtr("high"), + } + + options.SetCreateLogpushJobV2Request(createLogpushJobV2RequestGenericModel) + result, response, operationErr := testService.CreateLogpushJobV2(options) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + job := result.Result + + // List all Logpush Jobs + listOptions := testService.NewGetLogpushJobsV2Options() + getResult, getResponse, getErr := testService.GetLogpushJobsV2(listOptions) + Expect(getErr).To(BeNil()) + Expect(getResponse).ToNot(BeNil()) + Expect(getResult).ToNot(BeNil()) + + allJobs := getResult.Result + + // Get Logpush Job by jobID + getJob := allJobs[0] + getOptions := testService.NewGetLogpushJobV2Options(strconv.FormatInt(*getJob.ID, 10)) + result, response, operationErr = testService.GetLogpushJobV2(getOptions) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + //Update Logpush Jobs + updateOptions := testService.NewUpdateLogpushJobV2Options(strconv.FormatInt(*job.ID, 10)) + updateLogpushJobV2RequestGenericModel := &logpushjobsapiv1.UpdateLogpushJobV2RequestLogpushJobsUpdateGenericReq{ + Enabled: core.BoolPtr(false), + LogpullOptions: core.StringPtr("timestamps=rfc3339×tamps=rfc3339"), + DestinationConf: core.StringPtr("s3://mybucket/logs?region=us-west-1"), + Frequency: core.StringPtr("high"), + } + + updateOptions.SetUpdateLogpushJobV2Request(updateLogpushJobV2RequestGenericModel) + + updateResult, updateResponse, updateErr := testService.UpdateLogpushJobV2(updateOptions) + Expect(updateErr).To(BeNil()) + Expect(updateResponse).ToNot(BeNil()) + Expect(updateResult).ToNot(BeNil()) + + //Delete Logpush Jobs + for _, thisJob := range allJobs { + delOptions := testService.NewDeleteLogpushJobV2Options(strconv.FormatInt(*thisJob.ID, 10)) + delResult, delResponse, delErr := testService.DeleteLogpushJobV2(delOptions) + Expect(delErr).To(BeNil()) + Expect(delResponse).ToNot(BeNil()) + Expect(delResult).ToNot(BeNil()) + } + }) + + It(`create/update/delete/get logpush jobs for cos`, func() { + Skip("skipping") + shouldSkipTest() + + options := testService.NewCreateLogpushJobV2Options() + createLogpushJobV2RequestCosModel := &logpushjobsapiv1.CreateLogpushJobV2RequestLogpushJobCosReq{ + + Name: core.StringPtr("Test123"), + Enabled: core.BoolPtr(false), + LogpullOptions: core.StringPtr("timestamps=rfc3339×tamps=rfc3339"), + Cos: map[string]interface{}{"bucket_name": "cos-bucket001", "region": "us-south", "id": "231f5467-3072-4cb9-9e39-a906fa3032ea"}, + Dataset: core.StringPtr("http_requests"), + Frequency: core.StringPtr("high"), + OwnershipChallenge: core.StringPtr("xxxxx"), + } + + options.SetCreateLogpushJobV2Request(createLogpushJobV2RequestCosModel) + result, response, operationErr := testService.CreateLogpushJobV2(options) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + job := result.Result + + // List all Logpush Jobs + listOptions := testService.NewGetLogpushJobsV2Options() + getResult, getResponse, getErr := testService.GetLogpushJobsV2(listOptions) + Expect(getErr).To(BeNil()) + Expect(getResponse).ToNot(BeNil()) + Expect(getResult).ToNot(BeNil()) + + allJobs := getResult.Result + + // Get Logpush Job by jobID + getJob := allJobs[0] + getOptions := testService.NewGetLogpushJobV2Options(strconv.FormatInt(*getJob.ID, 10)) + result, response, operationErr = testService.GetLogpushJobV2(getOptions) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + //Update Logpush Jobs + updateOptions := testService.NewUpdateLogpushJobV2Options(strconv.FormatInt(*job.ID, 10)) + updateLogpushJobV2RequestCosModel := &logpushjobsapiv1.UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq{ + Enabled: core.BoolPtr(false), + LogpullOptions: core.StringPtr("timestamps=rfc3339×tamps=rfc3339"), + Frequency: core.StringPtr("low"), + } + + updateOptions.SetUpdateLogpushJobV2Request(updateLogpushJobV2RequestCosModel) + + updateResult, updateResponse, updateErr := testService.UpdateLogpushJobV2(updateOptions) + Expect(updateErr).To(BeNil()) + Expect(updateResponse).ToNot(BeNil()) + Expect(updateResult).ToNot(BeNil()) + + //Delete Logpush Jobs + for _, thisJob := range allJobs { + delOptions := testService.NewDeleteLogpushJobV2Options(strconv.FormatInt(*thisJob.ID, 10)) + delResult, delResponse, delErr := testService.DeleteLogpushJobV2(delOptions) + Expect(delErr).To(BeNil()) + Expect(delResponse).ToNot(BeNil()) + Expect(delResult).ToNot(BeNil()) + } + }) + + It(`create/update/delete/get logpush jobs for ibmcl`, func() { + shouldSkipTest() + + options := testService.NewCreateLogpushJobV2Options() + createLogpushJobV2RequestCosModel := &logpushjobsapiv1.CreateLogpushJobV2RequestLogpushJobIbmclReq{ + + Name: core.StringPtr("Test123"), + Enabled: core.BoolPtr(false), + LogpullOptions: core.StringPtr("timestamps=rfc3339×tamps=rfc3339"), + Ibmcl: &logpushjobsapiv1.LogpushJobIbmclReqIbmcl{InstanceID: core.StringPtr(os.Getenv("CIS_IBMCL_INSTANCE_ID")), Region: core.StringPtr("us-south"), ApiKey: core.StringPtr(os.Getenv("CIS_SERVICES_APIKEY"))}, + Dataset: core.StringPtr("http_requests"), + Frequency: core.StringPtr("high"), + } + + options.SetCreateLogpushJobV2Request(createLogpushJobV2RequestCosModel) + result, response, operationErr := testService.CreateLogpushJobV2(options) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + job := result.Result + + // List all Logpush Jobs + listOptions := testService.NewGetLogpushJobsV2Options() + getResult, getResponse, getErr := testService.GetLogpushJobsV2(listOptions) + Expect(getErr).To(BeNil()) + Expect(getResponse).ToNot(BeNil()) + Expect(getResult).ToNot(BeNil()) + + allJobs := getResult.Result + + // Get Logpush Job by jobID + getJob := allJobs[0] + getOptions := testService.NewGetLogpushJobV2Options(strconv.FormatInt(*getJob.ID, 10)) + result, response, operationErr = testService.GetLogpushJobV2(getOptions) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + //Update Logpush Jobs + updateOptions := testService.NewUpdateLogpushJobV2Options(strconv.FormatInt(*job.ID, 10)) + updateLogpushJobV2RequestCosModel := &logpushjobsapiv1.UpdateLogpushJobV2RequestLogpushJobsUpdateCosReq{ + Enabled: core.BoolPtr(false), + LogpullOptions: core.StringPtr("timestamps=rfc3339×tamps=rfc3339"), + Frequency: core.StringPtr("low"), + } + + updateOptions.SetUpdateLogpushJobV2Request(updateLogpushJobV2RequestCosModel) + + updateResult, updateResponse, updateErr := testService.UpdateLogpushJobV2(updateOptions) + Expect(updateErr).To(BeNil()) + Expect(updateResponse).ToNot(BeNil()) + Expect(updateResult).ToNot(BeNil()) + + //Delete Logpush Jobs + for _, thisJob := range allJobs { + delOptions := testService.NewDeleteLogpushJobV2Options(strconv.FormatInt(*thisJob.ID, 10)) + delResult, delResponse, delErr := testService.DeleteLogpushJobV2(delOptions) + Expect(delErr).To(BeNil()) Expect(delResponse).ToNot(BeNil()) Expect(delResult).ToNot(BeNil()) } @@ -230,6 +428,7 @@ var _ = Describe(`LogpushJobsApiV1`, func() { // fmt.Println(jobsResponse) fmt.Println(jobsResult) }) + }) }) }) From d867664280abfb40b0a8a2a38a19952170434c63 Mon Sep 17 00:00:00 2001 From: Arjun Chauhan Date: Fri, 13 Dec 2024 05:08:42 +0530 Subject: [PATCH 4/4] go mod dependency --- common/headers.go | 19 +++++++++++++------ go.mod | 2 +- go.sum | 8 ++------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/common/headers.go b/common/headers.go index 0ce39a8..8c06e12 100644 --- a/common/headers.go +++ b/common/headers.go @@ -19,14 +19,15 @@ package common import ( "fmt" "runtime" + + "github.com/IBM/go-sdk-core/v5/core" ) const ( - sdkName = "networking-go-sdk" + sdkName = "networking-go-sdk" headerNameUserAgent = "User-Agent" ) -// // GetSdkHeaders - returns the set of SDK-specific headers to be included in an outgoing request. // // This function is invoked by generated service methods (i.e. methods which implement the REST API operations @@ -54,13 +55,14 @@ const ( // as the analytics data collector uses this to gather usage data. // // Parameters: -// serviceName - the name of the service as defined in the API definition (e.g. "MyService1") -// serviceVersion - the version of the service as defined in the API definition (e.g. "V1") -// operationId - the operationId as defined in the API definition (e.g. getContext) +// +// serviceName - the name of the service as defined in the API definition (e.g. "MyService1") +// serviceVersion - the version of the service as defined in the API definition (e.g. "V1") +// operationId - the operationId as defined in the API definition (e.g. getContext) // // Returns: -// a Map which contains the set of headers to be included in the REST API request // +// a Map which contains the set of headers to be included in the REST API request func GetSdkHeaders(serviceName string, serviceVersion string, operationId string) map[string]string { sdkHeaders := make(map[string]string) @@ -80,3 +82,8 @@ var systemInfo = fmt.Sprintf("(lang=go; arch=%s; os=%s; go.version=%s)", runtime func GetSystemInfo() string { return systemInfo } + +func GetComponentInfo() *core.ProblemComponent { + // This should match the module name in go.mod. + return core.NewProblemComponent("github.com/IBM/networking-go-sdk", Version) +} diff --git a/go.mod b/go.mod index b6c15a2..08f5d84 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/IBM/networking-go-sdk go 1.22.4 require ( - github.com/IBM/go-sdk-core/v5 v5.17.3 + github.com/IBM/go-sdk-core/v5 v5.17.5 github.com/go-openapi/strfmt v0.22.1 github.com/google/uuid v1.6.0 github.com/joho/godotenv v1.5.1 diff --git a/go.sum b/go.sum index 31ed7a7..d4338e8 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,5 @@ -github.com/IBM/go-sdk-core/v5 v5.16.5 h1:5ZltNcryRI8kVcuvNJGR2EXKqb7HtM4atA0Nm5QwAFE= -github.com/IBM/go-sdk-core/v5 v5.16.5/go.mod h1:GatGZpxlo1KaxiRN6E10/rNgWtUtx1hN/GoHSCaSPKA= -github.com/IBM/go-sdk-core/v5 v5.17.3 h1:CZSVCKzhQc/hRQZOtuEmi9dlNtWMnxJvOsPtQKP7cZ4= -github.com/IBM/go-sdk-core/v5 v5.17.3/go.mod h1:GatGZpxlo1KaxiRN6E10/rNgWtUtx1hN/GoHSCaSPKA= +github.com/IBM/go-sdk-core/v5 v5.17.5 h1:AjGC7xNee5tgDIjndekBDW5AbypdERHSgib3EZ1KNsA= +github.com/IBM/go-sdk-core/v5 v5.17.5/go.mod h1:KsAAI7eStAWwQa4F96MLy+whYSh39JzNjklZRbN/8ns= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -57,8 +55,6 @@ github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVH github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU= github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= -github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=