當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Client.PostInvestigatorAdminFlag方法代碼示例

本文整理匯總了Golang中mig/ninja/mig/client.Client.PostInvestigatorAdminFlag方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.PostInvestigatorAdminFlag方法的具體用法?Golang Client.PostInvestigatorAdminFlag怎麽用?Golang Client.PostInvestigatorAdminFlag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mig/ninja/mig/client.Client的用法示例。


在下文中一共展示了Client.PostInvestigatorAdminFlag方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: investigatorReader


//.........這裏部分代碼省略.........
		}
		orders := strings.Split(strings.TrimSpace(input), " ")
		switch orders[0] {
		case "details":
			fmt.Printf("Investigator ID %.0f\nname     %s\nstatus   %s\nadmin    %v\nkey id   %s\ncreated  %s\nmodified %s\n",
				inv.ID, inv.Name, inv.Status, inv.IsAdmin, inv.PGPFingerprint, inv.CreatedAt, inv.LastModified)
		case "exit":
			fmt.Printf("exit\n")
			goto exit
		case "help":
			fmt.Printf(`The following orders are available:
details			print the details of the investigator
exit			exit this mode
help			show this help
lastactions <limit>	print the last actions ran by the investigator. limit=10 by default.
pubkey			show the armored public key of the investigator
r			refresh the investigator (get latest version from upstream)
setadmin <true|false>   enable or disable admin flag for investigator
setstatus <status>	changes the status of the investigator to <status> (can be 'active' or 'disabled')
`)
		case "lastactions":
			limit := 10
			if len(orders) > 1 {
				limit, err = strconv.Atoi(orders[1])
				if err != nil {
					panic(err)
				}
			}
			err = printInvestigatorLastActions(iid, limit, cli)
			if err != nil {
				panic(err)
			}
		case "pubkey":
			armoredPubKey, err := pgp.ArmorPubKey(inv.PublicKey)
			if err != nil {
				panic(err)
			}
			fmt.Printf("%s\n", armoredPubKey)
		case "r":
			inv, err = cli.GetInvestigator(iid)
			if err != nil {
				panic(err)
			}
			fmt.Println("Reload succeeded")
		case "setstatus":
			if len(orders) != 2 {
				fmt.Println("error: must be 'setstatus <status>'. try 'help'")
				break
			}
			newstatus := orders[1]
			err = cli.PostInvestigatorStatus(iid, newstatus)
			if err != nil {
				panic(err)
			} else {
				fmt.Println("Investigator status set to", newstatus)
			}
			inv, err = cli.GetInvestigator(iid)
			if err != nil {
				panic(err)
			}
		case "setadmin":
			if len(orders) != 2 {
				fmt.Println("error: must be 'setadmin <true|false>'. try 'help'")
				break
			}
			var flag bool
			valid := true
			switch strings.ToLower(orders[1]) {
			case "true":
				flag = true
			case "false":
				flag = false
			default:
				fmt.Println("error: must specify true or false")
				valid = false
			}
			if !valid {
				break
			}
			err = cli.PostInvestigatorAdminFlag(iid, flag)
			if err != nil {
				panic(err)
			} else {
				fmt.Println("Investigator admin flag set to", flag)
			}
			inv, err = cli.GetInvestigator(iid)
			if err != nil {
				panic(err)
			}
		case "":
			break
		default:
			fmt.Printf("Unknown order '%s'. You are in investigator mode. Try `help`.\n", orders[0])
		}
		readline.AddHistory(input)
	}
exit:
	fmt.Printf("\n")
	return
}
開發者ID:ZhuHangpeng,項目名稱:mig,代碼行數:101,代碼來源:investigator.go


注:本文中的mig/ninja/mig/client.Client.PostInvestigatorAdminFlag方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。