Skip to content

Commit

Permalink
Merge pull request #121 from philippschulte/refactor-timestamp-fields
Browse files Browse the repository at this point in the history
Refactor and add timestamp fields
  • Loading branch information
philippschulte authored Jun 13, 2019
2 parents 693f551 + 372294f commit 035d337
Show file tree
Hide file tree
Showing 21 changed files with 202 additions and 192 deletions.
12 changes: 6 additions & 6 deletions fastly/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import (
"fmt"
"net/url"
"sort"
"time"
)

type ACL struct {
ServiceID string `mapstructure:"service_id"`
Version int `mapstructure:"version"`

Name string `mapstructure:"name"`
ID string `mapstructure:"id"`

DeletedAt string `mapstructure:"deleted_at"`
CreatedAt string `mapstructure:"created_at"`
UpdatedAt string `mapstructure:"updated_at"`
Name string `mapstructure:"name"`
ID string `mapstructure:"id"`
CreatedAt *time.Time `mapstructure:"created_at"`
UpdatedAt *time.Time `mapstructure:"updated_at"`
DeletedAt *time.Time `mapstructure:"deleted_at"`
}

// ACLsByName is a sortable list of ACLs.
Expand Down
18 changes: 9 additions & 9 deletions fastly/acl_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ package fastly
import (
"fmt"
"sort"
"time"
)

type ACLEntry struct {
ServiceID string `mapstructure:"service_id"`
ACLID string `mapstructure:"acl_id"`

ID string `mapstructure:"id"`
IP string `mapstructure:"ip"`
Subnet string `mapstructure:"subnet"`
Negated bool `mapstructure:"negated"`
Comment string `mapstructure:"comment"`

DeletedAt string `mapstructure:"deleted_at"`
CreatedAt string `mapstructure:"created_at"`
UpdatedAt string `mapstructure:"updated_at"`
ID string `mapstructure:"id"`
IP string `mapstructure:"ip"`
Subnet string `mapstructure:"subnet"`
Negated bool `mapstructure:"negated"`
Comment string `mapstructure:"comment"`
CreatedAt *time.Time `mapstructure:"created_at"`
UpdatedAt *time.Time `mapstructure:"updated_at"`
DeletedAt *time.Time `mapstructure:"deleted_at"`
}

// entriesById is a sortable list of ACL entries.
Expand Down
56 changes: 30 additions & 26 deletions fastly/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,43 @@ import (
"fmt"
"net/url"
"sort"
"time"
)

// Backend represents a backend response from the Fastly API.
type Backend struct {
ServiceID string `mapstructure:"service_id"`
Version int `mapstructure:"version"`

Name string `mapstructure:"name"`
Comment string `mapstructure:"comment"`
Address string `mapstructure:"address"`
Port uint `mapstructure:"port"`
ConnectTimeout uint `mapstructure:"connect_timeout"`
MaxConn uint `mapstructure:"max_conn"`
ErrorThreshold uint `mapstructure:"error_threshold"`
FirstByteTimeout uint `mapstructure:"first_byte_timeout"`
BetweenBytesTimeout uint `mapstructure:"between_bytes_timeout"`
AutoLoadbalance bool `mapstructure:"auto_loadbalance"`
Weight uint `mapstructure:"weight"`
RequestCondition string `mapstructure:"request_condition"`
HealthCheck string `mapstructure:"healthcheck"`
Hostname string `mapstructure:"hostname"`
Shield string `mapstructure:"shield"`
UseSSL bool `mapstructure:"use_ssl"`
SSLCheckCert bool `mapstructure:"ssl_check_cert"`
SSLCACert string `mapstructure:"ssl_ca_cert"`
SSLClientCert string `mapstructure:"ssl_client_cert"`
SSLClientKey string `mapstructure:"ssl_client_key"`
SSLHostname string `mapstructure:"ssl_hostname"`
SSLCertHostname string `mapstructure:"ssl_cert_hostname"`
SSLSNIHostname string `mapstructure:"ssl_sni_hostname"`
MinTLSVersion string `mapstructure:"min_tls_version"`
MaxTLSVersion string `mapstructure:"max_tls_version"`
SSLCiphers []string `mapstructure:"ssl_ciphers"`
Name string `mapstructure:"name"`
Comment string `mapstructure:"comment"`
Address string `mapstructure:"address"`
Port uint `mapstructure:"port"`
ConnectTimeout uint `mapstructure:"connect_timeout"`
MaxConn uint `mapstructure:"max_conn"`
ErrorThreshold uint `mapstructure:"error_threshold"`
FirstByteTimeout uint `mapstructure:"first_byte_timeout"`
BetweenBytesTimeout uint `mapstructure:"between_bytes_timeout"`
AutoLoadbalance bool `mapstructure:"auto_loadbalance"`
Weight uint `mapstructure:"weight"`
RequestCondition string `mapstructure:"request_condition"`
HealthCheck string `mapstructure:"healthcheck"`
Hostname string `mapstructure:"hostname"`
Shield string `mapstructure:"shield"`
UseSSL bool `mapstructure:"use_ssl"`
SSLCheckCert bool `mapstructure:"ssl_check_cert"`
SSLCACert string `mapstructure:"ssl_ca_cert"`
SSLClientCert string `mapstructure:"ssl_client_cert"`
SSLClientKey string `mapstructure:"ssl_client_key"`
SSLHostname string `mapstructure:"ssl_hostname"`
SSLCertHostname string `mapstructure:"ssl_cert_hostname"`
SSLSNIHostname string `mapstructure:"ssl_sni_hostname"`
MinTLSVersion string `mapstructure:"min_tls_version"`
MaxTLSVersion string `mapstructure:"max_tls_version"`
SSLCiphers []string `mapstructure:"ssl_ciphers"`
CreatedAt *time.Time `mapstructure:"created_at"`
UpdatedAt *time.Time `mapstructure:"updated_at"`
DeletedAt *time.Time `mapstructure:"deleted_at"`
}

