/*
Data Streaming - OpenAPI

The Data Streaming API allows you to manage your existing data streamings and templates. Data Streaming allows you to feed your stream processing, SIEM, and big data platforms with the event logs from your applications on Azion in real time. 

API version: 1.0.0
*/

// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.

package data_streaming

import (
	"bytes"
	"context"
	"io"
	"net/http"
	"net/url"
	"strings"
)


// DataStreamingAPIService DataStreamingAPI service
type DataStreamingAPIService service

type ApiCreateNewDataStreamingRequest struct {
	ctx context.Context
	ApiService *DataStreamingAPIService
	createNewDataStreamingRequest *CreateNewDataStreamingRequest
}

func (r ApiCreateNewDataStreamingRequest) CreateNewDataStreamingRequest(createNewDataStreamingRequest CreateNewDataStreamingRequest) ApiCreateNewDataStreamingRequest {
	r.createNewDataStreamingRequest = &createNewDataStreamingRequest
	return r
}

func (r ApiCreateNewDataStreamingRequest) Execute() (*CreateNewDataStreaming201Response, *http.Response, error) {
	return r.ApiService.CreateNewDataStreamingExecute(r)
}

/*
CreateNewDataStreaming Create a new data streaming

Create a new data streaming.

 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 @return ApiCreateNewDataStreamingRequest
*/
func (a *DataStreamingAPIService) CreateNewDataStreaming(ctx context.Context) ApiCreateNewDataStreamingRequest {
	return ApiCreateNewDataStreamingRequest{
		ApiService: a,
		ctx: ctx,
	}
}

// Execute executes the request
//  @return CreateNewDataStreaming201Response
func (a *DataStreamingAPIService) CreateNewDataStreamingExecute(r ApiCreateNewDataStreamingRequest) (*CreateNewDataStreaming201Response, *http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodPost
		localVarPostBody     interface{}
		formFiles            []formFile
		localVarReturnValue  *CreateNewDataStreaming201Response
	)

	localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DataStreamingAPIService.CreateNewDataStreaming")
	if err != nil {
		return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
	}

	localVarPath := localBasePath + "/data_streaming/streamings"

	localVarHeaderParams := make(map[string]string)
	localVarQueryParams := url.Values{}
	localVarFormParams := url.Values{}
	if r.createNewDataStreamingRequest == nil {
		return localVarReturnValue, nil, reportError("createNewDataStreamingRequest is required and must be specified")
	}

	// to determine the Content-Type header
	localVarHTTPContentTypes := []string{"application/json"}

	// set Content-Type header
	localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
	if localVarHTTPContentType != "" {
		localVarHeaderParams["Content-Type"] = localVarHTTPContentType
	}

	// to determine the Accept header
	localVarHTTPHeaderAccepts := []string{"application/json"}

	// set Accept header
	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
	if localVarHTTPHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
	}
	// body params
	localVarPostBody = r.createNewDataStreamingRequest
	if r.ctx != nil {
		// API Key Authentication
		if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
			if apiKey, ok := auth["tokenAuth"]; ok {
				var key string
				if apiKey.Prefix != "" {
					key = apiKey.Prefix + " " + apiKey.Key
				} else {
					key = apiKey.Key
				}
				localVarHeaderParams["Authorization"] = key
			}
		}
	}
	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
	if err != nil {
		return localVarReturnValue, nil, err
	}

	localVarHTTPResponse, err := a.client.callAPI(req)
	if err != nil || localVarHTTPResponse == nil {
		return localVarReturnValue, localVarHTTPResponse, err
	}

	localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
	localVarHTTPResponse.Body.Close()
	localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
	if err != nil {
		return localVarReturnValue, localVarHTTPResponse, err
	}

	if localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		return localVarReturnValue, localVarHTTPResponse, newErr
	}

	err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
	if err != nil {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: err.Error(),
		}
		return localVarReturnValue, localVarHTTPResponse, newErr
	}

	return localVarReturnValue, localVarHTTPResponse, nil
}

type ApiDeleteDataStreamingByIdRequest struct {
	ctx context.Context
	ApiService *DataStreamingAPIService
	dataStreamingId int32
}

