AS AgentScopeAPI 手册 / API Reference

ResourceAccessService

@Service public class ResourceAccessService
源码Source io/agentscope/builder/web/share/ResourceAccessService.java:38–193

资源访问服务,承载智能体的部署、调度与服务化运行。位于 io.agentscope.builder.web.share 包。核心成员包括 tierFor、can、require、listShares、share、unshare。

Generic owner-or-shared access control for non-agent managed resources (environments, memory stores, vaults). Reuses AgentAclService.Tier so all ACL decisions in the app share the same three-tier vocabulary (CLONE < RUN < EDIT), but keeps grants in a single resource-type-keyed table (ResourceShareEntity) instead of one table per resource kind.

Rule: the resource owner always holds EDIT; any grant matching the caller (direct USER grant or a WORKSPACE grant applying to every logged-in user) contributes its tier, and the highest applicable tier wins.

构造器摘要Constructor Summary

构造器Constructor说明Description
public ResourceAccessService(ResourceShareEntityRepository repository)
初始化 `ResourceAccessService` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public Tier tierFor(String userId, String ownerId, String resourceType, String resourceId)
执行 `tierFor` 方法。
Returns the highest tier `userId` holds on the resource, or `null` if none.
public boolean can(String userId, String ownerId, String resourceType, String resourceId, Tier required)
执行可以相关操作。
`true` iff `userId` holds at least `required` on the resource.
public void require(String userId, String ownerId, String resourceType, String resourceId, Tier required)
执行 `require` 方法。
Verifies `userId` holds at least `required` on the resource.
public List<ResourceShareDto> listShares(String resourceType, String resourceId)
列出 `listShares`。
Lists share grants on a resource.
public ResourceShareDto share(String resourceType, String resourceId, String ownerId, String granteeType, String granteeId, Tier tier, String createdBy)
执行 `share` 方法。
Creates or updates a grant on `(resourceType, resourceId)` for the given grantee.
public void unshare(String resourceType, String resourceId, String shareId)
执行 `unshare` 方法。
Removes a share grant.

构造器详情Constructor Detail

ResourceAccessService

public ResourceAccessService(ResourceShareEntityRepository repository)

初始化 ResourceAccessService 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
repositoryResourceShareEntityRepository仓库(类型 `ResourceShareEntityRepository`)。The repository.
源码Source io/agentscope/builder/web/share/ResourceAccessService.java:43–45

方法详情Method Detail

tierFor

public Tier tierFor(String userId, String ownerId, String resourceType, String resourceId)

执行 tierFor 方法。

Returns the highest tier userId holds on the resource, or null if none.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
ownerIdString所有者标识(类型 `String`)。The owner id.
resourceTypeString资源类型(类型 `String`)。The resource type.
resourceIdString资源标识(类型 `String`)。The resource id.
返回Returns Tier
返回Tier。Returns tier.
源码Source io/agentscope/builder/web/share/ResourceAccessService.java:48–54

can

public boolean can(String userId, String ownerId, String resourceType, String resourceId, Tier required)

执行可以相关操作。

true iff userId holds at least required on the resource.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
ownerIdString所有者标识(类型 `String`)。The owner id.
resourceTypeString资源类型(类型 `String`)。The resource type.
resourceIdString资源标识(类型 `String`)。The resource id.
requiredTier必填(类型 `Tier`)。The required.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/builder/web/share/ResourceAccessService.java:57–61

require

public void require(String userId, String ownerId, String resourceType, String resourceId, Tier required)

执行 require 方法。

Verifies userId holds at least required on the resource.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
ownerIdString所有者标识(类型 `String`)。The owner id.
resourceTypeString资源类型(类型 `String`)。The resource type.
resourceIdString资源标识(类型 `String`)。The resource id.
requiredTier必填(类型 `Tier`)。The required.
抛出Throws
  • ResponseStatusException 可能抛出 `ResponseStatusException`。403 if the tier is insufficient
源码Source io/agentscope/builder/web/share/ResourceAccessService.java:68–75

listShares

public List<ResourceShareDto> listShares(String resourceType, String resourceId)

列出 listShares。

Lists share grants on a resource.

参数Parameters
名称Name类型Type说明Description
resourceTypeString资源类型(类型 `String`)。The resource type.
resourceIdString资源标识(类型 `String`)。The resource id.
返回Returns List<ResourceShareDto>
返回列出。Returns list.
源码Source io/agentscope/builder/web/share/ResourceAccessService.java:78–82

share

public ResourceShareDto share(String resourceType, String resourceId, String ownerId, String granteeType, String granteeId, Tier tier, String createdBy)

执行 share 方法。

Creates or updates a grant on (resourceType, resourceId) for the given grantee.

参数Parameters
名称Name类型Type说明Description
resourceTypeString资源类型(类型 `String`)。The resource type.
resourceIdString资源标识(类型 `String`)。The resource id.
ownerIdString所有者标识(类型 `String`)。The owner id.
granteeTypeStringgrantee 类型(类型 `String`)。The grantee type.
granteeIdStringgrantee 标识(类型 `String`)。The grantee id.
tierTiertier(类型 `Tier`)。The tier.
createdByString已创建通过(类型 `String`)。The created by.
返回Returns ResourceShareDto
返回ResourceShareDto。Returns resource share dto.
源码Source io/agentscope/builder/web/share/ResourceAccessService.java:88–116

unshare

public void unshare(String resourceType, String resourceId, String shareId)

执行 unshare 方法。

Removes a share grant.

参数Parameters
名称Name类型Type说明Description
resourceTypeString资源类型(类型 `String`)。The resource type.
resourceIdString资源标识(类型 `String`)。The resource id.
shareIdStringshare 标识(类型 `String`)。The share id.
源码Source io/agentscope/builder/web/share/ResourceAccessService.java:119–127
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.