diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 76d5fe88..ec74abd5 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -51,7 +51,7 @@ jobs: - name: 🔨 Integration Tests against Internal Server if: ${{ inputs.use-internal-image }} - run: dotnet test ${{ env.Solution }} --filter "Category=Integration" --configuration Release --no-build --no-restore --verbosity=normal /p:AltCover=true /p:AltCoverAttributeFilter=ExcludeFromCodeCoverage + run: dotnet test ${{ env.Solution }} --filter "(Category=Integration)&(Server!=Public)" --configuration Release --no-build --no-restore --verbosity=normal /p:AltCover=true /p:AltCoverAttributeFilter=ExcludeFromCodeCoverage - name: Upload coverage reports to Codecov with GitHub Action uses: codecov/codecov-action@v5 diff --git a/src/Speckle.Sdk/Api/GraphQL/Resources/ModelIngestionResource.cs b/src/Speckle.Sdk/Api/GraphQL/Resources/ModelIngestionResource.cs index 4b66ea14..d029a61d 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Resources/ModelIngestionResource.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Resources/ModelIngestionResource.cs @@ -6,7 +6,7 @@ using Speckle.Sdk.Api.GraphQL.Models.Responses; namespace Speckle.Sdk.Api.GraphQL.Resources; /// -/// Model Ingestion API is available for server versions 3.0.3-alpha.583 and above +/// Model Ingestion API is available for server versions 3.0.3 and above /// public sealed class ModelIngestionResource { @@ -23,7 +23,7 @@ public sealed class ModelIngestionResource /// /// The model ingestion created will have a processing state (not queued). This mutation is designed to be used /// by client/connectors that are immediately processing - /// Model Ingestion API is available for server versions 3.0.3-alpha.583 and above + /// Model Ingestion API is available for server versions 3.0.3 and above /// /// /// @@ -72,7 +72,7 @@ public sealed class ModelIngestionResource } /// - /// Model Ingestion API is available for server versions 3.0.3-alpha.583 and above + /// Model Ingestion API is available for server versions 3.0.3 and above /// /// /// @@ -121,7 +121,7 @@ public sealed class ModelIngestionResource /// For File Import / Cloud integrations only /// /// - /// Model Ingestion API is available for server versions 3.0.3-alpha.583 and above + /// Model Ingestion API is available for server versions 3.0.3 and above /// /// /// @@ -173,7 +173,7 @@ public sealed class ModelIngestionResource /// For File Import / Cloud integrations only /// /// - /// Model Ingestion API is available for server versions 3.0.3-alpha.583 and above + /// Model Ingestion API is available for server versions 3.0.3 and above /// /// /// @@ -222,7 +222,7 @@ public sealed class ModelIngestionResource } /// - /// Model Ingestion API is available for server versions 3.0.3-alpha.583 and above + /// Model Ingestion API is available for server versions 3.0.3 and above /// /// /// @@ -277,7 +277,7 @@ public sealed class ModelIngestionResource /// If successful, the job will be in a terminal "successful" state. /// /// - /// Model Ingestion API is available for server versions 3.0.3-alpha.583 and above + /// Model Ingestion API is available for server versions 3.0.3 and above /// /// /// @@ -320,7 +320,7 @@ public sealed class ModelIngestionResource /// /// /// For requested user cancellation, use instead
- /// Model Ingestion API is available for server versions 3.0.3-alpha.583 and above + /// Model Ingestion API is available for server versions 3.0.3 and above ///
/// /// @@ -375,7 +375,7 @@ public sealed class ModelIngestionResource /// This should only be done if the user has explicitly requested cancellation /// Other forms of cancellation use . /// The ingestion should then enter a terminal "canceled" state.
- /// Model Ingestion API is available for server versions 3.0.3-alpha.583 and above + /// Model Ingestion API is available for server versions 3.0.3 and above /// /// /// @@ -434,7 +434,7 @@ public sealed class ModelIngestionResource /// via /// and report it as canceled via /// See "cooperative cancellation pattern"
- /// Model Ingestion API is available for server versions 3.0.3-alpha.583 and above + /// Model Ingestion API is available for server versions 3.0.3 and above /// /// /// diff --git a/src/Speckle.Sdk/Api/GraphQL/Resources/ModelResource.cs b/src/Speckle.Sdk/Api/GraphQL/Resources/ModelResource.cs index 6e0af0b9..71a92d48 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Resources/ModelResource.cs +++ b/src/Speckle.Sdk/Api/GraphQL/Resources/ModelResource.cs @@ -359,4 +359,41 @@ public sealed class ModelResource .ConfigureAwait(false); return response.data.data.data; } + + /// + /// + /// + /// server versions <3.0.11 do not have canCreateIngestion and will throw this exception + /// + public async Task CanCreateModelIngestion( + string projectId, + string modelId, + CancellationToken cancellationToken = default + ) + { + //language=graphql + const string QUERY = """ + query ModelPermissions($projectId: String!, $modelId: String!) { + data:project(id: $projectId) { + data:model(id: $modelId) { + data:permissions { + data:canCreateIngestion { + authorized + code + message + } + } + } + } + } + """; + GraphQLRequest request = new() { Query = QUERY, Variables = new { projectId, modelId } }; + + var response = await _client + .ExecuteGraphQLRequest< + RequiredResponse>>> + >(request, cancellationToken) + .ConfigureAwait(false); + return response.data.data.data.data; + } } diff --git a/src/Speckle.Sdk/Api/GraphQL/Resources/graphql.config.yml b/src/Speckle.Sdk/Api/GraphQL/Resources/graphql.config.yml index 64c50ab2..57740f5e 100644 --- a/src/Speckle.Sdk/Api/GraphQL/Resources/graphql.config.yml +++ b/src/Speckle.Sdk/Api/GraphQL/Resources/graphql.config.yml @@ -1,2 +1,2 @@ -schema: https://app.speckle.systems/graphql +schema: https://latest.speckle.systems/graphql documents: '**/*.graphql' diff --git a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ModelResourceTests.cs b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ModelResourceTests.cs index b38436a3..3eeae350 100644 --- a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ModelResourceTests.cs +++ b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ModelResourceTests.cs @@ -141,4 +141,23 @@ public class ModelResourceTests : IAsyncLifetime guestResult.canCreateVersion.authorized.Should().Be(false); guestResult.canDelete.authorized.Should().Be(false); } + + [Fact] + [Trait("Server", "Internal")] + public async Task TestCanCreateModelIngestion_InternalServer() + { + var ownerResult = await Sut.CanCreateModelIngestion(_project.id, _model.id); + ownerResult.authorized.Should().Be(true); + } + + [Fact] + [Trait("Server", "Public")] + public async Task TestCanCreateModelIngestion_PublicServer_Throws() + { + var ex = await Assert.ThrowsAsync(async () => + await Sut.CanCreateModelIngestion(_project.id, _model.id) + ); + ex.InnerExceptions.Should().HaveCount(1); + ex.InnerExceptions.Should().AllBeOfType(); + } }