func (r ApiDeleteDataStreamingByIdRequest) Execute() (*http.Response, error) {
	return r.ApiService.DeleteDataStreamingByIdExecute(r)
}

/*
DeleteDataStreamingById Delete data streaming

Use the DELETE method to remove a data streaming from your account.


 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 @param dataStreamingId
 @return ApiDeleteDataStreamingByIdRequest
*/
func (a *DataStreamingAPIService) DeleteDataStreamingById(ctx context.Context, dataStreamingId int32) ApiDeleteDataStreamingByIdRequest {
	return ApiDeleteDataStreamingByIdRequest{
		ApiService: a,
		ctx: ctx,
		dataStreamingId: dataStreamingId,
	}
}

// Execute executes the request
func (a *DataStreamingAPIService) DeleteDataStreamingByIdExecute(r ApiDeleteDataStreamingByIdRequest) (*http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodDelete
		localVarPostBody     interface{}
		formFiles            []formFile
	)

	localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DataStreamingAPIService.DeleteDataStreamingById")
	if err != nil {
		return nil, &GenericOpenAPIError{error: err.Error()}
	}

	localVarPath := localBasePath + "/data_streaming/streamings/{data_streaming_id}"
	localVarPath = strings.Replace(localVarPath, "{"+"data_streaming_id"+"}", url.PathEscape(parameterValueToString(r.dataStreamingId, "dataStreamingId")), -1)

	localVarHeaderParams := make(map[string]string)
	localVarQueryParams := url.Values{}
	localVarFormParams := url.Values{}

	// to determine the Content-Type header
	localVarHTTPContentTypes := []string{}

	// set Content-Type header
	localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
	if localVarHTTPContentType != "" {
		localVarHeaderParams["Content-Type"] = localVarHTTPContentType
	}

	// to determine the Accept header
	localVarHTTPHeaderAccepts := []string{}

	// set Accept header
	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
	if localVarHTTPHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
	}
	if r.ctx != nil {
		// API Key Authentication
		if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
			if apiKey, ok := auth["tokenAuth"]; ok {
				var key string
				if apiKey.Prefix != "" {
					key = apiKey.Prefix + " " + apiKey.Key
				} else {
					key = apiKey.Key
				}
				localVarHeaderParams["Authorization"] = key
			}
		}
	}
	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
	if err != nil {
		return nil, err
	}

	localVarHTTPResponse, err := a.client.callAPI(req)
	if err != nil || localVarHTTPResponse == nil {
		return localVarHTTPResponse, err
	}

	localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
	localVarHTTPResponse.Body.Close()
	localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
	if err != nil {
		return localVarHTTPResponse, err
	}

	if localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		return localVarHTTPResponse, newErr
	}

	return localVarHTTPResponse, nil
}

type ApiEditDataStreamingByIdRequest struct {
	ctx context.Context
	ApiService *DataStreamingAPIService
	dataStreamingId int32
	createNewDataStreamingRequest *CreateNewDataStreamingRequest
}

func (r ApiEditDataStreamingByIdRequest) CreateNewDataStreamingRequest(createNewDataStreamingRequest CreateNewDataStreamingRequest) ApiEditDataStreamingByIdRequest {
	r.createNewDataStreamingRequest = &createNewDataStreamingRequest
	return r
}

func (r ApiEditDataStreamingByIdRequest) Execute() (*CreateNewDataStreaming201Response, *http.Response, error) {
	return r.ApiService.EditDataStreamingByIdExecute(r)
}

/*
EditDataStreamingById Edit data streaming

Use the PATCH method to change only select settings of your data streaming.


 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 @param dataStreamingId
 @return ApiEditDataStreamingByIdRequest
*/
func (a *DataStreamingAPIService) EditDataStreamingById(ctx context.Context, dataStreamingId int32) ApiEditDataStreamingByIdRequest {
	return ApiEditDataStreamingByIdRequest{
		ApiService: a,
		ctx: ctx,
		dataStreamingId: dataStreamingId,
	}
}

