MCPcopy
hub / github.com/larksuite/cli / resolveDeclaredServiceMethodScopes

Function resolveDeclaredServiceMethodScopes

cmd/error_auth_hint.go:101–114  ·  view source on GitHub ↗

resolveDeclaredServiceMethodScopes returns the scopes declared by a service/resource/method command. It reconstructs the catalog path from the command ancestry and resolves it through the same navigation Module the command tree is built from (apicatalog), so it stays correct for nested resources ins

(cmd *cobra.Command, identity string)

Source from the content-addressed store, hash-verified

99// Non-method commands (services, resources, shortcuts) resolve to a non-method
100// target and yield no scopes.
101func resolveDeclaredServiceMethodScopes(cmd *cobra.Command, identity string) []string {
102 if cmd == nil || strings.HasPrefix(cmd.Name(), "+") {
103 return nil
104 }
105 path := commandCatalogPath(cmd)
106 if len(path) == 0 {
107 return nil
108 }
109 target, err := registry.RuntimeCatalog().Resolve(path)
110 if err != nil || target.Kind != apicatalog.TargetMethod {
111 return nil
112 }
113 return registry.DeclaredScopesForMethod(target.Method.Method, identity)
114}
115
116// commandCatalogPath reconstructs the catalog path [service, resource..., method]
117// from a command's ancestry, excluding the root command. It is the inverse of

Calls 5

RuntimeCatalogFunction · 0.92
DeclaredScopesForMethodFunction · 0.92
commandCatalogPathFunction · 0.85
NameMethod · 0.65
ResolveMethod · 0.45

Tested by

no test coverage detected