/
api_item_refresh_service.go
135 lines (116 loc) · 4.58 KB
/
api_item_refresh_service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
* Emby REST API
*
* Explore the Emby Server API
*
*/
package embyapi
import (
"context"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
"github.com/antihax/optional"
)
// Linger please
var (
_ context.Context
)
type ItemRefreshServiceApiService service
/*
ItemRefreshServiceApiService Refreshes metadata for an item
Requires authentication as user
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param id Item Id
* @param optional nil or *ItemRefreshServiceApiPostItemsByIdRefreshOpts - Optional Parameters:
* @param "Recursive" (optional.Bool) - Indicates if the refresh should occur recursively.
* @param "MetadataRefreshMode" (optional.Interface of ProvidersMetadataRefreshMode) - Specifies the metadata refresh mode
* @param "ImageRefreshMode" (optional.Interface of ProvidersMetadataRefreshMode) - Specifies the image refresh mode
* @param "ReplaceAllMetadata" (optional.Bool) - Determines if metadata should be replaced. Only applicable if mode is FullRefresh
* @param "ReplaceAllImages" (optional.Bool) - Determines if images should be replaced. Only applicable if mode is FullRefresh
*/
type ItemRefreshServiceApiPostItemsByIdRefreshOpts struct {
Recursive optional.Bool
MetadataRefreshMode optional.Interface
ImageRefreshMode optional.Interface
ReplaceAllMetadata optional.Bool
ReplaceAllImages optional.Bool
}
func (a *ItemRefreshServiceApiService) PostItemsByIdRefresh(ctx context.Context, id string, localVarOptionals *ItemRefreshServiceApiPostItemsByIdRefreshOpts) (*http.Response, error) {
var (
localVarHttpMethod = strings.ToUpper("Post")
localVarPostBody interface{}
localVarFileName string
localVarFileBytes []byte
)
// create path and map variables
localVarPath := a.client.cfg.BasePath + "/Items/{Id}/Refresh"
localVarPath = strings.Replace(localVarPath, "{"+"Id"+"}", fmt.Sprintf("%v", id), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if localVarOptionals != nil && localVarOptionals.Recursive.IsSet() {
localVarQueryParams.Add("Recursive", parameterToString(localVarOptionals.Recursive.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.MetadataRefreshMode.IsSet() {
localVarQueryParams.Add("MetadataRefreshMode", parameterToString(localVarOptionals.MetadataRefreshMode.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.ImageRefreshMode.IsSet() {
localVarQueryParams.Add("ImageRefreshMode", parameterToString(localVarOptionals.ImageRefreshMode.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.ReplaceAllMetadata.IsSet() {
localVarQueryParams.Add("ReplaceAllMetadata", parameterToString(localVarOptionals.ReplaceAllMetadata.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.ReplaceAllImages.IsSet() {
localVarQueryParams.Add("ReplaceAllImages", parameterToString(localVarOptionals.ReplaceAllImages.Value(), ""))
}
// 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 ctx != nil {
// API Key Authentication
if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
var key string
if auth.Prefix != "" {
key = auth.Prefix + " " + auth.Key
} else {
key = auth.Key
}
localVarQueryParams.Add("api_key", key)
}
}
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,
}
return localVarHttpResponse, newErr
}
return localVarHttpResponse, nil
}