func main() { flag.Usage = Usage var host string var port int var protocol string var urlString string var framed bool var useHttp bool var parsedUrl url.URL var trans thrift.TTransport _ = strconv.Atoi _ = math.Abs flag.Usage = Usage flag.StringVar(&host, "h", "localhost", "Specify host and port") flag.IntVar(&port, "p", 9090, "Specify port") flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)") flag.StringVar(&urlString, "u", "", "Specify the url") flag.BoolVar(&framed, "framed", false, "Use framed transport") flag.BoolVar(&useHttp, "http", false, "Use http") flag.Parse() if len(urlString) > 0 { parsedUrl, err := url.Parse(urlString) if err != nil { fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) flag.Usage() } host = parsedUrl.Host useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http" } else if useHttp { _, err := url.Parse(fmt.Sprint("http://", host, ":", port)) if err != nil { fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) flag.Usage() } } cmd := flag.Arg(0) var err error if useHttp { trans, err = thrift.NewTHttpClient(parsedUrl.String()) } else { portStr := fmt.Sprint(port) if strings.Contains(host, ":") { host, portStr, err = net.SplitHostPort(host) if err != nil { fmt.Fprintln(os.Stderr, "error with host:", err) os.Exit(1) } } trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr)) if err != nil { fmt.Fprintln(os.Stderr, "error resolving address:", err) os.Exit(1) } if framed { trans = thrift.NewTFramedTransport(trans) } } if err != nil { fmt.Fprintln(os.Stderr, "Error creating transport", err) os.Exit(1) } defer trans.Close() var protocolFactory thrift.TProtocolFactory switch protocol { case "compact": protocolFactory = thrift.NewTCompactProtocolFactory() break case "simplejson": protocolFactory = thrift.NewTSimpleJSONProtocolFactory() break case "json": protocolFactory = thrift.NewTJSONProtocolFactory() break case "binary", "": protocolFactory = thrift.NewTBinaryProtocolFactoryDefault() break default: fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol) Usage() os.Exit(1) } client := servicessync.NewSearchManagerSyncClientFactory(trans, protocolFactory) if err := trans.Open(); err != nil { fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err) os.Exit(1) } switch cmd { case "searchPublicResources": if flag.NArg()-1 != 8 { fmt.Fprintln(os.Stderr, "SearchPublicResources requires 8 args") flag.Usage() } argvalue0 := flag.Arg(1) value0 := argvalue0 tmp1, err := (strconv.Atoi(flag.Arg(2))) if err != nil { Usage() return } argvalue1 := servicessync.SearchCategory(tmp1) value1 := argvalue1 tmp2, err := (strconv.Atoi(flag.Arg(3))) if err != nil { Usage() return } argvalue2 := servicessync.ResourceType(tmp2) value2 := argvalue2 tmp3, err := (strconv.Atoi(flag.Arg(4))) if err != nil { Usage() return } argvalue3 := servicessync.Zone(tmp3) value3 := argvalue3 tmp4, err463 := (strconv.Atoi(flag.Arg(5))) if err463 != nil { Usage() return } argvalue4 := int32(tmp4) value4 := argvalue4 tmp5, err464 := (strconv.Atoi(flag.Arg(6))) if err464 != nil { Usage() return } argvalue5 := int32(tmp5) value5 := argvalue5 arg465 := flag.Arg(7) mbTrans466 := thrift.NewTMemoryBufferLen(len(arg465)) defer mbTrans466.Close() _, err467 := mbTrans466.WriteString(arg465) if err467 != nil { Usage() return } factory468 := thrift.NewTSimpleJSONProtocolFactory() jsProt469 := factory468.GetProtocol(mbTrans466) containerStruct6 := servicessync.NewSearchPublicResourcesArgs() err470 := containerStruct6.ReadField7(jsProt469) if err470 != nil { Usage() return } argvalue6 := containerStruct6.Sortlist value6 := argvalue6 arg471 := flag.Arg(8) mbTrans472 := thrift.NewTMemoryBufferLen(len(arg471)) defer mbTrans472.Close() _, err473 := mbTrans472.WriteString(arg471) if err473 != nil { Usage() return } factory474 := thrift.NewTSimpleJSONProtocolFactory() jsProt475 := factory474.GetProtocol(mbTrans472) containerStruct7 := servicessync.NewSearchPublicResourcesArgs() err476 := containerStruct7.ReadField8(jsProt475) if err476 != nil { Usage() return } argvalue7 := containerStruct7.Filterlist value7 := argvalue7 fmt.Print(client.SearchPublicResources(value0, value1, value2, value3, value4, value5, value6, value7)) fmt.Print("\n") break case "searchGroupResources": if flag.NArg()-1 != 8 { fmt.Fprintln(os.Stderr, "SearchGroupResources requires 8 args") flag.Usage() } argvalue0 := flag.Arg(1) value0 := argvalue0 argvalue1, err478 := (strconv.ParseInt(flag.Arg(2), 10, 64)) if err478 != nil { Usage() return } value1 := argvalue1 tmp2, err := (strconv.Atoi(flag.Arg(3))) if err != nil { Usage() return } argvalue2 := servicessync.ResourceType(tmp2) value2 := argvalue2 tmp3, err := (strconv.Atoi(flag.Arg(4))) if err != nil { Usage() return } argvalue3 := servicessync.Zone(tmp3) value3 := argvalue3 tmp4, err479 := (strconv.Atoi(flag.Arg(5))) if err479 != nil { Usage() return } argvalue4 := int32(tmp4) value4 := argvalue4 tmp5, err480 := (strconv.Atoi(flag.Arg(6))) if err480 != nil { Usage() return } argvalue5 := int32(tmp5) value5 := argvalue5 arg481 := flag.Arg(7) mbTrans482 := thrift.NewTMemoryBufferLen(len(arg481)) defer mbTrans482.Close() _, err483 := mbTrans482.WriteString(arg481) if err483 != nil { Usage() return } factory484 := thrift.NewTSimpleJSONProtocolFactory() jsProt485 := factory484.GetProtocol(mbTrans482) containerStruct6 := servicessync.NewSearchGroupResourcesArgs() err486 := containerStruct6.ReadField7(jsProt485) if err486 != nil { Usage() return } argvalue6 := containerStruct6.Sortlist value6 := argvalue6 arg487 := flag.Arg(8) mbTrans488 := thrift.NewTMemoryBufferLen(len(arg487)) defer mbTrans488.Close() _, err489 := mbTrans488.WriteString(arg487) if err489 != nil { Usage() return } factory490 := thrift.NewTSimpleJSONProtocolFactory() jsProt491 := factory490.GetProtocol(mbTrans488) containerStruct7 := servicessync.NewSearchGroupResourcesArgs() err492 := containerStruct7.ReadField8(jsProt491) if err492 != nil { Usage() return } argvalue7 := containerStruct7.Filterlist value7 := argvalue7 fmt.Print(client.SearchGroupResources(value0, value1, value2, value3, value4, value5, value6, value7)) fmt.Print("\n") break case "searchGroup": if flag.NArg()-1 != 6 { fmt.Fprintln(os.Stderr, "SearchGroup requires 6 args") flag.Usage() } argvalue0 := flag.Arg(1) value0 := argvalue0 tmp1, err := (strconv.Atoi(flag.Arg(2))) if err != nil { Usage() return } argvalue1 := servicessync.GroupType(tmp1) value1 := argvalue1 tmp2, err494 := (strconv.Atoi(flag.Arg(3))) if err494 != nil { Usage() return } argvalue2 := int32(tmp2) value2 := argvalue2 tmp3, err495 := (strconv.Atoi(flag.Arg(4))) if err495 != nil { Usage() return } argvalue3 := int32(tmp3) value3 := argvalue3 arg496 := flag.Arg(5) mbTrans497 := thrift.NewTMemoryBufferLen(len(arg496)) defer mbTrans497.Close() _, err498 := mbTrans497.WriteString(arg496) if err498 != nil { Usage() return } factory499 := thrift.NewTSimpleJSONProtocolFactory() jsProt500 := factory499.GetProtocol(mbTrans497) containerStruct4 := servicessync.NewSearchGroupArgs() err501 := containerStruct4.ReadField5(jsProt500) if err501 != nil { Usage() return } argvalue4 := containerStruct4.Sortlist value4 := argvalue4 arg502 := flag.Arg(6) mbTrans503 := thrift.NewTMemoryBufferLen(len(arg502)) defer mbTrans503.Close() _, err504 := mbTrans503.WriteString(arg502) if err504 != nil { Usage() return } factory505 := thrift.NewTSimpleJSONProtocolFactory() jsProt506 := factory505.GetProtocol(mbTrans503) containerStruct5 := servicessync.NewSearchGroupArgs() err507 := containerStruct5.ReadField6(jsProt506) if err507 != nil { Usage() return } argvalue5 := containerStruct5.Filterlist value5 := argvalue5 fmt.Print(client.SearchGroup(value0, value1, value2, value3, value4, value5)) fmt.Print("\n") break case "searchUserBackend": if flag.NArg()-1 != 3 { fmt.Fprintln(os.Stderr, "SearchUserBackend requires 3 args") flag.Usage() } arg508 := flag.Arg(1) mbTrans509 := thrift.NewTMemoryBufferLen(len(arg508)) defer mbTrans509.Close() _, err510 := mbTrans509.WriteString(arg508) if err510 != nil { Usage() return } factory511 := thrift.NewTSimpleJSONProtocolFactory() jsProt512 := factory511.GetProtocol(mbTrans509) argvalue0 := servicessync.NewUserSearchInfo() err513 := argvalue0.Read(jsProt512) if err513 != nil { Usage() return } value0 := argvalue0 arg514 := flag.Arg(2) mbTrans515 := thrift.NewTMemoryBufferLen(len(arg514)) defer mbTrans515.Close() _, err516 := mbTrans515.WriteString(arg514) if err516 != nil { Usage() return } factory517 := thrift.NewTSimpleJSONProtocolFactory() jsProt518 := factory517.GetProtocol(mbTrans515) containerStruct1 := servicessync.NewSearchUserBackendArgs() err519 := containerStruct1.ReadField2(jsProt518) if err519 != nil { Usage() return } argvalue1 := containerStruct1.Sortlist value1 := argvalue1 arg520 := flag.Arg(3) mbTrans521 := thrift.NewTMemoryBufferLen(len(arg520)) defer mbTrans521.Close() _, err522 := mbTrans521.WriteString(arg520) if err522 != nil { Usage() return } factory523 := thrift.NewTSimpleJSONProtocolFactory() jsProt524 := factory523.GetProtocol(mbTrans521) containerStruct2 := servicessync.NewSearchUserBackendArgs() err525 := containerStruct2.ReadField3(jsProt524) if err525 != nil { Usage() return } argvalue2 := containerStruct2.Filterlist value2 := argvalue2 fmt.Print(client.SearchUserBackend(value0, value1, value2)) fmt.Print("\n") break case "searchResourceByTag": if flag.NArg()-1 != 7 { fmt.Fprintln(os.Stderr, "SearchResourceByTag requires 7 args") flag.Usage() } argvalue0 := flag.Arg(1) value0 := argvalue0 tmp1, err := (strconv.Atoi(flag.Arg(2))) if err != nil { Usage() return } argvalue1 := servicessync.ResourceType(tmp1) value1 := argvalue1 tmp2, err := (strconv.Atoi(flag.Arg(3))) if err != nil { Usage() return } argvalue2 := servicessync.Zone(tmp2) value2 := argvalue2 tmp3, err527 := (strconv.Atoi(flag.Arg(4))) if err527 != nil { Usage() return } argvalue3 := int32(tmp3) value3 := argvalue3 tmp4, err528 := (strconv.Atoi(flag.Arg(5))) if err528 != nil { Usage() return } argvalue4 := int32(tmp4) value4 := argvalue4 arg529 := flag.Arg(6) mbTrans530 := thrift.NewTMemoryBufferLen(len(arg529)) defer mbTrans530.Close() _, err531 := mbTrans530.WriteString(arg529) if err531 != nil { Usage() return } factory532 := thrift.NewTSimpleJSONProtocolFactory() jsProt533 := factory532.GetProtocol(mbTrans530) containerStruct5 := servicessync.NewSearchResourceByTagArgs() err534 := containerStruct5.ReadField6(jsProt533) if err534 != nil { Usage() return } argvalue5 := containerStruct5.Sortlist value5 := argvalue5 arg535 := flag.Arg(7) mbTrans536 := thrift.NewTMemoryBufferLen(len(arg535)) defer mbTrans536.Close() _, err537 := mbTrans536.WriteString(arg535) if err537 != nil { Usage() return } factory538 := thrift.NewTSimpleJSONProtocolFactory() jsProt539 := factory538.GetProtocol(mbTrans536) containerStruct6 := servicessync.NewSearchResourceByTagArgs() err540 := containerStruct6.ReadField7(jsProt539) if err540 != nil { Usage() return } argvalue6 := containerStruct6.Filterlist value6 := argvalue6 fmt.Print(client.SearchResourceByTag(value0, value1, value2, value3, value4, value5, value6)) fmt.Print("\n") break case "searchGroupIds": if flag.NArg()-1 != 4 { fmt.Fprintln(os.Stderr, "SearchGroupIds requires 4 args") flag.Usage() } argvalue0 := flag.Arg(1) value0 := argvalue0 tmp1, err := (strconv.Atoi(flag.Arg(2))) if err != nil { Usage() return } argvalue1 := servicessync.Zone(tmp1) value1 := argvalue1 arg542 := flag.Arg(3) mbTrans543 := thrift.NewTMemoryBufferLen(len(arg542)) defer mbTrans543.Close() _, err544 := mbTrans543.WriteString(arg542) if err544 != nil { Usage() return } factory545 := thrift.NewTSimpleJSONProtocolFactory() jsProt546 := factory545.GetProtocol(mbTrans543) containerStruct2 := servicessync.NewSearchGroupIdsArgs() err547 := containerStruct2.ReadField3(jsProt546) if err547 != nil { Usage() return } argvalue2 := containerStruct2.Sortlist value2 := argvalue2 arg548 := flag.Arg(4) mbTrans549 := thrift.NewTMemoryBufferLen(len(arg548)) defer mbTrans549.Close() _, err550 := mbTrans549.WriteString(arg548) if err550 != nil { Usage() return } factory551 := thrift.NewTSimpleJSONProtocolFactory() jsProt552 := factory551.GetProtocol(mbTrans549) containerStruct3 := servicessync.NewSearchGroupIdsArgs() err553 := containerStruct3.ReadField4(jsProt552) if err553 != nil { Usage() return } argvalue3 := containerStruct3.Filterlist value3 := argvalue3 fmt.Print(client.SearchGroupIds(value0, value1, value2, value3)) fmt.Print("\n") break case "": Usage() break default: fmt.Fprintln(os.Stderr, "Invalid function ", cmd) } }
func main() { flag.Usage = Usage var host string var port int var protocol string var urlString string var framed bool var useHttp bool var parsedUrl url.URL var trans thrift.TTransport _ = strconv.Atoi _ = math.Abs flag.Usage = Usage flag.StringVar(&host, "h", "localhost", "Specify host and port") flag.IntVar(&port, "p", 9090, "Specify port") flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)") flag.StringVar(&urlString, "u", "", "Specify the url") flag.BoolVar(&framed, "framed", false, "Use framed transport") flag.BoolVar(&useHttp, "http", false, "Use http") flag.Parse() if len(urlString) > 0 { parsedUrl, err := url.Parse(urlString) if err != nil { fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) flag.Usage() } host = parsedUrl.Host useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http" } else if useHttp { _, err := url.Parse(fmt.Sprint("http://", host, ":", port)) if err != nil { fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) flag.Usage() } } cmd := flag.Arg(0) var err error if useHttp { trans, err = thrift.NewTHttpClient(parsedUrl.String()) } else { portStr := fmt.Sprint(port) if strings.Contains(host, ":") { host, portStr, err = net.SplitHostPort(host) if err != nil { fmt.Fprintln(os.Stderr, "error with host:", err) os.Exit(1) } } trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr)) if err != nil { fmt.Fprintln(os.Stderr, "error resolving address:", err) os.Exit(1) } if framed { trans = thrift.NewTFramedTransport(trans) } } if err != nil { fmt.Fprintln(os.Stderr, "Error creating transport", err) os.Exit(1) } defer trans.Close() var protocolFactory thrift.TProtocolFactory switch protocol { case "compact": protocolFactory = thrift.NewTCompactProtocolFactory() break case "simplejson": protocolFactory = thrift.NewTSimpleJSONProtocolFactory() break case "json": protocolFactory = thrift.NewTJSONProtocolFactory() break case "binary", "": protocolFactory = thrift.NewTBinaryProtocolFactoryDefault() break default: fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol) Usage() os.Exit(1) } client := servicessync.NewResourceManagerSyncClientFactory(trans, protocolFactory) if err := trans.Open(); err != nil { fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err) os.Exit(1) } switch cmd { case "createResource": if flag.NArg()-1 != 2 { fmt.Fprintln(os.Stderr, "CreateResource requires 2 args") flag.Usage() } argvalue0, err313 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err313 != nil { Usage() return } value0 := argvalue0 arg314 := flag.Arg(2) mbTrans315 := thrift.NewTMemoryBufferLen(len(arg314)) defer mbTrans315.Close() _, err316 := mbTrans315.WriteString(arg314) if err316 != nil { Usage() return } factory317 := thrift.NewTSimpleJSONProtocolFactory() jsProt318 := factory317.GetProtocol(mbTrans315) argvalue1 := servicessync.NewResource() err319 := argvalue1.Read(jsProt318) if err319 != nil { Usage() return } value1 := argvalue1 fmt.Print(client.CreateResource(value0, value1)) fmt.Print("\n") break case "getResource": if flag.NArg()-1 != 1 { fmt.Fprintln(os.Stderr, "GetResource requires 1 args") flag.Usage() } argvalue0, err320 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err320 != nil { Usage() return } value0 := argvalue0 fmt.Print(client.GetResource(value0)) fmt.Print("\n") break case "getResourceInfo": if flag.NArg()-1 != 1 { fmt.Fprintln(os.Stderr, "GetResourceInfo requires 1 args") flag.Usage() } argvalue0, err321 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err321 != nil { Usage() return } value0 := argvalue0 fmt.Print(client.GetResourceInfo(value0)) fmt.Print("\n") break case "updateResource": if flag.NArg()-1 != 2 { fmt.Fprintln(os.Stderr, "UpdateResource requires 2 args") flag.Usage() } arg322 := flag.Arg(1) mbTrans323 := thrift.NewTMemoryBufferLen(len(arg322)) defer mbTrans323.Close() _, err324 := mbTrans323.WriteString(arg322) if err324 != nil { Usage() return } factory325 := thrift.NewTSimpleJSONProtocolFactory() jsProt326 := factory325.GetProtocol(mbTrans323) argvalue0 := servicessync.NewResource() err327 := argvalue0.Read(jsProt326) if err327 != nil { Usage() return } value0 := argvalue0 argvalue1, err328 := (strconv.ParseInt(flag.Arg(2), 10, 64)) if err328 != nil { Usage() return } value1 := argvalue1 fmt.Print(client.UpdateResource(value0, value1)) fmt.Print("\n") break case "deleteResource": if flag.NArg()-1 != 2 { fmt.Fprintln(os.Stderr, "DeleteResource requires 2 args") flag.Usage() } argvalue0, err329 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err329 != nil { Usage() return } value0 := argvalue0 argvalue1, err330 := (strconv.ParseInt(flag.Arg(2), 10, 64)) if err330 != nil { Usage() return } value1 := argvalue1 fmt.Print(client.DeleteResource(value0, value1)) fmt.Print("\n") break case "shareResource": if flag.NArg()-1 != 4 { fmt.Fprintln(os.Stderr, "ShareResource requires 4 args") flag.Usage() } arg331 := flag.Arg(1) mbTrans332 := thrift.NewTMemoryBufferLen(len(arg331)) defer mbTrans332.Close() _, err333 := mbTrans332.WriteString(arg331) if err333 != nil { Usage() return } factory334 := thrift.NewTSimpleJSONProtocolFactory() jsProt335 := factory334.GetProtocol(mbTrans332) argvalue0 := servicessync.NewResource() err336 := argvalue0.Read(jsProt335) if err336 != nil { Usage() return } value0 := argvalue0 arg337 := flag.Arg(2) mbTrans338 := thrift.NewTMemoryBufferLen(len(arg337)) defer mbTrans338.Close() _, err339 := mbTrans338.WriteString(arg337) if err339 != nil { Usage() return } factory340 := thrift.NewTSimpleJSONProtocolFactory() jsProt341 := factory340.GetProtocol(mbTrans338) containerStruct1 := servicessync.NewShareResourceArgs() err342 := containerStruct1.ReadField2(jsProt341) if err342 != nil { Usage() return } argvalue1 := containerStruct1.ShareGroups value1 := argvalue1 tmp2, err := (strconv.Atoi(flag.Arg(3))) if err != nil { Usage() return } argvalue2 := servicessync.Zone(tmp2) value2 := argvalue2 argvalue3, err343 := (strconv.ParseInt(flag.Arg(4), 10, 64)) if err343 != nil { Usage() return } value3 := argvalue3 fmt.Print(client.ShareResource(value0, value1, value2, value3)) fmt.Print("\n") break case "getSharedResources": if flag.NArg()-1 != 8 { fmt.Fprintln(os.Stderr, "GetSharedResources requires 8 args") flag.Usage() } argvalue0, err344 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err344 != nil { Usage() return } value0 := argvalue0 tmp1, err := (strconv.Atoi(flag.Arg(2))) if err != nil { Usage() return } argvalue1 := servicessync.Zone(tmp1) value1 := argvalue1 tmp2, err := (strconv.Atoi(flag.Arg(3))) if err != nil { Usage() return } argvalue2 := servicessync.ResourceType(tmp2) value2 := argvalue2 argvalue3, err345 := (strconv.ParseInt(flag.Arg(4), 10, 64)) if err345 != nil { Usage() return } value3 := argvalue3 argvalue4, err346 := (strconv.ParseInt(flag.Arg(5), 10, 64)) if err346 != nil { Usage() return } value4 := argvalue4 argvalue5, err347 := (strconv.ParseInt(flag.Arg(6), 10, 64)) if err347 != nil { Usage() return } value5 := argvalue5 argvalue6 := flag.Arg(7) == "true" value6 := argvalue6 tmp7, err349 := (strconv.Atoi(flag.Arg(8))) if err349 != nil { Usage() return } argvalue7 := int32(tmp7) value7 := argvalue7 fmt.Print(client.GetSharedResources(value0, value1, value2, value3, value4, value5, value6, value7)) fmt.Print("\n") break case "cancelSharedResource": if flag.NArg()-1 != 1 { fmt.Fprintln(os.Stderr, "CancelSharedResource requires 1 args") flag.Usage() } argvalue0 := flag.Arg(1) value0 := argvalue0 fmt.Print(client.CancelSharedResource(value0)) fmt.Print("\n") break case "getUserResources": if flag.NArg()-1 != 7 { fmt.Fprintln(os.Stderr, "GetUserResources requires 7 args") flag.Usage() } argvalue0, err351 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err351 != nil { Usage() return } value0 := argvalue0 tmp1, err := (strconv.Atoi(flag.Arg(2))) if err != nil { Usage() return } argvalue1 := servicessync.ResourceType(tmp1) value1 := argvalue1 argvalue2, err352 := (strconv.ParseInt(flag.Arg(3), 10, 64)) if err352 != nil { Usage() return } value2 := argvalue2 argvalue3, err353 := (strconv.ParseInt(flag.Arg(4), 10, 64)) if err353 != nil { Usage() return } value3 := argvalue3 argvalue4, err354 := (strconv.ParseInt(flag.Arg(5), 10, 64)) if err354 != nil { Usage() return } value4 := argvalue4 argvalue5 := flag.Arg(6) == "true" value5 := argvalue5 tmp6, err356 := (strconv.Atoi(flag.Arg(7))) if err356 != nil { Usage() return } argvalue6 := int32(tmp6) value6 := argvalue6 fmt.Print(client.GetUserResources(value0, value1, value2, value3, value4, value5, value6)) fmt.Print("\n") break case "addComment": if flag.NArg()-1 != 1 { fmt.Fprintln(os.Stderr, "AddComment requires 1 args") flag.Usage() } arg357 := flag.Arg(1) mbTrans358 := thrift.NewTMemoryBufferLen(len(arg357)) defer mbTrans358.Close() _, err359 := mbTrans358.WriteString(arg357) if err359 != nil { Usage() return } factory360 := thrift.NewTSimpleJSONProtocolFactory() jsProt361 := factory360.GetProtocol(mbTrans358) argvalue0 := servicessync.NewComment() err362 := argvalue0.Read(jsProt361) if err362 != nil { Usage() return } value0 := argvalue0 fmt.Print(client.AddComment(value0)) fmt.Print("\n") break case "deleteComment": if flag.NArg()-1 != 4 { fmt.Fprintln(os.Stderr, "DeleteComment requires 4 args") flag.Usage() } argvalue0, err363 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err363 != nil { Usage() return } value0 := argvalue0 argvalue1, err364 := (strconv.ParseInt(flag.Arg(2), 10, 64)) if err364 != nil { Usage() return } value1 := argvalue1 argvalue2, err365 := (strconv.ParseInt(flag.Arg(3), 10, 64)) if err365 != nil { Usage() return } value2 := argvalue2 argvalue3, err366 := (strconv.ParseInt(flag.Arg(4), 10, 64)) if err366 != nil { Usage() return } value3 := argvalue3 fmt.Print(client.DeleteComment(value0, value1, value2, value3)) fmt.Print("\n") break case "getComments": if flag.NArg()-1 != 6 { fmt.Fprintln(os.Stderr, "GetComments requires 6 args") flag.Usage() } argvalue0, err367 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err367 != nil { Usage() return } value0 := argvalue0 argvalue1, err368 := (strconv.ParseInt(flag.Arg(2), 10, 64)) if err368 != nil { Usage() return } value1 := argvalue1 argvalue2, err369 := (strconv.ParseInt(flag.Arg(3), 10, 64)) if err369 != nil { Usage() return } value2 := argvalue2 argvalue3, err370 := (strconv.ParseInt(flag.Arg(4), 10, 64)) if err370 != nil { Usage() return } value3 := argvalue3 argvalue4 := flag.Arg(5) == "true" value4 := argvalue4 tmp5, err372 := (strconv.Atoi(flag.Arg(6))) if err372 != nil { Usage() return } argvalue5 := int32(tmp5) value5 := argvalue5 fmt.Print(client.GetComments(value0, value1, value2, value3, value4, value5)) fmt.Print("\n") break case "operateThumb": if flag.NArg()-1 != 4 { fmt.Fprintln(os.Stderr, "OperateThumb requires 4 args") flag.Usage() } argvalue0, err373 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err373 != nil { Usage() return } value0 := argvalue0 argvalue1, err374 := (strconv.ParseInt(flag.Arg(2), 10, 64)) if err374 != nil { Usage() return } value1 := argvalue1 tmp2, err := (strconv.Atoi(flag.Arg(3))) if err != nil { Usage() return } argvalue2 := servicessync.ThumbType(tmp2) value2 := argvalue2 argvalue3, err375 := (strconv.ParseInt(flag.Arg(4), 10, 64)) if err375 != nil { Usage() return } value3 := argvalue3 fmt.Print(client.OperateThumb(value0, value1, value2, value3)) fmt.Print("\n") break case "getThumbs": if flag.NArg()-1 != 7 { fmt.Fprintln(os.Stderr, "GetThumbs requires 7 args") flag.Usage() } argvalue0, err376 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err376 != nil { Usage() return } value0 := argvalue0 argvalue1, err377 := (strconv.ParseInt(flag.Arg(2), 10, 64)) if err377 != nil { Usage() return } value1 := argvalue1 tmp2, err := (strconv.Atoi(flag.Arg(3))) if err != nil { Usage() return } argvalue2 := servicessync.ThumbType(tmp2) value2 := argvalue2 argvalue3, err378 := (strconv.ParseInt(flag.Arg(4), 10, 64)) if err378 != nil { Usage() return } value3 := argvalue3 argvalue4, err379 := (strconv.ParseInt(flag.Arg(5), 10, 64)) if err379 != nil { Usage() return } value4 := argvalue4 argvalue5 := flag.Arg(6) == "true" value5 := argvalue5 tmp6, err381 := (strconv.Atoi(flag.Arg(7))) if err381 != nil { Usage() return } argvalue6 := int32(tmp6) value6 := argvalue6 fmt.Print(client.GetThumbs(value0, value1, value2, value3, value4, value5, value6)) fmt.Print("\n") break case "getResources": if flag.NArg()-1 != 4 { fmt.Fprintln(os.Stderr, "GetResources requires 4 args") flag.Usage() } argvalue0, err382 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err382 != nil { Usage() return } value0 := argvalue0 argvalue1, err383 := (strconv.ParseInt(flag.Arg(2), 10, 64)) if err383 != nil { Usage() return } value1 := argvalue1 argvalue2 := flag.Arg(3) == "true" value2 := argvalue2 tmp3, err385 := (strconv.Atoi(flag.Arg(4))) if err385 != nil { Usage() return } argvalue3 := int32(tmp3) value3 := argvalue3 fmt.Print(client.GetResources(value0, value1, value2, value3)) fmt.Print("\n") break case "getLatestResourcesByGid": if flag.NArg()-1 != 2 { fmt.Fprintln(os.Stderr, "GetLatestResourcesByGid requires 2 args") flag.Usage() } argvalue0, err386 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err386 != nil { Usage() return } value0 := argvalue0 tmp1, err387 := (strconv.Atoi(flag.Arg(2))) if err387 != nil { Usage() return } argvalue1 := int32(tmp1) value1 := argvalue1 fmt.Print(client.GetLatestResourcesByGid(value0, value1)) fmt.Print("\n") break case "getResourceForOperationPlatform": if flag.NArg()-1 != 1 { fmt.Fprintln(os.Stderr, "GetResourceForOperationPlatform requires 1 args") flag.Usage() } argvalue0, err388 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err388 != nil { Usage() return } value0 := argvalue0 fmt.Print(client.GetResourceForOperationPlatform(value0)) fmt.Print("\n") break case "": Usage() break default: fmt.Fprintln(os.Stderr, "Invalid function ", cmd) } }
func main() { flag.Usage = Usage var host string var port int var protocol string var urlString string var framed bool var useHttp bool var parsedUrl url.URL var trans thrift.TTransport _ = strconv.Atoi _ = math.Abs flag.Usage = Usage flag.StringVar(&host, "h", "localhost", "Specify host and port") flag.IntVar(&port, "p", 9090, "Specify port") flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)") flag.StringVar(&urlString, "u", "", "Specify the url") flag.BoolVar(&framed, "framed", false, "Use framed transport") flag.BoolVar(&useHttp, "http", false, "Use http") flag.Parse() if len(urlString) > 0 { parsedUrl, err := url.Parse(urlString) if err != nil { fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) flag.Usage() } host = parsedUrl.Host useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http" } else if useHttp { _, err := url.Parse(fmt.Sprint("http://", host, ":", port)) if err != nil { fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) flag.Usage() } } cmd := flag.Arg(0) var err error if useHttp { trans, err = thrift.NewTHttpClient(parsedUrl.String()) } else { portStr := fmt.Sprint(port) if strings.Contains(host, ":") { host, portStr, err = net.SplitHostPort(host) if err != nil { fmt.Fprintln(os.Stderr, "error with host:", err) os.Exit(1) } } trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr)) if err != nil { fmt.Fprintln(os.Stderr, "error resolving address:", err) os.Exit(1) } if framed { trans = thrift.NewTFramedTransport(trans) } } if err != nil { fmt.Fprintln(os.Stderr, "Error creating transport", err) os.Exit(1) } defer trans.Close() var protocolFactory thrift.TProtocolFactory switch protocol { case "compact": protocolFactory = thrift.NewTCompactProtocolFactory() break case "simplejson": protocolFactory = thrift.NewTSimpleJSONProtocolFactory() break case "json": protocolFactory = thrift.NewTJSONProtocolFactory() break case "binary", "": protocolFactory = thrift.NewTBinaryProtocolFactoryDefault() break default: fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol) Usage() os.Exit(1) } client := servicessync.NewRecommendationManagerSyncClientFactory(trans, protocolFactory) if err := trans.Open(); err != nil { fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err) os.Exit(1) } switch cmd { case "getResourceRecommendation": if flag.NArg()-1 != 7 { fmt.Fprintln(os.Stderr, "GetResourceRecommendation requires 7 args") flag.Usage() } argvalue0, err640 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err640 != nil { Usage() return } value0 := argvalue0 argvalue1 := flag.Arg(2) value1 := argvalue1 tmp2, err := (strconv.Atoi(flag.Arg(3))) if err != nil { Usage() return } argvalue2 := servicessync.ResourceType(tmp2) value2 := argvalue2 tmp3, err642 := (strconv.Atoi(flag.Arg(4))) if err642 != nil { Usage() return } argvalue3 := int32(tmp3) value3 := argvalue3 tmp4, err643 := (strconv.Atoi(flag.Arg(5))) if err643 != nil { Usage() return } argvalue4 := int32(tmp4) value4 := argvalue4 arg644 := flag.Arg(6) mbTrans645 := thrift.NewTMemoryBufferLen(len(arg644)) defer mbTrans645.Close() _, err646 := mbTrans645.WriteString(arg644) if err646 != nil { Usage() return } factory647 := thrift.NewTSimpleJSONProtocolFactory() jsProt648 := factory647.GetProtocol(mbTrans645) argvalue5 := servicessync.NewRecommendationAugmentInfo() err649 := argvalue5.Read(jsProt648) if err649 != nil { Usage() return } value5 := argvalue5 tmp6, err := (strconv.Atoi(flag.Arg(7))) if err != nil { Usage() return } argvalue6 := servicessync.RecommendationReason(tmp6) value6 := argvalue6 fmt.Print(client.GetResourceRecommendation(value0, value1, value2, value3, value4, value5, value6)) fmt.Print("\n") break case "getGroupRecommendation": if flag.NArg()-1 != 6 { fmt.Fprintln(os.Stderr, "GetGroupRecommendation requires 6 args") flag.Usage() } argvalue0, err650 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err650 != nil { Usage() return } value0 := argvalue0 argvalue1 := flag.Arg(2) value1 := argvalue1 tmp2, err652 := (strconv.Atoi(flag.Arg(3))) if err652 != nil { Usage() return } argvalue2 := int32(tmp2) value2 := argvalue2 tmp3, err653 := (strconv.Atoi(flag.Arg(4))) if err653 != nil { Usage() return } argvalue3 := int32(tmp3) value3 := argvalue3 arg654 := flag.Arg(5) mbTrans655 := thrift.NewTMemoryBufferLen(len(arg654)) defer mbTrans655.Close() _, err656 := mbTrans655.WriteString(arg654) if err656 != nil { Usage() return } factory657 := thrift.NewTSimpleJSONProtocolFactory() jsProt658 := factory657.GetProtocol(mbTrans655) argvalue4 := servicessync.NewRecommendationAugmentInfo() err659 := argvalue4.Read(jsProt658) if err659 != nil { Usage() return } value4 := argvalue4 tmp5, err := (strconv.Atoi(flag.Arg(6))) if err != nil { Usage() return } argvalue5 := servicessync.RecommendationReason(tmp5) value5 := argvalue5 fmt.Print(client.GetGroupRecommendation(value0, value1, value2, value3, value4, value5)) fmt.Print("\n") break case "getTagRecommendation": if flag.NArg()-1 != 7 { fmt.Fprintln(os.Stderr, "GetTagRecommendation requires 7 args") flag.Usage() } argvalue0, err660 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err660 != nil { Usage() return } value0 := argvalue0 argvalue1 := flag.Arg(2) value1 := argvalue1 arg662 := flag.Arg(3) mbTrans663 := thrift.NewTMemoryBufferLen(len(arg662)) defer mbTrans663.Close() _, err664 := mbTrans663.WriteString(arg662) if err664 != nil { Usage() return } factory665 := thrift.NewTSimpleJSONProtocolFactory() jsProt666 := factory665.GetProtocol(mbTrans663) containerStruct2 := servicessync.NewGetTagRecommendationArgs() err667 := containerStruct2.ReadField3(jsProt666) if err667 != nil { Usage() return } argvalue2 := containerStruct2.TagList value2 := argvalue2 tmp3, err668 := (strconv.Atoi(flag.Arg(4))) if err668 != nil { Usage() return } argvalue3 := int32(tmp3) value3 := argvalue3 tmp4, err669 := (strconv.Atoi(flag.Arg(5))) if err669 != nil { Usage() return } argvalue4 := int32(tmp4) value4 := argvalue4 tmp5, err := (strconv.Atoi(flag.Arg(6))) if err != nil { Usage() return } argvalue5 := servicessync.RecommendationReason(tmp5) value5 := argvalue5 tmp6, err := (strconv.Atoi(flag.Arg(7))) if err != nil { Usage() return } argvalue6 := servicessync.ResourceType(tmp6) value6 := argvalue6 fmt.Print(client.GetTagRecommendation(value0, value1, value2, value3, value4, value5, value6)) fmt.Print("\n") break case "getFriendRecommendation": if flag.NArg()-1 != 5 { fmt.Fprintln(os.Stderr, "GetFriendRecommendation requires 5 args") flag.Usage() } argvalue0, err670 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err670 != nil { Usage() return } value0 := argvalue0 argvalue1 := flag.Arg(2) value1 := argvalue1 tmp2, err672 := (strconv.Atoi(flag.Arg(3))) if err672 != nil { Usage() return } argvalue2 := int32(tmp2) value2 := argvalue2 tmp3, err673 := (strconv.Atoi(flag.Arg(4))) if err673 != nil { Usage() return } argvalue3 := int32(tmp3) value3 := argvalue3 tmp4, err := (strconv.Atoi(flag.Arg(5))) if err != nil { Usage() return } argvalue4 := servicessync.RecommendationReason(tmp4) value4 := argvalue4 fmt.Print(client.GetFriendRecommendation(value0, value1, value2, value3, value4)) fmt.Print("\n") break case "getMixedRecommendation": if flag.NArg()-1 != 6 { fmt.Fprintln(os.Stderr, "GetMixedRecommendation requires 6 args") flag.Usage() } argvalue0, err674 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err674 != nil { Usage() return } value0 := argvalue0 argvalue1 := flag.Arg(2) value1 := argvalue1 tmp2, err676 := (strconv.Atoi(flag.Arg(3))) if err676 != nil { Usage() return } argvalue2 := int32(tmp2) value2 := argvalue2 tmp3, err677 := (strconv.Atoi(flag.Arg(4))) if err677 != nil { Usage() return } argvalue3 := int32(tmp3) value3 := argvalue3 arg678 := flag.Arg(5) mbTrans679 := thrift.NewTMemoryBufferLen(len(arg678)) defer mbTrans679.Close() _, err680 := mbTrans679.WriteString(arg678) if err680 != nil { Usage() return } factory681 := thrift.NewTSimpleJSONProtocolFactory() jsProt682 := factory681.GetProtocol(mbTrans679) argvalue4 := servicessync.NewRecommendationAugmentInfo() err683 := argvalue4.Read(jsProt682) if err683 != nil { Usage() return } value4 := argvalue4 tmp5, err := (strconv.Atoi(flag.Arg(6))) if err != nil { Usage() return } argvalue5 := servicessync.RecommendationReason(tmp5) value5 := argvalue5 fmt.Print(client.GetMixedRecommendation(value0, value1, value2, value3, value4, value5)) fmt.Print("\n") break case "": Usage() break default: fmt.Fprintln(os.Stderr, "Invalid function ", cmd) } }
func main() { flag.Usage = Usage var host string var port int var protocol string var urlString string var framed bool var useHttp bool var parsedUrl url.URL var trans thrift.TTransport _ = strconv.Atoi _ = math.Abs flag.Usage = Usage flag.StringVar(&host, "h", "localhost", "Specify host and port") flag.IntVar(&port, "p", 9090, "Specify port") flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)") flag.StringVar(&urlString, "u", "", "Specify the url") flag.BoolVar(&framed, "framed", false, "Use framed transport") flag.BoolVar(&useHttp, "http", false, "Use http") flag.Parse() if len(urlString) > 0 { parsedUrl, err := url.Parse(urlString) if err != nil { fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) flag.Usage() } host = parsedUrl.Host useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http" } else if useHttp { _, err := url.Parse(fmt.Sprint("http://", host, ":", port)) if err != nil { fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) flag.Usage() } } cmd := flag.Arg(0) var err error if useHttp { trans, err = thrift.NewTHttpClient(parsedUrl.String()) } else { portStr := fmt.Sprint(port) if strings.Contains(host, ":") { host, portStr, err = net.SplitHostPort(host) if err != nil { fmt.Fprintln(os.Stderr, "error with host:", err) os.Exit(1) } } trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr)) if err != nil { fmt.Fprintln(os.Stderr, "error resolving address:", err) os.Exit(1) } if framed { trans = thrift.NewTFramedTransport(trans) } } if err != nil { fmt.Fprintln(os.Stderr, "Error creating transport", err) os.Exit(1) } defer trans.Close() var protocolFactory thrift.TProtocolFactory switch protocol { case "compact": protocolFactory = thrift.NewTCompactProtocolFactory() break case "simplejson": protocolFactory = thrift.NewTSimpleJSONProtocolFactory() break case "json": protocolFactory = thrift.NewTJSONProtocolFactory() break case "binary", "": protocolFactory = thrift.NewTBinaryProtocolFactoryDefault() break default: fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol) Usage() os.Exit(1) } client := servicessync.NewAccessManagerSyncClientFactory(trans, protocolFactory) if err := trans.Open(); err != nil { fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err) os.Exit(1) } switch cmd { case "grantUserAccessToGroupRegion": if flag.NArg()-1 != 6 { fmt.Fprintln(os.Stderr, "GrantUserAccessToGroupRegion requires 6 args") flag.Usage() } argvalue0, err182 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err182 != nil { Usage() return } value0 := argvalue0 argvalue1, err183 := (strconv.ParseInt(flag.Arg(2), 10, 64)) if err183 != nil { Usage() return } value1 := argvalue1 arg184 := flag.Arg(3) mbTrans185 := thrift.NewTMemoryBufferLen(len(arg184)) defer mbTrans185.Close() _, err186 := mbTrans185.WriteString(arg184) if err186 != nil { Usage() return } factory187 := thrift.NewTSimpleJSONProtocolFactory() jsProt188 := factory187.GetProtocol(mbTrans185) containerStruct2 := servicessync.NewGrantUserAccessToGroupRegionArgs() err189 := containerStruct2.ReadField3(jsProt188) if err189 != nil { Usage() return } argvalue2 := containerStruct2.Zones value2 := argvalue2 tmp3, err190 := (strconv.Atoi(flag.Arg(4))) if err190 != nil { Usage() return } argvalue3 := int32(tmp3) value3 := argvalue3 tmp4, err191 := (strconv.Atoi(flag.Arg(5))) if err191 != nil { Usage() return } argvalue4 := int32(tmp4) value4 := argvalue4 argvalue5, err192 := (strconv.ParseInt(flag.Arg(6), 10, 64)) if err192 != nil { Usage() return } value5 := argvalue5 fmt.Print(client.GrantUserAccessToGroupRegion(value0, value1, value2, value3, value4, value5)) fmt.Print("\n") break case "hasAccessToRegion": if flag.NArg()-1 != 3 { fmt.Fprintln(os.Stderr, "HasAccessToRegion requires 3 args") flag.Usage() } argvalue0, err193 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err193 != nil { Usage() return } value0 := argvalue0 argvalue1, err194 := (strconv.ParseInt(flag.Arg(2), 10, 64)) if err194 != nil { Usage() return } value1 := argvalue1 tmp2, err := (strconv.Atoi(flag.Arg(3))) if err != nil { Usage() return } argvalue2 := servicessync.Zone(tmp2) value2 := argvalue2 fmt.Print(client.HasAccessToRegion(value0, value1, value2)) fmt.Print("\n") break case "getAccessableGroupResources": if flag.NArg()-1 != 9 { fmt.Fprintln(os.Stderr, "GetAccessableGroupResources requires 9 args") flag.Usage() } argvalue0, err195 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err195 != nil { Usage() return } value0 := argvalue0 argvalue1, err196 := (strconv.ParseInt(flag.Arg(2), 10, 64)) if err196 != nil { Usage() return } value1 := argvalue1 tmp2, err := (strconv.Atoi(flag.Arg(3))) if err != nil { Usage() return } argvalue2 := servicessync.Zone(tmp2) value2 := argvalue2 tmp3, err := (strconv.Atoi(flag.Arg(4))) if err != nil { Usage() return } argvalue3 := servicessync.ResourceType(tmp3) value3 := argvalue3 argvalue4, err197 := (strconv.ParseInt(flag.Arg(5), 10, 64)) if err197 != nil { Usage() return } value4 := argvalue4 argvalue5, err198 := (strconv.ParseInt(flag.Arg(6), 10, 64)) if err198 != nil { Usage() return } value5 := argvalue5 argvalue6, err199 := (strconv.ParseInt(flag.Arg(7), 10, 64)) if err199 != nil { Usage() return } value6 := argvalue6 argvalue7 := flag.Arg(8) == "true" value7 := argvalue7 tmp8, err201 := (strconv.Atoi(flag.Arg(9))) if err201 != nil { Usage() return } argvalue8 := int32(tmp8) value8 := argvalue8 fmt.Print(client.GetAccessableGroupResources(value0, value1, value2, value3, value4, value5, value6, value7, value8)) fmt.Print("\n") break case "getAccessZoneUsers": if flag.NArg()-1 != 4 { fmt.Fprintln(os.Stderr, "GetAccessZoneUsers requires 4 args") flag.Usage() } argvalue0, err202 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err202 != nil { Usage() return } value0 := argvalue0 tmp1, err := (strconv.Atoi(flag.Arg(2))) if err != nil { Usage() return } argvalue1 := servicessync.Zone(tmp1) value1 := argvalue1 argvalue2, err203 := (strconv.ParseInt(flag.Arg(3), 10, 64)) if err203 != nil { Usage() return } value2 := argvalue2 tmp3, err204 := (strconv.Atoi(flag.Arg(4))) if err204 != nil { Usage() return } argvalue3 := int32(tmp3) value3 := argvalue3 fmt.Print(client.GetAccessZoneUsers(value0, value1, value2, value3)) fmt.Print("\n") break case "getUserAccessZones": if flag.NArg()-1 != 2 { fmt.Fprintln(os.Stderr, "GetUserAccessZones requires 2 args") flag.Usage() } argvalue0, err205 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err205 != nil { Usage() return } value0 := argvalue0 argvalue1, err206 := (strconv.ParseInt(flag.Arg(2), 10, 64)) if err206 != nil { Usage() return } value1 := argvalue1 fmt.Print(client.GetUserAccessZones(value0, value1)) fmt.Print("\n") break case "moveZone": if flag.NArg()-1 != 5 { fmt.Fprintln(os.Stderr, "MoveZone requires 5 args") flag.Usage() } argvalue0, err207 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err207 != nil { Usage() return } value0 := argvalue0 arg208 := flag.Arg(2) mbTrans209 := thrift.NewTMemoryBufferLen(len(arg208)) defer mbTrans209.Close() _, err210 := mbTrans209.WriteString(arg208) if err210 != nil { Usage() return } factory211 := thrift.NewTSimpleJSONProtocolFactory() jsProt212 := factory211.GetProtocol(mbTrans209) containerStruct1 := servicessync.NewMoveZoneArgs() err213 := containerStruct1.ReadField2(jsProt212) if err213 != nil { Usage() return } argvalue1 := containerStruct1.Uids value1 := argvalue1 tmp2, err := (strconv.Atoi(flag.Arg(3))) if err != nil { Usage() return } argvalue2 := servicessync.Zone(tmp2) value2 := argvalue2 tmp3, err := (strconv.Atoi(flag.Arg(4))) if err != nil { Usage() return } argvalue3 := servicessync.Zone(tmp3) value3 := argvalue3 argvalue4, err214 := (strconv.ParseInt(flag.Arg(5), 10, 64)) if err214 != nil { Usage() return } value4 := argvalue4 fmt.Print(client.MoveZone(value0, value1, value2, value3, value4)) fmt.Print("\n") break case "": Usage() break default: fmt.Fprintln(os.Stderr, "Invalid function ", cmd) } }
func main() { flag.Usage = Usage var host string var port int var protocol string var urlString string var framed bool var useHttp bool var parsedUrl url.URL var trans thrift.TTransport _ = strconv.Atoi _ = math.Abs flag.Usage = Usage flag.StringVar(&host, "h", "localhost", "Specify host and port") flag.IntVar(&port, "p", 9090, "Specify port") flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)") flag.StringVar(&urlString, "u", "", "Specify the url") flag.BoolVar(&framed, "framed", false, "Use framed transport") flag.BoolVar(&useHttp, "http", false, "Use http") flag.Parse() if len(urlString) > 0 { parsedUrl, err := url.Parse(urlString) if err != nil { fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) flag.Usage() } host = parsedUrl.Host useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http" } else if useHttp { _, err := url.Parse(fmt.Sprint("http://", host, ":", port)) if err != nil { fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) flag.Usage() } } cmd := flag.Arg(0) var err error if useHttp { trans, err = thrift.NewTHttpClient(parsedUrl.String()) } else { portStr := fmt.Sprint(port) if strings.Contains(host, ":") { host, portStr, err = net.SplitHostPort(host) if err != nil { fmt.Fprintln(os.Stderr, "error with host:", err) os.Exit(1) } } trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr)) if err != nil { fmt.Fprintln(os.Stderr, "error resolving address:", err) os.Exit(1) } if framed { trans = thrift.NewTFramedTransport(trans) } } if err != nil { fmt.Fprintln(os.Stderr, "Error creating transport", err) os.Exit(1) } defer trans.Close() var protocolFactory thrift.TProtocolFactory switch protocol { case "compact": protocolFactory = thrift.NewTCompactProtocolFactory() break case "simplejson": protocolFactory = thrift.NewTSimpleJSONProtocolFactory() break case "json": protocolFactory = thrift.NewTJSONProtocolFactory() break case "binary", "": protocolFactory = thrift.NewTBinaryProtocolFactoryDefault() break default: fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol) Usage() os.Exit(1) } client := servicessync.NewResourceCategoryManagerSyncClientFactory(trans, protocolFactory) if err := trans.Open(); err != nil { fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err) os.Exit(1) } switch cmd { case "getChildren": if flag.NArg()-1 != 5 { fmt.Fprintln(os.Stderr, "GetChildren requires 5 args") flag.Usage() } argvalue0, err580 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err580 != nil { Usage() return } value0 := argvalue0 argvalue1, err581 := (strconv.ParseInt(flag.Arg(2), 10, 64)) if err581 != nil { Usage() return } value1 := argvalue1 tmp2, err := (strconv.Atoi(flag.Arg(3))) if err != nil { Usage() return } argvalue2 := servicessync.ResourceNodeType(tmp2) value2 := argvalue2 argvalue3, err582 := (strconv.ParseInt(flag.Arg(4), 10, 64)) if err582 != nil { Usage() return } value3 := argvalue3 tmp4, err583 := (strconv.Atoi(flag.Arg(5))) if err583 != nil { Usage() return } argvalue4 := int32(tmp4) value4 := argvalue4 fmt.Print(client.GetChildren(value0, value1, value2, value3, value4)) fmt.Print("\n") break case "getChildrenByType": if flag.NArg()-1 != 5 { fmt.Fprintln(os.Stderr, "GetChildrenByType requires 5 args") flag.Usage() } argvalue0, err584 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err584 != nil { Usage() return } value0 := argvalue0 argvalue1, err585 := (strconv.ParseInt(flag.Arg(2), 10, 64)) if err585 != nil { Usage() return } value1 := argvalue1 tmp2, err := (strconv.Atoi(flag.Arg(3))) if err != nil { Usage() return } argvalue2 := servicessync.ResourceNodeType(tmp2) value2 := argvalue2 argvalue3, err586 := (strconv.ParseInt(flag.Arg(4), 10, 64)) if err586 != nil { Usage() return } value3 := argvalue3 tmp4, err587 := (strconv.Atoi(flag.Arg(5))) if err587 != nil { Usage() return } argvalue4 := int32(tmp4) value4 := argvalue4 fmt.Print(client.GetChildrenByType(value0, value1, value2, value3, value4)) fmt.Print("\n") break case "removeChild": if flag.NArg()-1 != 4 { fmt.Fprintln(os.Stderr, "RemoveChild requires 4 args") flag.Usage() } argvalue0, err588 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err588 != nil { Usage() return } value0 := argvalue0 argvalue1, err589 := (strconv.ParseInt(flag.Arg(2), 10, 64)) if err589 != nil { Usage() return } value1 := argvalue1 tmp2, err := (strconv.Atoi(flag.Arg(3))) if err != nil { Usage() return } argvalue2 := servicessync.ResourceNodeType(tmp2) value2 := argvalue2 argvalue3, err590 := (strconv.ParseInt(flag.Arg(4), 10, 64)) if err590 != nil { Usage() return } value3 := argvalue3 fmt.Print(client.RemoveChild(value0, value1, value2, value3)) fmt.Print("\n") break case "moveChild": if flag.NArg()-1 != 5 { fmt.Fprintln(os.Stderr, "MoveChild requires 5 args") flag.Usage() } argvalue0, err591 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err591 != nil { Usage() return } value0 := argvalue0 argvalue1, err592 := (strconv.ParseInt(flag.Arg(2), 10, 64)) if err592 != nil { Usage() return } value1 := argvalue1 tmp2, err := (strconv.Atoi(flag.Arg(3))) if err != nil { Usage() return } argvalue2 := servicessync.ResourceNodeType(tmp2) value2 := argvalue2 argvalue3, err593 := (strconv.ParseInt(flag.Arg(4), 10, 64)) if err593 != nil { Usage() return } value3 := argvalue3 argvalue4, err594 := (strconv.ParseInt(flag.Arg(5), 10, 64)) if err594 != nil { Usage() return } value4 := argvalue4 fmt.Print(client.MoveChild(value0, value1, value2, value3, value4)) fmt.Print("\n") break case "renameChild": if flag.NArg()-1 != 5 { fmt.Fprintln(os.Stderr, "RenameChild requires 5 args") flag.Usage() } argvalue0, err595 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err595 != nil { Usage() return } value0 := argvalue0 argvalue1, err596 := (strconv.ParseInt(flag.Arg(2), 10, 64)) if err596 != nil { Usage() return } value1 := argvalue1 tmp2, err := (strconv.Atoi(flag.Arg(3))) if err != nil { Usage() return } argvalue2 := servicessync.ResourceNodeType(tmp2) value2 := argvalue2 argvalue3, err597 := (strconv.ParseInt(flag.Arg(4), 10, 64)) if err597 != nil { Usage() return } value3 := argvalue3 argvalue4 := flag.Arg(5) value4 := argvalue4 fmt.Print(client.RenameChild(value0, value1, value2, value3, value4)) fmt.Print("\n") break case "createCategory": if flag.NArg()-1 != 3 { fmt.Fprintln(os.Stderr, "CreateCategory requires 3 args") flag.Usage() } argvalue0, err599 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err599 != nil { Usage() return } value0 := argvalue0 argvalue1, err600 := (strconv.ParseInt(flag.Arg(2), 10, 64)) if err600 != nil { Usage() return } value1 := argvalue1 argvalue2 := flag.Arg(3) value2 := argvalue2 fmt.Print(client.CreateCategory(value0, value1, value2)) fmt.Print("\n") break case "assignCategory": if flag.NArg()-1 != 5 { fmt.Fprintln(os.Stderr, "AssignCategory requires 5 args") flag.Usage() } argvalue0, err602 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err602 != nil { Usage() return } value0 := argvalue0 argvalue1, err603 := (strconv.ParseInt(flag.Arg(2), 10, 64)) if err603 != nil { Usage() return } value1 := argvalue1 arg604 := flag.Arg(3) mbTrans605 := thrift.NewTMemoryBufferLen(len(arg604)) defer mbTrans605.Close() _, err606 := mbTrans605.WriteString(arg604) if err606 != nil { Usage() return } factory607 := thrift.NewTSimpleJSONProtocolFactory() jsProt608 := factory607.GetProtocol(mbTrans605) argvalue2 := servicessync.NewResource() err609 := argvalue2.Read(jsProt608) if err609 != nil { Usage() return } value2 := argvalue2 tmp3, err := (strconv.Atoi(flag.Arg(4))) if err != nil { Usage() return } argvalue3 := servicessync.Zone(tmp3) value3 := argvalue3 argvalue4 := flag.Arg(5) value4 := argvalue4 fmt.Print(client.AssignCategory(value0, value1, value2, value3, value4)) fmt.Print("\n") break case "assignResourceZone": if flag.NArg()-1 != 6 { fmt.Fprintln(os.Stderr, "AssignResourceZone requires 6 args") flag.Usage() } argvalue0, err611 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err611 != nil { Usage() return } value0 := argvalue0 argvalue1, err612 := (strconv.ParseInt(flag.Arg(2), 10, 64)) if err612 != nil { Usage() return } value1 := argvalue1 tmp2, err := (strconv.Atoi(flag.Arg(3))) if err != nil { Usage() return } argvalue2 := servicessync.ResourceNodeType(tmp2) value2 := argvalue2 argvalue3, err613 := (strconv.ParseInt(flag.Arg(4), 10, 64)) if err613 != nil { Usage() return } value3 := argvalue3 tmp4, err := (strconv.Atoi(flag.Arg(5))) if err != nil { Usage() return } argvalue4 := servicessync.Zone(tmp4) value4 := argvalue4 argvalue5 := flag.Arg(6) value5 := argvalue5 fmt.Print(client.AssignResourceZone(value0, value1, value2, value3, value4, value5)) fmt.Print("\n") break case "getUnclassifiedGroupResources": if flag.NArg()-1 != 8 { fmt.Fprintln(os.Stderr, "GetUnclassifiedGroupResources requires 8 args") flag.Usage() } argvalue0, err615 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err615 != nil { Usage() return } value0 := argvalue0 tmp1, err := (strconv.Atoi(flag.Arg(2))) if err != nil { Usage() return } argvalue1 := servicessync.Zone(tmp1) value1 := argvalue1 tmp2, err := (strconv.Atoi(flag.Arg(3))) if err != nil { Usage() return } argvalue2 := servicessync.ResourceType(tmp2) value2 := argvalue2 argvalue3, err616 := (strconv.ParseInt(flag.Arg(4), 10, 64)) if err616 != nil { Usage() return } value3 := argvalue3 argvalue4, err617 := (strconv.ParseInt(flag.Arg(5), 10, 64)) if err617 != nil { Usage() return } value4 := argvalue4 argvalue5, err618 := (strconv.ParseInt(flag.Arg(6), 10, 64)) if err618 != nil { Usage() return } value5 := argvalue5 argvalue6 := flag.Arg(7) == "true" value6 := argvalue6 tmp7, err620 := (strconv.Atoi(flag.Arg(8))) if err620 != nil { Usage() return } argvalue7 := int32(tmp7) value7 := argvalue7 fmt.Print(client.GetUnclassifiedGroupResources(value0, value1, value2, value3, value4, value5, value6, value7)) fmt.Print("\n") break case "getUnclassifiedGroupResourcesByType": if flag.NArg()-1 != 8 { fmt.Fprintln(os.Stderr, "GetUnclassifiedGroupResourcesByType requires 8 args") flag.Usage() } argvalue0, err621 := (strconv.ParseInt(flag.Arg(1), 10, 64)) if err621 != nil { Usage() return } value0 := argvalue0 tmp1, err := (strconv.Atoi(flag.Arg(2))) if err != nil { Usage() return } argvalue1 := servicessync.Zone(tmp1) value1 := argvalue1 tmp2, err := (strconv.Atoi(flag.Arg(3))) if err != nil { Usage() return } argvalue2 := servicessync.ResourceType(tmp2) value2 := argvalue2 argvalue3, err622 := (strconv.ParseInt(flag.Arg(4), 10, 64)) if err622 != nil { Usage() return } value3 := argvalue3 argvalue4, err623 := (strconv.ParseInt(flag.Arg(5), 10, 64)) if err623 != nil { Usage() return } value4 := argvalue4 argvalue5, err624 := (strconv.ParseInt(flag.Arg(6), 10, 64)) if err624 != nil { Usage() return } value5 := argvalue5 argvalue6 := flag.Arg(7) == "true" value6 := argvalue6 tmp7, err626 := (strconv.Atoi(flag.Arg(8))) if err626 != nil { Usage() return } argvalue7 := int32(tmp7) value7 := argvalue7 fmt.Print(client.GetUnclassifiedGroupResourcesByType(value0, value1, value2, value3, value4, value5, value6, value7)) fmt.Print("\n") break case "": Usage() break default: fmt.Fprintln(os.Stderr, "Invalid function ", cmd) } }