- Init project

This commit is contained in:
Alexander Garin 2023-04-04 22:45:55 +03:00
commit d713dab392
15 changed files with 9611 additions and 0 deletions

38
.gitignore vendored Normal file
View File

@ -0,0 +1,38 @@
*.exe
*.exe~
*.dll
*.so
*.dylib
*.test
*.out
go.work
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
.idea/**/aws.xml
.idea/**/contentModel.xml
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
.idea/**/gradle.xml
.idea/**/libraries
cmake-build-*/
.idea/**/mongoSettings.xml
*.iws
out/
.idea_modules/
atlassian-ide-plugin.xml
.idea/replstate.xml
.idea/sonarlint/
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
.idea/httpRequests
.idea/caches/build_file_checksums.ser

422
api/swagger.yaml Normal file
View File

@ -0,0 +1,422 @@
openapi: 3.0.3
info:
title: YouTube Kids Public API
description: For generate API REST clients for Feelter UGC
contact:
email: garin1221@yandex.ru
version: 1.0.0
servers:
- url: https://www.youtubekids.com/youtubei/v1
tags:
- name: browse
description: Browse resource content
paths:
# Получение контента определенного ресурса, {browseId}
/browse:
post:
tags:
- browse
summary: Browse resource content
description: Get content for resource
operationId: browse
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/BrowseRequestPayload'
responses:
'200':
description: OK
content:
'application/json':
"schema":
$ref: '#/components/schemas/BrowseResponsePayload'
'400':
description: Bad Request
content:
'application/json':
"schema":
$ref: '#/components/schemas/ErrorResponsePayload'
# Компоненты
components:
# Схемы данных
schemas:
# Ошибка
Error:
type: object
properties:
message:
type: string
domain:
type: string
reason:
type: string
# Доступность данных
AccessibilityData:
type: object
properties:
label:
type: string
# Доступность
Accessibility:
type: object
properties:
accessibilityData:
$ref: '#/components/schemas/AccessibilityData'
# WatchEndpoint
WatchEndpoint:
type: object
properties:
videoId:
type: string
# BrowseEndpoint
BrowseEndpoint:
type: object
properties:
browseId:
type: string
canonicalBaseUrl:
type: string
# Конечная точка навигации
NavigationEndpoint:
type: object
properties:
clickTrackingParams:
type: string
watchEndpoint:
$ref: '#/components/schemas/WatchEndpoint'
browseEndpoint:
$ref: '#/components/schemas/BrowseEndpoint'
# Текст -> Runs
TextRun:
type: object
properties:
text:
type: string
navigationEndpoint:
$ref: '#/components/schemas/NavigationEndpoint'
# Текст
Text:
type: object
properties:
runs:
type: array
items:
$ref: '#/components/schemas/TextRun'
accessibility:
$ref: '#/components/schemas/Accessibility'
# Строковый параметр ключ-зачение
KeyStringValue:
type: object
properties:
key:
type: string
value:
type: string
# Ассеты категории
CategoryAssets:
type: object
properties:
assetKey:
type: string
backgroundColor:
type: string
# Расширение для владельцев детских видео
KidsVideoOwnerExtension:
type: object
properties:
externalChannelId:
type: string
# Thumbnail
Thumbnail:
type: object
properties:
url:
type: string
width:
type: number
height:
type: number
# Компактный видеорендерер
CompactVideoRenderer:
type: object
properties:
videoId:
type: string
thumbnail:
type: object
properties:
thumbnails:
type: array
items:
$ref: '#/components/schemas/Thumbnail'
title:
$ref: '#/components/schemas/Text'
longBylineText:
$ref: '#/components/schemas/Text'
publishedTimeText:
$ref: '#/components/schemas/Text'
viewCountText:
$ref: '#/components/schemas/Text'
lengthText:
$ref: '#/components/schemas/Text'
navigationEndpoint:
$ref: '#/components/schemas/NavigationEndpoint'
shortBylineText:
$ref: '#/components/schemas/Text'
channelThumbnail:
type: object
properties:
thumbnails:
type: array
items:
$ref: '#/components/schemas/Thumbnail'
trackingParams:
type: string
shortViewCountText:
$ref: '#/components/schemas/Text'
accessibility:
$ref: '#/components/schemas/Accessibility'
kidsVideoOwnerExtension:
$ref: '#/components/schemas/KidsVideoOwnerExtension'
# Средство визуализации раздела элемента
ItemSectionRenderer:
type: object
properties:
contents:
type: array
items:
type: object
properties:
compactVideoRenderer:
$ref: '#/components/schemas/CompactVideoRenderer'
trackingParams:
type: string
# Рендер списка разделов
SectionListRenderer:
type: object
properties:
contents:
type: array
items:
type: object
properties:
itemSectionRenderer:
$ref: '#/components/schemas/ItemSectionRenderer'
trackingParams:
type: string
# Визуализатор закрепленных сечений
AnchoredSectionRenderer:
type: object
properties:
title:
type: string
content:
type: object
properties:
sectionListRenderer:
$ref: '#/components/schemas/SectionListRenderer'
trackingParams:
type: string
navigationEndpoint:
$ref: '#/components/schemas/NavigationEndpoint'
categoryAssets:
$ref: '#/components/schemas/CategoryAssets'
categoryType:
type: string
# Якорь экрана
ScreenAnchor:
type: object
properties:
anchoredSectionRenderer:
$ref: '#/components/schemas/AnchoredSectionRenderer'
# Рендерер экрана
ScreenRenderer:
type: object
properties:
anchors:
type: array
items:
$ref: '#/components/schemas/ScreenAnchor'
# Средство визуализации заголовка категории
CategoriesHeaderRenderer:
type: object
properties:
trackingParams:
type: string
# TODO
# Параметры контента
KidsAppContentSettings:
type: object
properties:
corpusPreference:
type: string
example: KIDS_CORPUS_PREFERENCE_TWEEN
kidsNoSearchMode:
type: string
example: YT_KIDS_NO_SEARCH_MODE_OFF
# Конфигурация категорий
KidsAppCategorySettings:
type: object
properties:
enabledCategories:
type: array
example: ["approved_for_you", "black_joy", "camp", "collections", "earth", "explore", "favorites", "gaming", "halloween", "hero", "learning", "making", "move", "music", "reading", "shared_by_parents", "shows", "soccer", "sports", "spotlight", "winter"]
items:
type: string
# Параметры приложения
KidsAppInfo:
type: object
description: Kids application configuration
properties:
contentSettings:
$ref: '#/components/schemas/KidsAppContentSettings'
categorySettings:
$ref: '#/components/schemas/KidsAppCategorySettings'
# Информация о клиенте в запросе
RequestClient:
type: object
description: Client information
properties:
clientName:
type: string
example: WEB_KIDS
clientVersion:
type: string
example: 2.20230202.00.00
hl:
type: string
example: ru
gl:
type: string
example: RU
experimentsToken:
type: string
browserName:
type: string
example: Safari
deviceMake:
type: string
example: apple
browserVersion:
type: string
example: '16.2'
osName:
type: string
example: Macintosh
osVersion:
type: string
example: 10_15_7
platform:
type: string
example: DESKTOP
kidsAppInfo:
$ref: '#/components/schemas/KidsAppInfo'
# Контекст запроса
RequestContext:
type: object
description: Request context
properties:
client:
$ref: '#/components/schemas/RequestClient'
# Контекст ответа
ResponseContext:
type: object
description: Response context
properties:
visitorData:
type: string
maxAgeSeconds:
type: number
serviceTrackingParams:
type: array
items:
type: object
properties:
service:
type: string
params:
type: array
items:
$ref: '#/components/schemas/KeyStringValue'
# Данные для запроса на получение контента определенного ресурса
BrowseRequestPayload:
type: object
properties:
context:
$ref: '#/components/schemas/RequestContext'
browseId:
type: string
example: FEkids_home
# Ответ на запрос получения контента определенного ресурса
BrowseResponsePayload:
type: object
properties:
responseContext:
$ref: '#/components/schemas/ResponseContext'
header:
type: object
properties:
kidsCategoriesHeaderRenderer:
$ref: '#/components/schemas/CategoriesHeaderRenderer'
contents:
type: object
properties:
kidsHomeScreenRenderer:
$ref: '#/components/schemas/ScreenRenderer'
trackingParams:
type: string
# Ответ с ошибкой
ErrorResponsePayload:
type: object
properties:
error:
type: object
properties:
code:
type: number
example: 400
message:
type: string
errors:
type: array
items:
$ref: '#/components/schemas/Error'
status:
type: string
example: FAILED_PRECONDITION