// backendsByName is a sortable list of backends.
Expand Down
4 changes: 4 additions & 0 deletions fastly/cache_setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"net/url"
"sort"
"time"
)

const (
Expand All @@ -30,6 +31,9 @@ type CacheSetting struct {
TTL uint `mapstructure:"ttl"`
StaleTTL uint `mapstructure:"stale_ttl"`
CacheCondition string `mapstructure:"cache_condition"`
CreatedAt *time.Time `mapstructure:"created_at"`
UpdatedAt *time.Time `mapstructure:"updated_at"`
DeletedAt *time.Time `mapstructure:"deleted_at"`
}

// cacheSettingsByName is a sortable list of cache settings.
Expand Down
14 changes: 9 additions & 5 deletions fastly/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@ import (
"fmt"
"net/url"
"sort"
"time"
)

// Condition represents a condition response from the Fastly API.
type Condition struct {
ServiceID string `mapstructure:"service_id"`
Version int `mapstructure:"version"`

Name string `mapstructure:"name"`
Comment string `mapstructure:"comment"`
Statement string `mapstructure:"statement"`
Type string `mapstructure:"type"`
Priority int `mapstructure:"priority"`
Name string `mapstructure:"name"`
Comment string `mapstructure:"comment"`
Statement string `mapstructure:"statement"`
Type string `mapstructure:"type"`
Priority int `mapstructure:"priority"`
CreatedAt *time.Time `mapstructure:"created_at"`
UpdatedAt *time.Time `mapstructure:"updated_at"`
DeletedAt *time.Time `mapstructure:"deleted_at"`
}

// conditionsByName is a sortable list of conditions.
Expand Down
31 changes: 9 additions & 22 deletions fastly/dictionary.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,20 @@ import (
"fmt"
"net/url"
"sort"
"time"
)

// Dictionary represents a dictionary response from the Fastly API.
type Dictionary struct {
// CreatedAt is the Time-stamp (GMT) when the dictionary was created.
CreatedAt string `mapstructure:"created_at"`

// DeletedAt is the Time-stamp (GMT) when the dictionary was deleted.
DeletedAt string `mapstructure:"deleted_at"`

// ID is the alphanumeric string identifying a dictionary.
ID string `mapstructure:"id"`

// Name is the name for the Dictionary.
Name string `mapstructure:"name"`

// ServiceID is the alphanumeric string identifying a service.
ServiceID string `mapstructure:"service_id"`

// UpdatedAt is the Time-stamp (GMT) when the dictionary was updated.
UpdatedAt string `mapstructure:"updated_at"`

// Version is the current version of the service.
Version int `mapstructure:"version"`

// WriteOnly Determines if items in the dictionary are readable or not.
WriteOnly bool `mapstructure:"write_only"`
Version int `mapstructure:"version"`

ID string `mapstructure:"id"`
Name string `mapstructure:"name"`
WriteOnly bool `mapstructure:"write_only"`
CreatedAt *time.Time `mapstructure:"created_at"`
UpdatedAt *time.Time `mapstructure:"updated_at"`
DeletedAt *time.Time `mapstructure:"deleted_at"`
}

// dictionariesByName is a sortable list of dictionaries.
Expand Down
25 changes: 7 additions & 18 deletions fastly/dictionary_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,19 @@ import (
"fmt"
"net/url"
"sort"
"time"
)

// DictionaryItem represents a dictionary item response from the Fastly API.
type DictionaryItem struct {
// DictionaryID is the alphanumeric string identifying the dictionary for this Item.
ServiceID string `mapstructure:"service_id"`
DictionaryID string `mapstructure:"dictionary_id"`
ItemKey string `mapstructure:"item_key"`

// ServiceID is the service the Dictionary belongs to.
ServiceID string `mapstructure:"service_id"`

// ItemKey is the value for the DictionaryKey.
ItemKey string `mapstructure:"item_key"`

// ItemValue is the value for the DictionaryItem.
ItemValue string `mapstructure:"item_value"`

// CreatedAt is the Time-stamp (GMT) when the dictionary was created.
CreatedAt string `mapstructure:"created_at"`

// DeletedAt is the Time-stamp (GMT) when the dictionary was deleted.
DeletedAt string `mapstructure:"deleted_at"`

// UpdatedAt is the Time-stamp (GMT) when the dictionary was updated.
UpdatedAt string `mapstructure:"updated_at"`
ItemValue string `mapstructure:"item_value"`
CreatedAt *time.Time `mapstructure:"created_at"`
UpdatedAt *time.Time `mapstructure:"updated_at"`
DeletedAt *time.Time `mapstructure:"deleted_at"`
}

// dictionaryItemsByKey is a sortable list of dictionary items.
Expand Down
22 changes: 11 additions & 11 deletions fastly/director.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"net/url"
"sort"
"time"
)

