本文整理汇总了Golang中github.com/caicloud/anchnet-go.Client.SendRequest方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.SendRequest方法的具体用法?Golang Client.SendRequest怎么用?Golang Client.SendRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/caicloud/anchnet-go.Client
的用法示例。
在下文中一共展示了Client.SendRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: execAddSecurityGroupRule
func execAddSecurityGroupRule(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
if len(args) != 2 {
fmt.Fprintln(os.Stderr, "Rule name and security group ID required")
os.Exit(1)
}
priority := getFlagInt(cmd, "priority")
direction := getFlagInt(cmd, "direction")
action := getFlagString(cmd, "action")
protocol := getFlagString(cmd, "protocol")
value1 := getFlagString(cmd, "value1")
value2 := getFlagString(cmd, "value2")
value3 := getFlagString(cmd, "value3")
request := anchnet.AddSecurityGroupRulesRequest{
SecurityGroupID: args[1],
SecurityGroupRules: []anchnet.AddSecurityGroupRule{
{
SecurityGroupRuleName: args[0],
Action: anchnet.SecurityGroupRuleAction(action),
Direction: anchnet.SecurityGroupRuleDirection(direction),
Protocol: anchnet.SecurityGroupRuleProtocol(protocol),
Priority: priority,
Value1: value1,
Value2: value2,
Value3: value3,
},
},
}
var response anchnet.AddSecurityGroupRulesResponse
sendResult(&response, out, "AddSecurityGroup", response.Code, client.SendRequest(request, &response))
}
示例2: execCreateUserProject
func execCreateUserProject(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
if len(args) == 0 {
fmt.Fprintln(os.Stderr, "Login ID required, i.e. username")
os.Exit(1)
}
sex := getFlagString(cmd, "sex")
mobile := getFlagString(cmd, "mobile")
passwd := getFlagString(cmd, "passwd")
// use {userid}@caicloud.io as loginid which is supposed to be unique.
loginID := args[0] + "@caicloud.io"
request := anchnet.CreateUserProjectRequest{
LoginID: loginID,
Sex: sex,
ProjectName: args[0],
Email: loginID,
ContactName: args[0],
Mobile: mobile,
LoginPasswd: passwd,
}
var response anchnet.CreateUserProjectResponse
sendResult(&response, out, "CreateUserProject", response.Code, client.SendRequest(request, &response))
}
示例3: execWaitJob
func execWaitJob(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
if len(args) == 0 {
fmt.Fprintln(os.Stderr, "Job id required")
os.Exit(1)
}
count := getFlagInt(cmd, "count")
status := getFlagString(cmd, "status")
interval := getFlagInt(cmd, "interval")
exitOnFail := getFlagBool(cmd, "exit_on_fail")
for i := 0; i < count; i++ {
request := anchnet.DescribeJobsRequest{
JobIDs: []string{args[0]},
}
var response anchnet.DescribeJobsResponse
err := client.SendRequest(request, &response)
if err == nil && len(response.ItemSet) == 1 {
// Return if there is no error and status matches.
if string(response.ItemSet[0].Status) == status {
return
}
// Return if there is no error, and status is failed + user wants early return.
if response.ItemSet[0].Status == anchnet.JobStatusFailed && exitOnFail {
fmt.Fprintf(os.Stderr, "Job %v failed", args[0])
os.Exit(1)
}
}
time.Sleep(time.Duration(interval) * time.Second)
}
fmt.Fprintf(os.Stderr, "Time out waiting for job %v", args[0])
os.Exit(1)
}
示例4: execCreateLoadBalancer
func execCreateLoadBalancer(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
if len(args) != 2 {
fmt.Fprintln(os.Stderr, "Load balancer name and public ips required")
os.Exit(1)
}
lb_type := getFlagInt(cmd, "type")
refs := strings.Split(args[1], ",")
ips := make([]anchnet.CreateLoadBalancerIP, len(refs))
for i, ip := range refs {
ips[i].RefID = ip
}
request := anchnet.CreateLoadBalancerRequest{
Product: anchnet.CreateLoadBalancerProduct{
Loadbalancer: anchnet.CreateLoadBalancerLB{
Name: args[0],
Type: anchnet.LoadBalancerType(lb_type),
},
Eips: ips,
},
}
var response anchnet.CreateLoadBalancerResponse
sendResult(&response, out, "CreateLoadBalancer", response.Code, client.SendRequest(request, &response))
}
示例5: execDeleteSecurityGroups
func execDeleteSecurityGroups(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
if len(args) != 1 {
fmt.Fprintln(os.Stderr, "Security group IDs required")
os.Exit(1)
}
request := anchnet.DeleteSecurityGroupsRequest{
SecurityGroupIDs: strings.Split(args[0], ","),
}
var response anchnet.DeleteSecurityGroupsResponse
sendResult(&response, out, "DeleteSecurityGroups", response.Code, client.SendRequest(request, &response))
}
示例6: execTerminateInstances
func execTerminateInstances(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
if len(args) == 0 {
fmt.Fprintln(os.Stderr, "Instance IDs required")
os.Exit(1)
}
request := anchnet.TerminateInstancesRequest{
InstanceIDs: strings.Split(args[0], ","),
}
var response anchnet.TerminateInstancesResponse
sendResult(&response, out, "TerminateInstance", response.Code, client.SendRequest(request, &response))
}
示例7: execDescribeVxnets
func execDescribeVxnets(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
if len(args) == 0 {
fmt.Fprintln(os.Stderr, "Vxnet IDs required")
os.Exit(1)
}
request := anchnet.DescribeVxnetsRequest{
VxnetIDs: strings.Split(args[0], ","),
}
var response anchnet.DescribeVxnetsResponse
sendResult(&response, out, "DescribeVxnet", response.Code, client.SendRequest(request, &response))
}
示例8: execReleaseEips
func execReleaseEips(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
if len(args) == 0 {
fmt.Fprintln(os.Stderr, "EIP IDs required")
os.Exit(1)
}
request := anchnet.ReleaseEipsRequest{
EipIDs: strings.Split(args[0], ","),
}
var response anchnet.ReleaseEipsResponse
sendResult(&response, out, "ReleaseEips", response.Code, client.SendRequest(request, &response))
}
示例9: execDescribeJob
func execDescribeJob(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
if len(args) == 0 {
fmt.Fprintln(os.Stderr, "Job id required")
os.Exit(1)
}
request := anchnet.DescribeJobsRequest{
JobIDs: []string{args[0]},
}
var response anchnet.DescribeJobsResponse
sendResult(&response, out, "DescribeJob", response.Code, client.SendRequest(request, &response))
}
示例10: execApplySecurityGroup
func execApplySecurityGroup(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
if len(args) != 2 {
fmt.Fprintln(os.Stderr, "Security group id and instance ids required")
os.Exit(1)
}
request := anchnet.ApplySecurityGroupRequest{
SecurityGroupID: args[0],
InstanceIDs: strings.Split(args[1], ","),
}
var response anchnet.ApplySecurityGroupResponse
sendResult(&response, out, "ApplySecurityGroup", response.Code, client.SendRequest(request, &response))
}
示例11: execJoinVxnet
func execJoinVxnet(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
if len(args) != 2 {
fmt.Fprintln(os.Stderr, "Vxnet and instances IDs required")
os.Exit(1)
}
request := anchnet.JoinVxnetRequest{
VxnetID: args[0],
InstanceIDs: strings.Split(args[1], ","),
}
var response anchnet.JoinVxnetResponse
sendResult(&response, out, "JobVxnet", response.Code, client.SendRequest(request, &response))
}
示例12: execRevokeImageFromUsers
func execRevokeImageFromUsers(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
if len(args) != 2 {
fmt.Fprintln(os.Stderr, "Image id and user ids required")
os.Exit(1)
}
request := anchnet.RevokeImageFromUsersRequest{
ImageIDs: []string{args[0]},
UserIDs: strings.Split(args[1], ","),
}
var response anchnet.RevokeImageFromUsersResponse
sendResult(&response, out, "RevokeImageToUsers", response.Code, client.SendRequest(request, &response))
}
示例13: execCaptureInstance
func execCaptureInstance(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
if len(args) != 2 {
fmt.Fprintln(os.Stderr, "Image name and instance id required")
os.Exit(1)
}
request := anchnet.CaptureInstanceRequest{
ImageName: args[0],
Instance: args[1],
}
var response anchnet.CaptureInstanceResponse
sendResult(&response, out, "CaptureInstance", response.Code, client.SendRequest(request, &response))
}
示例14: execDescribeProjects
func execDescribeProjects(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
if len(args) == 0 {
fmt.Fprintln(os.Stderr, "projectid required, e.g. pro-xxxxx")
os.Exit(1)
}
request := anchnet.DescribeProjectsRequest{
Projects: args[0],
}
var response anchnet.DescribeProjectsResponse
sendResult(&response, out, "DescribeProjects", response.Code, client.SendRequest(request, &response))
}
示例15: execSearchSecurityGroup
func execSearchSecurityGroup(cmd *cobra.Command, args []string, client *anchnet.Client, out io.Writer) {
if len(args) != 1 {
fmt.Fprintln(os.Stderr, "Security group name required")
os.Exit(1)
}
request := anchnet.DescribeSecurityGroupsRequest{
SearchWord: args[0],
Verbose: 1,
}
var response anchnet.DescribeSecurityGroupsResponse
sendResult(&response, out, "SearchSecurityGroup", response.Code, client.SendRequest(request, &response))
}