Compare commits
4 Commits
3.3.0-dev.1
...
3.3.3
| Author | SHA1 | Date | |
|---|---|---|---|
| 7f092d529c | |||
| a4f0e0e4aa | |||
| 227729a0df | |||
| 178085f3f8 |
@@ -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; }
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,4 +4,6 @@ public sealed class ProjectPermissionChecks
|
|||||||
{
|
{
|
||||||
public PermissionCheckResult canCreateModel { get; init; }
|
public PermissionCheckResult canCreateModel { get; init; }
|
||||||
public PermissionCheckResult canDelete { get; init; }
|
public PermissionCheckResult canDelete { get; init; }
|
||||||
|
public PermissionCheckResult canLoad { get; init; }
|
||||||
|
public PermissionCheckResult canPublish { get; init; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ public sealed class Workspace
|
|||||||
public string role { get; init; }
|
public string role { get; init; }
|
||||||
public string slug { get; init; }
|
public string slug { get; init; }
|
||||||
public string? description { get; init; }
|
public string? description { get; init; }
|
||||||
|
public string? logo { get; init; }
|
||||||
|
public DateTime? createdAt { get; init; }
|
||||||
|
public DateTime? updatedAt { get; init; }
|
||||||
|
public bool? readOnly { get; init; }
|
||||||
public WorkspacePermissionChecks permissions { get; init; }
|
public WorkspacePermissionChecks permissions { get; init; }
|
||||||
public WorkspaceCreationState? creationState { get; init; }
|
public WorkspaceCreationState? creationState { 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,6 +71,16 @@ public sealed class ProjectResource
|
|||||||
code
|
code
|
||||||
message
|
message
|
||||||
}
|
}
|
||||||
|
canLoad {
|
||||||
|
authorized
|
||||||
|
code
|
||||||
|
message
|
||||||
|
}
|
||||||
|
canPublish {
|
||||||
|
authorized
|
||||||
|
code
|
||||||
|
message
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,10 +50,10 @@ public sealed class WorkspaceResource
|
|||||||
var request = new GraphQLRequest { Query = QUERY, Variables = new { workspaceId } };
|
var request = new GraphQLRequest { Query = QUERY, Variables = new { workspaceId } };
|
||||||
|
|
||||||
var response = await _client
|
var response = await _client
|
||||||
.ExecuteGraphQLRequest<RequiredResponse<RequiredResponse<Workspace>>>(request, cancellationToken)
|
.ExecuteGraphQLRequest<RequiredResponse<Workspace>>(request, cancellationToken)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
return response.data.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <param name="workspaceId"></param>
|
/// <param name="workspaceId"></param>
|
||||||
|
|||||||
@@ -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