/// <summary> /// Timestamp format for the shape. /// </summary> public TimestampFormat GetTimestampFormat(MarshallLocation marshallLocation) { var timestampFormat = data.GetTimestampFormat(); if (timestampFormat == TimestampFormat.None) { timestampFormat = Member.GetDefaultTimestampFormat(marshallLocation, this.model.Type); } return(timestampFormat); }
/// <summary> /// Returns the marshaller method to use in the generated marshaller code for a /// shape of primitive type. This is used while marshalling lists and maps. /// </summary> public string PrimitiveMarshaller(MarshallLocation marshallLocation) { if (this.IsDateTime) { var timestampFormat = GetTimestampFormat(marshallLocation); return("StringUtils.FromDateTimeTo" + timestampFormat); } else { return("StringUtils.From" + this.GetPrimitiveType()); } }
internal static TimestampFormat GetDefaultTimestampFormat(MarshallLocation marshallLocation, ServiceType serviceType) { // Rules used to default the format if timestampFormat is not specified. // 1. All timestamp values serialized in HTTP headers are formatted using rfc822 by default. // 2. All timestamp values serialized in query strings are formatted using iso8601 by default. if (marshallLocation == MarshallLocation.Header) { return(TimestampFormat.RFC822); } else if (marshallLocation == MarshallLocation.QueryString) { return(TimestampFormat.ISO8601); } else { // Return protocol defaults if marshall location is not header or querystring. // The default timestamp formats per protocol for structured payload shapes are as follows. // rest-json: unixTimestamp // jsonrpc: unixTimestamp // rest-xml: iso8601 // query: iso8601 // ec2: iso8601 switch (serviceType) { case ServiceType.Rest_Json: return(TimestampFormat.UnixTimestamp); case ServiceType.Json: return(TimestampFormat.UnixTimestamp); case ServiceType.Query: return(TimestampFormat.ISO8601); case ServiceType.Rest_Xml: return(TimestampFormat.ISO8601); default: throw new InvalidOperationException( "Encountered unknown model type (protocol): " + serviceType); } } }