{"modulePath":"github.com/volcengine/volcengine-cli","version":"v1.2.3","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package cmd\n\nCopyright © 2022 NAME HERE \\\u003cEMAIL ADDRESS\u003e\n\nforce.go 实现 --force 强制泛化调用。\n\n正常模式下 CLI 仅允许 metadata 中已收录的 service/action；--force 跳过该校验， 直接通过 SDK 发起 RPC 请求，适用于未收录产品、新发布接口或需覆盖 API 版本的场景。\n\n调用入口（维护时按此排查）：\n\n 1. cmd\\_root.Execute       -\u003e tryExecuteGenericInvoke：metadata 中不存在的 service\n 2. cmd\\_service.runServiceCmd：已知 service、action 未匹配子命令时\n 3. cmd\\_action action RunE：已知 action 子命令且带 --force（可覆盖 --version/--method）\n\n共享调用前处理见 invocation.go；profile/endpoint 解析真相见 sdk\\_client.go （selectInvocationProfile / resolveClientEndpoint / hasEffectiveFixedEndpoint）。\n\n系统参数：parser.go publicSystemFlags / localizedSystemFlagsHelp（对外双横线；三横线为冲突逃逸）。 双横线保留控制参数：reserved\\_dynamic.go（--header / --body）。 force 路径额外约定：\n\n\t--force     纯开关，出现即启用（只放宽 service/action 元数据校验，不改变 endpoint 解析）\n\t--version   未收录 service 时必填；已收录可回落元数据\n\t--endpoint  与正常调用同一套解析（flag \u003e resolver=standard \u003e profile/env \u003e 已收录 SDK 解析）；\n\t            未收录需要最终生效的固定 host（standard / auto-addressing 不够）\n\t--method    可选；未指定时优先元数据，否则 GET\n\t--header    可重复 HTTP 头 Name=Value（Content-Type 可覆盖元数据；不进请求体）\n\t--body      JSON 请求体；与 flattened 业务参数互斥\n\ninvocation.go 存放正常路径与 force 路径共用的“调用前”处理： context 重置、参数解析、API 版本 / method 固定参数、call-style 解析、 service 级 action 分发。真正发 SDK 请求的 executeInvocation 仍在 cmd\\_action.go。\n\n## Constants\n\n```go\nconst (\n\tModeSSO          = \"sso\"\n\tModeConsoleLogin = \"console-login\"\n\tModeAK           = \"ak\"\n\tModeRamRoleArn   = \"ramrolearn\"\n\tModeOIDC         = \"oidc\"\n\tModeEcsRole      = \"ecsrole\"\n\tConfigFile       = \"config.json\"\n)\n```\n定义模式枚举常量\n\n```go\nconst (\n\n\t// ConsoleClientIDSameDevice is the legacy public client ID issued by the\n\t// removed authorization code flow. Login never mints it again; refresh\n\t// replays whatever client ID the cache holds, so caches written by older\n\t// CLI versions keep working. Kept to document that value and to pin it in\n\t// the compatibility tests.\n\tConsoleClientIDSameDevice = \"trn:signin:::devtools/same-device\"\n\n\t// ConsoleClientIDCrossDevice is the public client ID used by device code login.\n\tConsoleClientIDCrossDevice = \"trn:signin:::devtools/cross-device\"\n)\n```\n\n## Functions\n\n```go\nfunc Execute()\n```\n\n```go\nfunc GetServiceMapping(s string) (string, bool)\n```\n\n```go\nfunc SetServiceMapping(s1, s2 string)\n```\n\n```go\nfunc WriteConfigToFile(config *Configure) error\n```\nWriteConfigToFile store config\n\n## Types\n\n```go\ntype AccountInfo struct {\n\tAccountID   string `json:\"AccountId\"`\n\tAccountName string `json:\"AccountName\"`\n}\n```\nAccountInfo 表示 ListAccounts 返回的账号信息。\n\n```go\ntype ApiDescription struct {\n\tNameCn        string `json:\"name_cn,omitempty\"`\n\tNameEn        string `json:\"name_en,omitempty\"`\n\tDescriptionCn string `json:\"description_cn,omitempty\"`\n\tDescriptionEn string `json:\"description_en,omitempty\"`\n\tDescription   string `json:\"description,omitempty\"`\n}\n```\n\n```go\ntype ApiInfo struct {\n\tMethod      string\n\tContentType string\n\tServiceName string\n\tParamTypes  map[string]string\n}\n```\n\n```go\ntype ApiMeta struct {\n\tRequest  *Meta\n\tResponse *Meta\n}\n```\n\n```go\nfunc (m *ApiMeta) GetReqRequired(pattern string) bool\n```\n\n```go\nfunc (m *ApiMeta) GetReqTypeName(pattern string) string\n```\n\n```go\nfunc (m *ApiMeta) GetRequestParams() (params []param)\n```\n\n```go\ntype Configure struct {\n\tCurrent     string                 `json:\"current\"`\n\tProfiles    map[string]*Profile    `json:\"profiles\"`\n\tEnableColor bool                   `json:\"enableColor\"`\n\tSsoSession  map[string]*SsoSession `json:\"sso-session\"`\n}\n```\n\n```go\nfunc LoadConfig() *Configure\n```\nLoadConfig from CONFIG\\_FILE\\_DIR(default ~/.volcengine)\n\n```go\nfunc (config *Configure) SetRandomCurrentProfile()\n```\n\n```go\ntype ConsoleDeviceAuthorizationRequest struct {\n\tClientID   string\n\tScope      string\n\tDeviceInfo string\n}\n```\nConsoleDeviceAuthorizationRequest represents a device authorization request.\n\n```go\ntype ConsoleDeviceAuthorizationResponse struct {\n\tDeviceCode              string `json:\"device_code\"`\n\tUserCode                string `json:\"user_code\"`\n\tVerificationURI         string `json:\"verification_uri\"`\n\tVerificationURIComplete string `json:\"verification_uri_complete,omitempty\"`\n\tExpiresIn               int    `json:\"expires_in\"`\n\tInterval                int    `json:\"interval,omitempty\"`\n}\n```\nConsoleDeviceAuthorizationResponse represents a device authorization response.\n\n```go\ntype ConsoleLogin struct {\n\tProfile     string // profile name, default \"default\"\n\tRegion      string\n\tNoBrowser   bool   // true = do not automatically open a browser during authorization\n\tEndpointURL string // default \"https://signin.volcengine.com\"\n}\n```\nConsoleLogin holds runtime state for the volcengine login flow.\n\n```go\nfunc (cl *ConsoleLogin) Login() error\n```\n\n```go\ntype ConsoleLogout struct {\n\tProfile string // profile name, default \"default\"\n\tAll     bool   // true = clear all login caches\n}\n```\nConsoleLogout holds runtime state for the volcengine logout flow.\n\n```go\nfunc (cl *ConsoleLogout) Logout() error\n```\n\n```go\ntype ConsoleOAuthAPIError struct {\n\tStatusCode int\n\tResponse   ConsoleOAuthErrorResponse\n\tRawBody    string\n\tRequestID  string // X-Tt-Logid header\n}\n```\nConsoleOAuthAPIError wraps a non-2xx response from the console OAuth endpoints.\n\n```go\nfunc (e *ConsoleOAuthAPIError) Error() string\n```\n\n```go\nfunc (e *ConsoleOAuthAPIError) IsRetryable() bool\n```\nIsRetryable reports whether the error is transient and the request should be retried. Reuses the same HTTP status heuristic as the SSO client.\n\n```go\ntype ConsoleOAuthClient struct {\n\t// contains filtered or unexported fields\n}\n```\nConsoleOAuthClient wraps HTTP calls to the Volcengine console sign-in OAuth endpoints. Unlike the existing OAuthClient (which talks to CloudIdentity), this client targets signin.volcengine.com and implements the public-client device code flow.\n\n```go\nfunc NewConsoleOAuthClient(cfg *ConsoleOAuthClientConfig) *ConsoleOAuthClient\n```\nNewConsoleOAuthClient creates a new ConsoleOAuthClient with the given configuration. If cfg is nil or EndpointURL is empty, the default endpoint is used.\n\n```go\nfunc (c *ConsoleOAuthClient) ExchangeToken(ctx context.Context, req *ConsoleTokenRequest) (*ConsoleTokenResponse, error)\n```\nExchangeToken performs the token exchange by sending a POST request to the token endpoint with application/x-www-form-urlencoded body parameters.\n\nFor the device code grant: device\\_code and client\\_id are required.\n\nFor grant\\_type=refresh\\_token: refresh\\_token and client\\_id are required.\n\nThe method uses retry logic (doWithRetry) with up to 3 attempts for transient failures. Only errors where ConsoleOAuthAPIError.IsRetryable() returns true are retried.\n\n```go\nfunc (c *ConsoleOAuthClient) StartDeviceAuthorization(\n\tctx context.Context,\n\treq *ConsoleDeviceAuthorizationRequest,\n) (*ConsoleDeviceAuthorizationResponse, error)\n```\nStartDeviceAuthorization starts the OAuth 2.0 Device Authorization Grant flow.\n\n```go\ntype ConsoleOAuthClientConfig struct {\n\t// EndpointURL is the base URL of the console sign-in service,\n\t// e.g. \"https://signin.volcengine.com\". If empty, defaultConsoleEndpoint is used.\n\tEndpointURL string\n\t// HTTPClient allows injecting a custom HTTP client (e.g. for proxy or testing).\n\tHTTPClient *http.Client\n}\n```\nConsoleOAuthClientConfig holds configuration for console OAuth client.\n\n```go\ntype ConsoleOAuthErrorResponse struct {\n\tState            string `json:\"state,omitempty\"`\n\tError            string `json:\"error\"`\n\tErrorDescription string `json:\"error_description,omitempty\"`\n\tErrorURI         string `json:\"error_uri,omitempty\"`\n}\n```\nConsoleOAuthErrorResponse represents the error response body from the console signin OAuth endpoints. Structure per the signin API spec:\n\n\t{\n\t    \"state\": \"...\",               // echoed back if present in request\n\t    \"error\": \"invalid_grant\",     // OAuth error code (required)\n\t    \"error_description\": \"...\",   // human-readable detail (optional)\n\t    \"error_uri\": \"...\"            // URI for more info (optional)\n\t}\n\n```go\ntype ConsoleTokenRequest struct {\n\tGrantType    string // deviceCodeGrantType or \"refresh_token\"\n\tClientID     string\n\tScope        string\n\tRefreshToken string // for refresh_token grant\n\tDeviceCode   string // for device code grant\n}\n```\nConsoleTokenRequest represents the token exchange request for console OAuth.\n\n```go\ntype ConsoleTokenResponse struct {\n\tAccessToken  string `json:\"access_token\"` // JSON string containing STS credentials\n\tTokenType    string `json:\"token_type\"`   // e.g. \"urn:ietf:params:oauth:token-type:access_token_sts\"\n\tExpiresIn    int    `json:\"expires_in\"`   // seconds, e.g. 900\n\tRefreshToken string `json:\"refresh_token\"`\n\tScope        string `json:\"scope\"`\n\tIDToken      string `json:\"id_token\"` // JWT\n}\n```\nConsoleTokenResponse represents the raw token response from the console OAuth endpoint.\n\n```go\ntype Context struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewContext() *Context\n```\n\n```go\nfunc (c *Context) SetConfig(cfg *Configure)\n```\n\n```go\ntype CreateTokenRequest struct {\n\tGrantType    string `json:\"grant_type\"`\n\tClientID     string `json:\"client_id\"`\n\tClientSecret string `json:\"client_secret\"`\n\tRefreshToken string `json:\"refresh_token,omitempty\"`\n\tDeviceCode   string `json:\"device_code,omitempty\"`\n}\n```\nCreateTokenRequest 对应 CreateToken API 的请求参数。\n\n```go\ntype CreateTokenResponse struct {\n\tAccessToken  string `json:\"access_token\"`\n\tTokenType    string `json:\"token_type\"`\n\tRefreshToken string `json:\"refresh_token,omitempty\"`\n\tExpiresIn    int    `json:\"expires_in\"`\n}\n```\nCreateTokenResponse 表示获取 Token 成功后的返回结构。\n\n```go\ntype DebugLogger struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (l *DebugLogger) Close() error\n```\nClose 刷新缓冲区并关闭底层输出资源。 返回写入、刷新或关闭阶段遇到的首个错误；nil logger 直接返回 nil，便于调用方安全 defer。\n\n```go\nfunc (l *DebugLogger) Enabled() bool\n```\nEnabled 返回 debug logger 当前是否可写。 nil logger 或显式关闭 debug 时都视为未启用，方便调用方直接在链路中做空值保护。\n\n```go\nfunc (l *DebugLogger) Printf(format string, args ...interface{})\n```\nPrintf 在 debug logger 启用时写入一行格式化日志。 写入失败只记录首个错误并留到 Close 返回，避免 debug 日志问题打断主业务流程。\n\n```go\ntype DeviceCodeFetcher struct {\n\t// contains filtered or unexported fields\n}\n```\nDeviceCodeFetcher 负责基于设备码的 OAuth 授权流程。\n\n```go\nfunc (f *DeviceCodeFetcher) GetFreshTokenForLogin() (*SsoTokenCache, error)\n```\nGetFreshTokenForLogin 执行显式登录授权。 无论缓存 access token 是否有效，也不会用 refresh\\_token 静默完成登录。\n\n```go\nfunc (f *DeviceCodeFetcher) GetToken() (*SsoTokenCache, error)\n```\nGetToken 协调设备码流程、refresh token 刷新及缓存复用。 该方法保留给 configure sso 等交互式流程使用：它可以复用缓存、尝试 refresh，并在必要时回退到设备码授权。\n\n```go\nfunc (f *DeviceCodeFetcher) GetValidTokenForBusiness() (*SsoTokenCache, error)\n```\nGetValidTokenForBusiness 返回业务命令可用的 access token 缓存。 业务命令只允许静默 refresh，不允许回退到设备码授权，避免普通 API 调用突然打开浏览器或阻塞等待用户授权。\n\n```go\ntype Flag struct {\n\tName string\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (f *Flag) GetValue() string\n```\n\n```go\nfunc (f *Flag) GetValues() []string\n```\nGetValues returns all assigned values in order.\n\n```go\nfunc (f *Flag) SetValue(value string)\n```\nSetValue assigns a value. Multi-value flags append; single-value flags replace.\n\n```go\ntype FlagSet struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewFlagSet() *FlagSet\n```\n\n```go\nfunc (fs *FlagSet) AddByName(name string) (*Flag, error)\n```\n\n```go\nfunc (fs *FlagSet) AddFlag(f *Flag)\n```\n\n```go\nfunc (fs *FlagSet) GetByName(name string) *Flag\n```\nGetByName returns the flag with the given name, or nil if not found.\n\n```go\nfunc (fs *FlagSet) GetFlags() []*Flag\n```\n\n```go\ntype GetRoleCredentialsRequest struct {\n\tAccessToken string\n\tAccountID   string\n\tRoleName    string\n\tPageSize    int\n\tPageNumber  int\n}\n```\nGetRoleCredentialsRequest 为 GetRoleCredentials 的请求参数封装。\n\n```go\ntype GetRoleCredentialsResponse struct {\n\tRoleCredentials RoleCredentials\n\tRequestID       string\n}\n```\nGetRoleCredentialsResponse 返回临时凭证及请求 ID。\n\n```go\ntype Language string\n```\n\n```go\nconst (\n\tLanguageEnglish           Language = \"EN\"\n\tLanguageSimplifiedChinese Language = \"ZH\"\n)\n```\n\n```go\ntype ListAccountRolesRequest struct {\n\tAccessToken string\n\tAccountID   string\n\tPageSize    int\n\tPageNumber  int\n\tNextToken   string\n}\n```\nListAccountRolesRequest 为 ListAccountRoles 的请求参数封装。\n\n```go\ntype ListAccountRolesResponse struct {\n\tTotal      int\n\tPageNumber int\n\tPageSize   int\n\tRoleList   []RoleInfo\n\tNextToken  string\n\tRequestID  string\n}\n```\nListAccountRolesResponse 返回角色列表及分页信息。\n\n```go\ntype ListAccountsRequest struct {\n\tAccessToken string\n\tPageSize    int\n\tPageNumber  int\n\tNextToken   string\n}\n```\nListAccountsRequest 为 ListAccounts 的请求参数封装。\n\n```go\ntype ListAccountsResponse struct {\n\tTotal       int\n\tPageNumber  int\n\tPageSize    int\n\tAccountList []AccountInfo\n\tNextToken   string\n\tRequestID   string\n}\n```\nListAccountsResponse 返回账号列表及分页信息。\n\n```go\ntype LoginTokenCache struct {\n\tLoginSession string          `json:\"login_session\"`\n\tAccessToken  json.RawMessage `json:\"access_token\"`\n\tRefreshToken string          `json:\"refresh_token,omitempty\"`\n\tIDToken      string          `json:\"id_token,omitempty\"`\n\tScope        string          `json:\"scope\"`\n\tClientID     string          `json:\"client_id\"`\n\tEndpointURL  string          `json:\"endpoint_url,omitempty\"`\n\tIssuedAt     string          `json:\"issued_at\"`\n\tExpiresIn    int             `json:\"expires_in\"`\n\tTokenType    string          `json:\"token_type\"`\n}\n```\nLoginTokenCache represents the cached login token data persisted to disk.\n\n```go\ntype Meta struct {\n\tMetaTypes  map[string]*MetaType `json:\"MetaTypes,omitempty\"`\n\tChildMetas map[string]*Meta     `json:\"ChildMetas,omitempty\"`\n}\n```\n\n```go\nfunc (m *Meta) GetReqBody() map[string]interface{}\n```\n\n```go\ntype MetaInfo struct {\n\tBasic     *[]string\n\tStructure *map[string]MetaInfo\n}\n```\n\n```go\ntype MetaType struct {\n\tTypeName string `json:\"TypeName,omitempty\"`\n\tTypeOf   string `json:\"TypeOf,omitempty\"`\n\tRequired bool   `json:\"Required,omitempty\"`\n}\n```\n\n```go\ntype OAuthAPIError struct {\n\tStatusCode int\n\tResponse   oauthErrorResponse\n\tRawBody    string\n}\n```\nOAuthAPIError 用于承载 OAuth API 非 2xx 响应时的结构化错误信息。\n\n```go\nfunc (e *OAuthAPIError) Error() string\n```\n\n```go\ntype OAuthClient struct {\n\t// contains filtered or unexported fields\n}\n```\nOAuthClient 缓存拼好的 URL 和 HTTP 客户端，避免每次调用重新计算。\n\n```go\nfunc NewOAuthClient(cfg *OAuthClientConfig) *OAuthClient\n```\nNewOAuthClient 根据配置创建 OAuthClient，包含默认值和可选覆盖项。\n\n```go\nfunc (c *OAuthClient) CreateToken(ctx context.Context, req *CreateTokenRequest) (*CreateTokenResponse, error)\n```\nCreateToken 调用 CreateToken API，获取 access/refresh token。\n\n```go\nfunc (c *OAuthClient) RegisterClient(ctx context.Context, req *RegisterClientRequest) (*RegisterClientResponse, error)\n```\nRegisterClient 调用 RegisterClient API，返回注册后的 client\\_id/client\\_secret。\n\n```go\nfunc (c *OAuthClient) RevokeToken(ctx context.Context, req *RevokeTokenRequest) error\n```\nRevokeToken 调用 RevokeToken API 撤销 access/refresh token。\n\n```go\nfunc (c *OAuthClient) StartDeviceAuthorization(ctx context.Context, req *StartDeviceAuthorizationRequest) (*StartDeviceAuthorizationResponse, error)\n```\nStartDeviceAuthorization 发起设备码授权流程。\n\n```go\ntype OAuthClientAPI interface {\n\tRegisterClient(ctx context.Context, req *RegisterClientRequest) (*RegisterClientResponse, error)\n\tCreateToken(ctx context.Context, req *CreateTokenRequest) (*CreateTokenResponse, error)\n\tRevokeToken(ctx context.Context, req *RevokeTokenRequest) error\n\tStartDeviceAuthorization(ctx context.Context, req *StartDeviceAuthorizationRequest) (*StartDeviceAuthorizationResponse, error)\n}\n```\nOAuthClientAPI 定义 OAuth 客户端对外暴露的方法集合，便于测试或替换实现。\n\n```go\ntype OAuthClientConfig struct {\n\t// Region 控制使用的区域（默认：cn-beijing）。\n\tRegion string\n\t// HTTPClient 允许注入自定义 HTTP 客户端（例如代理、超时）。\n\tHTTPClient *http.Client\n}\n```\nOAuthClientConfig 用于配置 OAuth 客户端的可选项。\n\n```go\ntype Parser struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewParser(args []string, actionParameters ...map[string]struct{}) *Parser\n```\n\n```go\nfunc (p *Parser) ReadArgs(ctx *Context) ([]string, error)\n```\nReadArgs parses invocation arguments with a single left-to-right pass, so the result never depends on how many arguments are given or where presence-only switches appear.\n\nA flag token opens a value slot (presence-only system switches excepted). The next token fills the slot verbatim unless it unambiguously starts another flag, in which case the open flag is reported as missing its value. Tokens outside a value slot that are not flags are returned as positional arguments.\n\n```go\ntype PortalAPIError struct {\n\tStatusCode int\n\tRequestID  string\n\tMessage    string\n\tRawBody    string\n}\n```\nPortalAPIError 用于承载 Portal API 非 2xx 响应时的结构化错误信息。\n\n```go\nfunc (e *PortalAPIError) Error() string\n```\n\n```go\ntype PortalClient struct {\n\t// contains filtered or unexported fields\n}\n```\nPortalClient 封装 CloudIdentity Portal API 调用，集中管理 URL、HTTP 客户端和默认分页参数。\n\n```go\nfunc NewPortalClient(cfg *PortalClientConfig) *PortalClient\n```\nNewPortalClient 根据配置创建 PortalClient，包含默认值和可选覆盖项。\n\n```go\nfunc (c *PortalClient) GetRoleCredentials(ctx context.Context, req *GetRoleCredentialsRequest) (*GetRoleCredentialsResponse, error)\n```\nGetRoleCredentials 使用 Portal 访问令牌换取指定账号和角色的临时凭证。\n\n```go\nfunc (c *PortalClient) ListAccountRoles(ctx context.Context, req *ListAccountRolesRequest) (*ListAccountRolesResponse, error)\n```\nListAccountRoles 调用 ListAccountRoles API，返回指定账号下当前令牌可用的角色列表。\n\n```go\nfunc (c *PortalClient) ListAccounts(ctx context.Context, req *ListAccountsRequest) (*ListAccountsResponse, error)\n```\nListAccounts 调用 ListAccounts API，返回当前访问令牌可见的账号列表。\n\n```go\ntype PortalClientAPI interface {\n\tListAccounts(ctx context.Context, req *ListAccountsRequest) (*ListAccountsResponse, error)\n\tListAccountRoles(ctx context.Context, req *ListAccountRolesRequest) (*ListAccountRolesResponse, error)\n\tGetRoleCredentials(ctx context.Context, req *GetRoleCredentialsRequest) (*GetRoleCredentialsResponse, error)\n}\n```\nPortalClientAPI 定义 Portal 客户端对外暴露的方法集合，便于测试或替换实现。\n\n```go\ntype PortalClientConfig struct {\n\tRegion          string       // 区域标识（当前逻辑未使用）\n\tBaseURL         string       // 自定义 Portal 基础地址\n\tHTTPClient      *http.Client // 自定义 HTTP 客户端（可注入超时、代理等）\n\tDefaultPageSize int          // 默认分页大小\n}\n```\nPortalClientConfig 用于配置 Portal 客户端的可选项，比如自定义 BaseURL、HTTPClient 或分页大小。\n\n```go\ntype Profile struct {\n\tName             string `json:\"name\"`\n\tMode             string `json:\"mode\"`\n\tAccessKey        string `json:\"access-key\"`\n\tSecretKey        string `json:\"secret-key\"`\n\tRegion           string `json:\"region\"`\n\tEndpoint         string `json:\"endpoint\"`\n\tEndpointResolver string `json:\"endpoint-resolver,omitempty\"`\n\tHTTPProxy        string `json:\"http-proxy,omitempty\"`\n\tHTTPSProxy       string `json:\"https-proxy,omitempty\"`\n\tUseDualStack     *bool  `json:\"use-dual-stack,omitempty\"`\n\tSessionToken     string `json:\"session-token\"`\n\tDisableSSL       *bool  `json:\"disable-ssl\"`\n\tSsoSessionName   string `json:\"sso-session-name\"`\n\tAccountId        string `json:\"account-id\"`\n\tRoleName         string `json:\"role-name\"`\n\tStsExpiration    int64  `json:\"sts-expiration\"`\n\tOidcTokenFile    string `json:\"oidc-token-file,omitempty\"`\n\tRoleTrn          string `json:\"role-trn,omitempty\"`\n\tLoginSession     string `json:\"login-session,omitempty\"`\n}\n```\n\n```go\nfunc (p *Profile) String() string\n```\n\n```go\nfunc (p *Profile) ToDisplayMap(showSensitive bool) map[string]interface{}\n```\nToDisplayMap 返回用于展示的 profile map。 showSensitive 为 false 时，按 profileMaskRules 遮盖敏感字段；该方法只改动返回的副本，不影响 profile 本身。\n\n```go\nfunc (p *Profile) ToMap() map[string]interface{}\n```\n\n```go\ntype RegisterClientRequest struct {\n\tClientName string   `json:\"client_name\"`\n\tClientType string   `json:\"client_type\"`\n\tGrantTypes []string `json:\"grant_types,omitempty\"`\n\tScopes     []string `json:\"scopes,omitempty\"`\n}\n```\nRegisterClientRequest 对应 RegisterClient API 的请求参数。\n\n```go\ntype RegisterClientResponse struct {\n\tClientID              string `json:\"client_id\"`\n\tClientSecret          string `json:\"client_secret\"`\n\tClientIDIssuedAt      int64  `json:\"client_id_issued_at,omitempty\"`\n\tClientSecretExpiresAt int64  `json:\"client_secret_expires_at,omitempty\"`\n}\n```\nRegisterClientResponse 表示注册客户端成功后的返回结构。\n\n```go\ntype ResponseMetadata struct {\n\tRequestID string `json:\"RequestId\"`\n}\n```\nResponseMetadata 表示 Portal API 返回的基础元信息。\n\n```go\ntype RevokeTokenRequest struct {\n\tClientID     string `json:\"client_id\"`\n\tClientSecret string `json:\"client_secret\"`\n\tToken        string `json:\"token\"`\n}\n```\nRevokeTokenRequest 为撤销 token 的请求参数。\n\n```go\ntype RoleCredentials struct {\n\tAccessKeyID     string `json:\"AccessKeyId\"`\n\tExpiration      int64  `json:\"Expiration\"`\n\tSecretAccessKey string `json:\"SecretAccessKey\"`\n\tSessionToken    string `json:\"sessionToken\"`\n}\n```\nRoleCredentials 表示 GetRoleCredentials 返回的临时凭证信息。\n\n```go\ntype RoleInfo struct {\n\tAccountID string `json:\"AccountId\"`\n\tRoleName  string `json:\"RoleName\"`\n}\n```\nRoleInfo 表示 ListAccountRoles 返回的角色信息。\n\n```go\ntype RootSupport struct {\n\tSupportSvc    []string\n\tSupportAction map[string]map[string]*VolcengineMeta\n\tVersions      map[string]string\n\tSupportTypes  map[string]map[string]*ApiMeta\n}\n```\n\n```go\nfunc NewRootSupport() *RootSupport\n```\n\n```go\nfunc (r *RootSupport) GetAllAction(svc string) []string\n```\n\n```go\nfunc (r *RootSupport) GetAllSvc() []string\n```\n\n```go\nfunc (r *RootSupport) GetAllSvcCompatible() []string\n```\n\n```go\nfunc (r *RootSupport) GetApiInfo(svc string, action string) *ApiInfo\n```\n\n```go\nfunc (r *RootSupport) GetApiMeta(svc string, action string) *ApiMeta\n```\n\n```go\nfunc (r *RootSupport) GetVersion(svc string) string\n```\n\n```go\nfunc (r *RootSupport) IsValidAction(svc, action string) bool\n```\n\n```go\nfunc (r *RootSupport) IsValidSvc(svc string) bool\n```\n\n```go\ntype SSOService interface {\n\tSetProfile() error\n\tLogin() error\n\tLogout() error\n\tGetAccessToken() (string, error)\n\tGetRoleCredentials() (*RoleCredentials, error)\n}\n```\nSSOService 定义对外暴露的 SSO 操作接口。\n\n```go\ntype STSCredentials struct {\n\tAccessKeyID     string `json:\"access_key_id\"`\n\tSecretAccessKey string `json:\"secret_access_key\"`\n\tSessionToken    string `json:\"session_token\"`\n}\n```\nSTSCredentials represents the parsed STS credentials extracted from the access\\_token field of ConsoleTokenResponse. The access\\_token is a JSON-encoded string that must be parsed separately.\n\n```go\nfunc EnsureValidLoginToken(cfg *Configure, profileName string) (*STSCredentials, error)\n```\n\n```go\nfunc ParseSTSCredentials(accessToken string) (*STSCredentials, error)\n```\nParseSTSCredentials parses the JSON-encoded access\\_token string into an STSCredentials struct. The access\\_token field in ConsoleTokenResponse is not a simple bearer token; it is a JSON string containing STS temporary credentials.\n\n```go\ntype SdkClient struct {\n\tConfig      *volcengine.Config\n\tSession     *session.Session\n\tDebugLogger *DebugLogger\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewSimpleClient(ctx *Context) (*SdkClient, error)\n```\nNewSimpleClient creates an SDK client with credential resolution:\n\n 1. If a profile is configured: a. SSO mode: CLI refreshes STS credentials (EnsureValidStsToken), then delegates to SDK CliProvider. b. Console Login mode: CLI refreshes the login cache, then delegates to SDK CliProvider. c. Other modes: directly delegates to SDK CliProvider for credential resolution.\n 2. If no profile is configured, use the SDK default credential chain (Env → OIDC → CliProvider → EcsRole).\n\n```go\nfunc (s *SdkClient) CallSdk(info SdkClientInfo, input interface{}) (output *map[string]interface{}, err error)\n```\n\n```go\nfunc (s *SdkClient) CallSdkWithContext(ctx context.Context, info SdkClientInfo, input interface{}) (output *map[string]interface{}, err error)\n```\n\n```go\ntype SdkClientInfo struct {\n\tServiceName string\n\tAction      string\n\tVersion     string\n\tMethod      string\n\tContentType string\n\t// Headers are custom HTTP headers from --header Name=Value. Content-Type is\n\t// also carried in ContentType so protocol selection can happen before build.\n\tHeaders []requestHeader\n}\n```\n\n```go\ntype ServiceDescription struct {\n\tServiceCn string `json:\"service_cn,omitempty\"`\n\tServiceEn string `json:\"service_en,omitempty\"`\n}\n```\n\n```go\ntype Sso struct {\n\tProfile        *Profile\n\tSsoSessionName string\n\tStartURL       string\n\tRegion         string\n\tUseDeviceCode  bool\n\tNoBrowser      bool\n\tScopes         []string\n}\n```\nSso 持有 SSO 运行时所需的配置与状态。\n\n```go\nfunc (s *Sso) EnsureValidStsToken(ctx *Context) error\n```\nEnsureValidStsToken 确保 SSO 模式下的 STS Token 有效（过期或缺失则刷新）。\n\n```go\nfunc (s *Sso) GetAccessToken() (string, error)\n```\nGetAccessToken 从缓存获取有效的 access token。\n\n```go\nfunc (s *Sso) GetRoleCredentials() (*RoleCredentials, error)\n```\nGetRoleCredentials 获取当前 profile 对应角色的临时凭证。\n\n```go\nfunc (s *Sso) GetValidAccessToken() (string, error)\n```\nGetValidAccessToken 获取业务命令可用的 access token。 access token 未进入刷新窗口时直接复用；过期或即将过期时仅尝试 refresh\\_token 静默续期。\n\n```go\nfunc (s *Sso) Login() error\n```\nLogin 执行 SSO 登录并写入缓存。\n\n```go\nfunc (s *Sso) Logout() error\n```\nLogout 撤销缓存 token 并清理本地凭据。\n\n```go\nfunc (s *Sso) SetProfile() error\n```\nSetProfile 通过 SSO 登录并写入配置文件。\n\n```go\ntype SsoSession struct {\n\tName               string   `json:\"name\"`\n\tStartURL           string   `json:\"start-url\"`\n\tRegion             string   `json:\"region\"`\n\tRegistrationScopes []string `json:\"registration-scopes,omitempty\"`\n}\n```\n\n```go\ntype SsoTokenCache struct {\n\tStartURL              string `json:\"start_url\"`\n\tSessionName           string `json:\"session_name\"`\n\tAccessToken           string `json:\"access_token\"`\n\tExpiresAt             string `json:\"expires_at\"`\n\tClientId              string `json:\"client_id\"`\n\tClientSecret          string `json:\"client_secret\"`\n\tClientIdIssuedAt      int64  `json:\"client_id_issued_at,omitempty\"`\n\tClientSecretExpiresAt int64  `json:\"client_secret_expires_at,omitempty\"`\n\tRefreshToken          string `json:\"refresh_token,omitempty\"`\n\tRegion                string `json:\"region\"`\n}\n```\nSsoTokenCache 保存 SSO 访问令牌及客户端凭据的缓存结构。\n\n```go\ntype StartDeviceAuthorizationRequest struct {\n\tClientID     string   `json:\"client_id\"`\n\tClientSecret string   `json:\"client_secret\"`\n\tScopes       []string `json:\"scopes,omitempty\"`\n\tPortalUrl    string   `json:\"portal_url,omitempty\"`\n}\n```\nStartDeviceAuthorizationRequest 为设备码授权的请求参数。\n\n```go\ntype StartDeviceAuthorizationResponse struct {\n\tDeviceCode              string `json:\"device_code\"`\n\tUserCode                string `json:\"user_code\"`\n\tVerificationURI         string `json:\"verification_uri\"`\n\tVerificationURIComplete string `json:\"verification_uri_complete\"`\n\tExpiresIn               int    `json:\"expires_in\"`\n\tInterval                int    `json:\"interval,omitempty\"`\n}\n```\nStartDeviceAuthorizationResponse 表示设备码授权成功后的返回结构。\n\n```go\ntype StructInfo struct {\n\tPkgName     string\n\tServiceName string\n\tVersion     string\n}\n```\n\n```go\ntype VolcengineMeta struct {\n\tApiInfo  *ApiInfo\n\tRequest  *MetaInfo\n\tResponse *MetaInfo\n}\n```\n\n```go\nfunc (meta *VolcengineMeta) GetRequestParams(apiMeta *ApiMeta) (params []param)\n```\n\n","path":"github.com/volcengine/volcengine-cli/cmd","name":"cmd","synopsis":"","isRedistributable":true}