const (
Expand All @@ -28,17 +29,16 @@ type Director struct {
ServiceID string `mapstructure:"service_id"`
Version int `mapstructure:"version"`

Name string `mapstructure:"name"`
Comment string `mapstructure:"comment"`
Shield string `mapstructure:"shield"`
Quorum uint `mapstructure:"quorum"`
Type DirectorType `mapstructure:"type"`
Retries uint `mapstructure:"retries"`
Capacity uint `mapstructure:"capacity"`

DeletedAt string `mapstructure:"deleted_at"`
CreatedAt string `mapstructure:"created_at"`
UpdatedAt string `mapstructure:"updated_at"`
Name string `mapstructure:"name"`
Comment string `mapstructure:"comment"`
Shield string `mapstructure:"shield"`
Quorum uint `mapstructure:"quorum"`
Type DirectorType `mapstructure:"type"`
Retries uint `mapstructure:"retries"`
Capacity uint `mapstructure:"capacity"`
CreatedAt *time.Time `mapstructure:"created_at"`
UpdatedAt *time.Time `mapstructure:"updated_at"`
DeletedAt *time.Time `mapstructure:"deleted_at"`
}

// directorsByName is a sortable list of directors.
Expand Down
8 changes: 6 additions & 2 deletions fastly/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ import (
"fmt"
"net/url"
"sort"
"time"
)

// Domain represents the the domain name Fastly will serve content for.
type Domain struct {
ServiceID string `mapstructure:"service_id"`
Version int `mapstructure:"version"`

Name string `mapstructure:"name"`
Comment string `mapstructure:"comment"`
Name string `mapstructure:"name"`
Comment string `mapstructure:"comment"`
CreatedAt *time.Time `mapstructure:"created_at"`
UpdatedAt *time.Time `mapstructure:"updated_at"`
DeletedAt *time.Time `mapstructure:"deleted_at"`
}

// domainsByName is a sortable list of backends.
Expand Down
6 changes: 4 additions & 2 deletions fastly/event_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/google/jsonapi"
"io"
"io/ioutil"
"net/http"
"reflect"
"strconv"
"time"

"github.com/google/jsonapi"
)

// Events represents an event_logs item response from the Fastly API.
Expand All @@ -22,7 +24,7 @@ type Event struct {
Metadata map[string]interface{} `jsonapi:"attr,metadata,omitempty"`
ServiceID string `jsonapi:"attr,service_id"`
UserID string `jsonapi:"attr,user_id"`
CreatedAt string `jsonapi:"attr,created_at"`
CreatedAt *time.Time `jsonapi:"attr,created_at,iso8601"`
Admin bool `jsonapi:"attr,admin"`
}

Expand Down
30 changes: 17 additions & 13 deletions fastly/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,30 @@ import (
"fmt"
"net/url"
"sort"
"time"
)

// GCS represents an GCS logging response from the Fastly API.
type GCS struct {
ServiceID string `mapstructure:"service_id"`
Version int `mapstructure:"version"`

Name string `mapstructure:"name"`
Bucket string `mapstructure:"bucket_name"`
User string `mapstructure:"user"`
SecretKey string `mapstructure:"secret_key"`
Path string `mapstructure:"path"`
Period uint `mapstructure:"period"`
GzipLevel uint8 `mapstructure:"gzip_level"`
Format string `mapstructure:"format"`
FormatVersion uint `mapstructure:"format_version"`
MessageType string `mapstructure:"message_type"`
ResponseCondition string `mapstructure:"response_condition"`
TimestampFormat string `mapstructure:"timestamp_format"`
Placement string `mapstructure:"placement"`
Name string `mapstructure:"name"`
Bucket string `mapstructure:"bucket_name"`
User string `mapstructure:"user"`
SecretKey string `mapstructure:"secret_key"`
Path string `mapstructure:"path"`
Period uint `mapstructure:"period"`
GzipLevel uint8 `mapstructure:"gzip_level"`
Format string `mapstructure:"format"`
FormatVersion uint `mapstructure:"format_version"`
MessageType string `mapstructure:"message_type"`
ResponseCondition string `mapstructure:"response_condition"`
TimestampFormat string `mapstructure:"timestamp_format"`
Placement string `mapstructure:"placement"`
CreatedAt *time.Time `mapstructure:"created_at"`
UpdatedAt *time.Time `mapstructure:"updated_at"`
DeletedAt *time.Time `mapstructure:"deleted_at"`
}

// gcsesByName is a sortable list of gcses.
Expand Down
Loading

0 comments on commit 035d337

Please sign in to comment.