// Execute executes the request
//  @return CreateNewDataStreaming201Response
func (a *DataStreamingAPIService) EditDataStreamingByIdExecute(r ApiEditDataStreamingByIdRequest) (*CreateNewDataStreaming201Response, *http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodPatch
		localVarPostBody     interface{}
		formFiles            []formFile
		localVarReturnValue  *CreateNewDataStreaming201Response
	)

	localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DataStreamingAPIService.EditDataStreamingById")
	if err != nil {
		return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
	}

	localVarPath := localBasePath + "/data_streaming/streamings/{data_streaming_id}"
	localVarPath = strings.Replace(localVarPath, "{"+"data_streaming_id"+"}", url.PathEscape(parameterValueToString(r.dataStreamingId, "dataStreamingId")), -1)

	localVarHeaderParams := make(map[string]string)
	localVarQueryParams := url.Values{}
	localVarFormParams := url.Values{}
	if r.createNewDataStreamingRequest == nil {
		return localVarReturnValue, nil, reportError("createNewDataStreamingRequest is required and must be specified")
	}

	// to determine the Content-Type header
	localVarHTTPContentTypes := []string{"application/json"}

	// set Content-Type header
	localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
	if localVarHTTPContentType != "" {
		localVarHeaderParams["Content-Type"] = localVarHTTPContentType
	}

	// to determine the Accept header
	localVarHTTPHeaderAccepts := []string{"application/json"}

	// set Accept header
	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
	if localVarHTTPHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
	}
	// body params
	localVarPostBody = r.createNewDataStreamingRequest
	if r.ctx != nil {
		// API Key Authentication
		if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
			if apiKey, ok := auth["tokenAuth"]; ok {
				var key string
				if apiKey.Prefix != "" {
					key = apiKey.Prefix + " " + apiKey.Key
				} else {
					key = apiKey.Key
				}
				localVarHeaderParams["Authorization"] = key
			}
		}
	}
	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
	if err != nil {
		return localVarReturnValue, nil, err
	}

	localVarHTTPResponse, err := a.client.callAPI(req)
	if err != nil || localVarHTTPResponse == nil {
		return localVarReturnValue, localVarHTTPResponse, err
	}

	localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
	localVarHTTPResponse.Body.Close()
	localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
	if err != nil {
		return localVarReturnValue, localVarHTTPResponse, err
	}

	if localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		return localVarReturnValue, localVarHTTPResponse, newErr
	}

	err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
	if err != nil {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: err.Error(),
		}
		return localVarReturnValue, localVarHTTPResponse, newErr
	}

	return localVarReturnValue, localVarHTTPResponse, nil
}

type ApiListDataStreamingByIdRequest struct {
	ctx context.Context
	ApiService *DataStreamingAPIService
	dataStreamingId int32
}

func (r ApiListDataStreamingByIdRequest) Execute() (*DataStreamingsById, *http.Response, error) {
	return r.ApiService.ListDataStreamingByIdExecute(r)
}

/*
ListDataStreamingById Get expecific data streaming by Data Streaming ID

Use the GET method and add the data streaming's ID to the URI of the request to get more data on a specific data streaming.

 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 @param dataStreamingId
 @return ApiListDataStreamingByIdRequest
*/
func (a *DataStreamingAPIService) ListDataStreamingById(ctx context.Context, dataStreamingId int32) ApiListDataStreamingByIdRequest {
	return ApiListDataStreamingByIdRequest{
		ApiService: a,
		ctx: ctx,
		dataStreamingId: dataStreamingId,
	}
}

