Skip to content

Commit 0798489

Browse files
author
Rajat Goel
authored
Merge pull request #76 from dropbox/handle-timestamp
Handle nullable timestamp
2 parents 41fdcda + 058f1b9 commit 0798489

File tree

7 files changed

+47
-42
lines changed

7 files changed

+47
-42
lines changed

dropbox/files/types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ type CommitInfo struct {
175175
// the Dropbox servers. It can also record an additional timestamp, provided
176176
// by Dropbox desktop clients, mobile clients, and API apps of when the file
177177
// was actually created or modified.
178-
ClientModified time.Time `json:"client_modified,omitempty"`
178+
ClientModified *time.Time `json:"client_modified,omitempty"`
179179
// Mute : Normally, users are made aware of any file modifications in their
180180
// Dropbox account via notifications in the client software. If true, this
181181
// tells the clients that this modification shouldn't result in a user
@@ -1316,7 +1316,7 @@ type FileLockMetadata struct {
13161316
// LockholderAccountId : The account ID of the lock holder if known.
13171317
LockholderAccountId string `json:"lockholder_account_id,omitempty"`
13181318
// Created : The timestamp of the lock was created.
1319-
Created time.Time `json:"created,omitempty"`
1319+
Created *time.Time `json:"created,omitempty"`
13201320
}
13211321

13221322
// NewFileLockMetadata returns a new FileLockMetadata instance
@@ -2160,7 +2160,7 @@ type ListRevisionsResult struct {
21602160
// is either deleted or moved.
21612161
IsDeleted bool `json:"is_deleted"`
21622162
// ServerDeleted : The time of deletion if the file was deleted.
2163-
ServerDeleted time.Time `json:"server_deleted,omitempty"`
2163+
ServerDeleted *time.Time `json:"server_deleted,omitempty"`
21642164
// Entries : The revisions for the file. Only revisions that are not deleted
21652165
// will show up here.
21662166
Entries []*FileMetadata `json:"entries"`
@@ -2459,7 +2459,7 @@ type MediaMetadata struct {
24592459
// Location : The GPS coordinate of the photo/video.
24602460
Location *GpsCoordinates `json:"location,omitempty"`
24612461
// TimeTaken : The timestamp when the photo/video is taken.
2462-
TimeTaken time.Time `json:"time_taken,omitempty"`
2462+
TimeTaken *time.Time `json:"time_taken,omitempty"`
24632463
}
24642464

24652465
// NewMediaMetadata returns a new MediaMetadata instance

dropbox/paper/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ type Cursor struct {
138138
// time will have a very short expiration as docs do get modified very often
139139
// and the modified time can be changed while the iteration is happening
140140
// thus altering the results.
141-
Expiration time.Time `json:"expiration,omitempty"`
141+
Expiration *time.Time `json:"expiration,omitempty"`
142142
}
143143

144144
// NewCursor returns a new Cursor instance

dropbox/sharing/types.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ type LinkMetadata struct {
427427
// Visibility : Who can access the link.
428428
Visibility *Visibility `json:"visibility"`
429429
// Expires : Expiration time, if set. By default the link won't expire.
430-
Expires time.Time `json:"expires,omitempty"`
430+
Expires *time.Time `json:"expires,omitempty"`
431431
}
432432

433433
// NewLinkMetadata returns a new LinkMetadata instance
@@ -671,7 +671,7 @@ type SharedContentLinkMetadataBase struct {
671671
CurrentAudience *LinkAudience `json:"current_audience"`
672672
// Expiry : Whether the link has an expiry set on it. A link with an expiry
673673
// will have its audience changed to members when the expiry is reached.
674-
Expiry time.Time `json:"expiry,omitempty"`
674+
Expiry *time.Time `json:"expiry,omitempty"`
675675
// LinkPermissions : A list of permissions for actions you can perform on
676676
// the link.
677677
LinkPermissions []*LinkPermission `json:"link_permissions"`
@@ -801,7 +801,7 @@ type SharedLinkMetadata struct {
801801
// slash.
802802
Name string `json:"name"`
803803
// Expires : Expiration time, if set. By default the link won't expire.
804-
Expires time.Time `json:"expires,omitempty"`
804+
Expires *time.Time `json:"expires,omitempty"`
805805
// PathLower : The lowercased full path in the user's Dropbox. This always
806806
// starts with a slash. This field will only be present only if the linked
807807
// file is in the authenticated user's dropbox.
@@ -3680,7 +3680,7 @@ type SharedFileMetadata struct {
36803680
// this shared file. If the user was not invited to the shared file, the
36813681
// timestamp will indicate when the user was invited to the parent shared
36823682
// folder. This value may be absent.
3683-
TimeInvited time.Time `json:"time_invited,omitempty"`
3683+
TimeInvited *time.Time `json:"time_invited,omitempty"`
36843684
}
36853685

36863686
// NewSharedFileMetadata returns a new SharedFileMetadata instance
@@ -3922,7 +3922,7 @@ type SharedLinkSettings struct {
39223922
LinkPassword string `json:"link_password,omitempty"`
39233923
// Expires : Expiration time of the shared link. By default the link won't
39243924
// expire.
3925-
Expires time.Time `json:"expires,omitempty"`
3925+
Expires *time.Time `json:"expires,omitempty"`
39263926
// Audience : The new audience who can benefit from the access level
39273927
// specified by the link's access level specified in the `link_access_level`
39283928
// field of `LinkPermissions`. This is used in conjunction with team
@@ -4424,7 +4424,7 @@ type UserFileMembershipInfo struct {
44244424
UserMembershipInfo
44254425
// TimeLastSeen : The UTC timestamp of when the user has last seen the
44264426
// content, if they have.
4427-
TimeLastSeen time.Time `json:"time_last_seen,omitempty"`
4427+
TimeLastSeen *time.Time `json:"time_last_seen,omitempty"`
44284428
// PlatformType : The platform on which the user has last seen the content,
44294429
// or unknown.
44304430
PlatformType *seen_state.PlatformType `json:"platform_type,omitempty"`

dropbox/team/types.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ type DeviceSession struct {
4444
// made.
4545
Country string `json:"country,omitempty"`
4646
// Created : The time this session was created.
47-
Created time.Time `json:"created,omitempty"`
47+
Created *time.Time `json:"created,omitempty"`
4848
// Updated : The time of the last activity from this session.
49-
Updated time.Time `json:"updated,omitempty"`
49+
Updated *time.Time `json:"updated,omitempty"`
5050
}
5151

5252
// NewDeviceSession returns a new DeviceSession instance
@@ -66,7 +66,7 @@ type ActiveWebSession struct {
6666
// Browser : Information on the browser used for this web session.
6767
Browser string `json:"browser"`
6868
// Expires : The time this session expires.
69-
Expires time.Time `json:"expires,omitempty"`
69+
Expires *time.Time `json:"expires,omitempty"`
7070
}
7171

7272
// NewActiveWebSession returns a new ActiveWebSession instance
@@ -278,7 +278,7 @@ type ApiApp struct {
278278
// PublisherUrl : The publisher's URL.
279279
PublisherUrl string `json:"publisher_url,omitempty"`
280280
// Linked : The time this application was linked.
281-
Linked time.Time `json:"linked,omitempty"`
281+
Linked *time.Time `json:"linked,omitempty"`
282282
// IsAppFolder : Whether the linked application uses a dedicated folder.
283283
IsAppFolder bool `json:"is_app_folder"`
284284
}
@@ -439,9 +439,9 @@ func NewCustomQuotaUsersArg(Users []*UserSelectorArg) *CustomQuotaUsersArg {
439439
type DateRange struct {
440440
// StartDate : Optional starting date (inclusive). If start_date is None or
441441
// too long ago, this field will be set to 6 months ago.
442-
StartDate time.Time `json:"start_date,omitempty"`
442+
StartDate *time.Time `json:"start_date,omitempty"`
443443
// EndDate : Optional ending date (exclusive).
444-
EndDate time.Time `json:"end_date,omitempty"`
444+
EndDate *time.Time `json:"end_date,omitempty"`
445445
}
446446

447447
// NewDateRange returns a new DateRange instance
@@ -1950,7 +1950,7 @@ type LegalHoldPolicy struct {
19501950
// Description : A description of the legal hold policy.
19511951
Description string `json:"description,omitempty"`
19521952
// ActivationTime : The time at which the legal hold was activated.
1953-
ActivationTime time.Time `json:"activation_time,omitempty"`
1953+
ActivationTime *time.Time `json:"activation_time,omitempty"`
19541954
// Members : Team members IDs and number of permanetly deleted members under
19551955
// hold.
19561956
Members *MembersInfo `json:"members"`
@@ -1959,7 +1959,7 @@ type LegalHoldPolicy struct {
19591959
// StartDate : Start date of the legal hold policy.
19601960
StartDate time.Time `json:"start_date"`
19611961
// EndDate : End date of the legal hold policy.
1962-
EndDate time.Time `json:"end_date,omitempty"`
1962+
EndDate *time.Time `json:"end_date,omitempty"`
19631963
}
19641964

19651965
// NewLegalHoldPolicy returns a new LegalHoldPolicy instance
@@ -2156,9 +2156,9 @@ type LegalHoldsPolicyCreateArg struct {
21562156
// Members : List of team member IDs added to the hold.
21572157
Members []string `json:"members"`
21582158
// StartDate : start date of the legal hold policy.
2159-
StartDate time.Time `json:"start_date,omitempty"`
2159+
StartDate *time.Time `json:"start_date,omitempty"`
21602160
// EndDate : end date of the legal hold policy.
2161-
EndDate time.Time `json:"end_date,omitempty"`
2161+
EndDate *time.Time `json:"end_date,omitempty"`
21622162
}
21632163

21642164
// NewLegalHoldsPolicyCreateArg returns a new LegalHoldsPolicyCreateArg instance
@@ -2830,14 +2830,14 @@ type MemberProfile struct {
28302830
MembershipType *TeamMembershipType `json:"membership_type"`
28312831
// InvitedOn : The date and time the user was invited to the team (contains
28322832
// value only when the member's status matches `TeamMemberStatus.invited`).
2833-
InvitedOn time.Time `json:"invited_on,omitempty"`
2833+
InvitedOn *time.Time `json:"invited_on,omitempty"`
28342834
// JoinedOn : The date and time the user joined as a member of a specific
28352835
// team.
2836-
JoinedOn time.Time `json:"joined_on,omitempty"`
2836+
JoinedOn *time.Time `json:"joined_on,omitempty"`
28372837
// SuspendedOn : The date and time the user was suspended from the team
28382838
// (contains value only when the member's status matches
28392839
// `TeamMemberStatus.suspended`).
2840-
SuspendedOn time.Time `json:"suspended_on,omitempty"`
2840+
SuspendedOn *time.Time `json:"suspended_on,omitempty"`
28412841
// PersistentId : Persistent ID that a team can attach to the user. The
28422842
// persistent ID is unique ID to be used for SAML authentication.
28432843
PersistentId string `json:"persistent_id,omitempty"`

dropbox/team_common/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ const (
9292
// TimeRange : Time range.
9393
type TimeRange struct {
9494
// StartTime : Optional starting time (inclusive).
95-
StartTime time.Time `json:"start_time,omitempty"`
95+
StartTime *time.Time `json:"start_time,omitempty"`
9696
// EndTime : Optional ending time (exclusive).
97-
EndTime time.Time `json:"end_time,omitempty"`
97+
EndTime *time.Time `json:"end_time,omitempty"`
9898
}
9999

100100
// NewTimeRange returns a new TimeRange instance

dropbox/team_log/types.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,10 +1854,10 @@ type DeviceSessionLogInfo struct {
18541854
IpAddress string `json:"ip_address,omitempty"`
18551855
// Created : The time this session was created. Might be missing due to
18561856
// historical data gap.
1857-
Created time.Time `json:"created,omitempty"`
1857+
Created *time.Time `json:"created,omitempty"`
18581858
// Updated : The time of the last activity from this session. Might be
18591859
// missing due to historical data gap.
1860-
Updated time.Time `json:"updated,omitempty"`
1860+
Updated *time.Time `json:"updated,omitempty"`
18611861
}
18621862

18631863
// NewDeviceSessionLogInfo returns a new DeviceSessionLogInfo instance
@@ -13228,7 +13228,7 @@ func NewFileRequestCreateType(Description string) *FileRequestCreateType {
1322813228
type FileRequestDeadline struct {
1322913229
// Deadline : The deadline for this file request. Might be missing due to
1323013230
// historical data gap.
13231-
Deadline time.Time `json:"deadline,omitempty"`
13231+
Deadline *time.Time `json:"deadline,omitempty"`
1323213232
// AllowLateUploads : If set, allow uploads after the deadline has passed.
1323313233
// Might be missing due to historical data gap.
1323413234
AllowLateUploads string `json:"allow_late_uploads,omitempty"`
@@ -15134,7 +15134,7 @@ type LegalHoldsActivateAHoldDetails struct {
1513415134
// StartDate : Hold start date.
1513515135
StartDate time.Time `json:"start_date"`
1513615136
// EndDate : Hold end date.
15137-
EndDate time.Time `json:"end_date,omitempty"`
15137+
EndDate *time.Time `json:"end_date,omitempty"`
1513815138
}
1513915139

1514015140
// NewLegalHoldsActivateAHoldDetails returns a new LegalHoldsActivateAHoldDetails instance
@@ -19809,7 +19809,7 @@ func NewSharedContentAddInviteesType(Description string) *SharedContentAddInvite
1980919809
type SharedContentAddLinkExpiryDetails struct {
1981019810
// NewValue : New shared content link expiration date. Might be missing due
1981119811
// to historical data gap.
19812-
NewValue time.Time `json:"new_value,omitempty"`
19812+
NewValue *time.Time `json:"new_value,omitempty"`
1981319813
}
1981419814

1981519815
// NewSharedContentAddLinkExpiryDetails returns a new SharedContentAddLinkExpiryDetails instance
@@ -19979,10 +19979,10 @@ func NewSharedContentChangeLinkAudienceType(Description string) *SharedContentCh
1997919979
type SharedContentChangeLinkExpiryDetails struct {
1998019980
// NewValue : New shared content link expiration date. Might be missing due
1998119981
// to historical data gap.
19982-
NewValue time.Time `json:"new_value,omitempty"`
19982+
NewValue *time.Time `json:"new_value,omitempty"`
1998319983
// PreviousValue : Previous shared content link expiration date. Might be
1998419984
// missing due to historical data gap.
19985-
PreviousValue time.Time `json:"previous_value,omitempty"`
19985+
PreviousValue *time.Time `json:"previous_value,omitempty"`
1998619986
}
1998719987

1998819988
// NewSharedContentChangeLinkExpiryDetails returns a new SharedContentChangeLinkExpiryDetails instance
@@ -20234,7 +20234,7 @@ func NewSharedContentRemoveInviteesType(Description string) *SharedContentRemove
2023420234
type SharedContentRemoveLinkExpiryDetails struct {
2023520235
// PreviousValue : Previous shared content link expiration date. Might be
2023620236
// missing due to historical data gap.
20237-
PreviousValue time.Time `json:"previous_value,omitempty"`
20237+
PreviousValue *time.Time `json:"previous_value,omitempty"`
2023820238
}
2023920239

2024020240
// NewSharedContentRemoveLinkExpiryDetails returns a new SharedContentRemoveLinkExpiryDetails instance
@@ -20778,10 +20778,10 @@ func NewSharedLinkAddExpiryType(Description string) *SharedLinkAddExpiryType {
2077820778
type SharedLinkChangeExpiryDetails struct {
2077920779
// NewValue : New shared link expiration date. Might be missing due to
2078020780
// historical data gap.
20781-
NewValue time.Time `json:"new_value,omitempty"`
20781+
NewValue *time.Time `json:"new_value,omitempty"`
2078220782
// PreviousValue : Previous shared link expiration date. Might be missing
2078320783
// due to historical data gap.
20784-
PreviousValue time.Time `json:"previous_value,omitempty"`
20784+
PreviousValue *time.Time `json:"previous_value,omitempty"`
2078520785
}
2078620786

2078720787
// NewSharedLinkChangeExpiryDetails returns a new SharedLinkChangeExpiryDetails instance
@@ -20940,7 +20940,7 @@ func NewSharedLinkDownloadType(Description string) *SharedLinkDownloadType {
2094020940
type SharedLinkRemoveExpiryDetails struct {
2094120941
// PreviousValue : Previous shared link expiration date. Might be missing
2094220942
// due to historical data gap.
20943-
PreviousValue time.Time `json:"previous_value,omitempty"`
20943+
PreviousValue *time.Time `json:"previous_value,omitempty"`
2094420944
}
2094520945

2094620946
// NewSharedLinkRemoveExpiryDetails returns a new SharedLinkRemoveExpiryDetails instance
@@ -20971,7 +20971,7 @@ type SharedLinkSettingsAddExpirationDetails struct {
2097120971
SharedContentLink string `json:"shared_content_link,omitempty"`
2097220972
// NewValue : New shared content link expiration date. Might be missing due
2097320973
// to historical data gap.
20974-
NewValue time.Time `json:"new_value,omitempty"`
20974+
NewValue *time.Time `json:"new_value,omitempty"`
2097520975
}
2097620976

2097720977
// NewSharedLinkSettingsAddExpirationDetails returns a new SharedLinkSettingsAddExpirationDetails instance
@@ -21121,10 +21121,10 @@ type SharedLinkSettingsChangeExpirationDetails struct {
2112121121
SharedContentLink string `json:"shared_content_link,omitempty"`
2112221122
// NewValue : New shared content link expiration date. Might be missing due
2112321123
// to historical data gap.
21124-
NewValue time.Time `json:"new_value,omitempty"`
21124+
NewValue *time.Time `json:"new_value,omitempty"`
2112521125
// PreviousValue : Previous shared content link expiration date. Might be
2112621126
// missing due to historical data gap.
21127-
PreviousValue time.Time `json:"previous_value,omitempty"`
21127+
PreviousValue *time.Time `json:"previous_value,omitempty"`
2112821128
}
2112921129

2113021130
// NewSharedLinkSettingsChangeExpirationDetails returns a new SharedLinkSettingsChangeExpirationDetails instance
@@ -21185,7 +21185,7 @@ type SharedLinkSettingsRemoveExpirationDetails struct {
2118521185
SharedContentLink string `json:"shared_content_link,omitempty"`
2118621186
// PreviousValue : Previous shared link expiration date. Might be missing
2118721187
// due to historical data gap.
21188-
PreviousValue time.Time `json:"previous_value,omitempty"`
21188+
PreviousValue *time.Time `json:"previous_value,omitempty"`
2118921189
}
2119021190

2119121191
// NewSharedLinkSettingsRemoveExpirationDetails returns a new SharedLinkSettingsRemoveExpirationDetails instance

generator/go_helpers.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,12 @@ def fmt_type(data_type, namespace=None, use_interface=False, raw=False):
8585
if use_interface and _needs_base_type(data_type):
8686
return _type_table.get(data_type.__class__, type_name)
8787
else:
88-
return _type_table.get(data_type.__class__, '*' + type_name)
88+
if data_type.__class__ not in _type_table:
89+
return '*' + type_name
90+
if data_type.__class__ == Timestamp:
91+
# For other primitive types, `omitempty` does the job.
92+
return ('*' if nullable else '') + _type_table[data_type.__class__]
93+
return _type_table[data_type.__class__]
8994

9095

9196
def fmt_var(name, export=True, check_reserved=False):

0 commit comments

Comments
 (0)