3
generate.go Normal file
View File

@ -0,0 +1,3 @@
package go_youtubekids_client
//go:generate go run github.com/ogen-go/ogen/cmd/ogen -target . -clean -generate-tests -no-server -no-webhook-server -no-webhook-client -package go_youtubekids_client ./api/swagger.yaml

36
go.mod Normal file
View File

@ -0,0 +1,36 @@
module githouse.ru/feelter-ugc/go-youtubekids-client
go 1.20
require (
github.com/go-faster/errors v0.6.1
github.com/go-faster/jx v1.0.0
github.com/ogen-go/ogen v0.61.0
go.opentelemetry.io/otel v1.14.0
go.opentelemetry.io/otel/metric v0.37.0
go.opentelemetry.io/otel/trace v1.14.0
)
require (
github.com/dlclark/regexp2 v1.8.1 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-faster/yaml v0.4.3 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/segmentio/asm v1.2.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/tools v0.7.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

69
go.sum Normal file
View File

@ -0,0 +1,69 @@
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/dlclark/regexp2 v1.8.1 h1:6Lcdwya6GjPUNsBct8Lg/yRPwMhABj269AAzdGSiR+0=
github.com/dlclark/regexp2 v1.8.1/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-faster/errors v0.6.1 h1:nNIPOBkprlKzkThvS/0YaX8Zs9KewLCOSFQS5BU06FI=
github.com/go-faster/errors v0.6.1/go.mod h1:5MGV2/2T9yvlrbhe9pD9LO5Z/2zCSq2T8j+Jpi2LAyY=
github.com/go-faster/jx v1.0.0 h1:HE+ms2e6ZGkZ6u13t8u+onBinrPvIPI+0hWXGELm74g=
github.com/go-faster/jx v1.0.0/go.mod h1:zm8SlkwK+H0TYNKYtVJ/7cWFS7soJBQWhcPctKyYL/4=
github.com/go-faster/yaml v0.4.3 h1:j7blP1oLA/2aBQEaWUibtrNNIayr49VGHGpR076NB8k=
github.com/go-faster/yaml v0.4.3/go.mod h1:K2zdBSnXHZ6/rz8iQ1yxgY+R+ytdlZPzdro0NB8EYxw=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98=
github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/ogen-go/ogen v0.61.0 h1:U3hkx9ydCL2tb0055ut0o8hWaEOWCs2+rG2rpwCMGPM=
github.com/ogen-go/ogen v0.61.0/go.mod h1:Rn43MIqVcT8utwLi45lv7e/a4kPRk+klLsWsgB1z9GQ=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM=
go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU=
go.opentelemetry.io/otel/metric v0.37.0 h1:pHDQuLQOZwYD+Km0eb657A25NaRzy0a+eLyKfDXedEs=
go.opentelemetry.io/otel/metric v0.37.0/go.mod h1:DmdaHfGt54iV6UKxsV9slj2bBRJcKC1B1uvDLIioc1s=
go.opentelemetry.io/otel/trace v1.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M=
go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8=
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug=
golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs=
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4=
golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

136
oas_cfg_gen.go Normal file
View File

@ -0,0 +1,136 @@
// Code generated by ogen, DO NOT EDIT.
package go_youtubekids_client
import (
"net/http"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/instrument"
"go.opentelemetry.io/otel/trace"
ht "github.com/ogen-go/ogen/http"
"github.com/ogen-go/ogen/otelogen"
)
var (
// Allocate option closure once.
clientSpanKind = trace.WithSpanKind(trace.SpanKindClient)
)
type (
optionFunc[C any] func(*C)
otelOptionFunc func(*otelConfig)
)
type otelConfig struct {
TracerProvider trace.TracerProvider
Tracer trace.Tracer
MeterProvider metric.MeterProvider
Meter metric.Meter
}
func (cfg *otelConfig) initOTEL() {
if cfg.TracerProvider == nil {
cfg.TracerProvider = otel.GetTracerProvider()
}
if cfg.MeterProvider == nil {
cfg.MeterProvider = metric.NewNoopMeterProvider()
}
cfg.Tracer = cfg.TracerProvider.Tracer(otelogen.Name,
trace.WithInstrumentationVersion(otelogen.SemVersion()),
)
cfg.Meter = cfg.MeterProvider.Meter(otelogen.Name)
}
type clientConfig struct {
otelConfig
Client ht.Client
}
// ClientOption is client config option.
type ClientOption interface {
applyClient(*clientConfig)
}
var _ = []ClientOption{
(optionFunc[clientConfig])(nil),
(otelOptionFunc)(nil),
}
func (o optionFunc[C]) applyClient(c *C) {
o(c)
}
func (o otelOptionFunc) applyClient(c *clientConfig) {
o(&c.otelConfig)
}
func newClientConfig(opts ...ClientOption) clientConfig {
cfg := clientConfig{
Client: http.DefaultClient,
}
for _, opt := range opts {
opt.applyClient(&cfg)
}
cfg.initOTEL()
return cfg
}
type baseClient struct {
cfg clientConfig
requests instrument.Int64Counter
errors instrument.Int64Counter
duration instrument.Int64Histogram
}
func (cfg clientConfig) baseClient() (c baseClient, err error) {
c = baseClient{cfg: cfg}
if c.requests, err = c.cfg.Meter.Int64Counter(otelogen.ClientRequestCount); err != nil {
return c, err
}
if c.errors, err = c.cfg.Meter.Int64Counter(otelogen.ClientErrorsCount); err != nil {
return c, err
}
if c.duration, err = c.cfg.Meter.Int64Histogram(otelogen.ClientDuration); err != nil {
return c, err
}
return c, nil
}
// Option is config option.
type Option interface {
ClientOption
}
// WithTracerProvider specifies a tracer provider to use for creating a tracer.
//
// If none is specified, the global provider is used.
func WithTracerProvider(provider trace.TracerProvider) Option {
return otelOptionFunc(func(cfg *otelConfig) {
if provider != nil {
cfg.TracerProvider = provider
}
})
}
// WithMeterProvider specifies a meter provider to use for creating a meter.
//
// If none is specified, the metric.NewNoopMeterProvider is used.
func WithMeterProvider(provider metric.MeterProvider) Option {
return otelOptionFunc(func(cfg *otelConfig) {
if provider != nil {
cfg.MeterProvider = provider
}
})
}
// WithClient specifies http client to use.
func WithClient(client ht.Client) ClientOption {
return optionFunc[clientConfig](func(cfg *clientConfig) {
if client != nil {
cfg.Client = client
}
})
}

136
oas_client_gen.go Normal file
View File

@ -0,0 +1,136 @@
// Code generated by ogen, DO NOT EDIT.
package go_youtubekids_client
import (
"context"
"net/url"
"strings"
"time"
"github.com/go-faster/errors"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/trace"
ht "github.com/ogen-go/ogen/http"
"github.com/ogen-go/ogen/otelogen"
"github.com/ogen-go/ogen/uri"
)
// Client implements OAS client.
type Client struct {
serverURL *url.URL
baseClient
}
func trimTrailingSlashes(u *url.URL) {
u.Path = strings.TrimRight(u.Path, "/")
u.RawPath = strings.TrimRight(u.RawPath, "/")
}
// NewClient initializes new Client defined by OAS.
func NewClient(serverURL string, opts ...ClientOption) (*Client, error) {
u, err := url.Parse(serverURL)
if err != nil {
return nil, err
}
trimTrailingSlashes(u)
c, err := newClientConfig(opts...).baseClient()
if err != nil {
return nil, err
}
return &Client{
serverURL: u,
baseClient: c,
}, nil
}
type serverURLKey struct{}
// WithServerURL sets context key to override server URL.
func WithServerURL(ctx context.Context, u *url.URL) context.Context {
return context.WithValue(ctx, serverURLKey{}, u)
}
func (c *Client) requestURL(ctx context.Context) *url.URL {
u, ok := ctx.Value(serverURLKey{}).(*url.URL)
if !ok {
return c.serverURL
}
return u
}
// Browse invokes browse operation.
//
// Get content for resource.
//
// POST /browse
func (c *Client) Browse(ctx context.Context, request *BrowseRequestPayload) (BrowseRes, error) {
res, err := c.sendBrowse(ctx, request)
_ = res
return res, err
}
func (c *Client) sendBrowse(ctx context.Context, request *BrowseRequestPayload) (res BrowseRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("browse"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
c.requests.Add(ctx, 1, otelAttrs...)
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "Browse",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, otelAttrs...)
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
var pathParts [1]string
pathParts[0] = "/browse"
uri.AddPathParts(u, pathParts[:]...)
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "POST", u, nil)
if err != nil {
return res, errors.Wrap(err, "create request")
}
if err := encodeBrowseRequest(request, r); err != nil {
return res, errors.Wrap(err, "encode request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeBrowseResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}

928
oas_faker_gen.go Normal file
View File

@ -0,0 +1,928 @@
// Code generated by ogen, DO NOT EDIT.
package go_youtubekids_client
// SetFake set fake values.
func (s *Accessibility) SetFake() {
{
{
s.AccessibilityData.SetFake()
}
}
}
// SetFake set fake values.
func (s *AccessibilityData) SetFake() {
{
{
s.Label.SetFake()
}
}
}
// SetFake set fake values.
func (s *AnchoredSectionRenderer) SetFake() {
{
{
s.Title.SetFake()
}
}
{
{
s.Content.SetFake()
}
}
{
{
s.TrackingParams.SetFake()
}
}
{
{
s.NavigationEndpoint.SetFake()
}
}
{
{
s.CategoryAssets.SetFake()
}
}
{
{
s.CategoryType.SetFake()
}
}
}
// SetFake set fake values.
func (s *AnchoredSectionRendererContent) SetFake() {
{
{
s.SectionListRenderer.SetFake()
}
}
}
// SetFake set fake values.
func (s *BrowseEndpoint) SetFake() {
{
{
s.BrowseId.SetFake()
}
}
{
{
s.CanonicalBaseUrl.SetFake()
}
}
}
// SetFake set fake values.
func (s *BrowseRequestPayload) SetFake() {
{
{
s.Context.SetFake()
}
}
{
{
s.BrowseId.SetFake()
}
}
}
// SetFake set fake values.
func (s *BrowseResponsePayload) SetFake() {
{
{
s.ResponseContext.SetFake()
}
}
{
{
s.Header.SetFake()
}
}
{
{
s.Contents.SetFake()
}
}
{
{
s.TrackingParams.SetFake()
}
}
}
// SetFake set fake values.
func (s *BrowseResponsePayloadContents) SetFake() {
{
{
s.KidsHomeScreenRenderer.SetFake()
}
}
}
// SetFake set fake values.
func (s *BrowseResponsePayloadHeader) SetFake() {
{
{
s.KidsCategoriesHeaderRenderer.SetFake()
}
}
}
// SetFake set fake values.
func (s *CategoriesHeaderRenderer) SetFake() {
{
{
s.TrackingParams.SetFake()
}
}
}
// SetFake set fake values.
func (s *CategoryAssets) SetFake() {
{
{
s.AssetKey.SetFake()
}
}
{
{
s.BackgroundColor.SetFake()
}
}
}
// SetFake set fake values.
func (s *CompactVideoRenderer) SetFake() {
{
{
s.VideoId.SetFake()
}
}
{
{
s.Thumbnail.SetFake()
}
}
{
{
s.Title.SetFake()
}
}
{
{
s.LongBylineText.SetFake()
}
}
{
{
s.PublishedTimeText.SetFake()
}
}
{
{
s.ViewCountText.SetFake()
}
}
{
{
s.LengthText.SetFake()
}
}
{
{
s.NavigationEndpoint.SetFake()
}
}
{
{
s.ShortBylineText.SetFake()
}
}
{
{
s.ChannelThumbnail.SetFake()
}
}
{
{
s.TrackingParams.SetFake()
}
}
{
{
s.ShortViewCountText.SetFake()
}
}
{
{
s.Accessibility.SetFake()
}
}
{
{
s.KidsVideoOwnerExtension.SetFake()
}
}
}
// SetFake set fake values.
func (s *CompactVideoRendererChannelThumbnail) SetFake() {
{
{
s.Thumbnails = nil
for i := 0; i < 0; i++ {
var elem Thumbnail
{
elem.SetFake()
}
s.Thumbnails = append(s.Thumbnails, elem)
}
}
}
}
// SetFake set fake values.
func (s *CompactVideoRendererThumbnail) SetFake() {
{
{
s.Thumbnails = nil
for i := 0; i < 0; i++ {
var elem Thumbnail
{
elem.SetFake()
}
s.Thumbnails = append(s.Thumbnails, elem)
}
}
}
}
// SetFake set fake values.
func (s *Error) SetFake() {
{
{
s.Message.SetFake()
}
}
{
{
s.Domain.SetFake()
}
}
{
{
s.Reason.SetFake()
}
}
}
// SetFake set fake values.
func (s *ErrorResponsePayload) SetFake() {
{
{
s.Error.SetFake()
}
}
}
// SetFake set fake values.
func (s *ErrorResponsePayloadError) SetFake() {
{
{
s.Code.SetFake()
}
}
{
{
s.Message.SetFake()
}
}
{
{
s.Errors = nil
for i := 0; i < 0; i++ {
var elem Error
{
elem.SetFake()
}
s.Errors = append(s.Errors, elem)
}
}
}
{
{
s.Status.SetFake()
}
}
}
// SetFake set fake values.
func (s *ItemSectionRenderer) SetFake() {
{
{
s.Contents = nil
for i := 0; i < 0; i++ {
var elem ItemSectionRendererContentsItem
{
elem.SetFake()
}
s.Contents = append(s.Contents, elem)
}
}
}
{
{
s.TrackingParams.SetFake()
}
}
}
// SetFake set fake values.
func (s *ItemSectionRendererContentsItem) SetFake() {
{
{
s.CompactVideoRenderer.SetFake()
}
}
}
// SetFake set fake values.
func (s *KeyStringValue) SetFake() {
{
{
s.Key.SetFake()
}
}
{
{
s.Value.SetFake()
}
}
}
// SetFake set fake values.
func (s *KidsAppCategorySettings) SetFake() {
{
{
s.EnabledCategories = nil
for i := 0; i < 0; i++ {
var elem string
{
elem = "string"
}
s.EnabledCategories = append(s.EnabledCategories, elem)
}
}
}
}
// SetFake set fake values.
func (s *KidsAppContentSettings) SetFake() {
{
{
s.CorpusPreference.SetFake()
}
}
{
{
s.KidsNoSearchMode.SetFake()
}
}
}
// SetFake set fake values.
func (s *KidsAppInfo) SetFake() {
{
{
s.ContentSettings.SetFake()
}
}
{
{
s.CategorySettings.SetFake()
}
}
}
// SetFake set fake values.
func (s *KidsVideoOwnerExtension) SetFake() {
{
{
s.ExternalChannelId.SetFake()
}
}
}
// SetFake set fake values.
func (s *NavigationEndpoint) SetFake() {
{
{
s.ClickTrackingParams.SetFake()
}
}
{
{
s.WatchEndpoint.SetFake()
}
}
{
{
s.BrowseEndpoint.SetFake()
}
}
}
// SetFake set fake values.
func (s *OptAccessibility) SetFake() {
var elem Accessibility
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptAccessibilityData) SetFake() {
var elem AccessibilityData
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptAnchoredSectionRenderer) SetFake() {
var elem AnchoredSectionRenderer
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptAnchoredSectionRendererContent) SetFake() {
var elem AnchoredSectionRendererContent
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptBrowseEndpoint) SetFake() {
var elem BrowseEndpoint
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptBrowseResponsePayloadContents) SetFake() {
var elem BrowseResponsePayloadContents
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptBrowseResponsePayloadHeader) SetFake() {
var elem BrowseResponsePayloadHeader
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptCategoriesHeaderRenderer) SetFake() {
var elem CategoriesHeaderRenderer
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptCategoryAssets) SetFake() {
var elem CategoryAssets
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptCompactVideoRenderer) SetFake() {
var elem CompactVideoRenderer
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptCompactVideoRendererChannelThumbnail) SetFake() {
var elem CompactVideoRendererChannelThumbnail
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptCompactVideoRendererThumbnail) SetFake() {
var elem CompactVideoRendererThumbnail
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptErrorResponsePayloadError) SetFake() {
var elem ErrorResponsePayloadError
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptFloat64) SetFake() {
var elem float64
{
elem = float64(0)
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptItemSectionRenderer) SetFake() {
var elem ItemSectionRenderer
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptKidsAppCategorySettings) SetFake() {
var elem KidsAppCategorySettings
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptKidsAppContentSettings) SetFake() {
var elem KidsAppContentSettings
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptKidsAppInfo) SetFake() {
var elem KidsAppInfo
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptKidsVideoOwnerExtension) SetFake() {
var elem KidsVideoOwnerExtension
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptNavigationEndpoint) SetFake() {
var elem NavigationEndpoint
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptRequestClient) SetFake() {
var elem RequestClient
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptRequestContext) SetFake() {
var elem RequestContext
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptResponseContext) SetFake() {
var elem ResponseContext
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptScreenRenderer) SetFake() {
var elem ScreenRenderer
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptSectionListRenderer) SetFake() {
var elem SectionListRenderer
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptString) SetFake() {
var elem string
{
elem = "string"
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptText) SetFake() {
var elem Text
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptWatchEndpoint) SetFake() {
var elem WatchEndpoint
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *RequestClient) SetFake() {
{
{
s.ClientName.SetFake()
}
}
{
{
s.ClientVersion.SetFake()
}
}
{
{
s.Hl.SetFake()
}
}
{
{
s.Gl.SetFake()
}
}
{
{
s.ExperimentsToken.SetFake()
}
}
{
{
s.BrowserName.SetFake()
}
}
{
{
s.DeviceMake.SetFake()
}
}
{
{
s.BrowserVersion.SetFake()
}
}
{
{
s.OsName.SetFake()
}
}
{
{
s.OsVersion.SetFake()
}
}
{
{
s.Platform.SetFake()
}
}
{
{
s.KidsAppInfo.SetFake()
}
}
}
// SetFake set fake values.
func (s *RequestContext) SetFake() {
{
{
s.Client.SetFake()
}
}
}
// SetFake set fake values.
func (s *ResponseContext) SetFake() {
{
{
s.VisitorData.SetFake()
}
}
{
{
s.MaxAgeSeconds.SetFake()
}
}
{
{
s.ServiceTrackingParams = nil
for i := 0; i < 0; i++ {
var elem ResponseContextServiceTrackingParamsItem
{
elem.SetFake()
}
s.ServiceTrackingParams = append(s.ServiceTrackingParams, elem)
}
}
}
}
// SetFake set fake values.
func (s *ResponseContextServiceTrackingParamsItem) SetFake() {
{
{
s.Service.SetFake()
}
}
{
{
s.Params = nil
for i := 0; i < 0; i++ {
var elem KeyStringValue
{
elem.SetFake()
}
s.Params = append(s.Params, elem)
}
}
}
}
// SetFake set fake values.
func (s *ScreenAnchor) SetFake() {
{
{
s.AnchoredSectionRenderer.SetFake()
}
}
}
// SetFake set fake values.
func (s *ScreenRenderer) SetFake() {
{
{
s.Anchors = nil
for i := 0; i < 0; i++ {
var elem ScreenAnchor
{
elem.SetFake()
}
s.Anchors = append(s.Anchors, elem)
}
}
}
}
// SetFake set fake values.
func (s *SectionListRenderer) SetFake() {
{
{
s.Contents = nil
for i := 0; i < 0; i++ {
var elem SectionListRendererContentsItem
{
elem.SetFake()
}
s.Contents = append(s.Contents, elem)
}
}
}
{
{
s.TrackingParams.SetFake()
}
}
}
// SetFake set fake values.
func (s *SectionListRendererContentsItem) SetFake() {
{
{
s.ItemSectionRenderer.SetFake()
}
}
}
// SetFake set fake values.
func (s *Text) SetFake() {
{
{
s.Runs = nil
for i := 0; i < 0; i++ {
var elem TextRun
{
elem.SetFake()
}
s.Runs = append(s.Runs, elem)
}
}
}
{
{
s.Accessibility.SetFake()
}
}
}
// SetFake set fake values.
func (s *TextRun) SetFake() {
{
{
s.Text.SetFake()
}
}
{
{
s.NavigationEndpoint.SetFake()
}
}
}
// SetFake set fake values.
func (s *Thumbnail) SetFake() {
{
{
s.URL.SetFake()
}
}
{
{
s.Width.SetFake()
}
}
{
{
s.Height.SetFake()
}
}
}
// SetFake set fake values.
func (s *WatchEndpoint) SetFake() {
{
{
s.VideoId.SetFake()
}
}
}

6
oas_interfaces_gen.go Normal file
View File

@ -0,0 +1,6 @@
// Code generated by ogen, DO NOT EDIT.
package go_youtubekids_client
type BrowseRes interface {
browseRes()
}

4297
oas_json_gen.go Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,26 @@
// Code generated by ogen, DO NOT EDIT.
package go_youtubekids_client
import (
"bytes"
"net/http"
"github.com/go-faster/jx"
ht "github.com/ogen-go/ogen/http"
)
func encodeBrowseRequest(
req *BrowseRequestPayload,
r *http.Request,
) error {
const contentType = "application/json"
e := jx.GetEncoder()
{
req.Encode(e)
}
encoded := e.Bytes()
ht.SetBody(r, bytes.NewReader(encoded), contentType)
return nil
}

View File

@ -0,0 +1,91 @@
// Code generated by ogen, DO NOT EDIT.
package go_youtubekids_client
import (
"io"
"mime"
"net/http"
"github.com/go-faster/errors"
"github.com/go-faster/jx"
"github.com/ogen-go/ogen/ogenerrors"
"github.com/ogen-go/ogen/validate"
)
func decodeBrowseResponse(resp *http.Response) (res BrowseRes, err error) {
switch resp.StatusCode {
case 200:
// Code 200.
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
if err != nil {
return res, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/json":
buf, err := io.ReadAll(resp.Body)
if err != nil {
return res, err
}
d := jx.DecodeBytes(buf)
var response BrowseResponsePayload
if err := func() error {
if err := response.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return res, err
}
return &response, nil
default:
return res, validate.InvalidContentType(ct)
}
case 400:
// Code 400.
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
if err != nil {
return res, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/json":
buf, err := io.ReadAll(resp.Body)
if err != nil {
return res, err
}
d := jx.DecodeBytes(buf)
var response ErrorResponsePayload
if err := func() error {
if err := response.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return res, err
}
return &response, nil
default:
return res, validate.InvalidContentType(ct)
}
}
return res, validate.UnexpectedStatusCode(resp.StatusCode)
}

2439
oas_schemas_gen.go Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,457 @@
// Code generated by ogen, DO NOT EDIT.
package go_youtubekids_client
import (
"github.com/go-faster/jx"
std "encoding/json"
"testing"
"github.com/stretchr/testify/require"
)
func TestAccessibility_EncodeDecode(t *testing.T) {
var typ Accessibility
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 Accessibility
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestAccessibilityData_EncodeDecode(t *testing.T) {
var typ AccessibilityData
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 AccessibilityData
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestAnchoredSectionRenderer_EncodeDecode(t *testing.T) {
var typ AnchoredSectionRenderer
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 AnchoredSectionRenderer
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestAnchoredSectionRendererContent_EncodeDecode(t *testing.T) {
var typ AnchoredSectionRendererContent
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 AnchoredSectionRendererContent
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestBrowseEndpoint_EncodeDecode(t *testing.T) {
var typ BrowseEndpoint
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 BrowseEndpoint
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestBrowseRequestPayload_EncodeDecode(t *testing.T) {
var typ BrowseRequestPayload
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 BrowseRequestPayload
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestBrowseResponsePayload_EncodeDecode(t *testing.T) {
var typ BrowseResponsePayload
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 BrowseResponsePayload
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestBrowseResponsePayloadContents_EncodeDecode(t *testing.T) {
var typ BrowseResponsePayloadContents
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 BrowseResponsePayloadContents
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestBrowseResponsePayloadHeader_EncodeDecode(t *testing.T) {
var typ BrowseResponsePayloadHeader
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 BrowseResponsePayloadHeader
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestCategoriesHeaderRenderer_EncodeDecode(t *testing.T) {
var typ CategoriesHeaderRenderer
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 CategoriesHeaderRenderer
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestCategoryAssets_EncodeDecode(t *testing.T) {
var typ CategoryAssets
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 CategoryAssets
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestCompactVideoRenderer_EncodeDecode(t *testing.T) {
var typ CompactVideoRenderer
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 CompactVideoRenderer
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestCompactVideoRendererChannelThumbnail_EncodeDecode(t *testing.T) {
var typ CompactVideoRendererChannelThumbnail
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 CompactVideoRendererChannelThumbnail
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestCompactVideoRendererThumbnail_EncodeDecode(t *testing.T) {
var typ CompactVideoRendererThumbnail
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 CompactVideoRendererThumbnail
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestError_EncodeDecode(t *testing.T) {
var typ Error
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 Error
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestErrorResponsePayload_EncodeDecode(t *testing.T) {
var typ ErrorResponsePayload
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 ErrorResponsePayload
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestErrorResponsePayloadError_EncodeDecode(t *testing.T) {
var typ ErrorResponsePayloadError
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 ErrorResponsePayloadError
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestItemSectionRenderer_EncodeDecode(t *testing.T) {
var typ ItemSectionRenderer
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 ItemSectionRenderer
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestItemSectionRendererContentsItem_EncodeDecode(t *testing.T) {
var typ ItemSectionRendererContentsItem
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 ItemSectionRendererContentsItem
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestKeyStringValue_EncodeDecode(t *testing.T) {
var typ KeyStringValue
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 KeyStringValue
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestKidsAppCategorySettings_EncodeDecode(t *testing.T) {
var typ KidsAppCategorySettings
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 KidsAppCategorySettings
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestKidsAppContentSettings_EncodeDecode(t *testing.T) {
var typ KidsAppContentSettings
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 KidsAppContentSettings
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestKidsAppInfo_EncodeDecode(t *testing.T) {
var typ KidsAppInfo
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 KidsAppInfo
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestKidsVideoOwnerExtension_EncodeDecode(t *testing.T) {
var typ KidsVideoOwnerExtension
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 KidsVideoOwnerExtension
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestNavigationEndpoint_EncodeDecode(t *testing.T) {
var typ NavigationEndpoint
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 NavigationEndpoint
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestRequestClient_EncodeDecode(t *testing.T) {
var typ RequestClient
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 RequestClient
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestRequestContext_EncodeDecode(t *testing.T) {
var typ RequestContext
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 RequestContext
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestResponseContext_EncodeDecode(t *testing.T) {
var typ ResponseContext
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 ResponseContext
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestResponseContextServiceTrackingParamsItem_EncodeDecode(t *testing.T) {
var typ ResponseContextServiceTrackingParamsItem
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 ResponseContextServiceTrackingParamsItem
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestScreenAnchor_EncodeDecode(t *testing.T) {
var typ ScreenAnchor
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 ScreenAnchor
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestScreenRenderer_EncodeDecode(t *testing.T) {
var typ ScreenRenderer
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 ScreenRenderer
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestSectionListRenderer_EncodeDecode(t *testing.T) {
var typ SectionListRenderer
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 SectionListRenderer
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestSectionListRendererContentsItem_EncodeDecode(t *testing.T) {
var typ SectionListRendererContentsItem
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 SectionListRendererContentsItem
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestText_EncodeDecode(t *testing.T) {
var typ Text
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 Text
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestTextRun_EncodeDecode(t *testing.T) {
var typ TextRun
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 TextRun
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestThumbnail_EncodeDecode(t *testing.T) {
var typ Thumbnail
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 Thumbnail
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestWatchEndpoint_EncodeDecode(t *testing.T) {
var typ WatchEndpoint
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 WatchEndpoint
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}

527
oas_validators_gen.go Normal file
View File

@ -0,0 +1,527 @@
// Code generated by ogen, DO NOT EDIT.
package go_youtubekids_client
import (
"fmt"
"github.com/go-faster/errors"
"github.com/ogen-go/ogen/validate"
)
func (s *AnchoredSectionRenderer) Validate() error {
var failures []validate.FieldError
if err := func() error {
if s.Content.Set {
if err := func() error {
if err := s.Content.Value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "content",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *AnchoredSectionRendererContent) Validate() error {
var failures []validate.FieldError
if err := func() error {
if s.SectionListRenderer.Set {
if err := func() error {
if err := s.SectionListRenderer.Value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "sectionListRenderer",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *BrowseResponsePayload) Validate() error {
var failures []validate.FieldError
if err := func() error {
if s.ResponseContext.Set {
if err := func() error {
if err := s.ResponseContext.Value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "responseContext",
Error: err,
})
}
if err := func() error {
if s.Contents.Set {
if err := func() error {
if err := s.Contents.Value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "contents",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *BrowseResponsePayloadContents) Validate() error {
var failures []validate.FieldError
if err := func() error {
if s.KidsHomeScreenRenderer.Set {
if err := func() error {
if err := s.KidsHomeScreenRenderer.Value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "kidsHomeScreenRenderer",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *CompactVideoRenderer) Validate() error {
var failures []validate.FieldError
if err := func() error {
if s.Thumbnail.Set {
if err := func() error {
if err := s.Thumbnail.Value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "thumbnail",
Error: err,
})
}
if err := func() error {
if s.ChannelThumbnail.Set {
if err := func() error {
if err := s.ChannelThumbnail.Value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "channelThumbnail",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *CompactVideoRendererChannelThumbnail) Validate() error {
var failures []validate.FieldError
if err := func() error {
var failures []validate.FieldError
for i, elem := range s.Thumbnails {
if err := func() error {
if err := elem.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: fmt.Sprintf("[%d]", i),
Error: err,
})
}
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "thumbnails",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *CompactVideoRendererThumbnail) Validate() error {
var failures []validate.FieldError
if err := func() error {
var failures []validate.FieldError
for i, elem := range s.Thumbnails {
if err := func() error {
if err := elem.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: fmt.Sprintf("[%d]", i),
Error: err,
})
}
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "thumbnails",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *ErrorResponsePayload) Validate() error {
var failures []validate.FieldError
if err := func() error {
if s.Error.Set {
if err := func() error {
if err := s.Error.Value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "error",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *ErrorResponsePayloadError) Validate() error {
var failures []validate.FieldError
if err := func() error {
if s.Code.Set {
if err := func() error {
if err := (validate.Float{}).Validate(float64(s.Code.Value)); err != nil {
return errors.Wrap(err, "float")
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "code",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *ItemSectionRenderer) Validate() error {
var failures []validate.FieldError
if err := func() error {
var failures []validate.FieldError
for i, elem := range s.Contents {
if err := func() error {
if err := elem.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: fmt.Sprintf("[%d]", i),
Error: err,
})
}
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "contents",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *ItemSectionRendererContentsItem) Validate() error {
var failures []validate.FieldError
if err := func() error {
if s.CompactVideoRenderer.Set {
if err := func() error {
if err := s.CompactVideoRenderer.Value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "compactVideoRenderer",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *ResponseContext) Validate() error {
var failures []validate.FieldError
if err := func() error {
if s.MaxAgeSeconds.Set {
if err := func() error {
if err := (validate.Float{}).Validate(float64(s.MaxAgeSeconds.Value)); err != nil {
return errors.Wrap(err, "float")
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "maxAgeSeconds",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *ScreenAnchor) Validate() error {
var failures []validate.FieldError
if err := func() error {
if s.AnchoredSectionRenderer.Set {
if err := func() error {
if err := s.AnchoredSectionRenderer.Value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "anchoredSectionRenderer",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *ScreenRenderer) Validate() error {
var failures []validate.FieldError
if err := func() error {
var failures []validate.FieldError
for i, elem := range s.Anchors {
if err := func() error {
if err := elem.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: fmt.Sprintf("[%d]", i),
Error: err,
})
}
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "anchors",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *SectionListRenderer) Validate() error {
var failures []validate.FieldError
if err := func() error {
var failures []validate.FieldError
for i, elem := range s.Contents {
if err := func() error {
if err := elem.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: fmt.Sprintf("[%d]", i),
Error: err,
})
}
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "contents",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *SectionListRendererContentsItem) Validate() error {
var failures []validate.FieldError
if err := func() error {
if s.ItemSectionRenderer.Set {
if err := func() error {
if err := s.ItemSectionRenderer.Value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "itemSectionRenderer",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *Thumbnail) Validate() error {
var failures []validate.FieldError
if err := func() error {
if s.Width.Set {
if err := func() error {
if err := (validate.Float{}).Validate(float64(s.Width.Value)); err != nil {
return errors.Wrap(err, "float")
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "width",
Error: err,
})
}
if err := func() error {
if s.Height.Set {
if err := func() error {
if err := (validate.Float{}).Validate(float64(s.Height.Value)); err != nil {
return errors.Wrap(err, "float")
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "height",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}