Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c517dead03 | |||
| 2b61ab7d2e | |||
| 4b319499c3 | |||
| d4055c6ff1 |
@@ -1,3 +1,5 @@
|
||||
using Speckle.Newtonsoft.Json;
|
||||
|
||||
namespace Speckle.Sdk.Api.GraphQL.Models;
|
||||
|
||||
public class LimitedWorkspace
|
||||
@@ -6,8 +8,12 @@ public class LimitedWorkspace
|
||||
public string name { get; init; }
|
||||
public string? role { get; init; }
|
||||
public string slug { get; init; }
|
||||
public string? logo { get; init; }
|
||||
public string? logoUri { get; init; }
|
||||
public string? description { get; init; }
|
||||
|
||||
[JsonIgnore]
|
||||
[Obsolete($"Deprecated, use {nameof(logoUri)} instead", true)]
|
||||
public string? logo { get; init; }
|
||||
}
|
||||
|
||||
public class Workspace : LimitedWorkspace
|
||||
@@ -16,9 +22,13 @@ public class Workspace : LimitedWorkspace
|
||||
public DateTime updatedAt { get; init; }
|
||||
public bool readOnly { get; init; }
|
||||
public WorkspacePermissionChecks permissions { get; init; }
|
||||
|
||||
[JsonIgnore]
|
||||
[Obsolete("Workspaces no longer have creation state, is always created true", true)]
|
||||
public WorkspaceCreationState? creationState { get; init; }
|
||||
}
|
||||
|
||||
[Obsolete("Workspaces no longer have creation state, is always created true")]
|
||||
public sealed class WorkspaceCreationState
|
||||
{
|
||||
public bool completed { get; init; }
|
||||
|
||||
@@ -264,15 +264,11 @@ public sealed class ActiveUserResource
|
||||
name
|
||||
role
|
||||
slug
|
||||
logo
|
||||
logoUrl
|
||||
createdAt
|
||||
updatedAt
|
||||
readOnly
|
||||
description
|
||||
creationState
|
||||
{
|
||||
completed
|
||||
}
|
||||
permissions {
|
||||
canCreateProject {
|
||||
authorized
|
||||
@@ -317,7 +313,7 @@ public sealed class ActiveUserResource
|
||||
/// <remarks>note this returns a <see cref="LimitedWorkspace"/>, because it may be a workspace the user is not a member of</remarks>
|
||||
/// <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<LimitedWorkspace?> GetActiveWorkspace(CancellationToken cancellationToken = default)
|
||||
private async Task<LimitedWorkspace?> GetActiveWorkspace_Legacy(CancellationToken cancellationToken = default)
|
||||
{
|
||||
//language=graphql
|
||||
const string QUERY = """
|
||||
@@ -328,7 +324,6 @@ public sealed class ActiveUserResource
|
||||
name
|
||||
role
|
||||
slug
|
||||
logo
|
||||
description
|
||||
}
|
||||
}
|
||||
@@ -349,6 +344,47 @@ public sealed class ActiveUserResource
|
||||
return response.data.data;
|
||||
}
|
||||
|
||||
public async Task<LimitedWorkspace?> GetActiveWorkspace(CancellationToken cancellationToken = default)
|
||||
{
|
||||
//language=graphql
|
||||
const string QUERY = """
|
||||
query ActiveUser {
|
||||
data:activeUser {
|
||||
data:activeWorkspace {
|
||||
id
|
||||
name
|
||||
role
|
||||
slug
|
||||
logoUrl
|
||||
description
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
var request = new GraphQLRequest { Query = QUERY };
|
||||
|
||||
NullableResponse<NullableResponse<LimitedWorkspace?>?> response;
|
||||
try
|
||||
{
|
||||
response = await _client
|
||||
.ExecuteGraphQLRequest<NullableResponse<NullableResponse<LimitedWorkspace?>?>>(request, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
catch (SpeckleGraphQLInvalidQueryException)
|
||||
{
|
||||
//v2.x.x servers do not have a logoUrl property
|
||||
return await GetActiveWorkspace_Legacy(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;
|
||||
}
|
||||
|
||||
/// <param name="limit">Max number of projects to fetch</param>
|
||||
/// <param name="cursor">Optional cursor for pagination</param>
|
||||
/// <param name="filter">Optional filter</param>
|
||||
|
||||
@@ -52,7 +52,6 @@ public sealed class OtherUserResource
|
||||
/// <param name="query">String to search for. Must be at least 3 characters</param>
|
||||
/// <param name="limit">Max number of users to fetch</param>
|
||||
/// <param name="cursor">Optional cursor for pagination</param>
|
||||
/// <param name="archived"></param>
|
||||
/// <param name="emailOnly"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
@@ -61,26 +60,25 @@ public sealed class OtherUserResource
|
||||
string query,
|
||||
int limit = ServerLimits.DEFAULT_PAGINATION_REQUEST,
|
||||
string? cursor = null,
|
||||
bool archived = false,
|
||||
bool emailOnly = false,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//language=graphql
|
||||
const string QUERY = """
|
||||
query UserSearch($query: String!, $limit: Int!, $cursor: String, $archived: Boolean, $emailOnly: Boolean) {
|
||||
data:userSearch(query: $query, limit: $limit, cursor: $cursor, archived: $archived, emailOnly: $emailOnly) {
|
||||
query Users($input: UsersRetrievalInput!) {
|
||||
data:users(input: $input) {
|
||||
cursor
|
||||
items {
|
||||
id
|
||||
name
|
||||
bio
|
||||
company
|
||||
avatar
|
||||
verified
|
||||
role
|
||||
}
|
||||
}
|
||||
id
|
||||
name
|
||||
bio
|
||||
company
|
||||
avatar
|
||||
verified
|
||||
role
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
@@ -89,11 +87,13 @@ public sealed class OtherUserResource
|
||||
Query = QUERY,
|
||||
Variables = new
|
||||
{
|
||||
query,
|
||||
limit,
|
||||
cursor,
|
||||
archived,
|
||||
emailOnly,
|
||||
input = new
|
||||
{
|
||||
query,
|
||||
limit,
|
||||
emailOnly,
|
||||
cursor,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ public sealed class SubscriptionResource : IDisposable
|
||||
/// <summary>Subscribe to updates to resource comments/threads. Optionally specify resource ID string to only receive updates regarding comments for those resources</summary>
|
||||
/// <remarks><inheritdoc cref="CreateUserProjectsUpdatedSubscription"/></remarks>
|
||||
/// <inheritdoc cref="ISpeckleGraphQLClient.SubscribeTo{T}"/>
|
||||
[Obsolete("Comments are now issues, and we've not update SDKs with the new subs")]
|
||||
public Subscription<ProjectCommentsUpdatedMessage> CreateProjectCommentsUpdatedSubscription(
|
||||
ViewerUpdateTrackingTarget target
|
||||
)
|
||||
|
||||
@@ -28,15 +28,11 @@ public sealed class WorkspaceResource
|
||||
name
|
||||
role
|
||||
slug
|
||||
logo
|
||||
logoUrl
|
||||
createdAt
|
||||
updatedAt
|
||||
readOnly
|
||||
description
|
||||
creationState
|
||||
{
|
||||
completed
|
||||
}
|
||||
permissions {
|
||||
canCreateProject {
|
||||
authorized
|
||||
|
||||
@@ -21,7 +21,7 @@ public class WorkspaceResourceTests
|
||||
return testUser;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Fact, Trait("Server", "Internal")]
|
||||
public async Task TestGetWorkspace()
|
||||
{
|
||||
var ex = await Assert.ThrowsAsync<AggregateException>(async () => _ = await Sut.Get("non-existent-id"));
|
||||
|
||||
Reference in New Issue
Block a user