github.com/qiniu/go-sdk/v7@v7.27.0/pili/stat.go (about) 1 package pili 2 3 import ( 4 "context" 5 "net/http" 6 ) 7 8 // GetStatUpflow 获取上行流量 9 // GET /statd/upflow 10 func (m *Manager) GetStatUpflow(ctx context.Context, req GetStatUpflowRequest) ([]StatResponse, error) { 11 if err := defaultValidator.Validate(req); err != nil { 12 return nil, err 13 } 14 if len(req.Select) == 0 { 15 req.Select = []string{FlowDefaultSelect} 16 } 17 18 var resp []StatResponse 19 if err := m.client.CallWithForm(ctx, &resp, http.MethodGet, m.url("/statd/upflow"), nil, Form(req)); err != nil { 20 return nil, err 21 } 22 return resp, nil 23 } 24 25 // GroupStatUpflow 分组获取上行流量 26 // GET /statd/upflow 27 func (m *Manager) GroupStatUpflow(ctx context.Context, req GroupStatUpflowRequest) ([]StatGroupResponse, error) { 28 if err := defaultValidator.Validate(req); err != nil { 29 return nil, err 30 } 31 if len(req.Select) == 0 { 32 req.Select = []string{FlowDefaultSelect} 33 } 34 35 var resp []StatGroupResponse 36 if err := m.client.CallWithForm(ctx, &resp, http.MethodGet, m.url("/statd/upflow"), nil, Form(req)); err != nil { 37 return nil, err 38 } 39 return resp, nil 40 } 41 42 // GetStatDownflow 获取下行流量 43 // GET /statd/downflow 44 func (m *Manager) GetStatDownflow(ctx context.Context, req GetStatDownflowRequest) ([]StatResponse, error) { 45 if err := defaultValidator.Validate(req); err != nil { 46 return nil, err 47 } 48 if len(req.Select) == 0 { 49 req.Select = []string{FlowDefaultSelect} 50 } 51 52 var resp []StatResponse 53 if err := m.client.CallWithForm(ctx, &resp, http.MethodGet, m.url("/statd/downflow"), nil, Form(req)); err != nil { 54 return nil, err 55 } 56 return resp, nil 57 } 58 59 // GroupStatDownflow 分组获取下行流量 60 // GET /statd/downflow 61 func (m *Manager) GroupStatDownflow(ctx context.Context, req GroupStatDownflowRequest) ([]StatGroupResponse, error) { 62 if err := defaultValidator.Validate(req); err != nil { 63 return nil, err 64 } 65 if len(req.Select) == 0 { 66 req.Select = []string{FlowDefaultSelect} 67 } 68 69 var resp []StatGroupResponse 70 if err := m.client.CallWithForm(ctx, &resp, http.MethodGet, m.url("/statd/downflow"), nil, Form(req)); err != nil { 71 return nil, err 72 } 73 return resp, nil 74 } 75 76 // GetStatCodec 获取直播转码使用量 77 // GET /statd/codec 78 func (m *Manager) GetStatCodec(ctx context.Context, req GetStatCodecRequest) ([]StatResponse, error) { 79 if err := defaultValidator.Validate(req); err != nil { 80 return nil, err 81 } 82 if len(req.Select) == 0 { 83 req.Select = []string{CodecDefaultSelect} 84 } 85 86 var resp []StatResponse 87 if err := m.client.CallWithForm(ctx, &resp, http.MethodGet, m.url("/statd/codec"), nil, Form(req)); err != nil { 88 return nil, err 89 } 90 return resp, nil 91 } 92 93 // GroupStatCodec 分组获取直播转码使用量 94 // GET /statd/codec 95 func (m *Manager) GroupStatCodec(ctx context.Context, req GroupStatCodecRequest) ([]StatGroupResponse, error) { 96 if err := defaultValidator.Validate(req); err != nil { 97 return nil, err 98 } 99 if len(req.Select) == 0 { 100 req.Select = []string{CodecDefaultSelect} 101 } 102 103 var resp []StatGroupResponse 104 if err := m.client.CallWithForm(ctx, &resp, http.MethodGet, m.url("/statd/codec"), nil, Form(req)); err != nil { 105 return nil, err 106 } 107 return resp, nil 108 } 109 110 // GetStatNrop 获取直播鉴黄使用量 111 // GET /statd/nrop 112 func (m *Manager) GetStatNrop(ctx context.Context, req GetStatNropRequest) ([]StatResponse, error) { 113 if err := defaultValidator.Validate(req); err != nil { 114 return nil, err 115 } 116 if len(req.Select) == 0 { 117 req.Select = []string{NropDefaultSelect} 118 } 119 120 var resp []StatResponse 121 if err := m.client.CallWithForm(ctx, &resp, http.MethodGet, m.url("/statd/nrop"), nil, Form(req)); err != nil { 122 return nil, err 123 } 124 return resp, nil 125 } 126 127 // GroupStatNrop 分组获取直播鉴黄使用量 128 // GET /statd/nrop 129 func (m *Manager) GroupStatNrop(ctx context.Context, req GroupStatNropRequest) ([]StatGroupResponse, error) { 130 if err := defaultValidator.Validate(req); err != nil { 131 return nil, err 132 } 133 if len(req.Select) == 0 { 134 req.Select = []string{NropDefaultSelect} 135 } 136 137 var resp []StatGroupResponse 138 if err := m.client.CallWithForm(ctx, &resp, http.MethodGet, m.url("/statd/nrop"), nil, Form(req)); err != nil { 139 return nil, err 140 } 141 return resp, nil 142 } 143 144 // GetStatCaster 获取导播台使用量 145 // GET /statd/caster 146 func (m *Manager) GetStatCaster(ctx context.Context, req GetStatCasterRequest) ([]StatResponse, error) { 147 if err := defaultValidator.Validate(req); err != nil { 148 return nil, err 149 } 150 151 var resp []StatResponse 152 if err := m.client.CallWithForm(ctx, &resp, http.MethodGet, m.url("/statd/caster"), nil, Form(req)); err != nil { 153 return nil, err 154 } 155 return resp, nil 156 } 157 158 // GroupStatCaster 分组获取导播台使用量 159 // GET /statd/caster 160 func (m *Manager) GroupStatCaster(ctx context.Context, req GroupStatCasterRequest) ([]StatGroupResponse, error) { 161 if err := defaultValidator.Validate(req); err != nil { 162 return nil, err 163 } 164 165 var resp []StatGroupResponse 166 if err := m.client.CallWithForm(ctx, &resp, http.MethodGet, m.url("/statd/caster"), nil, Form(req)); err != nil { 167 return nil, err 168 } 169 return resp, nil 170 } 171 172 // GetStatPub 获取Pub服务使用量 173 // GET /statd/pub 174 func (m *Manager) GetStatPub(ctx context.Context, req GetStatPubRequest) ([]StatResponse, error) { 175 if err := defaultValidator.Validate(req); err != nil { 176 return nil, err 177 } 178 179 var resp []StatResponse 180 if err := m.client.CallWithForm(ctx, &resp, http.MethodGet, m.url("/statd/pub"), nil, Form(req)); err != nil { 181 return nil, err 182 } 183 return resp, nil 184 } 185 186 // GroupStatPub 分组获取Pub服务使用量 187 // GET /statd/pub 188 func (m *Manager) GroupStatPub(ctx context.Context, req GroupStatPubRequest) ([]StatGroupResponse, error) { 189 if err := defaultValidator.Validate(req); err != nil { 190 return nil, err 191 } 192 193 var resp []StatGroupResponse 194 if err := m.client.CallWithForm(ctx, &resp, http.MethodGet, m.url("/statd/pub"), nil, Form(req)); err != nil { 195 return nil, err 196 } 197 return resp, nil 198 }