aboutsummaryrefslogtreecommitdiff
path: root/generated.go.in
diff options
context:
space:
mode:
Diffstat (limited to 'generated.go.in')
-rw-r--r--generated.go.in80
1 files changed, 36 insertions, 44 deletions
diff --git a/generated.go.in b/generated.go.in
index 034a8e4..808c950 100644
--- a/generated.go.in
+++ b/generated.go.in
@@ -1,33 +1,33 @@
{
"Account": {
"Fields": [
- { "Header": "X-Account-Bytes-Used", "Attribute": "BytesUsed", "Type": "headers.Uint64Readonly" },
- { "Header": "X-Account-Container-Count", "Attribute": "ContainerCount", "Type": "headers.Uint64Readonly" },
- { "Header": "X-Account-Meta-", "Attribute": "Metadata", "Type": "headers.Metadata" },
- { "Header": "X-Account-Meta-Quota-Bytes", "Attribute": "QuotaBytes", "Type": "headers.Uint64" },
- { "Header": "X-Account-Meta-Temp-URL-Key-2", "Attribute": "TempURLKey2", "Type": "headers.String" },
- { "Header": "X-Account-Meta-Temp-URL-Key", "Attribute": "TempURLKey", "Type": "headers.String" },
- { "Header": "X-Account-Object-Count", "Attribute": "ObjectCount", "Type": "headers.Uint64Readonly" },
- { "Header": "X-Timestamp", "Attribute": "Timestamp", "Type": "headers.UnixTimeReadonly" }
+ { "Header": "X-Account-Bytes-Used", "Attribute": "BytesUsed", "Type": "Uint64Readonly" },
+ { "Header": "X-Account-Container-Count", "Attribute": "ContainerCount", "Type": "Uint64Readonly" },
+ { "Header": "X-Account-Meta-", "Attribute": "Metadata", "Type": "Metadata" },
+ { "Header": "X-Account-Meta-Quota-Bytes", "Attribute": "QuotaBytes", "Type": "Uint64" },
+ { "Header": "X-Account-Meta-Temp-URL-Key-2", "Attribute": "TempURLKey2", "Type": "String" },
+ { "Header": "X-Account-Meta-Temp-URL-Key", "Attribute": "TempURLKey", "Type": "String" },
+ { "Header": "X-Account-Object-Count", "Attribute": "ObjectCount", "Type": "Uint64Readonly" },
+ { "Header": "X-Timestamp", "Attribute": "Timestamp", "Type": "UnixTimeReadonly" }
]
},
"Container": {
"Fields": [
- { "Header": "X-Container-Bytes-Used", "Attribute": "BytesUsed", "Type": "headers.Uint64Readonly" },
- { "Header": "X-Container-Meta-", "Attribute": "Metadata", "Type": "headers.Metadata" },
- { "Header": "X-Container-Meta-Quota-Bytes", "Attribute": "BytesUsedQuota", "Type": "headers.Uint64" },
- { "Header": "X-Container-Meta-Quota-Count", "Attribute": "ObjectCountQuota", "Type": "headers.Uint64" },
- { "Header": "X-Container-Meta-Temp-URL-Key-2", "Attribute": "TempURLKey2", "Type": "headers.String" },
- { "Header": "X-Container-Meta-Temp-URL-Key", "Attribute": "TempURLKey", "Type": "headers.String" },
- { "Header": "X-Container-Object-Count", "Attribute": "ObjectCount", "Type": "headers.Uint64Readonly" },
- { "Header": "X-Container-Read", "Attribute": "ReadACL", "Type": "headers.String" },
- { "Header": "X-Container-Sync-Key", "Attribute": "SyncKey", "Type": "headers.String" },
- { "Header": "X-Container-Sync-To", "Attribute": "SyncTo", "Type": "headers.String" },
- { "Header": "X-Container-Write", "Attribute": "WriteACL", "Type": "headers.String" },
- { "Header": "X-History-Location", "Attribute": "HistoryLocation", "Type": "headers.String" },
- { "Header": "X-Storage-Policy", "Attribute": "StoragePolicy", "Type": "headers.String" },
- { "Header": "X-Timestamp", "Attribute": "Timestamp", "Type": "headers.UnixTimeReadonly" },
- { "Header": "X-Versions-Location", "Attribute": "VersionsLocation", "Type": "headers.String" }
+ { "Header": "X-Container-Bytes-Used", "Attribute": "BytesUsed", "Type": "Uint64Readonly" },
+ { "Header": "X-Container-Meta-", "Attribute": "Metadata", "Type": "Metadata" },
+ { "Header": "X-Container-Meta-Quota-Bytes", "Attribute": "BytesUsedQuota", "Type": "Uint64" },
+ { "Header": "X-Container-Meta-Quota-Count", "Attribute": "ObjectCountQuota", "Type": "Uint64" },
+ { "Header": "X-Container-Meta-Temp-URL-Key-2", "Attribute": "TempURLKey2", "Type": "String" },
+ { "Header": "X-Container-Meta-Temp-URL-Key", "Attribute": "TempURLKey", "Type": "String" },
+ { "Header": "X-Container-Object-Count", "Attribute": "ObjectCount", "Type": "Uint64Readonly" },
+ { "Header": "X-Container-Read", "Attribute": "ReadACL", "Type": "String" },
+ { "Header": "X-Container-Sync-Key", "Attribute": "SyncKey", "Type": "String" },
+ { "Header": "X-Container-Sync-To", "Attribute": "SyncTo", "Type": "String" },
+ { "Header": "X-Container-Write", "Attribute": "WriteACL", "Type": "String" },
+ { "Header": "X-History-Location", "Attribute": "HistoryLocation", "Type": "String" },
+ { "Header": "X-Storage-Policy", "Attribute": "StoragePolicy", "Type": "String" },
+ { "Header": "X-Timestamp", "Attribute": "Timestamp", "Type": "UnixTimeReadonly" },
+ { "Header": "X-Versions-Location", "Attribute": "VersionsLocation", "Type": "String" }
]
}
}
@@ -42,18 +42,15 @@
package schwift
-import (
- "net/textproto"
-
- "github.com/majewsky/schwift/headers"
-)
+import "net/textproto"
{{- range $htype, $hmeta := . }}
//{{$htype}}Headers contains the headers for a schwift.{{$htype}} instance.
//
//To read and write well-known headers, use the methods on this type.
-//To read and write arbitary headers, use the methods on type Headers.
+//To read and write arbitary headers, use the http.Header-like methods Get(),
+//Set(), Clear(), Del().
type {{$htype}}Headers map[string]string
//Clear sets the value for the specified header to the empty string. When the
@@ -91,30 +88,25 @@ func (h {{$htype}}Headers) Set(key, value string) {
h[textproto.CanonicalMIMEHeaderKey(key)] = value
}
-//Validate returns headers.MalformedHeaderError if the value of any well-known
-//header does not conform to its data type. This is called automatically by
-//Schwift when preparing an {{$htype}}Headers instance from a GET/HEAD response,
-//so you usually do not need to do it yourself. You will get the validation error
-//from the {{$htype}} method doing the request, e.g. Headers().
+//Validate returns MalformedHeaderError if the value of any well-known header
+//does not conform to its data type. This is called automatically by Schwift
+//when preparing an {{$htype}}Headers instance from a GET/HEAD response, so you
+//usually do not need to do it yourself. You will get the validation error from
+//the {{$htype}} method doing the request, e.g. Headers().
func (h {{$htype}}Headers) Validate() error {
-{{- range $field := $hmeta.Fields }}{{if not (eq $field.Type "headers.String" "headers.Metadata")}}
- if err := h.{{$field.Attribute}}().Validate(); err != nil {
+{{- range $field := $hmeta.Fields }}
+ if err := h.{{$field.Attribute}}().validate(); err != nil {
return err
}
-{{- end }}{{ end }}
+{{- end }}
return evadeGolintComplaint1()
}
{{- range $field := $hmeta.Fields }}
//{{$field.Attribute}} provides type-safe access to {{$field.Header}} headers.
-func (h {{$htype}}Headers) {{$field.Attribute}}() {{$field.Type}} {
- return {{$field.Type}}{
- Base: headers.Base{
- H: h,
- K: "{{$field.Header}}",
- },
- }
+func (h {{$htype}}Headers) {{$field.Attribute}}() Field{{$field.Type}} {
+ return Field{{$field.Type}}{h, "{{$field.Header}}"}
}
{{- end }}
{{- end }}