_id
stringlengths 2
7
| title
stringlengths 1
118
| partition
stringclasses 3
values | text
stringlengths 52
85.5k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q500 | SetHasFlaggedResources | train | func (s *TrustedAdvisorCheckSummary) SetHasFlaggedResources(v bool) *TrustedAdvisorCheckSummary {
s.HasFlaggedResources = &v
return s
} | go | {
"resource": ""
} |
q501 | SetEstimatedMonthlySavings | train | func (s *TrustedAdvisorCostOptimizingSummary) SetEstimatedMonthlySavings(v float64) *TrustedAdvisorCostOptimizingSummary {
s.EstimatedMonthlySavings = &v
return s
} | go | {
"resource": ""
} |
q502 | SetEstimatedPercentMonthlySavings | train | func (s *TrustedAdvisorCostOptimizingSummary) SetEstimatedPercentMonthlySavings(v float64) *TrustedAdvisorCostOptimizingSummary {
s.EstimatedPercentMonthlySavings = &v
return s
} | go | {
"resource": ""
} |
q503 | SetIsSuppressed | train | func (s *TrustedAdvisorResourceDetail) SetIsSuppressed(v bool) *TrustedAdvisorResourceDetail {
s.IsSuppressed = &v
return s
} | go | {
"resource": ""
} |
q504 | SetResourcesFlagged | train | func (s *TrustedAdvisorResourcesSummary) SetResourcesFlagged(v int64) *TrustedAdvisorResourcesSummary {
s.ResourcesFlagged = &v
return s
} | go | {
"resource": ""
} |
q505 | SetResourcesIgnored | train | func (s *TrustedAdvisorResourcesSummary) SetResourcesIgnored(v int64) *TrustedAdvisorResourcesSummary {
s.ResourcesIgnored = &v
return s
} | go | {
"resource": ""
} |
q506 | SetResourcesProcessed | train | func (s *TrustedAdvisorResourcesSummary) SetResourcesProcessed(v int64) *TrustedAdvisorResourcesSummary {
s.ResourcesProcessed = &v
return s
} | go | {
"resource": ""
} |
q507 | SetResourcesSuppressed | train | func (s *TrustedAdvisorResourcesSummary) SetResourcesSuppressed(v int64) *TrustedAdvisorResourcesSummary {
s.ResourcesSuppressed = &v
return s
} | go | {
"resource": ""
} |
q508 | GoFmt | train | func GoFmt(buf string) string {
formatted, err := format.Source([]byte(buf))
if err != nil {
panic(fmt.Errorf("%s\nOriginal code:\n%s", err.Error(), buf))
}
return string(formatted)
} | go | {
"resource": ""
} |
q509 | Capitalize | train | func Capitalize(s string) string {
if len(s) == 1 {
return strings.ToUpper(s)
}
return strings.ToUpper(s[0:1]) + s[1:]
} | go | {
"resource": ""
} |
q510 | SortXML | train | func SortXML(r io.Reader) string {
var buf bytes.Buffer
d := xml.NewDecoder(r)
root, _ := xmlutil.XMLToStruct(d, nil)
e := xml.NewEncoder(&buf)
xmlutil.StructToXML(e, root, true)
return buf.String()
} | go | {
"resource": ""
} |
q511 | PrettyPrint | train | func PrettyPrint(v interface{}) string {
value := reflect.ValueOf(v)
switch value.Kind() {
case reflect.Struct:
str := fullName(value.Type()) + "{\n"
for i := 0; i < value.NumField(); i++ {
l := string(value.Type().Field(i).Name[0])
if strings.ToUpper(l) == l {
str += value.Type().Field(i).Name + ": "
str += PrettyPrint(value.Field(i).Interface())
str += ",\n"
}
}
str += "}"
return str
case reflect.Map:
str := "map[" + fullName(value.Type().Key()) + "]" + fullName(value.Type().Elem()) + "{\n"
for _, k := range value.MapKeys() {
str += "\"" + k.String() + "\": "
str += PrettyPrint(value.MapIndex(k).Interface())
str += ",\n"
}
str += "}"
return str
case reflect.Ptr:
if e := value.Elem(); e.IsValid() {
return "&" + PrettyPrint(e.Interface())
}
return "nil"
case reflect.Slice:
str := "[]" + fullName(value.Type().Elem()) + "{\n"
for i := 0; i < value.Len(); i++ {
str += PrettyPrint(value.Index(i).Interface())
str += ",\n"
}
str += "}"
return str
default:
return fmt.Sprintf("%#v", v)
}
} | go | {
"resource": ""
} |
q512 | SetForceDeleteWithoutRecovery | train | func (s *DeleteSecretInput) SetForceDeleteWithoutRecovery(v bool) *DeleteSecretInput {
s.ForceDeleteWithoutRecovery = &v
return s
} | go | {
"resource": ""
} |
q513 | SetRecoveryWindowInDays | train | func (s *DeleteSecretInput) SetRecoveryWindowInDays(v int64) *DeleteSecretInput {
s.RecoveryWindowInDays = &v
return s
} | go | {
"resource": ""
} |
q514 | SetVersionIdsToStages | train | func (s *DescribeSecretOutput) SetVersionIdsToStages(v map[string][]*string) *DescribeSecretOutput {
s.VersionIdsToStages = v
return s
} | go | {
"resource": ""
} |
q515 | SetExcludeCharacters | train | func (s *GetRandomPasswordInput) SetExcludeCharacters(v string) *GetRandomPasswordInput {
s.ExcludeCharacters = &v
return s
} | go | {
"resource": ""
} |
q516 | SetExcludeLowercase | train | func (s *GetRandomPasswordInput) SetExcludeLowercase(v bool) *GetRandomPasswordInput {
s.ExcludeLowercase = &v
return s
} | go | {
"resource": ""
} |
q517 | SetExcludeNumbers | train | func (s *GetRandomPasswordInput) SetExcludeNumbers(v bool) *GetRandomPasswordInput {
s.ExcludeNumbers = &v
return s
} | go | {
"resource": ""
} |
q518 | SetExcludePunctuation | train | func (s *GetRandomPasswordInput) SetExcludePunctuation(v bool) *GetRandomPasswordInput {
s.ExcludePunctuation = &v
return s
} | go | {
"resource": ""
} |
q519 | SetExcludeUppercase | train | func (s *GetRandomPasswordInput) SetExcludeUppercase(v bool) *GetRandomPasswordInput {
s.ExcludeUppercase = &v
return s
} | go | {
"resource": ""
} |
q520 | SetIncludeSpace | train | func (s *GetRandomPasswordInput) SetIncludeSpace(v bool) *GetRandomPasswordInput {
s.IncludeSpace = &v
return s
} | go | {
"resource": ""
} |
q521 | SetPasswordLength | train | func (s *GetRandomPasswordInput) SetPasswordLength(v int64) *GetRandomPasswordInput {
s.PasswordLength = &v
return s
} | go | {
"resource": ""
} |
q522 | SetRequireEachIncludedType | train | func (s *GetRandomPasswordInput) SetRequireEachIncludedType(v bool) *GetRandomPasswordInput {
s.RequireEachIncludedType = &v
return s
} | go | {
"resource": ""
} |
q523 | SetRandomPassword | train | func (s *GetRandomPasswordOutput) SetRandomPassword(v string) *GetRandomPasswordOutput {
s.RandomPassword = &v
return s
} | go | {
"resource": ""
} |
q524 | SetIncludeDeprecated | train | func (s *ListSecretVersionIdsInput) SetIncludeDeprecated(v bool) *ListSecretVersionIdsInput {
s.IncludeDeprecated = &v
return s
} | go | {
"resource": ""
} |
q525 | SetSecretList | train | func (s *ListSecretsOutput) SetSecretList(v []*SecretListEntry) *ListSecretsOutput {
s.SecretList = v
return s
} | go | {
"resource": ""
} |
q526 | SetAutomaticallyAfterDays | train | func (s *RotationRulesType) SetAutomaticallyAfterDays(v int64) *RotationRulesType {
s.AutomaticallyAfterDays = &v
return s
} | go | {
"resource": ""
} |
q527 | SetSecretVersionsToStages | train | func (s *SecretListEntry) SetSecretVersionsToStages(v map[string][]*string) *SecretListEntry {
s.SecretVersionsToStages = v
return s
} | go | {
"resource": ""
} |
q528 | SetMoveToVersionId | train | func (s *UpdateSecretVersionStageInput) SetMoveToVersionId(v string) *UpdateSecretVersionStageInput {
s.MoveToVersionId = &v
return s
} | go | {
"resource": ""
} |
q529 | SetRemoveFromVersionId | train | func (s *UpdateSecretVersionStageInput) SetRemoveFromVersionId(v string) *UpdateSecretVersionStageInput {
s.RemoveFromVersionId = &v
return s
} | go | {
"resource": ""
} |
q530 | SetAuthorizationToken | train | func (s *AuthorizationData) SetAuthorizationToken(v string) *AuthorizationData {
s.AuthorizationToken = &v
return s
} | go | {
"resource": ""
} |
q531 | SetProxyEndpoint | train | func (s *AuthorizationData) SetProxyEndpoint(v string) *AuthorizationData {
s.ProxyEndpoint = &v
return s
} | go | {
"resource": ""
} |
q532 | SetAcceptedMediaTypes | train | func (s *BatchGetImageInput) SetAcceptedMediaTypes(v []*string) *BatchGetImageInput {
s.AcceptedMediaTypes = v
return s
} | go | {
"resource": ""
} |
q533 | SetImageDetails | train | func (s *DescribeImagesOutput) SetImageDetails(v []*ImageDetail) *DescribeImagesOutput {
s.ImageDetails = v
return s
} | go | {
"resource": ""
} |
q534 | SetRegistryIds | train | func (s *GetAuthorizationTokenInput) SetRegistryIds(v []*string) *GetAuthorizationTokenInput {
s.RegistryIds = v
return s
} | go | {
"resource": ""
} |
q535 | SetAuthorizationData | train | func (s *GetAuthorizationTokenOutput) SetAuthorizationData(v []*AuthorizationData) *GetAuthorizationTokenOutput {
s.AuthorizationData = v
return s
} | go | {
"resource": ""
} |
q536 | SetPreviewResults | train | func (s *GetLifecyclePolicyPreviewOutput) SetPreviewResults(v []*LifecyclePolicyPreviewResult) *GetLifecyclePolicyPreviewOutput {
s.PreviewResults = v
return s
} | go | {
"resource": ""
} |
q537 | SetImageSizeInBytes | train | func (s *ImageDetail) SetImageSizeInBytes(v int64) *ImageDetail {
s.ImageSizeInBytes = &v
return s
} | go | {
"resource": ""
} |
q538 | SetLayerAvailability | train | func (s *Layer) SetLayerAvailability(v string) *Layer {
s.LayerAvailability = &v
return s
} | go | {
"resource": ""
} |
q539 | SetLayerSize | train | func (s *Layer) SetLayerSize(v int64) *Layer {
s.LayerSize = &v
return s
} | go | {
"resource": ""
} |
q540 | SetAppliedRulePriority | train | func (s *LifecyclePolicyPreviewResult) SetAppliedRulePriority(v int64) *LifecyclePolicyPreviewResult {
s.AppliedRulePriority = &v
return s
} | go | {
"resource": ""
} |
q541 | SetExpiringImageTotalCount | train | func (s *LifecyclePolicyPreviewSummary) SetExpiringImageTotalCount(v int64) *LifecyclePolicyPreviewSummary {
s.ExpiringImageTotalCount = &v
return s
} | go | {
"resource": ""
} |
q542 | SetRepositoryArn | train | func (s *Repository) SetRepositoryArn(v string) *Repository {
s.RepositoryArn = &v
return s
} | go | {
"resource": ""
} |
q543 | SetRepositoryUri | train | func (s *Repository) SetRepositoryUri(v string) *Repository {
s.RepositoryUri = &v
return s
} | go | {
"resource": ""
} |
q544 | SetLayerPartBlob | train | func (s *UploadLayerPartInput) SetLayerPartBlob(v []byte) *UploadLayerPartInput {
s.LayerPartBlob = v
return s
} | go | {
"resource": ""
} |
q545 | SetPartFirstByte | train | func (s *UploadLayerPartInput) SetPartFirstByte(v int64) *UploadLayerPartInput {
s.PartFirstByte = &v
return s
} | go | {
"resource": ""
} |
q546 | SetPartLastByte | train | func (s *UploadLayerPartInput) SetPartLastByte(v int64) *UploadLayerPartInput {
s.PartLastByte = &v
return s
} | go | {
"resource": ""
} |
q547 | SetLastByteReceived | train | func (s *UploadLayerPartOutput) SetLastByteReceived(v int64) *UploadLayerPartOutput {
s.LastByteReceived = &v
return s
} | go | {
"resource": ""
} |
q548 | UnmarshalXML | train | func UnmarshalXML(v interface{}, d *xml.Decoder, wrapper string) error {
n, err := XMLToStruct(d, nil)
if err != nil {
return err
}
if n.Children != nil {
for _, root := range n.Children {
for _, c := range root {
if wrappedChild, ok := c.Children[wrapper]; ok {
c = wrappedChild[0] // pull out wrapped element
}
err = parse(reflect.ValueOf(v), c, "")
if err != nil {
if err == io.EOF {
return nil
}
return err
}
}
}
return nil
}
return nil
} | go | {
"resource": ""
} |
q549 | parse | train | func parse(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
rtype := r.Type()
if rtype.Kind() == reflect.Ptr {
rtype = rtype.Elem() // check kind of actual element type
}
t := tag.Get("type")
if t == "" {
switch rtype.Kind() {
case reflect.Struct:
// also it can't be a time object
if _, ok := r.Interface().(*time.Time); !ok {
t = "structure"
}
case reflect.Slice:
// also it can't be a byte slice
if _, ok := r.Interface().([]byte); !ok {
t = "list"
}
case reflect.Map:
t = "map"
}
}
switch t {
case "structure":
if field, ok := rtype.FieldByName("_"); ok {
tag = field.Tag
}
return parseStruct(r, node, tag)
case "list":
return parseList(r, node, tag)
case "map":
return parseMap(r, node, tag)
default:
return parseScalar(r, node, tag)
}
} | go | {
"resource": ""
} |
q550 | parseStruct | train | func parseStruct(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
t := r.Type()
if r.Kind() == reflect.Ptr {
if r.IsNil() { // create the structure if it's nil
s := reflect.New(r.Type().Elem())
r.Set(s)
r = s
}
r = r.Elem()
t = t.Elem()
}
// unwrap any payloads
if payload := tag.Get("payload"); payload != "" {
field, _ := t.FieldByName(payload)
return parseStruct(r.FieldByName(payload), node, field.Tag)
}
for i := 0; i < t.NumField(); i++ {
field := t.Field(i)
if c := field.Name[0:1]; strings.ToLower(c) == c {
continue // ignore unexported fields
}
// figure out what this field is called
name := field.Name
if field.Tag.Get("flattened") != "" && field.Tag.Get("locationNameList") != "" {
name = field.Tag.Get("locationNameList")
} else if locName := field.Tag.Get("locationName"); locName != "" {
name = locName
}
// try to find the field by name in elements
elems := node.Children[name]
if elems == nil { // try to find the field in attributes
if val, ok := node.findElem(name); ok {
elems = []*XMLNode{{Text: val}}
}
}
member := r.FieldByName(field.Name)
for _, elem := range elems {
err := parse(member, elem, field.Tag)
if err != nil {
return err
}
}
}
return nil
} | go | {
"resource": ""
} |
q551 | parseList | train | func parseList(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
t := r.Type()
if tag.Get("flattened") == "" { // look at all item entries
mname := "member"
if name := tag.Get("locationNameList"); name != "" {
mname = name
}
if Children, ok := node.Children[mname]; ok {
if r.IsNil() {
r.Set(reflect.MakeSlice(t, len(Children), len(Children)))
}
for i, c := range Children {
err := parse(r.Index(i), c, "")
if err != nil {
return err
}
}
}
} else { // flattened list means this is a single element
if r.IsNil() {
r.Set(reflect.MakeSlice(t, 0, 0))
}
childR := reflect.Zero(t.Elem())
r.Set(reflect.Append(r, childR))
err := parse(r.Index(r.Len()-1), node, "")
if err != nil {
return err
}
}
return nil
} | go | {
"resource": ""
} |
q552 | parseMap | train | func parseMap(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
if r.IsNil() {
r.Set(reflect.MakeMap(r.Type()))
}
if tag.Get("flattened") == "" { // look at all child entries
for _, entry := range node.Children["entry"] {
parseMapEntry(r, entry, tag)
}
} else { // this element is itself an entry
parseMapEntry(r, node, tag)
}
return nil
} | go | {
"resource": ""
} |
q553 | parseMapEntry | train | func parseMapEntry(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
kname, vname := "key", "value"
if n := tag.Get("locationNameKey"); n != "" {
kname = n
}
if n := tag.Get("locationNameValue"); n != "" {
vname = n
}
keys, ok := node.Children[kname]
values := node.Children[vname]
if ok {
for i, key := range keys {
keyR := reflect.ValueOf(key.Text)
value := values[i]
valueR := reflect.New(r.Type().Elem()).Elem()
parse(valueR, value, "")
r.SetMapIndex(keyR, valueR)
}
}
return nil
} | go | {
"resource": ""
} |
q554 | parseScalar | train | func parseScalar(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
switch r.Interface().(type) {
case *string:
r.Set(reflect.ValueOf(&node.Text))
return nil
case []byte:
b, err := base64.StdEncoding.DecodeString(node.Text)
if err != nil {
return err
}
r.Set(reflect.ValueOf(b))
case *bool:
v, err := strconv.ParseBool(node.Text)
if err != nil {
return err
}
r.Set(reflect.ValueOf(&v))
case *int64:
v, err := strconv.ParseInt(node.Text, 10, 64)
if err != nil {
return err
}
r.Set(reflect.ValueOf(&v))
case *float64:
v, err := strconv.ParseFloat(node.Text, 64)
if err != nil {
return err
}
r.Set(reflect.ValueOf(&v))
case *time.Time:
format := tag.Get("timestampFormat")
if len(format) == 0 {
format = protocol.ISO8601TimeFormatName
}
t, err := protocol.ParseTime(format, node.Text)
if err != nil {
return err
}
r.Set(reflect.ValueOf(&t))
default:
return fmt.Errorf("unsupported value: %v (%s)", r.Interface(), r.Type())
}
return nil
} | go | {
"resource": ""
} |
q555 | Copy | train | func (h *Handlers) Copy() Handlers {
return Handlers{
Validate: h.Validate.copy(),
Build: h.Build.copy(),
Sign: h.Sign.copy(),
Send: h.Send.copy(),
ValidateResponse: h.ValidateResponse.copy(),
Unmarshal: h.Unmarshal.copy(),
UnmarshalStream: h.UnmarshalStream.copy(),
UnmarshalError: h.UnmarshalError.copy(),
UnmarshalMeta: h.UnmarshalMeta.copy(),
Retry: h.Retry.copy(),
AfterRetry: h.AfterRetry.copy(),
CompleteAttempt: h.CompleteAttempt.copy(),
Complete: h.Complete.copy(),
}
} | go | {
"resource": ""
} |
q556 | Clear | train | func (h *Handlers) Clear() {
h.Validate.Clear()
h.Build.Clear()
h.Send.Clear()
h.Sign.Clear()
h.Unmarshal.Clear()
h.UnmarshalStream.Clear()
h.UnmarshalMeta.Clear()
h.UnmarshalError.Clear()
h.ValidateResponse.Clear()
h.Retry.Clear()
h.AfterRetry.Clear()
h.CompleteAttempt.Clear()
h.Complete.Clear()
} | go | {
"resource": ""
} |
q557 | copy | train | func (l *HandlerList) copy() HandlerList {
n := HandlerList{
AfterEachFn: l.AfterEachFn,
}
if len(l.list) == 0 {
return n
}
n.list = append(make([]NamedHandler, 0, len(l.list)), l.list...)
return n
} | go | {
"resource": ""
} |
q558 | PushBackNamed | train | func (l *HandlerList) PushBackNamed(n NamedHandler) {
if cap(l.list) == 0 {
l.list = make([]NamedHandler, 0, 5)
}
l.list = append(l.list, n)
} | go | {
"resource": ""
} |
q559 | PushFrontNamed | train | func (l *HandlerList) PushFrontNamed(n NamedHandler) {
if cap(l.list) == len(l.list) {
// Allocating new list required
l.list = append([]NamedHandler{n}, l.list...)
} else {
// Enough room to prepend into list.
l.list = append(l.list, NamedHandler{})
copy(l.list[1:], l.list)
l.list[0] = n
}
} | go | {
"resource": ""
} |
q560 | RemoveByName | train | func (l *HandlerList) RemoveByName(name string) {
for i := 0; i < len(l.list); i++ {
m := l.list[i]
if m.Name == name {
// Shift array preventing creating new arrays
copy(l.list[i:], l.list[i+1:])
l.list[len(l.list)-1] = NamedHandler{}
l.list = l.list[:len(l.list)-1]
// decrement list so next check to length is correct
i--
}
}
} | go | {
"resource": ""
} |
q561 | SwapNamed | train | func (l *HandlerList) SwapNamed(n NamedHandler) (swapped bool) {
for i := 0; i < len(l.list); i++ {
if l.list[i].Name == n.Name {
l.list[i].Fn = n.Fn
swapped = true
}
}
return swapped
} | go | {
"resource": ""
} |
q562 | Swap | train | func (l *HandlerList) Swap(name string, replace NamedHandler) bool {
var swapped bool
for i := 0; i < len(l.list); i++ {
if l.list[i].Name == name {
l.list[i] = replace
swapped = true
}
}
return swapped
} | go | {
"resource": ""
} |
q563 | SetBackNamed | train | func (l *HandlerList) SetBackNamed(n NamedHandler) {
if !l.SwapNamed(n) {
l.PushBackNamed(n)
}
} | go | {
"resource": ""
} |
q564 | SetFrontNamed | train | func (l *HandlerList) SetFrontNamed(n NamedHandler) {
if !l.SwapNamed(n) {
l.PushFrontNamed(n)
}
} | go | {
"resource": ""
} |
q565 | Run | train | func (l *HandlerList) Run(r *Request) {
for i, h := range l.list {
h.Fn(r)
item := HandlerListRunItem{
Index: i, Handler: h, Request: r,
}
if l.AfterEachFn != nil && !l.AfterEachFn(item) {
return
}
}
} | go | {
"resource": ""
} |
q566 | HandlerListLogItem | train | func HandlerListLogItem(item HandlerListRunItem) bool {
if item.Request.Config.Logger == nil {
return true
}
item.Request.Config.Logger.Log("DEBUG: RequestHandler",
item.Index, item.Handler.Name, item.Request.Error)
return true
} | go | {
"resource": ""
} |
q567 | WithAppendUserAgent | train | func WithAppendUserAgent(s string) Option {
return func(r *Request) {
r.Handlers.Build.PushBack(func(r2 *Request) {
AddToUserAgent(r, s)
})
}
} | go | {
"resource": ""
} |
q568 | BuildXML | train | func BuildXML(params interface{}, e *xml.Encoder) error {
return buildXML(params, e, false)
} | go | {
"resource": ""
} |
q569 | elemOf | train | func elemOf(value reflect.Value) reflect.Value {
for value.Kind() == reflect.Ptr {
value = value.Elem()
}
return value
} | go | {
"resource": ""
} |
q570 | buildValue | train | func (b *xmlBuilder) buildValue(value reflect.Value, current *XMLNode, tag reflect.StructTag) error {
value = elemOf(value)
if !value.IsValid() { // no need to handle zero values
return nil
} else if tag.Get("location") != "" { // don't handle non-body location values
return nil
}
t := tag.Get("type")
if t == "" {
switch value.Kind() {
case reflect.Struct:
t = "structure"
case reflect.Slice:
t = "list"
case reflect.Map:
t = "map"
}
}
switch t {
case "structure":
if field, ok := value.Type().FieldByName("_"); ok {
tag = tag + reflect.StructTag(" ") + field.Tag
}
return b.buildStruct(value, current, tag)
case "list":
return b.buildList(value, current, tag)
case "map":
return b.buildMap(value, current, tag)
default:
return b.buildScalar(value, current, tag)
}
} | go | {
"resource": ""
} |
q571 | buildStruct | train | func (b *xmlBuilder) buildStruct(value reflect.Value, current *XMLNode, tag reflect.StructTag) error {
if !value.IsValid() {
return nil
}
// unwrap payloads
if payload := tag.Get("payload"); payload != "" {
field, _ := value.Type().FieldByName(payload)
tag = field.Tag
value = elemOf(value.FieldByName(payload))
if !value.IsValid() {
return nil
}
}
child := NewXMLElement(xml.Name{Local: tag.Get("locationName")})
// there is an xmlNamespace associated with this struct
if prefix, uri := tag.Get("xmlPrefix"), tag.Get("xmlURI"); uri != "" {
ns := xml.Attr{
Name: xml.Name{Local: "xmlns"},
Value: uri,
}
if prefix != "" {
b.namespaces[prefix] = uri // register the namespace
ns.Name.Local = "xmlns:" + prefix
}
child.Attr = append(child.Attr, ns)
}
var payloadFields, nonPayloadFields int
t := value.Type()
for i := 0; i < value.NumField(); i++ {
member := elemOf(value.Field(i))
field := t.Field(i)
if field.PkgPath != "" {
continue // ignore unexported fields
}
if field.Tag.Get("ignore") != "" {
continue
}
mTag := field.Tag
if mTag.Get("location") != "" { // skip non-body members
nonPayloadFields++
continue
}
payloadFields++
if protocol.CanSetIdempotencyToken(value.Field(i), field) {
token := protocol.GetIdempotencyToken()
member = reflect.ValueOf(token)
}
memberName := mTag.Get("locationName")
if memberName == "" {
memberName = field.Name
mTag = reflect.StructTag(string(mTag) + ` locationName:"` + memberName + `"`)
}
if err := b.buildValue(member, child, mTag); err != nil {
return err
}
}
// Only case where the child shape is not added is if the shape only contains
// non-payload fields, e.g headers/query.
if !(payloadFields == 0 && nonPayloadFields > 0) {
current.AddChild(child)
}
return nil
} | go | {
"resource": ""
} |
q572 | buildList | train | func (b *xmlBuilder) buildList(value reflect.Value, current *XMLNode, tag reflect.StructTag) error {
if value.IsNil() { // don't build omitted lists
return nil
}
// check for unflattened list member
flattened := tag.Get("flattened") != ""
xname := xml.Name{Local: tag.Get("locationName")}
if flattened {
for i := 0; i < value.Len(); i++ {
child := NewXMLElement(xname)
current.AddChild(child)
if err := b.buildValue(value.Index(i), child, ""); err != nil {
return err
}
}
} else {
list := NewXMLElement(xname)
current.AddChild(list)
for i := 0; i < value.Len(); i++ {
iname := tag.Get("locationNameList")
if iname == "" {
iname = "member"
}
child := NewXMLElement(xml.Name{Local: iname})
list.AddChild(child)
if err := b.buildValue(value.Index(i), child, ""); err != nil {
return err
}
}
}
return nil
} | go | {
"resource": ""
} |
q573 | buildScalar | train | func (b *xmlBuilder) buildScalar(value reflect.Value, current *XMLNode, tag reflect.StructTag) error {
var str string
switch converted := value.Interface().(type) {
case string:
str = converted
case []byte:
if !value.IsNil() {
str = base64.StdEncoding.EncodeToString(converted)
}
case bool:
str = strconv.FormatBool(converted)
case int64:
str = strconv.FormatInt(converted, 10)
case int:
str = strconv.Itoa(converted)
case float64:
str = strconv.FormatFloat(converted, 'f', -1, 64)
case float32:
str = strconv.FormatFloat(float64(converted), 'f', -1, 32)
case time.Time:
format := tag.Get("timestampFormat")
if len(format) == 0 {
format = protocol.ISO8601TimeFormatName
}
str = protocol.FormatTime(format, converted)
default:
return fmt.Errorf("unsupported value for param %s: %v (%s)",
tag.Get("locationName"), value.Interface(), value.Type().Name())
}
xname := xml.Name{Local: tag.Get("locationName")}
if tag.Get("xmlAttribute") != "" { // put into current node's attribute list
attr := xml.Attr{Name: xname, Value: str}
current.Attr = append(current.Attr, attr)
} else { // regular text node
current.AddChild(&XMLNode{Name: xname, Text: str})
}
return nil
} | go | {
"resource": ""
} |
q574 | WaitUntilIdentityExists | train | func (c *SES) WaitUntilIdentityExists(input *GetIdentityVerificationAttributesInput) error {
return c.WaitUntilIdentityExistsWithContext(aws.BackgroundContext(), input)
} | go | {
"resource": ""
} |
q575 | WaitUntilDistributionDeployed | train | func (c *CloudFront) WaitUntilDistributionDeployed(input *GetDistributionInput) error {
return c.WaitUntilDistributionDeployedWithContext(aws.BackgroundContext(), input)
} | go | {
"resource": ""
} |
q576 | WaitUntilInvalidationCompleted | train | func (c *CloudFront) WaitUntilInvalidationCompleted(input *GetInvalidationInput) error {
return c.WaitUntilInvalidationCompletedWithContext(aws.BackgroundContext(), input)
} | go | {
"resource": ""
} |
q577 | WaitUntilStreamingDistributionDeployed | train | func (c *CloudFront) WaitUntilStreamingDistributionDeployed(input *GetStreamingDistributionInput) error {
return c.WaitUntilStreamingDistributionDeployedWithContext(aws.BackgroundContext(), input)
} | go | {
"resource": ""
} |
q578 | WaitUntilAppExists | train | func (c *OpsWorks) WaitUntilAppExists(input *DescribeAppsInput) error {
return c.WaitUntilAppExistsWithContext(aws.BackgroundContext(), input)
} | go | {
"resource": ""
} |
q579 | WaitUntilDeploymentSuccessful | train | func (c *OpsWorks) WaitUntilDeploymentSuccessful(input *DescribeDeploymentsInput) error {
return c.WaitUntilDeploymentSuccessfulWithContext(aws.BackgroundContext(), input)
} | go | {
"resource": ""
} |
q580 | WaitUntilInstanceOnline | train | func (c *OpsWorks) WaitUntilInstanceOnline(input *DescribeInstancesInput) error {
return c.WaitUntilInstanceOnlineWithContext(aws.BackgroundContext(), input)
} | go | {
"resource": ""
} |
q581 | WaitUntilInstanceRegistered | train | func (c *OpsWorks) WaitUntilInstanceRegistered(input *DescribeInstancesInput) error {
return c.WaitUntilInstanceRegisteredWithContext(aws.BackgroundContext(), input)
} | go | {
"resource": ""
} |
q582 | WaitUntilInstanceTerminated | train | func (c *OpsWorks) WaitUntilInstanceTerminated(input *DescribeInstancesInput) error {
return c.WaitUntilInstanceTerminatedWithContext(aws.BackgroundContext(), input)
} | go | {
"resource": ""
} |
q583 | SetSharedDirectory | train | func (s *AcceptSharedDirectoryOutput) SetSharedDirectory(v *SharedDirectory) *AcceptSharedDirectoryOutput {
s.SharedDirectory = v
return s
} | go | {
"resource": ""
} |
q584 | SetIpRoutes | train | func (s *AddIpRoutesInput) SetIpRoutes(v []*IpRoute) *AddIpRoutesInput {
s.IpRoutes = v
return s
} | go | {
"resource": ""
} |
q585 | SetUpdateSecurityGroupForDirectoryControllers | train | func (s *AddIpRoutesInput) SetUpdateSecurityGroupForDirectoryControllers(v bool) *AddIpRoutesInput {
s.UpdateSecurityGroupForDirectoryControllers = &v
return s
} | go | {
"resource": ""
} |
q586 | SetComputerId | train | func (s *Computer) SetComputerId(v string) *Computer {
s.ComputerId = &v
return s
} | go | {
"resource": ""
} |
q587 | SetReplicationScope | train | func (s *ConditionalForwarder) SetReplicationScope(v string) *ConditionalForwarder {
s.ReplicationScope = &v
return s
} | go | {
"resource": ""
} |
q588 | SetComputer | train | func (s *CreateComputerOutput) SetComputer(v *Computer) *CreateComputerOutput {
s.Computer = v
return s
} | go | {
"resource": ""
} |
q589 | SetConditionalForwarderIpAddrs | train | func (s *CreateTrustInput) SetConditionalForwarderIpAddrs(v []*string) *CreateTrustInput {
s.ConditionalForwarderIpAddrs = v
return s
} | go | {
"resource": ""
} |
q590 | SetTrustPassword | train | func (s *CreateTrustInput) SetTrustPassword(v string) *CreateTrustInput {
s.TrustPassword = &v
return s
} | go | {
"resource": ""
} |
q591 | SetDeleteAssociatedConditionalForwarder | train | func (s *DeleteTrustInput) SetDeleteAssociatedConditionalForwarder(v bool) *DeleteTrustInput {
s.DeleteAssociatedConditionalForwarder = &v
return s
} | go | {
"resource": ""
} |
q592 | SetRemoteDomainNames | train | func (s *DescribeConditionalForwardersInput) SetRemoteDomainNames(v []*string) *DescribeConditionalForwardersInput {
s.RemoteDomainNames = v
return s
} | go | {
"resource": ""
} |
q593 | SetConditionalForwarders | train | func (s *DescribeConditionalForwardersOutput) SetConditionalForwarders(v []*ConditionalForwarder) *DescribeConditionalForwardersOutput {
s.ConditionalForwarders = v
return s
} | go | {
"resource": ""
} |
q594 | SetDirectoryDescriptions | train | func (s *DescribeDirectoriesOutput) SetDirectoryDescriptions(v []*DirectoryDescription) *DescribeDirectoriesOutput {
s.DirectoryDescriptions = v
return s
} | go | {
"resource": ""
} |
q595 | SetDomainControllerIds | train | func (s *DescribeDomainControllersInput) SetDomainControllerIds(v []*string) *DescribeDomainControllersInput {
s.DomainControllerIds = v
return s
} | go | {
"resource": ""
} |
q596 | SetTopicNames | train | func (s *DescribeEventTopicsInput) SetTopicNames(v []*string) *DescribeEventTopicsInput {
s.TopicNames = v
return s
} | go | {
"resource": ""
} |
q597 | SetEventTopics | train | func (s *DescribeEventTopicsOutput) SetEventTopics(v []*EventTopic) *DescribeEventTopicsOutput {
s.EventTopics = v
return s
} | go | {
"resource": ""
} |
q598 | SetSharedDirectoryIds | train | func (s *DescribeSharedDirectoriesInput) SetSharedDirectoryIds(v []*string) *DescribeSharedDirectoriesInput {
s.SharedDirectoryIds = v
return s
} | go | {
"resource": ""
} |
q599 | SetSharedDirectories | train | func (s *DescribeSharedDirectoriesOutput) SetSharedDirectories(v []*SharedDirectory) *DescribeSharedDirectoriesOutput {
s.SharedDirectories = v
return s
} | go | {
"resource": ""
} |