Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7f092d529c |
@@ -26,3 +26,8 @@ public sealed class ProjectWithTeam : Project
|
|||||||
public List<PendingStreamCollaborator> invitedTeam { get; init; }
|
public List<PendingStreamCollaborator> invitedTeam { get; init; }
|
||||||
public List<ProjectCollaborator> team { get; init; }
|
public List<ProjectCollaborator> team { get; init; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public sealed class ProjectWithPermissions : Project
|
||||||
|
{
|
||||||
|
public ProjectPermissionChecks permissions { get; init; }
|
||||||
|
}
|
||||||
|
|||||||
@@ -361,4 +361,89 @@ public sealed class ActiveUserResource
|
|||||||
|
|
||||||
return response.data.data;
|
return response.data.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <param name="limit">Max number of projects to fetch</param>
|
||||||
|
/// <param name="cursor">Optional cursor for pagination</param>
|
||||||
|
/// <param name="filter">Optional filter</param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <inheritdoc cref="ISpeckleGraphQLClient.ExecuteGraphQLRequest{T}"/>
|
||||||
|
/// <exception cref="SpeckleException">The ActiveUser could not be found (e.g. the client is not authenticated)</exception>
|
||||||
|
public async Task<ResourceCollection<ProjectWithPermissions>> GetProjectsWithPermissions(
|
||||||
|
int limit = ServerLimits.DEFAULT_PAGINATION_REQUEST,
|
||||||
|
string? cursor = null,
|
||||||
|
UserProjectsFilter? filter = null,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//language=graphql
|
||||||
|
const string QUERY = """
|
||||||
|
query User($limit: Int!, $cursor: String, $filter: UserProjectsFilter) {
|
||||||
|
data: activeUser {
|
||||||
|
data: projects(limit: $limit, cursor: $cursor, filter: $filter) {
|
||||||
|
totalCount
|
||||||
|
cursor
|
||||||
|
items {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
description
|
||||||
|
visibility
|
||||||
|
allowPublicComments
|
||||||
|
role
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
sourceApps
|
||||||
|
workspaceId
|
||||||
|
permissions {
|
||||||
|
canCreateModel {
|
||||||
|
code
|
||||||
|
authorized
|
||||||
|
message
|
||||||
|
}
|
||||||
|
canDelete {
|
||||||
|
code
|
||||||
|
authorized
|
||||||
|
message
|
||||||
|
}
|
||||||
|
canLoad {
|
||||||
|
code
|
||||||
|
authorized
|
||||||
|
message
|
||||||
|
}
|
||||||
|
canPublish {
|
||||||
|
code
|
||||||
|
authorized
|
||||||
|
message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
""";
|
||||||
|
var request = new GraphQLRequest
|
||||||
|
{
|
||||||
|
Query = QUERY,
|
||||||
|
Variables = new
|
||||||
|
{
|
||||||
|
limit,
|
||||||
|
cursor,
|
||||||
|
filter,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
var response = await _client
|
||||||
|
.ExecuteGraphQLRequest<NullableResponse<RequiredResponse<ResourceCollection<ProjectWithPermissions>>?>>(
|
||||||
|
request,
|
||||||
|
cancellationToken
|
||||||
|
)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (response.data is null)
|
||||||
|
{
|
||||||
|
throw new SpeckleException("GraphQL response indicated that the ActiveUser could not be found");
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.data.data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,19 @@ public class ActiveUserResourceTests : IAsyncLifetime
|
|||||||
res.items.Count.Should().Be(2);
|
res.items.Count.Should().Be(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task ActiveUserGetProjectsWithPermissions()
|
||||||
|
{
|
||||||
|
var p1 = await _testUser.Project.Create(new("Project 3", null, null));
|
||||||
|
var p2 = await _testUser.Project.Create(new("Project 4", null, null));
|
||||||
|
|
||||||
|
var res = await Sut.GetProjectsWithPermissions();
|
||||||
|
|
||||||
|
res.items.Should().Contain(x => x.id == p1.id);
|
||||||
|
res.items.Should().Contain(x => x.id == p2.id);
|
||||||
|
res.items.Count.Should().Be(2);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task ActiveUserGetProjects_NoAuth()
|
public async Task ActiveUserGetProjects_NoAuth()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user