Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

Commit 114d177

Browse files
committed
asd
1 parent 9da98ba commit 114d177

15 files changed

Lines changed: 251 additions & 159 deletions

api/datetime.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package api
2+
3+
import (
4+
"time"
5+
)
6+
7+
const format = time.RFC1123
8+
9+
type Time time.Time
10+
11+
func (dt *Time) UnmarshalText(text []byte) error {
12+
if len(text) == 0 || string(text) == `""` {
13+
*dt = Time(time.Time{})
14+
return nil
15+
}
16+
17+
t, err := time.Parse(format, string(text))
18+
if err != nil {
19+
return err //nolint:wrapcheck
20+
}
21+
22+
*dt = Time(t)
23+
24+
return nil
25+
}
26+
27+
func Date(year int, month time.Month, day, hour, minute, sec, nsec int, loc *time.Location) Time {
28+
return Time(time.Date(year, month, day, hour, minute, sec, nsec, loc))
29+
}

api/server.gen.go

Lines changed: 85 additions & 90 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/types.gen.go

Lines changed: 10 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/types.manual.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package api
22

3-
import "time"
4-
53
// GetQ returns the Q field value.
64
func (g GetFileParams) GetQ() *int {
75
return g.Q
@@ -27,6 +25,10 @@ func (g GetFileParams) GetF() *OutputImageFormat {
2725
return g.F
2826
}
2927

28+
func (g GetFileParams) HasImageManipulationOptions() bool {
29+
return g.Q != nil || g.H != nil || g.W != nil || g.B != nil || g.F != nil
30+
}
31+
3032
// GetIfMatch returns the IfMatch field value.
3133
func (g GetFileParams) GetIfMatch() *string {
3234
return g.IfMatch
@@ -38,12 +40,12 @@ func (g GetFileParams) GetIfNoneMatch() *string {
3840
}
3941

4042
// GetIfModifiedSince returns the IfModifiedSince field value.
41-
func (g GetFileParams) GetIfModifiedSince() *time.Time {
43+
func (g GetFileParams) GetIfModifiedSince() *Time {
4244
return g.IfModifiedSince
4345
}
4446

4547
// GetIfUnmodifiedSince returns the IfUnmodifiedSince field value.
46-
func (g GetFileParams) GetIfUnmodifiedSince() *time.Time {
48+
func (g GetFileParams) GetIfUnmodifiedSince() *Time {
4749
return g.IfUnmodifiedSince
4850
}
4951

@@ -72,6 +74,10 @@ func (g GetFileMetadataHeadersParams) GetF() *OutputImageFormat {
7274
return g.F
7375
}
7476

77+
func (g GetFileMetadataHeadersParams) HasImageManipulationOptions() bool {
78+
return g.Q != nil || g.H != nil || g.W != nil || g.B != nil || g.F != nil
79+
}
80+
7581
// GetIfMatch returns the IfMatch field value.
7682
func (g GetFileMetadataHeadersParams) GetIfMatch() *string {
7783
return g.IfMatch
@@ -83,12 +89,12 @@ func (g GetFileMetadataHeadersParams) GetIfNoneMatch() *string {
8389
}
8490

8591
// GetIfModifiedSince returns the IfModifiedSince field value.
86-
func (g GetFileMetadataHeadersParams) GetIfModifiedSince() *time.Time {
92+
func (g GetFileMetadataHeadersParams) GetIfModifiedSince() *Time {
8793
return g.IfModifiedSince
8894
}
8995

9096
// GetIfUnmodifiedSince returns the IfUnmodifiedSince field value.
91-
func (g GetFileMetadataHeadersParams) GetIfUnmodifiedSince() *time.Time {
97+
func (g GetFileMetadataHeadersParams) GetIfUnmodifiedSince() *Time {
9298
return g.IfUnmodifiedSince
9399
}
94100

@@ -117,6 +123,10 @@ func (g GetFileWithPresignedURLParams) GetF() *OutputImageFormat {
117123
return g.F
118124
}
119125

126+
func (g GetFileWithPresignedURLParams) HasImageManipulationOptions() bool {
127+
return g.Q != nil || g.H != nil || g.W != nil || g.B != nil || g.F != nil
128+
}
129+
120130
// GetIfMatch returns the IfMatch field value.
121131
func (g GetFileWithPresignedURLParams) GetIfMatch() *string {
122132
return g.IfMatch
@@ -128,11 +138,11 @@ func (g GetFileWithPresignedURLParams) GetIfNoneMatch() *string {
128138
}
129139

130140
// GetIfModifiedSince returns the IfModifiedSince field value.
131-
func (g GetFileWithPresignedURLParams) GetIfModifiedSince() *time.Time {
141+
func (g GetFileWithPresignedURLParams) GetIfModifiedSince() *Time {
132142
return g.IfModifiedSince
133143
}
134144

135145
// GetIfUnmodifiedSince returns the IfUnmodifiedSince field value.
136-
func (g GetFileWithPresignedURLParams) GetIfUnmodifiedSince() *time.Time {
146+
func (g GetFileWithPresignedURLParams) GetIfUnmodifiedSince() *Time {
137147
return g.IfUnmodifiedSince
138148
}

client/client.gen.go

Lines changed: 22 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/datetime.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package client
2+
3+
import (
4+
"time"
5+
)
6+
7+
const format = time.RFC1123
8+
9+
type Time struct {
10+
t time.Time
11+
}
12+
13+
func NewTime(t time.Time) Time {
14+
return Time{t: t}
15+
}
16+
17+
func (dt Time) MarshalText() ([]byte, error) {
18+
if dt.t.IsZero() {
19+
return []byte(`""`), nil
20+
}
21+
22+
return []byte(dt.t.Format(format)), nil
23+
}

client/get_file_metadata_headers_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func TestGetFileMetadataHeaders(t *testing.T) { //nolint:maintidx
131131
name: "IfModifiedSince matches",
132132
id: id1,
133133
params: &client.GetFileMetadataHeadersParams{
134-
IfModifiedSince: ptr(time.Now().Add(-time.Hour)),
134+
IfModifiedSince: ptr(client.NewTime(time.Now().Add(-time.Hour))),
135135
},
136136
interceptor: WithAccessToken(accessTokenValidUser),
137137
expectedStatusCode: http.StatusOK,
@@ -152,7 +152,7 @@ func TestGetFileMetadataHeaders(t *testing.T) { //nolint:maintidx
152152
name: "IfModifiedSince does not match",
153153
id: id1,
154154
params: &client.GetFileMetadataHeadersParams{
155-
IfModifiedSince: ptr(time.Now().Add(time.Hour)),
155+
IfModifiedSince: ptr(client.NewTime(time.Now().Add(time.Hour))),
156156
},
157157
interceptor: WithAccessToken(accessTokenValidUser),
158158
expectedStatusCode: http.StatusNotModified,
@@ -169,7 +169,7 @@ func TestGetFileMetadataHeaders(t *testing.T) { //nolint:maintidx
169169
name: "IfUnmodifiedSince matches",
170170
id: id1,
171171
params: &client.GetFileMetadataHeadersParams{
172-
IfUnmodifiedSince: ptr(time.Now().Add(-time.Hour)),
172+
IfUnmodifiedSince: ptr(client.NewTime(time.Now().Add(-time.Hour))),
173173
},
174174
interceptor: WithAccessToken(accessTokenValidUser),
175175
expectedStatusCode: http.StatusPreconditionFailed,
@@ -186,7 +186,7 @@ func TestGetFileMetadataHeaders(t *testing.T) { //nolint:maintidx
186186
name: "IfUnmodifiedSince does not match",
187187
id: id1,
188188
params: &client.GetFileMetadataHeadersParams{
189-
IfUnmodifiedSince: ptr(time.Now().Add(time.Hour)),
189+
IfUnmodifiedSince: ptr(client.NewTime(time.Now().Add(time.Hour))),
190190
},
191191
interceptor: WithAccessToken(accessTokenValidUser),
192192
expectedStatusCode: http.StatusOK,

client/get_file_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func TestGetFile(t *testing.T) { //nolint:maintidx
189189
name: "IfModifiedSince matches",
190190
id: id1,
191191
params: &client.GetFileParams{
192-
IfModifiedSince: ptr(time.Now().Add(-time.Hour)),
192+
IfModifiedSince: ptr(client.NewTime(time.Now().Add(-time.Hour))),
193193
},
194194
interceptor: WithAccessToken(accessTokenValidUser),
195195
expectedStatusCode: http.StatusOK,
@@ -211,7 +211,7 @@ func TestGetFile(t *testing.T) { //nolint:maintidx
211211
name: "IfModifiedSince does not match",
212212
id: id1,
213213
params: &client.GetFileParams{
214-
IfModifiedSince: ptr(time.Now().Add(time.Hour)),
214+
IfModifiedSince: ptr(client.NewTime(time.Now().Add(time.Hour))),
215215
},
216216
interceptor: WithAccessToken(accessTokenValidUser),
217217
expectedStatusCode: http.StatusNotModified,
@@ -229,7 +229,7 @@ func TestGetFile(t *testing.T) { //nolint:maintidx
229229
name: "IfUnmodifiedSince matches",
230230
id: id1,
231231
params: &client.GetFileParams{
232-
IfUnmodifiedSince: ptr(time.Now().Add(-time.Hour)),
232+
IfUnmodifiedSince: ptr(client.NewTime(time.Now().Add(-time.Hour))),
233233
},
234234
interceptor: WithAccessToken(accessTokenValidUser),
235235
expectedStatusCode: http.StatusPreconditionFailed,
@@ -248,7 +248,7 @@ func TestGetFile(t *testing.T) { //nolint:maintidx
248248
name: "IfUnmodifiedSince does not match",
249249
id: id1,
250250
params: &client.GetFileParams{
251-
IfUnmodifiedSince: ptr(time.Now().Add(time.Hour)),
251+
IfUnmodifiedSince: ptr(client.NewTime(time.Now().Add(time.Hour))),
252252
},
253253
interceptor: WithAccessToken(accessTokenValidUser),
254254
expectedStatusCode: http.StatusOK,

client/get_file_with_presigned_url_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func TestGetFileWithPresignedURL(t *testing.T) { //nolint:cyclop,maintidx
230230
id: id1,
231231
requestParams: func() *client.GetFileWithPresignedURLParams {
232232
req := params1()
233-
req.IfModifiedSince = ptr(time.Now().Add(-time.Hour))
233+
req.IfModifiedSince = ptr(client.NewTime(time.Now().Add(-time.Hour)))
234234
return req
235235
},
236236
interceptor: WithAccessToken(accessTokenValidUser),
@@ -254,7 +254,7 @@ func TestGetFileWithPresignedURL(t *testing.T) { //nolint:cyclop,maintidx
254254
id: id1,
255255
requestParams: func() *client.GetFileWithPresignedURLParams {
256256
req := params1()
257-
req.IfModifiedSince = ptr(time.Now().Add(time.Hour))
257+
req.IfModifiedSince = ptr(client.NewTime(time.Now().Add(time.Hour)))
258258
return req
259259
},
260260
interceptor: WithAccessToken(accessTokenValidUser),
@@ -274,7 +274,7 @@ func TestGetFileWithPresignedURL(t *testing.T) { //nolint:cyclop,maintidx
274274
id: id1,
275275
requestParams: func() *client.GetFileWithPresignedURLParams {
276276
req := params1()
277-
req.IfUnmodifiedSince = ptr(time.Now().Add(-time.Hour))
277+
req.IfUnmodifiedSince = ptr(client.NewTime(time.Now().Add(-time.Hour)))
278278
return req
279279
},
280280
interceptor: WithAccessToken(accessTokenValidUser),
@@ -295,7 +295,7 @@ func TestGetFileWithPresignedURL(t *testing.T) { //nolint:cyclop,maintidx
295295
id: id1,
296296
requestParams: func() *client.GetFileWithPresignedURLParams {
297297
req := params1()
298-
req.IfUnmodifiedSince = ptr(time.Now().Add(time.Hour))
298+
req.IfUnmodifiedSince = ptr(client.NewTime(time.Now().Add(time.Hour)))
299299
return req
300300
},
301301
interceptor: WithAccessToken(accessTokenValidUser),

0 commit comments

Comments
 (0)