-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathstreams_live_api.go
106 lines (86 loc) · 3.58 KB
/
streams_live_api.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
package api
import (
"github.com/bitmovin/bitmovin-api-sdk-go/apiclient"
"github.com/bitmovin/bitmovin-api-sdk-go/model"
"github.com/bitmovin/bitmovin-api-sdk-go/pagination"
)
// StreamsLiveAPI communicates with '/streams/live' endpoints
type StreamsLiveAPI struct {
apiClient *apiclient.APIClient
// Stop communicates with '/streams/live/{stream_id}/stop' endpoints
Stop *StreamsLiveStopAPI
// Start communicates with '/streams/live/{stream_id}/start' endpoints
Start *StreamsLiveStartAPI
}
// NewStreamsLiveAPI constructor for StreamsLiveAPI that takes options as argument
func NewStreamsLiveAPI(options ...apiclient.APIClientOption) (*StreamsLiveAPI, error) {
apiClient, err := apiclient.NewAPIClient(options...)
if err != nil {
return nil, err
}
return NewStreamsLiveAPIWithClient(apiClient), nil
}
// NewStreamsLiveAPIWithClient constructor for StreamsLiveAPI that takes an APIClient as argument
func NewStreamsLiveAPIWithClient(apiClient *apiclient.APIClient) *StreamsLiveAPI {
a := &StreamsLiveAPI{apiClient: apiClient}
a.Stop = NewStreamsLiveStopAPIWithClient(apiClient)
a.Start = NewStreamsLiveStartAPIWithClient(apiClient)
return a
}
// PatchStreamsLive Partially update live stream by id
func (api *StreamsLiveAPI) PatchStreamsLive(streamId string, streamsLiveUpdateRequest model.StreamsLiveUpdateRequest) (*model.StreamsLiveResponse, error) {
reqParams := func(params *apiclient.RequestParams) {
params.PathParams["stream_id"] = streamId
}
var responseModel model.StreamsLiveResponse
err := api.apiClient.Patch("/streams/live/{stream_id}", &streamsLiveUpdateRequest, &responseModel, reqParams)
return &responseModel, err
}
// Create new live stream
func (api *StreamsLiveAPI) Create(streamsLiveCreateRequest model.StreamsLiveCreateRequest) (*model.StreamsLiveResponse, error) {
reqParams := func(params *apiclient.RequestParams) {
}
var responseModel model.StreamsLiveResponse
err := api.apiClient.Post("/streams/live", &streamsLiveCreateRequest, &responseModel, reqParams)
return &responseModel, err
}
// Delete Stream
func (api *StreamsLiveAPI) Delete(streamId string) error {
reqParams := func(params *apiclient.RequestParams) {
params.PathParams["stream_id"] = streamId
}
err := api.apiClient.Delete("/streams/live/{stream_id}", nil, nil, reqParams)
return err
}
// Get live stream by id
func (api *StreamsLiveAPI) Get(streamId string) (*model.StreamsLiveResponse, error) {
reqParams := func(params *apiclient.RequestParams) {
params.PathParams["stream_id"] = streamId
}
var responseModel model.StreamsLiveResponse
err := api.apiClient.Get("/streams/live/{stream_id}", nil, &responseModel, reqParams)
return &responseModel, err
}
// List Get paginated list of live streams
func (api *StreamsLiveAPI) List(queryParams ...func(*StreamsLiveAPIListQueryParams)) (*pagination.StreamsLiveResponsesListPagination, error) {
queryParameters := &StreamsLiveAPIListQueryParams{}
for _, queryParam := range queryParams {
queryParam(queryParameters)
}
reqParams := func(params *apiclient.RequestParams) {
params.QueryParams = queryParameters
}
var responseModel pagination.StreamsLiveResponsesListPagination
err := api.apiClient.Get("/streams/live", nil, &responseModel, reqParams)
return &responseModel, err
}
// StreamsLiveAPIListQueryParams contains all query parameters for the List endpoint
type StreamsLiveAPIListQueryParams struct {
Offset int32 `query:"offset"`
Limit int32 `query:"limit"`
Sort string `query:"sort"`
}
// Params will return a map of query parameters
func (q *StreamsLiveAPIListQueryParams) Params() map[string]string {
return apiclient.GetParamsMap(q)
}