// Execute executes the request
//  @return DataStreamingsById
func (a *DataStreamingAPIService) ListDataStreamingByIdExecute(r ApiListDataStreamingByIdRequest) (*DataStreamingsById, *http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodGet
		localVarPostBody     interface{}
		formFiles            []formFile
		localVarReturnValue  *DataStreamingsById
	)

	localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DataStreamingAPIService.ListDataStreamingById")
	if err != nil {
		return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
	}

	localVarPath := localBasePath + "/data_streaming/streamings/{data_streaming_id}"
	localVarPath = strings.Replace(localVarPath, "{"+"data_streaming_id"+"}", url.PathEscape(parameterValueToString(r.dataStreamingId, "dataStreamingId")), -1)

	localVarHeaderParams := make(map[string]string)
	localVarQueryParams := url.Values{}
	localVarFormParams := url.Values{}

	// to determine the Content-Type header
	localVarHTTPContentTypes := []string{}

	// set Content-Type header
	localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
	if localVarHTTPContentType != "" {
		localVarHeaderParams["Content-Type"] = localVarHTTPContentType
	}

	// to determine the Accept header
	localVarHTTPHeaderAccepts := []string{"application/json"}

	// set Accept header
	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
	if localVarHTTPHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
	}
	if r.ctx != nil {
		// API Key Authentication
		if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
			if apiKey, ok := auth["tokenAuth"]; ok {
				var key string
				if apiKey.Prefix != "" {
					key = apiKey.Prefix + " " + apiKey.Key
				} else {
					key = apiKey.Key
				}
				localVarHeaderParams["Authorization"] = key
			}
		}
	}
	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
	if err != nil {
		return localVarReturnValue, nil, err
	}

	localVarHTTPResponse, err := a.client.callAPI(req)
	if err != nil || localVarHTTPResponse == nil {
		return localVarReturnValue, localVarHTTPResponse, err
	}

	localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
	localVarHTTPResponse.Body.Close()
	localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
	if err != nil {
		return localVarReturnValue, localVarHTTPResponse, err
	}

	if localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		return localVarReturnValue, localVarHTTPResponse, newErr
	}

	err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
	if err != nil {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: err.Error(),
		}
		return localVarReturnValue, localVarHTTPResponse, newErr
	}

	return localVarReturnValue, localVarHTTPResponse, nil
}

type ApiListDataStreamingsRequest struct {
	ctx context.Context
	ApiService *DataStreamingAPIService
}

func (r ApiListDataStreamingsRequest) Execute() (*DataStreamingResponseWithResults, *http.Response, error) {
	return r.ApiService.ListDataStreamingsExecute(r)
}

/*
ListDataStreamings List all exist data streamings

Use the GET method to list all data streamings, both active and inactive, and its properties.

 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 @return ApiListDataStreamingsRequest
*/
func (a *DataStreamingAPIService) ListDataStreamings(ctx context.Context) ApiListDataStreamingsRequest {
	return ApiListDataStreamingsRequest{
		ApiService: a,
		ctx: ctx,
	}
}

// Execute executes the request
//  @return DataStreamingResponseWithResults
func (a *DataStreamingAPIService) ListDataStreamingsExecute(r ApiListDataStreamingsRequest) (*DataStreamingResponseWithResults, *http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodGet
		localVarPostBody     interface{}
		formFiles            []formFile
		localVarReturnValue  *DataStreamingResponseWithResults
	)

	localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DataStreamingAPIService.ListDataStreamings")
	if err != nil {
		return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
	}

	localVarPath := localBasePath + "/data_streaming/streamings"

	localVarHeaderParams := make(map[string]string)
	localVarQueryParams := url.Values{}
	localVarFormParams := url.Values{}

	// to determine the Content-Type header
	localVarHTTPContentTypes := []string{}

	// set Content-Type header
	localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
	if localVarHTTPContentType != "" {
		localVarHeaderParams["Content-Type"] = localVarHTTPContentType
	}

	// to determine the Accept header
	localVarHTTPHeaderAccepts := []string{"application/json"}

	// set Accept header
	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
	if localVarHTTPHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
	}
	if r.ctx != nil {
		// API Key Authentication
		if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
			if apiKey, ok := auth["tokenAuth"]; ok {
				var key string
				if apiKey.Prefix != "" {
					key = apiKey.Prefix + " " + apiKey.Key
				} else {
					key = apiKey.Key
				}
				localVarHeaderParams["Authorization"] = key
			}
		}
	}
	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
	if err != nil {
		return localVarReturnValue, nil, err
	}

	localVarHTTPResponse, err := a.client.callAPI(req)
	if err != nil || localVarHTTPResponse == nil {
		return localVarReturnValue, localVarHTTPResponse, err
	}

	localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
	localVarHTTPResponse.Body.Close()
	localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
	if err != nil {
		return localVarReturnValue, localVarHTTPResponse, err
	}

	if localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		return localVarReturnValue, localVarHTTPResponse, newErr
	}

	err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
	if err != nil {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: err.Error(),
		}
		return localVarReturnValue, localVarHTTPResponse, newErr
	}

	return localVarReturnValue, localVarHTTPResponse, nil
}

