|
| 1 | +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. |
| 2 | +// This product includes software developed at Datadog (https://www.datadoghq.com/). |
| 3 | +// Copyright 2019-Present Datadog, Inc. |
| 4 | + |
| 5 | +package datadogV2 |
| 6 | + |
| 7 | +import ( |
| 8 | + _context "context" |
| 9 | + _fmt "fmt" |
| 10 | + _log "log" |
| 11 | + _nethttp "net/http" |
| 12 | + _neturl "net/url" |
| 13 | + |
| 14 | + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" |
| 15 | +) |
| 16 | + |
| 17 | +// RumReplayApi service type |
| 18 | +type RumReplayApi datadog.Service |
| 19 | + |
| 20 | +// GenerateReplaySummaryOptionalParameters holds optional parameters for GenerateReplaySummary. |
| 21 | +type GenerateReplaySummaryOptionalParameters struct { |
| 22 | + Ts *int64 |
| 23 | +} |
| 24 | + |
| 25 | +// NewGenerateReplaySummaryOptionalParameters creates an empty struct for parameters. |
| 26 | +func NewGenerateReplaySummaryOptionalParameters() *GenerateReplaySummaryOptionalParameters { |
| 27 | + this := GenerateReplaySummaryOptionalParameters{} |
| 28 | + return &this |
| 29 | +} |
| 30 | + |
| 31 | +// WithTs sets the corresponding parameter name and returns the struct. |
| 32 | +func (r *GenerateReplaySummaryOptionalParameters) WithTs(ts int64) *GenerateReplaySummaryOptionalParameters { |
| 33 | + r.Ts = &ts |
| 34 | + return r |
| 35 | +} |
| 36 | + |
| 37 | +// GenerateReplaySummary Generate replay summary. |
| 38 | +// Generate an AI-powered summary for a RUM replay session, including chapter breakdowns and behavioral analysis. |
| 39 | +func (a *RumReplayApi) GenerateReplaySummary(ctx _context.Context, sessionId string, dataSource string, body ReplaySummaryRequest, o ...GenerateReplaySummaryOptionalParameters) (ReplaySummaryResponse, *_nethttp.Response, error) { |
| 40 | + var ( |
| 41 | + localVarHTTPMethod = _nethttp.MethodPost |
| 42 | + localVarPostBody interface{} |
| 43 | + localVarReturnValue ReplaySummaryResponse |
| 44 | + optionalParams GenerateReplaySummaryOptionalParameters |
| 45 | + ) |
| 46 | + |
| 47 | + if len(o) > 1 { |
| 48 | + return localVarReturnValue, nil, datadog.ReportError("only one argument of type GenerateReplaySummaryOptionalParameters is allowed") |
| 49 | + } |
| 50 | + if len(o) == 1 { |
| 51 | + optionalParams = o[0] |
| 52 | + } |
| 53 | + |
| 54 | + operationId := "v2.GenerateReplaySummary" |
| 55 | + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) |
| 56 | + if !isOperationEnabled { |
| 57 | + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} |
| 58 | + } |
| 59 | + if isOperationEnabled && a.Client.Cfg.Debug { |
| 60 | + _log.Printf("WARNING: Using unstable operation '%s'", operationId) |
| 61 | + } |
| 62 | + |
| 63 | + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.RumReplayApi.GenerateReplaySummary") |
| 64 | + if err != nil { |
| 65 | + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} |
| 66 | + } |
| 67 | + |
| 68 | + localVarPath := localBasePath + "/api/v2/replay/summary/{session_id}" |
| 69 | + localVarPath = datadog.ReplacePathParameter(localVarPath, "{session_id}", _neturl.PathEscape(datadog.ParameterToString(sessionId, ""))) |
| 70 | + |
| 71 | + localVarHeaderParams := make(map[string]string) |
| 72 | + localVarQueryParams := _neturl.Values{} |
| 73 | + localVarFormParams := _neturl.Values{} |
| 74 | + localVarQueryParams.Add("data_source", datadog.ParameterToString(dataSource, "")) |
| 75 | + if optionalParams.Ts != nil { |
| 76 | + localVarQueryParams.Add("ts", datadog.ParameterToString(*optionalParams.Ts, "")) |
| 77 | + } |
| 78 | + localVarHeaderParams["Content-Type"] = "application/json" |
| 79 | + localVarHeaderParams["Accept"] = "application/json" |
| 80 | + |
| 81 | + // body params |
| 82 | + localVarPostBody = &body |
| 83 | + if a.Client.Cfg.DelegatedTokenConfig != nil { |
| 84 | + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) |
| 85 | + if err != nil { |
| 86 | + return localVarReturnValue, nil, err |
| 87 | + } |
| 88 | + } else { |
| 89 | + datadog.SetAuthKeys( |
| 90 | + ctx, |
| 91 | + &localVarHeaderParams, |
| 92 | + [2]string{"apiKeyAuth", "DD-API-KEY"}, |
| 93 | + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, |
| 94 | + ) |
| 95 | + } |
| 96 | + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) |
| 97 | + if err != nil { |
| 98 | + return localVarReturnValue, nil, err |
| 99 | + } |
| 100 | + |
| 101 | + localVarHTTPResponse, err := a.Client.CallAPI(req) |
| 102 | + if err != nil || localVarHTTPResponse == nil { |
| 103 | + return localVarReturnValue, localVarHTTPResponse, err |
| 104 | + } |
| 105 | + |
| 106 | + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) |
| 107 | + if err != nil { |
| 108 | + return localVarReturnValue, localVarHTTPResponse, err |
| 109 | + } |
| 110 | + |
| 111 | + if localVarHTTPResponse.StatusCode >= 300 { |
| 112 | + newErr := datadog.GenericOpenAPIError{ |
| 113 | + ErrorBody: localVarBody, |
| 114 | + ErrorMessage: localVarHTTPResponse.Status, |
| 115 | + } |
| 116 | + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 { |
| 117 | + var v JSONAPIErrorResponse |
| 118 | + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) |
| 119 | + if err != nil { |
| 120 | + return localVarReturnValue, localVarHTTPResponse, newErr |
| 121 | + } |
| 122 | + newErr.ErrorModel = v |
| 123 | + return localVarReturnValue, localVarHTTPResponse, newErr |
| 124 | + } |
| 125 | + if localVarHTTPResponse.StatusCode == 429 { |
| 126 | + var v APIErrorResponse |
| 127 | + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) |
| 128 | + if err != nil { |
| 129 | + return localVarReturnValue, localVarHTTPResponse, newErr |
| 130 | + } |
| 131 | + newErr.ErrorModel = v |
| 132 | + } |
| 133 | + return localVarReturnValue, localVarHTTPResponse, newErr |
| 134 | + } |
| 135 | + |
| 136 | + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) |
| 137 | + if err != nil { |
| 138 | + newErr := datadog.GenericOpenAPIError{ |
| 139 | + ErrorBody: localVarBody, |
| 140 | + ErrorMessage: err.Error(), |
| 141 | + } |
| 142 | + return localVarReturnValue, localVarHTTPResponse, newErr |
| 143 | + } |
| 144 | + |
| 145 | + return localVarReturnValue, localVarHTTPResponse, nil |
| 146 | +} |
| 147 | + |
| 148 | +// NewRumReplayApi Returns NewRumReplayApi. |
| 149 | +func NewRumReplayApi(client *datadog.APIClient) *RumReplayApi { |
| 150 | + return &RumReplayApi{ |
| 151 | + Client: client, |
| 152 | + } |
| 153 | +} |
0 commit comments