mirror of
https://github.com/taigrr/elevenlabs.git
synced 2026-04-02 03:08:57 -07:00
start history rewrite
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
# elevenlabs
|
# elevenlabs
|
||||||
Unofficial [elevenlabs.io](https://beta.elevenlabs.io/) ([11.ai](11.ai)) voice synthesis client
|
Unofficial [elevenlabs.io](https://beta.elevenlabs.io/) ([11.ai](11.ai)) voice synthesis client
|
||||||
|
|
||||||
This library is not affiliated with, not associated with ElevenLabs in any way.
|
This library is not affiliated with, nor associated with ElevenLabs in any way.
|
||||||
|
|
||||||
ElevenLabs' official api documentation, upon which this client has been
|
ElevenLabs' official api documentation, upon which this client has been
|
||||||
derived, [can be found here](https://api.elevenlabs.io/docs).
|
derived, [can be found here](https://api.elevenlabs.io/docs).
|
||||||
|
|||||||
@@ -1,515 +0,0 @@
|
|||||||
/*
|
|
||||||
* ElevenLabs API Documentation
|
|
||||||
*
|
|
||||||
* This is the documentation for the ElevenLabs API. You can use this API to use our service programmatically, this is done by using your xi-api-key. <br/> You can view your xi-api-key using the 'Profile' tab on https://beta.elevenlabs.io. Our API is experimental so all endpoints are subject to change.
|
|
||||||
*
|
|
||||||
* API version: 1.0
|
|
||||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
|
||||||
*/
|
|
||||||
package swagger
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
|
||||||
"net/url"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/antihax/optional"
|
|
||||||
|
|
||||||
"github.com/taigrr/elevenlabs/client/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Linger please
|
|
||||||
var (
|
|
||||||
_ context.Context
|
|
||||||
)
|
|
||||||
|
|
||||||
/*
|
|
||||||
HistoryApiService Delete History Item
|
|
||||||
Delete a history item by its ID
|
|
||||||
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
||||||
* @param historyItemId History item ID to be used, you can use GET https://api.elevenlabs.io/v1/history to receive a list of history items and their IDs.
|
|
||||||
* @param optional nil or *HistoryApiDeleteHistoryItemV1HistoryHistoryItemIdDeleteOpts - Optional Parameters:
|
|
||||||
* @param "XiApiKey" (optional.String) - Your API key. This is required by most endpoints to access our API programatically. You can view your xi-api-key using the 'Profile' tab on the website.
|
|
||||||
@return Object
|
|
||||||
*/
|
|
||||||
|
|
||||||
func (a *HistoryApiService) DeleteHistoryItemV1HistoryHistoryItemIdDelete(ctx context.Context, historyItemId string, localVarOptionals *HistoryApiDeleteHistoryItemV1HistoryHistoryItemIdDeleteOpts) (Object, *http.Response, error) {
|
|
||||||
var (
|
|
||||||
localVarHttpMethod = strings.ToUpper("Delete")
|
|
||||||
localVarPostBody interface{}
|
|
||||||
localVarFileName string
|
|
||||||
localVarFileBytes []byte
|
|
||||||
localVarReturnValue Object
|
|
||||||
)
|
|
||||||
|
|
||||||
// create path and map variables
|
|
||||||
localVarPath := a.client.cfg.BasePath + "/v1/history/{history_item_id}"
|
|
||||||
localVarPath = strings.Replace(localVarPath, "{"+"history_item_id"+"}", fmt.Sprintf("%v", historyItemId), -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 localVarOptionals != nil && localVarOptionals.XiApiKey.IsSet() {
|
|
||||||
localVarHeaderParams["xi-api-key"] = parameterToString(localVarOptionals.XiApiKey.Value(), "")
|
|
||||||
}
|
|
||||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
|
||||||
if err != nil {
|
|
||||||
return localVarReturnValue, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
localVarHttpResponse, err := a.client.callAPI(r)
|
|
||||||
if err != nil || localVarHttpResponse == nil {
|
|
||||||
return localVarReturnValue, localVarHttpResponse, err
|
|
||||||
}
|
|
||||||
|
|
||||||
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
|
|
||||||
localVarHttpResponse.Body.Close()
|
|
||||||
if err != nil {
|
|
||||||
return localVarReturnValue, localVarHttpResponse, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if localVarHttpResponse.StatusCode < 300 {
|
|
||||||
// If we succeed, return the data, otherwise pass on to decode error.
|
|
||||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
||||||
if err == nil {
|
|
||||||
return localVarReturnValue, localVarHttpResponse, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if localVarHttpResponse.StatusCode >= 300 {
|
|
||||||
newErr := GenericSwaggerError{
|
|
||||||
body: localVarBody,
|
|
||||||
error: localVarHttpResponse.Status,
|
|
||||||
}
|
|
||||||
if localVarHttpResponse.StatusCode == 200 {
|
|
||||||
var v Object
|
|
||||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
||||||
if err != nil {
|
|
||||||
newErr.error = err.Error()
|
|
||||||
return localVarReturnValue, localVarHttpResponse, newErr
|
|
||||||
}
|
|
||||||
newErr.model = v
|
|
||||||
return localVarReturnValue, localVarHttpResponse, newErr
|
|
||||||
}
|
|
||||||
if localVarHttpResponse.StatusCode == 422 {
|
|
||||||
var v HttpValidationError
|
|
||||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
||||||
if err != nil {
|
|
||||||
newErr.error = err.Error()
|
|
||||||
return localVarReturnValue, localVarHttpResponse, newErr
|
|
||||||
}
|
|
||||||
newErr.model = v
|
|
||||||
return localVarReturnValue, localVarHttpResponse, newErr
|
|
||||||
}
|
|
||||||
return localVarReturnValue, localVarHttpResponse, newErr
|
|
||||||
}
|
|
||||||
|
|
||||||
return localVarReturnValue, localVarHttpResponse, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
HistoryApiService Delete History Items
|
|
||||||
Delete a number of history items by their IDs.
|
|
||||||
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
||||||
* @param body
|
|
||||||
* @param optional nil or *HistoryApiDeleteHistoryItemsV1HistoryDeletePostOpts - Optional Parameters:
|
|
||||||
* @param "XiApiKey" (optional.String) - Your API key. This is required by most endpoints to access our API programatically. You can view your xi-api-key using the 'Profile' tab on the website.
|
|
||||||
@return Object
|
|
||||||
*/
|
|
||||||
|
|
||||||
type HistoryApiDeleteHistoryItemsV1HistoryDeletePostOpts struct {
|
|
||||||
XiApiKey optional.String
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *HistoryApiService) DeleteHistoryItemsV1HistoryDeletePost(ctx context.Context, body BodyDeleteHistoryItemsV1HistoryDeletePost, localVarOptionals *HistoryApiDeleteHistoryItemsV1HistoryDeletePostOpts) (Object, *http.Response, error) {
|
|
||||||
var (
|
|
||||||
localVarHttpMethod = strings.ToUpper("Post")
|
|
||||||
localVarPostBody interface{}
|
|
||||||
localVarFileName string
|
|
||||||
localVarFileBytes []byte
|
|
||||||
localVarReturnValue Object
|
|
||||||
)
|
|
||||||
|
|
||||||
// create path and map variables
|
|
||||||
localVarPath := a.client.cfg.BasePath + "/v1/history/delete"
|
|
||||||
|
|
||||||
localVarHeaderParams := make(map[string]string)
|
|
||||||
localVarQueryParams := url.Values{}
|
|
||||||
localVarFormParams := url.Values{}
|
|
||||||
|
|
||||||
// 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
|
|
||||||
}
|
|
||||||
if localVarOptionals != nil && localVarOptionals.XiApiKey.IsSet() {
|
|
||||||
localVarHeaderParams["xi-api-key"] = parameterToString(localVarOptionals.XiApiKey.Value(), "")
|
|
||||||
}
|
|
||||||
// body params
|
|
||||||
localVarPostBody = &body
|
|
||||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
|
||||||
if err != nil {
|
|
||||||
return localVarReturnValue, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
localVarHttpResponse, err := a.client.callAPI(r)
|
|
||||||
if err != nil || localVarHttpResponse == nil {
|
|
||||||
return localVarReturnValue, localVarHttpResponse, err
|
|
||||||
}
|
|
||||||
|
|
||||||
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
|
|
||||||
localVarHttpResponse.Body.Close()
|
|
||||||
if err != nil {
|
|
||||||
return localVarReturnValue, localVarHttpResponse, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if localVarHttpResponse.StatusCode < 300 {
|
|
||||||
// If we succeed, return the data, otherwise pass on to decode error.
|
|
||||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
||||||
if err == nil {
|
|
||||||
return localVarReturnValue, localVarHttpResponse, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if localVarHttpResponse.StatusCode >= 300 {
|
|
||||||
newErr := GenericSwaggerError{
|
|
||||||
body: localVarBody,
|
|
||||||
error: localVarHttpResponse.Status,
|
|
||||||
}
|
|
||||||
if localVarHttpResponse.StatusCode == 200 {
|
|
||||||
var v Object
|
|
||||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
||||||
if err != nil {
|
|
||||||
newErr.error = err.Error()
|
|
||||||
return localVarReturnValue, localVarHttpResponse, newErr
|
|
||||||
}
|
|
||||||
newErr.model = v
|
|
||||||
return localVarReturnValue, localVarHttpResponse, newErr
|
|
||||||
}
|
|
||||||
if localVarHttpResponse.StatusCode == 422 {
|
|
||||||
var v HttpValidationError
|
|
||||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
||||||
if err != nil {
|
|
||||||
newErr.error = err.Error()
|
|
||||||
return localVarReturnValue, localVarHttpResponse, newErr
|
|
||||||
}
|
|
||||||
newErr.model = v
|
|
||||||
return localVarReturnValue, localVarHttpResponse, newErr
|
|
||||||
}
|
|
||||||
return localVarReturnValue, localVarHttpResponse, newErr
|
|
||||||
}
|
|
||||||
|
|
||||||
return localVarReturnValue, localVarHttpResponse, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
HistoryApiService Download History Items
|
|
||||||
Download one or more history items. If one history item ID is provided, we will return a single audio file. If more than one history item IDs are provided, we will provide the history items packed into a .zip file.
|
|
||||||
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
||||||
* @param body
|
|
||||||
* @param optional nil or *HistoryApiDownloadHistoryItemsV1HistoryDownloadPostOpts - Optional Parameters:
|
|
||||||
* @param "XiApiKey" (optional.String) - Your API key. This is required by most endpoints to access our API programatically. You can view your xi-api-key using the 'Profile' tab on the website.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
type HistoryApiDownloadHistoryItemsV1HistoryDownloadPostOpts struct {
|
|
||||||
XiApiKey optional.String
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *HistoryApiService) DownloadHistoryItemsV1HistoryDownloadPost(ctx context.Context, body BodyDownloadHistoryItemsV1HistoryDownloadPost, localVarOptionals *HistoryApiDownloadHistoryItemsV1HistoryDownloadPostOpts) (*http.Response, error) {
|
|
||||||
var (
|
|
||||||
localVarHttpMethod = strings.ToUpper("Post")
|
|
||||||
localVarPostBody interface{}
|
|
||||||
localVarFileName string
|
|
||||||
localVarFileBytes []byte
|
|
||||||
)
|
|
||||||
|
|
||||||
// create path and map variables
|
|
||||||
localVarPath := a.client.cfg.BasePath + "/v1/history/download"
|
|
||||||
|
|
||||||
localVarHeaderParams := make(map[string]string)
|
|
||||||
localVarQueryParams := url.Values{}
|
|
||||||
localVarFormParams := url.Values{}
|
|
||||||
|
|
||||||
// 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
|
|
||||||
}
|
|
||||||
if localVarOptionals != nil && localVarOptionals.XiApiKey.IsSet() {
|
|
||||||
localVarHeaderParams["xi-api-key"] = parameterToString(localVarOptionals.XiApiKey.Value(), "")
|
|
||||||
}
|
|
||||||
// body params
|
|
||||||
localVarPostBody = &body
|
|
||||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
localVarHttpResponse, err := a.client.callAPI(r)
|
|
||||||
if err != nil || localVarHttpResponse == nil {
|
|
||||||
return localVarHttpResponse, err
|
|
||||||
}
|
|
||||||
|
|
||||||
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
|
|
||||||
localVarHttpResponse.Body.Close()
|
|
||||||
if err != nil {
|
|
||||||
return localVarHttpResponse, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if localVarHttpResponse.StatusCode >= 300 {
|
|
||||||
newErr := GenericSwaggerError{
|
|
||||||
body: localVarBody,
|
|
||||||
error: localVarHttpResponse.Status,
|
|
||||||
}
|
|
||||||
if localVarHttpResponse.StatusCode == 422 {
|
|
||||||
var v HttpValidationError
|
|
||||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
||||||
if err != nil {
|
|
||||||
newErr.error = err.Error()
|
|
||||||
return localVarHttpResponse, newErr
|
|
||||||
}
|
|
||||||
newErr.model = v
|
|
||||||
return localVarHttpResponse, newErr
|
|
||||||
}
|
|
||||||
return localVarHttpResponse, newErr
|
|
||||||
}
|
|
||||||
|
|
||||||
return localVarHttpResponse, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
HistoryApiService Get Audio From History Item
|
|
||||||
Returns the audio of an history item.
|
|
||||||
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
||||||
* @param historyItemId History item ID to be used, you can use GET https://api.elevenlabs.io/v1/history to receive a list of history items and their IDs.
|
|
||||||
* @param optional nil or *HistoryApiGetAudioFromHistoryItemV1HistoryHistoryItemIdAudioGetOpts - Optional Parameters:
|
|
||||||
* @param "XiApiKey" (optional.String) - Your API key. This is required by most endpoints to access our API programatically. You can view your xi-api-key using the 'Profile' tab on the website.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
type HistoryApiGetAudioFromHistoryItemV1HistoryHistoryItemIdAudioGetOpts struct {
|
|
||||||
XiApiKey optional.String
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *HistoryApiService) GetAudioFromHistoryItemV1HistoryHistoryItemIdAudioGet(ctx context.Context, historyItemId string, localVarOptionals *HistoryApiGetAudioFromHistoryItemV1HistoryHistoryItemIdAudioGetOpts) (*http.Response, error) {
|
|
||||||
var (
|
|
||||||
localVarHttpMethod = strings.ToUpper("Get")
|
|
||||||
localVarPostBody interface{}
|
|
||||||
localVarFileName string
|
|
||||||
localVarFileBytes []byte
|
|
||||||
)
|
|
||||||
|
|
||||||
// create path and map variables
|
|
||||||
localVarPath := a.client.cfg.BasePath + "/v1/history/{history_item_id}/audio"
|
|
||||||
localVarPath = strings.Replace(localVarPath, "{"+"history_item_id"+"}", fmt.Sprintf("%v", historyItemId), -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{"audio/mpeg", "application/json"}
|
|
||||||
|
|
||||||
// set Accept header
|
|
||||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
|
||||||
if localVarHttpHeaderAccept != "" {
|
|
||||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
|
||||||
}
|
|
||||||
if localVarOptionals != nil && localVarOptionals.XiApiKey.IsSet() {
|
|
||||||
localVarHeaderParams["xi-api-key"] = parameterToString(localVarOptionals.XiApiKey.Value(), "")
|
|
||||||
}
|
|
||||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
localVarHttpResponse, err := a.client.callAPI(r)
|
|
||||||
if err != nil || localVarHttpResponse == nil {
|
|
||||||
return localVarHttpResponse, err
|
|
||||||
}
|
|
||||||
|
|
||||||
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
|
|
||||||
localVarHttpResponse.Body.Close()
|
|
||||||
if err != nil {
|
|
||||||
return localVarHttpResponse, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if localVarHttpResponse.StatusCode >= 300 {
|
|
||||||
newErr := GenericSwaggerError{
|
|
||||||
body: localVarBody,
|
|
||||||
error: localVarHttpResponse.Status,
|
|
||||||
}
|
|
||||||
if localVarHttpResponse.StatusCode == 422 {
|
|
||||||
var v HttpValidationError
|
|
||||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
||||||
if err != nil {
|
|
||||||
newErr.error = err.Error()
|
|
||||||
return localVarHttpResponse, newErr
|
|
||||||
}
|
|
||||||
newErr.model = v
|
|
||||||
return localVarHttpResponse, newErr
|
|
||||||
}
|
|
||||||
return localVarHttpResponse, newErr
|
|
||||||
}
|
|
||||||
|
|
||||||
return localVarHttpResponse, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
HistoryApiService Get Generated Items
|
|
||||||
Returns metadata about all your generated audio.
|
|
||||||
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
||||||
* @param optional nil or *HistoryApiGetGeneratedItemsV1HistoryGetOpts - Optional Parameters:
|
|
||||||
* @param "XiApiKey" (optional.String) - Your API key. This is required by most endpoints to access our API programatically. You can view your xi-api-key using the 'Profile' tab on the website.
|
|
||||||
@return GetHistoryResponseModel
|
|
||||||
*/
|
|
||||||
|
|
||||||
type HistoryApiGetGeneratedItemsV1HistoryGetOpts struct {
|
|
||||||
XiApiKey optional.String
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetGeneratedItemsV1HistoryGet(ctx context.Context, localVarOptionals *HistoryApiGetGeneratedItemsV1HistoryGetOpts) (types.GetHistoryResponseModel, *http.Response, error) {
|
|
||||||
var (
|
|
||||||
localVarHttpMethod = strings.ToUpper("Get")
|
|
||||||
localVarPostBody interface{}
|
|
||||||
localVarFileName string
|
|
||||||
localVarFileBytes []byte
|
|
||||||
localVarReturnValue types.GetHistoryResponseModel
|
|
||||||
)
|
|
||||||
|
|
||||||
// create path and map variables
|
|
||||||
localVarPath := a.client.cfg.BasePath + "/v1/history"
|
|
||||||
|
|
||||||
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 localVarOptionals != nil && localVarOptionals.XiApiKey.IsSet() {
|
|
||||||
localVarHeaderParams["xi-api-key"] = parameterToString(localVarOptionals.XiApiKey.Value(), "")
|
|
||||||
}
|
|
||||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
|
||||||
if err != nil {
|
|
||||||
return localVarReturnValue, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
localVarHttpResponse, err := a.client.callAPI(r)
|
|
||||||
if err != nil || localVarHttpResponse == nil {
|
|
||||||
return localVarReturnValue, localVarHttpResponse, err
|
|
||||||
}
|
|
||||||
|
|
||||||
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
|
|
||||||
localVarHttpResponse.Body.Close()
|
|
||||||
if err != nil {
|
|
||||||
return localVarReturnValue, localVarHttpResponse, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if localVarHttpResponse.StatusCode < 300 {
|
|
||||||
// If we succeed, return the data, otherwise pass on to decode error.
|
|
||||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
||||||
if err == nil {
|
|
||||||
return localVarReturnValue, localVarHttpResponse, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if localVarHttpResponse.StatusCode >= 300 {
|
|
||||||
newErr := GenericSwaggerError{
|
|
||||||
body: localVarBody,
|
|
||||||
error: localVarHttpResponse.Status,
|
|
||||||
}
|
|
||||||
if localVarHttpResponse.StatusCode == 200 {
|
|
||||||
var v GetHistoryResponseModel
|
|
||||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
||||||
if err != nil {
|
|
||||||
newErr.error = err.Error()
|
|
||||||
return localVarReturnValue, localVarHttpResponse, newErr
|
|
||||||
}
|
|
||||||
newErr.model = v
|
|
||||||
return localVarReturnValue, localVarHttpResponse, newErr
|
|
||||||
}
|
|
||||||
if localVarHttpResponse.StatusCode == 422 {
|
|
||||||
var v HttpValidationError
|
|
||||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
||||||
if err != nil {
|
|
||||||
newErr.error = err.Error()
|
|
||||||
return localVarReturnValue, localVarHttpResponse, newErr
|
|
||||||
}
|
|
||||||
newErr.model = v
|
|
||||||
return localVarReturnValue, localVarHttpResponse, newErr
|
|
||||||
}
|
|
||||||
return localVarReturnValue, localVarHttpResponse, newErr
|
|
||||||
}
|
|
||||||
|
|
||||||
return localVarReturnValue, localVarHttpResponse, nil
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
package client
|
package client
|
||||||
|
|
||||||
|
const apiEndpoint = "https://api.elevenlabs.io"
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
apiKey string
|
apiKey string
|
||||||
}
|
}
|
||||||
|
|||||||
85
client/history.go
Normal file
85
client/history.go
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
package client
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/taigrr/elevenlabs/client/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
var ErrUnauthorized error
|
||||||
|
|
||||||
|
func (c Client) HistoryDelete(ctx context.Context, historyItemId string) (bool, error) {
|
||||||
|
// create path and map variables
|
||||||
|
url := fmt.Sprintf(apiEndpoint+"/v1/history/%s", historyItemId)
|
||||||
|
|
||||||
|
client := &http.Client{}
|
||||||
|
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
req.Header.Set("accept", "application/json")
|
||||||
|
req.Header.Set("xi-api-key", c.apiKey)
|
||||||
|
req.Header.Set("User-Agent", "github.com/taigrr/elevenlabs")
|
||||||
|
res, err := client.Do(req)
|
||||||
|
|
||||||
|
switch res.StatusCode {
|
||||||
|
case 422:
|
||||||
|
return false, err
|
||||||
|
case 401:
|
||||||
|
return false, ErrUnauthorized
|
||||||
|
case 200:
|
||||||
|
if err != nil {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Client) HistoryDownload(ctx context.Context, id string, additionalIDs ...string) ([]byte, error) {
|
||||||
|
url := apiEndpoint + "/v1/history/download"
|
||||||
|
downloads := append(additionalIDs, id)
|
||||||
|
toDownload := types.HistoryPost{
|
||||||
|
HistoryItemIds: downloads,
|
||||||
|
}
|
||||||
|
client := &http.Client{}
|
||||||
|
body, _ := json.Marshal(toDownload)
|
||||||
|
bodyReader := bytes.NewReader(body)
|
||||||
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bodyReader)
|
||||||
|
if err != nil {
|
||||||
|
return []byte{}, err
|
||||||
|
}
|
||||||
|
if len(downloads) == 1 {
|
||||||
|
req.Header.Set("accept", "audio/mpeg")
|
||||||
|
} else {
|
||||||
|
req.Header.Set("accept", "archive/zip")
|
||||||
|
}
|
||||||
|
req.Header.Set("xi-api-key", c.apiKey)
|
||||||
|
req.Header.Set("User-Agent", "github.com/taigrr/elevenlabs")
|
||||||
|
res, err := client.Do(req)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Client) DownloadAudioByID(ctx context.Context, ID string) ([]byte, error) {
|
||||||
|
url := fmt.Sprintf(apiEndpoint+"/v1/history/%s/audio", ID)
|
||||||
|
client := &http.Client{}
|
||||||
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return []byte{}, err
|
||||||
|
}
|
||||||
|
req.Header.Set("xi-api-key", c.apiKey)
|
||||||
|
req.Header.Set("User-Agent", "github.com/taigrr/elevenlabs")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Client) GetHistoryList(ctx context.Context) ([]string, error) {
|
||||||
|
url := apiEndpoint + "/v1/history"
|
||||||
|
client := &http.Client{}
|
||||||
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return []string{}, err
|
||||||
|
}
|
||||||
|
req.Header.Set("xi-api-key", c.apiKey)
|
||||||
|
req.Header.Set("User-Agent", "github.com/taigrr/elevenlabs")
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user