type ApiOverwriteDataStreamingByIdRequest struct {
	ctx context.Context
	ApiService *DataStreamingAPIService
	dataStreamingId int32
	createNewDataStreamingRequest *CreateNewDataStreamingRequest
}

func (r ApiOverwriteDataStreamingByIdRequest) CreateNewDataStreamingRequest(createNewDataStreamingRequest CreateNewDataStreamingRequest) ApiOverwriteDataStreamingByIdRequest {
	r.createNewDataStreamingRequest = &createNewDataStreamingRequest
	return r
}

func (r ApiOverwriteDataStreamingByIdRequest) Execute() (*CreateNewDataStreaming201Response, *http.Response, error) {
	return r.ApiService.OverwriteDataStreamingByIdExecute(r)
}

/*
OverwriteDataStreamingById Overwrite data streaming

Use the PUT method to overwrite the data streaming. Although  you can change a single property using the PUT method, you must pass all fields for the request to be completed.


 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 @param dataStreamingId
 @return ApiOverwriteDataStreamingByIdRequest
*/
func (a *DataStreamingAPIService) OverwriteDataStreamingById(ctx context.Context, dataStreamingId int32) ApiOverwriteDataStreamingByIdRequest {
	return ApiOverwriteDataStreamingByIdRequest{
		ApiService: a,
		ctx: ctx,
		dataStreamingId: dataStreamingId,
	}
}

// Execute executes the request
//  @return CreateNewDataStreaming201Response
func (a *DataStreamingAPIService) OverwriteDataStreamingByIdExecute(r ApiOverwriteDataStreamingByIdRequest) (*CreateNewDataStreaming201Response, *http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodPut
		localVarPostBody     interface{}
		formFiles            []formFile
		localVarReturnValue  *CreateNewDataStreaming201Response
	)

	localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DataStreamingAPIService.OverwriteDataStreamingById")
	if err != nil {
		return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
	}

	localVarPath := localBasePath + "/data_streaming/streamings/{data_streaming_id}"
	localVarPath = strings.Replace(localVarPath, "{"+"data_streaming_id"+"}", url.PathEscape(parameterValueToString(r.dataStreamingId, "dataStreamingId")), -1)

	localVarHeaderParams := make(map[string]string)
	localVarQueryParams := url.Values{}
	localVarFormParams := url.Values{}
	if r.createNewDataStreamingRequest == nil {
		return localVarReturnValue, nil, reportError("createNewDataStreamingRequest is required and must be specified")
	}

	// to determine the Content-Type header
	localVarHTTPContentTypes := []string{"application/json"}

	// set Content-Type header
	localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
	if localVarHTTPContentType != "" {
		localVarHeaderParams["Content-Type"] = localVarHTTPContentType
	}

	// to determine the Accept header
	localVarHTTPHeaderAccepts := []string{"application/json"}

	// set Accept header
	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
	if localVarHTTPHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
	}
	// body params
	localVarPostBody = r.createNewDataStreamingRequest
	if r.ctx != nil {
		// API Key Authentication
		if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
			if apiKey, ok := auth["tokenAuth"]; ok {
				var key string
				if apiKey.Prefix != "" {
					key = apiKey.Prefix + " " + apiKey.Key
				} else {
					key = apiKey.Key
				}
				localVarHeaderParams["Authorization"] = key
			}
		}
	}
	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
	if err != nil {
		return localVarReturnValue, nil, err
	}

	localVarHTTPResponse, err := a.client.callAPI(req)
	if err != nil || localVarHTTPResponse == nil {
		return localVarReturnValue, localVarHTTPResponse, err
	}

	localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
	localVarHTTPResponse.Body.Close()
	localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
	if err != nil {
		return localVarReturnValue, localVarHTTPResponse, err
	}

	if localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		return localVarReturnValue, localVarHTTPResponse, newErr
	}

	err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
	if err != nil {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: err.Error(),
		}
		return localVarReturnValue, localVarHTTPResponse, newErr
	}

	return localVarReturnValue, localVarHTTPResponse, nil
}
