diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 1b5dc400..0a40b9d7 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.39.0" + ".": "0.40.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 16d8f91d..47035ac5 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 213 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/casemark/router-d877f8733c59535fe64ede3e403087094b7b62563cabd9f13b3cba08fc08a492.yml -openapi_spec_hash: 2f86e023964eb545ae8516a453e516e2 -config_hash: a31ba9c8a6ed0f2b6739f6522213040e +configured_endpoints: 211 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/casemark/router-866cc91e422dbe530e40757e8548c78340d886c61bd6ab5cef81a742a141db2d.yml +openapi_spec_hash: 3ba7c949a852fc2787cc75fcf81bc16e +config_hash: 2726ecf6661ab60be4ece0848a240344 diff --git a/CHANGELOG.md b/CHANGELOG.md index 104e05a5..5a6b4e37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.40.0 (2026-05-19) + +Full Changelog: [v0.39.0...v0.40.0](https://github.com/CaseMark/casedev-csharp/compare/v0.39.0...v0.40.0) + +### Features + +* **api:** api update ([bd22d11](https://github.com/CaseMark/casedev-csharp/commit/bd22d11fe19b2c05a7eaf46e8d04dc95c86d2c41)) + ## 0.39.0 (2026-05-15) Full Changelog: [v0.38.2...v0.39.0](https://github.com/CaseMark/casedev-csharp/compare/v0.38.2...v0.39.0) diff --git a/src/Casedev.Tests/Models/Agent/Skills/Namespaces/NamespaceCreateParamsTest.cs b/src/Casedev.Tests/Models/Agent/Skills/Namespaces/NamespaceCreateParamsTest.cs new file mode 100644 index 00000000..94bb364f --- /dev/null +++ b/src/Casedev.Tests/Models/Agent/Skills/Namespaces/NamespaceCreateParamsTest.cs @@ -0,0 +1,92 @@ +using System; +using System.Text.Json; +using Casedev.Models.Agent.Skills.Namespaces; + +namespace Casedev.Tests.Models.Agent.Skills.Namespaces; + +public class NamespaceCreateParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new NamespaceCreateParams + { + NamespaceID = "namespaceId", + Description = "description", + Label = "label", + Metadata = JsonSerializer.Deserialize("{}"), + }; + + string expectedNamespaceID = "namespaceId"; + string expectedDescription = "description"; + string expectedLabel = "label"; + JsonElement expectedMetadata = JsonSerializer.Deserialize("{}"); + + Assert.Equal(expectedNamespaceID, parameters.NamespaceID); + Assert.Equal(expectedDescription, parameters.Description); + Assert.Equal(expectedLabel, parameters.Label); + Assert.NotNull(parameters.Metadata); + Assert.True(JsonElement.DeepEquals(expectedMetadata, parameters.Metadata.Value)); + } + + [Fact] + public void OptionalNullableParamsUnsetAreNotSet_Works() + { + var parameters = new NamespaceCreateParams { NamespaceID = "namespaceId" }; + + Assert.Null(parameters.Description); + Assert.False(parameters.RawBodyData.ContainsKey("description")); + Assert.Null(parameters.Label); + Assert.False(parameters.RawBodyData.ContainsKey("label")); + Assert.Null(parameters.Metadata); + Assert.False(parameters.RawBodyData.ContainsKey("metadata")); + } + + [Fact] + public void OptionalNullableParamsSetToNullAreSetToNull_Works() + { + var parameters = new NamespaceCreateParams + { + NamespaceID = "namespaceId", + + Description = null, + Label = null, + Metadata = null, + }; + + Assert.Null(parameters.Description); + Assert.True(parameters.RawBodyData.ContainsKey("description")); + Assert.Null(parameters.Label); + Assert.True(parameters.RawBodyData.ContainsKey("label")); + Assert.Null(parameters.Metadata); + Assert.True(parameters.RawBodyData.ContainsKey("metadata")); + } + + [Fact] + public void Url_Works() + { + NamespaceCreateParams parameters = new() { NamespaceID = "namespaceId" }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.True( + TestBase.UrisEqual(new Uri("https://api.case.dev/agent/skills/namespaces"), url) + ); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new NamespaceCreateParams + { + NamespaceID = "namespaceId", + Description = "description", + Label = "label", + Metadata = JsonSerializer.Deserialize("{}"), + }; + + NamespaceCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/Casedev.Tests/Models/Agent/Skills/Namespaces/NamespaceDeleteParamsTest.cs b/src/Casedev.Tests/Models/Agent/Skills/Namespaces/NamespaceDeleteParamsTest.cs new file mode 100644 index 00000000..f4298f75 --- /dev/null +++ b/src/Casedev.Tests/Models/Agent/Skills/Namespaces/NamespaceDeleteParamsTest.cs @@ -0,0 +1,39 @@ +using System; +using Casedev.Models.Agent.Skills.Namespaces; + +namespace Casedev.Tests.Models.Agent.Skills.Namespaces; + +public class NamespaceDeleteParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new NamespaceDeleteParams { ID = "id" }; + + string expectedID = "id"; + + Assert.Equal(expectedID, parameters.ID); + } + + [Fact] + public void Url_Works() + { + NamespaceDeleteParams parameters = new() { ID = "id" }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.True( + TestBase.UrisEqual(new Uri("https://api.case.dev/agent/skills/namespaces/id"), url) + ); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new NamespaceDeleteParams { ID = "id" }; + + NamespaceDeleteParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/Casedev.Tests/Models/Agent/Skills/Namespaces/NamespaceListParamsTest.cs b/src/Casedev.Tests/Models/Agent/Skills/Namespaces/NamespaceListParamsTest.cs new file mode 100644 index 00000000..3268ecfd --- /dev/null +++ b/src/Casedev.Tests/Models/Agent/Skills/Namespaces/NamespaceListParamsTest.cs @@ -0,0 +1 @@ +namespace Casedev.Tests.Models.Agent.Skills.Namespaces; diff --git a/src/Casedev.Tests/Models/Agent/Skills/Namespaces/NamespacePublishParamsTest.cs b/src/Casedev.Tests/Models/Agent/Skills/Namespaces/NamespacePublishParamsTest.cs new file mode 100644 index 00000000..3ddf4e27 --- /dev/null +++ b/src/Casedev.Tests/Models/Agent/Skills/Namespaces/NamespacePublishParamsTest.cs @@ -0,0 +1,314 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using Casedev.Core; +using Casedev.Exceptions; +using Casedev.Models.Agent.Skills.Namespaces; + +namespace Casedev.Tests.Models.Agent.Skills.Namespaces; + +public class NamespacePublishParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new NamespacePublishParams + { + ID = "id", + Files = + [ + new() + { + Content = "content", + Encoding = Encoding.Utf8, + Path = "path", + ContentType = "contentType", + }, + ], + }; + + string expectedID = "id"; + List expectedFiles = + [ + new() + { + Content = "content", + Encoding = Encoding.Utf8, + Path = "path", + ContentType = "contentType", + }, + ]; + + Assert.Equal(expectedID, parameters.ID); + Assert.Equal(expectedFiles.Count, parameters.Files.Count); + for (int i = 0; i < expectedFiles.Count; i++) + { + Assert.Equal(expectedFiles[i], parameters.Files[i]); + } + } + + [Fact] + public void Url_Works() + { + NamespacePublishParams parameters = new() + { + ID = "id", + Files = + [ + new() + { + Content = "content", + Encoding = Encoding.Utf8, + Path = "path", + ContentType = "contentType", + }, + ], + }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.case.dev/agent/skills/namespaces/id/publish"), + url + ) + ); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new NamespacePublishParams + { + ID = "id", + Files = + [ + new() + { + Content = "content", + Encoding = Encoding.Utf8, + Path = "path", + ContentType = "contentType", + }, + ], + }; + + NamespacePublishParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} + +public class FileTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new File + { + Content = "content", + Encoding = Encoding.Utf8, + Path = "path", + ContentType = "contentType", + }; + + string expectedContent = "content"; + ApiEnum expectedEncoding = Encoding.Utf8; + string expectedPath = "path"; + string expectedContentType = "contentType"; + + Assert.Equal(expectedContent, model.Content); + Assert.Equal(expectedEncoding, model.Encoding); + Assert.Equal(expectedPath, model.Path); + Assert.Equal(expectedContentType, model.ContentType); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new File + { + Content = "content", + Encoding = Encoding.Utf8, + Path = "path", + ContentType = "contentType", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new File + { + Content = "content", + Encoding = Encoding.Utf8, + Path = "path", + ContentType = "contentType", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + Assert.NotNull(deserialized); + + string expectedContent = "content"; + ApiEnum expectedEncoding = Encoding.Utf8; + string expectedPath = "path"; + string expectedContentType = "contentType"; + + Assert.Equal(expectedContent, deserialized.Content); + Assert.Equal(expectedEncoding, deserialized.Encoding); + Assert.Equal(expectedPath, deserialized.Path); + Assert.Equal(expectedContentType, deserialized.ContentType); + } + + [Fact] + public void Validation_Works() + { + var model = new File + { + Content = "content", + Encoding = Encoding.Utf8, + Path = "path", + ContentType = "contentType", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new File + { + Content = "content", + Encoding = Encoding.Utf8, + Path = "path", + }; + + Assert.Null(model.ContentType); + Assert.False(model.RawData.ContainsKey("contentType")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new File + { + Content = "content", + Encoding = Encoding.Utf8, + Path = "path", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new File + { + Content = "content", + Encoding = Encoding.Utf8, + Path = "path", + + ContentType = null, + }; + + Assert.Null(model.ContentType); + Assert.True(model.RawData.ContainsKey("contentType")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new File + { + Content = "content", + Encoding = Encoding.Utf8, + Path = "path", + + ContentType = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new File + { + Content = "content", + Encoding = Encoding.Utf8, + Path = "path", + ContentType = "contentType", + }; + + File copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class EncodingTest : TestBase +{ + [Theory] + [InlineData(Encoding.Utf8)] + [InlineData(Encoding.Base64)] + public void Validation_Works(Encoding rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Encoding.Utf8)] + [InlineData(Encoding.Base64)] + public void SerializationRoundtrip_Works(Encoding rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} diff --git a/src/Casedev.Tests/Models/Agent/Skills/Namespaces/NamespacePullParamsTest.cs b/src/Casedev.Tests/Models/Agent/Skills/Namespaces/NamespacePullParamsTest.cs new file mode 100644 index 00000000..1f0d6ab9 --- /dev/null +++ b/src/Casedev.Tests/Models/Agent/Skills/Namespaces/NamespacePullParamsTest.cs @@ -0,0 +1,39 @@ +using System; +using Casedev.Models.Agent.Skills.Namespaces; + +namespace Casedev.Tests.Models.Agent.Skills.Namespaces; + +public class NamespacePullParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new NamespacePullParams { ID = "id" }; + + string expectedID = "id"; + + Assert.Equal(expectedID, parameters.ID); + } + + [Fact] + public void Url_Works() + { + NamespacePullParams parameters = new() { ID = "id" }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.True( + TestBase.UrisEqual(new Uri("https://api.case.dev/agent/skills/namespaces/id/pull"), url) + ); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new NamespacePullParams { ID = "id" }; + + NamespacePullParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/Casedev.Tests/Models/Agent/Skills/Namespaces/NamespaceRetrieveParamsTest.cs b/src/Casedev.Tests/Models/Agent/Skills/Namespaces/NamespaceRetrieveParamsTest.cs new file mode 100644 index 00000000..61d48406 --- /dev/null +++ b/src/Casedev.Tests/Models/Agent/Skills/Namespaces/NamespaceRetrieveParamsTest.cs @@ -0,0 +1,39 @@ +using System; +using Casedev.Models.Agent.Skills.Namespaces; + +namespace Casedev.Tests.Models.Agent.Skills.Namespaces; + +public class NamespaceRetrieveParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new NamespaceRetrieveParams { ID = "id" }; + + string expectedID = "id"; + + Assert.Equal(expectedID, parameters.ID); + } + + [Fact] + public void Url_Works() + { + NamespaceRetrieveParams parameters = new() { ID = "id" }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.True( + TestBase.UrisEqual(new Uri("https://api.case.dev/agent/skills/namespaces/id"), url) + ); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new NamespaceRetrieveParams { ID = "id" }; + + NamespaceRetrieveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/Casedev.Tests/Models/Agent/Skills/Namespaces/NamespaceRotateTokenParamsTest.cs b/src/Casedev.Tests/Models/Agent/Skills/Namespaces/NamespaceRotateTokenParamsTest.cs new file mode 100644 index 00000000..20156c4d --- /dev/null +++ b/src/Casedev.Tests/Models/Agent/Skills/Namespaces/NamespaceRotateTokenParamsTest.cs @@ -0,0 +1,42 @@ +using System; +using Casedev.Models.Agent.Skills.Namespaces; + +namespace Casedev.Tests.Models.Agent.Skills.Namespaces; + +public class NamespaceRotateTokenParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new NamespaceRotateTokenParams { ID = "id" }; + + string expectedID = "id"; + + Assert.Equal(expectedID, parameters.ID); + } + + [Fact] + public void Url_Works() + { + NamespaceRotateTokenParams parameters = new() { ID = "id" }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.case.dev/agent/skills/namespaces/id/rotate-token"), + url + ) + ); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new NamespaceRotateTokenParams { ID = "id" }; + + NamespaceRotateTokenParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/Casedev.Tests/Models/Compute/V1/Instances/InstanceCreateParamsTest.cs b/src/Casedev.Tests/Models/Compute/V1/Instances/InstanceCreateParamsTest.cs index ce9de6e9..e4876dcc 100644 --- a/src/Casedev.Tests/Models/Compute/V1/Instances/InstanceCreateParamsTest.cs +++ b/src/Casedev.Tests/Models/Compute/V1/Instances/InstanceCreateParamsTest.cs @@ -14,20 +14,17 @@ public void FieldRoundtrip_Works() InstanceType = "gpu_1x_a10", Name = "ocr-batch-job", Region = "us-west-1", - AutoShutdownMinutes = 120, VaultIds = ["vault_abc123"], }; string expectedInstanceType = "gpu_1x_a10"; string expectedName = "ocr-batch-job"; string expectedRegion = "us-west-1"; - long expectedAutoShutdownMinutes = 120; List expectedVaultIds = ["vault_abc123"]; Assert.Equal(expectedInstanceType, parameters.InstanceType); Assert.Equal(expectedName, parameters.Name); Assert.Equal(expectedRegion, parameters.Region); - Assert.Equal(expectedAutoShutdownMinutes, parameters.AutoShutdownMinutes); Assert.NotNull(parameters.VaultIds); Assert.Equal(expectedVaultIds.Count, parameters.VaultIds.Count); for (int i = 0; i < expectedVaultIds.Count; i++) @@ -44,7 +41,6 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() InstanceType = "gpu_1x_a10", Name = "ocr-batch-job", Region = "us-west-1", - AutoShutdownMinutes = 120, }; Assert.Null(parameters.VaultIds); @@ -59,7 +55,6 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() InstanceType = "gpu_1x_a10", Name = "ocr-batch-job", Region = "us-west-1", - AutoShutdownMinutes = 120, // Null should be interpreted as omitted for these properties VaultIds = null, @@ -69,38 +64,6 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() Assert.False(parameters.RawBodyData.ContainsKey("vaultIds")); } - [Fact] - public void OptionalNullableParamsUnsetAreNotSet_Works() - { - var parameters = new InstanceCreateParams - { - InstanceType = "gpu_1x_a10", - Name = "ocr-batch-job", - Region = "us-west-1", - VaultIds = ["vault_abc123"], - }; - - Assert.Null(parameters.AutoShutdownMinutes); - Assert.False(parameters.RawBodyData.ContainsKey("autoShutdownMinutes")); - } - - [Fact] - public void OptionalNullableParamsSetToNullAreSetToNull_Works() - { - var parameters = new InstanceCreateParams - { - InstanceType = "gpu_1x_a10", - Name = "ocr-batch-job", - Region = "us-west-1", - VaultIds = ["vault_abc123"], - - AutoShutdownMinutes = null, - }; - - Assert.Null(parameters.AutoShutdownMinutes); - Assert.True(parameters.RawBodyData.ContainsKey("autoShutdownMinutes")); - } - [Fact] public void Url_Works() { @@ -124,7 +87,6 @@ public void CopyConstructor_Works() InstanceType = "gpu_1x_a10", Name = "ocr-batch-job", Region = "us-west-1", - AutoShutdownMinutes = 120, VaultIds = ["vault_abc123"], }; diff --git a/src/Casedev.Tests/Models/Compute/V1/Instances/InstanceCreateResponseTest.cs b/src/Casedev.Tests/Models/Compute/V1/Instances/InstanceCreateResponseTest.cs index 385db2f5..b044627b 100644 --- a/src/Casedev.Tests/Models/Compute/V1/Instances/InstanceCreateResponseTest.cs +++ b/src/Casedev.Tests/Models/Compute/V1/Instances/InstanceCreateResponseTest.cs @@ -13,7 +13,6 @@ public void FieldRoundtrip_Works() var model = new InstanceCreateResponse { ID = "id", - AutoShutdownMinutes = 0, CreatedAt = "createdAt", Gpu = "gpu", InstanceType = "instanceType", @@ -27,7 +26,6 @@ public void FieldRoundtrip_Works() }; string expectedID = "id"; - long expectedAutoShutdownMinutes = 0; string expectedCreatedAt = "createdAt"; string expectedGpu = "gpu"; string expectedInstanceType = "instanceType"; @@ -40,7 +38,6 @@ public void FieldRoundtrip_Works() List expectedVaults = [JsonSerializer.Deserialize("{}")]; Assert.Equal(expectedID, model.ID); - Assert.Equal(expectedAutoShutdownMinutes, model.AutoShutdownMinutes); Assert.Equal(expectedCreatedAt, model.CreatedAt); Assert.Equal(expectedGpu, model.Gpu); Assert.Equal(expectedInstanceType, model.InstanceType); @@ -65,7 +62,6 @@ public void SerializationRoundtrip_Works() var model = new InstanceCreateResponse { ID = "id", - AutoShutdownMinutes = 0, CreatedAt = "createdAt", Gpu = "gpu", InstanceType = "instanceType", @@ -93,7 +89,6 @@ public void FieldRoundtripThroughSerialization_Works() var model = new InstanceCreateResponse { ID = "id", - AutoShutdownMinutes = 0, CreatedAt = "createdAt", Gpu = "gpu", InstanceType = "instanceType", @@ -114,7 +109,6 @@ public void FieldRoundtripThroughSerialization_Works() Assert.NotNull(deserialized); string expectedID = "id"; - long expectedAutoShutdownMinutes = 0; string expectedCreatedAt = "createdAt"; string expectedGpu = "gpu"; string expectedInstanceType = "instanceType"; @@ -127,7 +121,6 @@ public void FieldRoundtripThroughSerialization_Works() List expectedVaults = [JsonSerializer.Deserialize("{}")]; Assert.Equal(expectedID, deserialized.ID); - Assert.Equal(expectedAutoShutdownMinutes, deserialized.AutoShutdownMinutes); Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); Assert.Equal(expectedGpu, deserialized.Gpu); Assert.Equal(expectedInstanceType, deserialized.InstanceType); @@ -152,7 +145,6 @@ public void Validation_Works() var model = new InstanceCreateResponse { ID = "id", - AutoShutdownMinutes = 0, CreatedAt = "createdAt", Gpu = "gpu", InstanceType = "instanceType", @@ -171,7 +163,7 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new InstanceCreateResponse { AutoShutdownMinutes = 0 }; + var model = new InstanceCreateResponse { }; Assert.Null(model.ID); Assert.False(model.RawData.ContainsKey("id")); @@ -200,7 +192,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new InstanceCreateResponse { AutoShutdownMinutes = 0 }; + var model = new InstanceCreateResponse { }; model.Validate(); } @@ -210,8 +202,6 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { var model = new InstanceCreateResponse { - AutoShutdownMinutes = 0, - // Null should be interpreted as omitted for these properties ID = null, CreatedAt = null, @@ -255,8 +245,6 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() { var model = new InstanceCreateResponse { - AutoShutdownMinutes = 0, - // Null should be interpreted as omitted for these properties ID = null, CreatedAt = null, @@ -274,103 +262,12 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new InstanceCreateResponse - { - ID = "id", - CreatedAt = "createdAt", - Gpu = "gpu", - InstanceType = "instanceType", - Message = "message", - Name = "name", - PricePerHour = "pricePerHour", - Region = "region", - Specs = JsonSerializer.Deserialize("{}"), - Status = "status", - Vaults = [JsonSerializer.Deserialize("{}")], - }; - - Assert.Null(model.AutoShutdownMinutes); - Assert.False(model.RawData.ContainsKey("autoShutdownMinutes")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new InstanceCreateResponse - { - ID = "id", - CreatedAt = "createdAt", - Gpu = "gpu", - InstanceType = "instanceType", - Message = "message", - Name = "name", - PricePerHour = "pricePerHour", - Region = "region", - Specs = JsonSerializer.Deserialize("{}"), - Status = "status", - Vaults = [JsonSerializer.Deserialize("{}")], - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new InstanceCreateResponse - { - ID = "id", - CreatedAt = "createdAt", - Gpu = "gpu", - InstanceType = "instanceType", - Message = "message", - Name = "name", - PricePerHour = "pricePerHour", - Region = "region", - Specs = JsonSerializer.Deserialize("{}"), - Status = "status", - Vaults = [JsonSerializer.Deserialize("{}")], - - AutoShutdownMinutes = null, - }; - - Assert.Null(model.AutoShutdownMinutes); - Assert.True(model.RawData.ContainsKey("autoShutdownMinutes")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new InstanceCreateResponse - { - ID = "id", - CreatedAt = "createdAt", - Gpu = "gpu", - InstanceType = "instanceType", - Message = "message", - Name = "name", - PricePerHour = "pricePerHour", - Region = "region", - Specs = JsonSerializer.Deserialize("{}"), - Status = "status", - Vaults = [JsonSerializer.Deserialize("{}")], - - AutoShutdownMinutes = null, - }; - - model.Validate(); - } - [Fact] public void CopyConstructor_Works() { var model = new InstanceCreateResponse { ID = "id", - AutoShutdownMinutes = 0, CreatedAt = "createdAt", Gpu = "gpu", InstanceType = "instanceType", diff --git a/src/Casedev.Tests/Models/Compute/V1/Instances/InstanceListResponseTest.cs b/src/Casedev.Tests/Models/Compute/V1/Instances/InstanceListResponseTest.cs index 3894e207..6999b8b7 100644 --- a/src/Casedev.Tests/Models/Compute/V1/Instances/InstanceListResponseTest.cs +++ b/src/Casedev.Tests/Models/Compute/V1/Instances/InstanceListResponseTest.cs @@ -20,7 +20,6 @@ public void FieldRoundtrip_Works() new() { ID = "id", - AutoShutdownMinutes = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Gpu = "gpu", InstanceType = "instanceType", @@ -42,7 +41,6 @@ public void FieldRoundtrip_Works() new() { ID = "id", - AutoShutdownMinutes = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Gpu = "gpu", InstanceType = "instanceType", @@ -77,7 +75,6 @@ public void SerializationRoundtrip_Works() new() { ID = "id", - AutoShutdownMinutes = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Gpu = "gpu", InstanceType = "instanceType", @@ -113,7 +110,6 @@ public void FieldRoundtripThroughSerialization_Works() new() { ID = "id", - AutoShutdownMinutes = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Gpu = "gpu", InstanceType = "instanceType", @@ -142,7 +138,6 @@ public void FieldRoundtripThroughSerialization_Works() new() { ID = "id", - AutoShutdownMinutes = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Gpu = "gpu", InstanceType = "instanceType", @@ -177,7 +172,6 @@ public void Validation_Works() new() { ID = "id", - AutoShutdownMinutes = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Gpu = "gpu", InstanceType = "instanceType", @@ -255,7 +249,6 @@ public void CopyConstructor_Works() new() { ID = "id", - AutoShutdownMinutes = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Gpu = "gpu", InstanceType = "instanceType", @@ -285,7 +278,6 @@ public void FieldRoundtrip_Works() var model = new Instance { ID = "id", - AutoShutdownMinutes = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Gpu = "gpu", InstanceType = "instanceType", @@ -300,7 +292,6 @@ public void FieldRoundtrip_Works() }; string expectedID = "id"; - long expectedAutoShutdownMinutes = 0; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); string expectedGpu = "gpu"; string expectedInstanceType = "instanceType"; @@ -314,7 +305,6 @@ public void FieldRoundtrip_Works() long expectedTotalRuntimeSeconds = 0; Assert.Equal(expectedID, model.ID); - Assert.Equal(expectedAutoShutdownMinutes, model.AutoShutdownMinutes); Assert.Equal(expectedCreatedAt, model.CreatedAt); Assert.Equal(expectedGpu, model.Gpu); Assert.Equal(expectedInstanceType, model.InstanceType); @@ -334,7 +324,6 @@ public void SerializationRoundtrip_Works() var model = new Instance { ID = "id", - AutoShutdownMinutes = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Gpu = "gpu", InstanceType = "instanceType", @@ -360,7 +349,6 @@ public void FieldRoundtripThroughSerialization_Works() var model = new Instance { ID = "id", - AutoShutdownMinutes = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Gpu = "gpu", InstanceType = "instanceType", @@ -382,7 +370,6 @@ public void FieldRoundtripThroughSerialization_Works() Assert.NotNull(deserialized); string expectedID = "id"; - long expectedAutoShutdownMinutes = 0; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); string expectedGpu = "gpu"; string expectedInstanceType = "instanceType"; @@ -396,7 +383,6 @@ public void FieldRoundtripThroughSerialization_Works() long expectedTotalRuntimeSeconds = 0; Assert.Equal(expectedID, deserialized.ID); - Assert.Equal(expectedAutoShutdownMinutes, deserialized.AutoShutdownMinutes); Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); Assert.Equal(expectedGpu, deserialized.Gpu); Assert.Equal(expectedInstanceType, deserialized.InstanceType); @@ -416,7 +402,6 @@ public void Validation_Works() var model = new Instance { ID = "id", - AutoShutdownMinutes = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Gpu = "gpu", InstanceType = "instanceType", @@ -438,7 +423,6 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { var model = new Instance { - AutoShutdownMinutes = 0, IP = "ip", StartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }; @@ -470,7 +454,6 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() { var model = new Instance { - AutoShutdownMinutes = 0, IP = "ip", StartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }; @@ -483,7 +466,6 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { var model = new Instance { - AutoShutdownMinutes = 0, IP = "ip", StartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), @@ -527,7 +509,6 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() { var model = new Instance { - AutoShutdownMinutes = 0, IP = "ip", StartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), @@ -564,8 +545,6 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() TotalRuntimeSeconds = 0, }; - Assert.Null(model.AutoShutdownMinutes); - Assert.False(model.RawData.ContainsKey("autoShutdownMinutes")); Assert.Null(model.IP); Assert.False(model.RawData.ContainsKey("ip")); Assert.Null(model.StartedAt); @@ -608,13 +587,10 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() TotalCost = "totalCost", TotalRuntimeSeconds = 0, - AutoShutdownMinutes = null, IP = null, StartedAt = null, }; - Assert.Null(model.AutoShutdownMinutes); - Assert.True(model.RawData.ContainsKey("autoShutdownMinutes")); Assert.Null(model.IP); Assert.True(model.RawData.ContainsKey("ip")); Assert.Null(model.StartedAt); @@ -637,7 +613,6 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() TotalCost = "totalCost", TotalRuntimeSeconds = 0, - AutoShutdownMinutes = null, IP = null, StartedAt = null, }; @@ -651,7 +626,6 @@ public void CopyConstructor_Works() var model = new Instance { ID = "id", - AutoShutdownMinutes = 0, CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), Gpu = "gpu", InstanceType = "instanceType", diff --git a/src/Casedev.Tests/Models/Compute/V1/Instances/InstanceRetrieveResponseTest.cs b/src/Casedev.Tests/Models/Compute/V1/Instances/InstanceRetrieveResponseTest.cs index edb974d4..c3d3c854 100644 --- a/src/Casedev.Tests/Models/Compute/V1/Instances/InstanceRetrieveResponseTest.cs +++ b/src/Casedev.Tests/Models/Compute/V1/Instances/InstanceRetrieveResponseTest.cs @@ -13,7 +13,6 @@ public void FieldRoundtrip_Works() var model = new InstanceRetrieveResponse { ID = "id", - AutoShutdownMinutes = 0, CreatedAt = "createdAt", CurrentCost = "currentCost", CurrentRuntimeSeconds = 0, @@ -38,7 +37,6 @@ public void FieldRoundtrip_Works() }; string expectedID = "id"; - long expectedAutoShutdownMinutes = 0; string expectedCreatedAt = "createdAt"; string expectedCurrentCost = "currentCost"; long expectedCurrentRuntimeSeconds = 0; @@ -62,7 +60,6 @@ public void FieldRoundtrip_Works() JsonElement expectedVaultMounts = JsonSerializer.Deserialize("{}"); Assert.Equal(expectedID, model.ID); - Assert.Equal(expectedAutoShutdownMinutes, model.AutoShutdownMinutes); Assert.Equal(expectedCreatedAt, model.CreatedAt); Assert.Equal(expectedCurrentCost, model.CurrentCost); Assert.Equal(expectedCurrentRuntimeSeconds, model.CurrentRuntimeSeconds); @@ -87,7 +84,6 @@ public void SerializationRoundtrip_Works() var model = new InstanceRetrieveResponse { ID = "id", - AutoShutdownMinutes = 0, CreatedAt = "createdAt", CurrentCost = "currentCost", CurrentRuntimeSeconds = 0, @@ -126,7 +122,6 @@ public void FieldRoundtripThroughSerialization_Works() var model = new InstanceRetrieveResponse { ID = "id", - AutoShutdownMinutes = 0, CreatedAt = "createdAt", CurrentCost = "currentCost", CurrentRuntimeSeconds = 0, @@ -158,7 +153,6 @@ public void FieldRoundtripThroughSerialization_Works() Assert.NotNull(deserialized); string expectedID = "id"; - long expectedAutoShutdownMinutes = 0; string expectedCreatedAt = "createdAt"; string expectedCurrentCost = "currentCost"; long expectedCurrentRuntimeSeconds = 0; @@ -182,7 +176,6 @@ public void FieldRoundtripThroughSerialization_Works() JsonElement expectedVaultMounts = JsonSerializer.Deserialize("{}"); Assert.Equal(expectedID, deserialized.ID); - Assert.Equal(expectedAutoShutdownMinutes, deserialized.AutoShutdownMinutes); Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); Assert.Equal(expectedCurrentCost, deserialized.CurrentCost); Assert.Equal(expectedCurrentRuntimeSeconds, deserialized.CurrentRuntimeSeconds); @@ -207,7 +200,6 @@ public void Validation_Works() var model = new InstanceRetrieveResponse { ID = "id", - AutoShutdownMinutes = 0, CreatedAt = "createdAt", CurrentCost = "currentCost", CurrentRuntimeSeconds = 0, @@ -239,7 +231,6 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { var model = new InstanceRetrieveResponse { - AutoShutdownMinutes = 0, IP = "ip", Ssh = new() { @@ -282,7 +273,6 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() { var model = new InstanceRetrieveResponse { - AutoShutdownMinutes = 0, IP = "ip", Ssh = new() { @@ -304,7 +294,6 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { var model = new InstanceRetrieveResponse { - AutoShutdownMinutes = 0, IP = "ip", Ssh = new() { @@ -360,7 +349,6 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() { var model = new InstanceRetrieveResponse { - AutoShutdownMinutes = 0, IP = "ip", Ssh = new() { @@ -408,8 +396,6 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Status = "status", }; - Assert.Null(model.AutoShutdownMinutes); - Assert.False(model.RawData.ContainsKey("autoShutdownMinutes")); Assert.Null(model.IP); Assert.False(model.RawData.ContainsKey("ip")); Assert.Null(model.Ssh); @@ -458,15 +444,12 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Specs = JsonSerializer.Deserialize("{}"), Status = "status", - AutoShutdownMinutes = null, IP = null, Ssh = null, StartedAt = null, VaultMounts = null, }; - Assert.Null(model.AutoShutdownMinutes); - Assert.True(model.RawData.ContainsKey("autoShutdownMinutes")); Assert.Null(model.IP); Assert.True(model.RawData.ContainsKey("ip")); Assert.Null(model.Ssh); @@ -494,7 +477,6 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Specs = JsonSerializer.Deserialize("{}"), Status = "status", - AutoShutdownMinutes = null, IP = null, Ssh = null, StartedAt = null, @@ -510,7 +492,6 @@ public void CopyConstructor_Works() var model = new InstanceRetrieveResponse { ID = "id", - AutoShutdownMinutes = 0, CreatedAt = "createdAt", CurrentCost = "currentCost", CurrentRuntimeSeconds = 0, diff --git a/src/Casedev.Tests/Models/Worker/V1/V1BootParamsTest.cs b/src/Casedev.Tests/Models/Worker/V1/V1BootParamsTest.cs deleted file mode 100644 index 85f9fffc..00000000 --- a/src/Casedev.Tests/Models/Worker/V1/V1BootParamsTest.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using Casedev.Models.Worker.V1; - -namespace Casedev.Tests.Models.Worker.V1; - -public class V1BootParamsTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var parameters = new V1BootParams { ID = "id" }; - - string expectedID = "id"; - - Assert.Equal(expectedID, parameters.ID); - } - - [Fact] - public void Url_Works() - { - V1BootParams parameters = new() { ID = "id" }; - - var url = parameters.Url(new() { ApiKey = "My API Key" }); - - Assert.True(TestBase.UrisEqual(new Uri("https://api.case.dev/worker/v1/id/boot"), url)); - } - - [Fact] - public void CopyConstructor_Works() - { - var parameters = new V1BootParams { ID = "id" }; - - V1BootParams copied = new(parameters); - - Assert.Equal(parameters, copied); - } -} diff --git a/src/Casedev.Tests/Models/Worker/V1/V1CreateParamsTest.cs b/src/Casedev.Tests/Models/Worker/V1/V1CreateParamsTest.cs deleted file mode 100644 index aed09cf1..00000000 --- a/src/Casedev.Tests/Models/Worker/V1/V1CreateParamsTest.cs +++ /dev/null @@ -1 +0,0 @@ -namespace Casedev.Tests.Models.Worker.V1; diff --git a/src/Casedev.Tests/Models/Worker/V1/V1DeleteParamsTest.cs b/src/Casedev.Tests/Models/Worker/V1/V1DeleteParamsTest.cs deleted file mode 100644 index dd4bdd3a..00000000 --- a/src/Casedev.Tests/Models/Worker/V1/V1DeleteParamsTest.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using Casedev.Models.Worker.V1; - -namespace Casedev.Tests.Models.Worker.V1; - -public class V1DeleteParamsTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var parameters = new V1DeleteParams { ID = "id" }; - - string expectedID = "id"; - - Assert.Equal(expectedID, parameters.ID); - } - - [Fact] - public void Url_Works() - { - V1DeleteParams parameters = new() { ID = "id" }; - - var url = parameters.Url(new() { ApiKey = "My API Key" }); - - Assert.True(TestBase.UrisEqual(new Uri("https://api.case.dev/worker/v1/id"), url)); - } - - [Fact] - public void CopyConstructor_Works() - { - var parameters = new V1DeleteParams { ID = "id" }; - - V1DeleteParams copied = new(parameters); - - Assert.Equal(parameters, copied); - } -} diff --git a/src/Casedev.Tests/Models/Worker/V1/V1ProxyDeleteParamsTest.cs b/src/Casedev.Tests/Models/Worker/V1/V1ProxyDeleteParamsTest.cs deleted file mode 100644 index ed447dd3..00000000 --- a/src/Casedev.Tests/Models/Worker/V1/V1ProxyDeleteParamsTest.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using Casedev.Models.Worker.V1; - -namespace Casedev.Tests.Models.Worker.V1; - -public class V1ProxyDeleteParamsTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var parameters = new V1ProxyDeleteParams { ID = "id", WorkerPath = "workerPath" }; - - string expectedID = "id"; - string expectedWorkerPath = "workerPath"; - - Assert.Equal(expectedID, parameters.ID); - Assert.Equal(expectedWorkerPath, parameters.WorkerPath); - } - - [Fact] - public void Url_Works() - { - V1ProxyDeleteParams parameters = new() { ID = "id", WorkerPath = "workerPath" }; - - var url = parameters.Url(new() { ApiKey = "My API Key" }); - - Assert.True( - TestBase.UrisEqual(new Uri("https://api.case.dev/worker/v1/id/workerPath"), url) - ); - } - - [Fact] - public void CopyConstructor_Works() - { - var parameters = new V1ProxyDeleteParams { ID = "id", WorkerPath = "workerPath" }; - - V1ProxyDeleteParams copied = new(parameters); - - Assert.Equal(parameters, copied); - } -} diff --git a/src/Casedev.Tests/Models/Worker/V1/V1ProxyGetParamsTest.cs b/src/Casedev.Tests/Models/Worker/V1/V1ProxyGetParamsTest.cs deleted file mode 100644 index 1fb5838c..00000000 --- a/src/Casedev.Tests/Models/Worker/V1/V1ProxyGetParamsTest.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using Casedev.Models.Worker.V1; - -namespace Casedev.Tests.Models.Worker.V1; - -public class V1ProxyGetParamsTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var parameters = new V1ProxyGetParams { ID = "id", WorkerPath = "workerPath" }; - - string expectedID = "id"; - string expectedWorkerPath = "workerPath"; - - Assert.Equal(expectedID, parameters.ID); - Assert.Equal(expectedWorkerPath, parameters.WorkerPath); - } - - [Fact] - public void Url_Works() - { - V1ProxyGetParams parameters = new() { ID = "id", WorkerPath = "workerPath" }; - - var url = parameters.Url(new() { ApiKey = "My API Key" }); - - Assert.True( - TestBase.UrisEqual(new Uri("https://api.case.dev/worker/v1/id/workerPath"), url) - ); - } - - [Fact] - public void CopyConstructor_Works() - { - var parameters = new V1ProxyGetParams { ID = "id", WorkerPath = "workerPath" }; - - V1ProxyGetParams copied = new(parameters); - - Assert.Equal(parameters, copied); - } -} diff --git a/src/Casedev.Tests/Models/Worker/V1/V1ProxyPatchParamsTest.cs b/src/Casedev.Tests/Models/Worker/V1/V1ProxyPatchParamsTest.cs deleted file mode 100644 index c54e30ea..00000000 --- a/src/Casedev.Tests/Models/Worker/V1/V1ProxyPatchParamsTest.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using Casedev.Models.Worker.V1; - -namespace Casedev.Tests.Models.Worker.V1; - -public class V1ProxyPatchParamsTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var parameters = new V1ProxyPatchParams { ID = "id", WorkerPath = "workerPath" }; - - string expectedID = "id"; - string expectedWorkerPath = "workerPath"; - - Assert.Equal(expectedID, parameters.ID); - Assert.Equal(expectedWorkerPath, parameters.WorkerPath); - } - - [Fact] - public void Url_Works() - { - V1ProxyPatchParams parameters = new() { ID = "id", WorkerPath = "workerPath" }; - - var url = parameters.Url(new() { ApiKey = "My API Key" }); - - Assert.True( - TestBase.UrisEqual(new Uri("https://api.case.dev/worker/v1/id/workerPath"), url) - ); - } - - [Fact] - public void CopyConstructor_Works() - { - var parameters = new V1ProxyPatchParams { ID = "id", WorkerPath = "workerPath" }; - - V1ProxyPatchParams copied = new(parameters); - - Assert.Equal(parameters, copied); - } -} diff --git a/src/Casedev.Tests/Models/Worker/V1/V1ProxyPostParamsTest.cs b/src/Casedev.Tests/Models/Worker/V1/V1ProxyPostParamsTest.cs deleted file mode 100644 index 154eb091..00000000 --- a/src/Casedev.Tests/Models/Worker/V1/V1ProxyPostParamsTest.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using Casedev.Models.Worker.V1; - -namespace Casedev.Tests.Models.Worker.V1; - -public class V1ProxyPostParamsTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var parameters = new V1ProxyPostParams { ID = "id", WorkerPath = "workerPath" }; - - string expectedID = "id"; - string expectedWorkerPath = "workerPath"; - - Assert.Equal(expectedID, parameters.ID); - Assert.Equal(expectedWorkerPath, parameters.WorkerPath); - } - - [Fact] - public void Url_Works() - { - V1ProxyPostParams parameters = new() { ID = "id", WorkerPath = "workerPath" }; - - var url = parameters.Url(new() { ApiKey = "My API Key" }); - - Assert.True( - TestBase.UrisEqual(new Uri("https://api.case.dev/worker/v1/id/workerPath"), url) - ); - } - - [Fact] - public void CopyConstructor_Works() - { - var parameters = new V1ProxyPostParams { ID = "id", WorkerPath = "workerPath" }; - - V1ProxyPostParams copied = new(parameters); - - Assert.Equal(parameters, copied); - } -} diff --git a/src/Casedev.Tests/Models/Worker/V1/V1ProxyPutParamsTest.cs b/src/Casedev.Tests/Models/Worker/V1/V1ProxyPutParamsTest.cs deleted file mode 100644 index 892d7d4d..00000000 --- a/src/Casedev.Tests/Models/Worker/V1/V1ProxyPutParamsTest.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using Casedev.Models.Worker.V1; - -namespace Casedev.Tests.Models.Worker.V1; - -public class V1ProxyPutParamsTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var parameters = new V1ProxyPutParams { ID = "id", WorkerPath = "workerPath" }; - - string expectedID = "id"; - string expectedWorkerPath = "workerPath"; - - Assert.Equal(expectedID, parameters.ID); - Assert.Equal(expectedWorkerPath, parameters.WorkerPath); - } - - [Fact] - public void Url_Works() - { - V1ProxyPutParams parameters = new() { ID = "id", WorkerPath = "workerPath" }; - - var url = parameters.Url(new() { ApiKey = "My API Key" }); - - Assert.True( - TestBase.UrisEqual(new Uri("https://api.case.dev/worker/v1/id/workerPath"), url) - ); - } - - [Fact] - public void CopyConstructor_Works() - { - var parameters = new V1ProxyPutParams { ID = "id", WorkerPath = "workerPath" }; - - V1ProxyPutParams copied = new(parameters); - - Assert.Equal(parameters, copied); - } -} diff --git a/src/Casedev.Tests/Models/Worker/V1/V1RetrieveParamsTest.cs b/src/Casedev.Tests/Models/Worker/V1/V1RetrieveParamsTest.cs deleted file mode 100644 index e724e355..00000000 --- a/src/Casedev.Tests/Models/Worker/V1/V1RetrieveParamsTest.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using Casedev.Models.Worker.V1; - -namespace Casedev.Tests.Models.Worker.V1; - -public class V1RetrieveParamsTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var parameters = new V1RetrieveParams { ID = "id" }; - - string expectedID = "id"; - - Assert.Equal(expectedID, parameters.ID); - } - - [Fact] - public void Url_Works() - { - V1RetrieveParams parameters = new() { ID = "id" }; - - var url = parameters.Url(new() { ApiKey = "My API Key" }); - - Assert.True(TestBase.UrisEqual(new Uri("https://api.case.dev/worker/v1/id"), url)); - } - - [Fact] - public void CopyConstructor_Works() - { - var parameters = new V1RetrieveParams { ID = "id" }; - - V1RetrieveParams copied = new(parameters); - - Assert.Equal(parameters, copied); - } -} diff --git a/src/Casedev.Tests/Services/Agent/Skills/NamespaceServiceTest.cs b/src/Casedev.Tests/Services/Agent/Skills/NamespaceServiceTest.cs new file mode 100644 index 00000000..e7d95462 --- /dev/null +++ b/src/Casedev.Tests/Services/Agent/Skills/NamespaceServiceTest.cs @@ -0,0 +1,87 @@ +using System.Threading.Tasks; +using Casedev.Models.Agent.Skills.Namespaces; + +namespace Casedev.Tests.Services.Agent.Skills; + +public class NamespaceServiceTest : TestBase +{ + [Fact] + public async Task Create_Works() + { + await this.client.Agent.Skills.Namespaces.Create( + new() { NamespaceID = "namespaceId" }, + TestContext.Current.CancellationToken + ); + } + + [Fact] + public async Task Retrieve_Works() + { + await this.client.Agent.Skills.Namespaces.Retrieve( + "id", + new(), + TestContext.Current.CancellationToken + ); + } + + [Fact] + public async Task List_Works() + { + await this.client.Agent.Skills.Namespaces.List( + new(), + TestContext.Current.CancellationToken + ); + } + + [Fact] + public async Task Delete_Works() + { + await this.client.Agent.Skills.Namespaces.Delete( + "id", + new(), + TestContext.Current.CancellationToken + ); + } + + [Fact] + public async Task Publish_Works() + { + await this.client.Agent.Skills.Namespaces.Publish( + "id", + new() + { + Files = + [ + new() + { + Content = "content", + Encoding = Encoding.Utf8, + Path = "path", + ContentType = "contentType", + }, + ], + }, + TestContext.Current.CancellationToken + ); + } + + [Fact] + public async Task Pull_Works() + { + await this.client.Agent.Skills.Namespaces.Pull( + "id", + new(), + TestContext.Current.CancellationToken + ); + } + + [Fact] + public async Task RotateToken_Works() + { + await this.client.Agent.Skills.Namespaces.RotateToken( + "id", + new(), + TestContext.Current.CancellationToken + ); + } +} diff --git a/src/Casedev.Tests/Services/Worker/V1ServiceTest.cs b/src/Casedev.Tests/Services/Worker/V1ServiceTest.cs deleted file mode 100644 index 26ac6f9d..00000000 --- a/src/Casedev.Tests/Services/Worker/V1ServiceTest.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System.Threading.Tasks; - -namespace Casedev.Tests.Services.Worker; - -public class V1ServiceTest : TestBase -{ - [Fact] - public async Task Create_Works() - { - await this.client.Worker.V1.Create(new(), TestContext.Current.CancellationToken); - } - - [Fact] - public async Task Retrieve_Works() - { - await this.client.Worker.V1.Retrieve("id", new(), TestContext.Current.CancellationToken); - } - - [Fact] - public async Task Delete_Works() - { - await this.client.Worker.V1.Delete("id", new(), TestContext.Current.CancellationToken); - } - - [Fact] - public async Task Boot_Works() - { - await this.client.Worker.V1.Boot("id", new(), TestContext.Current.CancellationToken); - } - - [Fact] - public async Task ProxyDelete_Works() - { - await this.client.Worker.V1.ProxyDelete( - "workerPath", - new() { ID = "id" }, - TestContext.Current.CancellationToken - ); - } - - [Fact] - public async Task ProxyGet_Works() - { - await this.client.Worker.V1.ProxyGet( - "workerPath", - new() { ID = "id" }, - TestContext.Current.CancellationToken - ); - } - - [Fact] - public async Task ProxyPatch_Works() - { - await this.client.Worker.V1.ProxyPatch( - "workerPath", - new() { ID = "id" }, - TestContext.Current.CancellationToken - ); - } - - [Fact] - public async Task ProxyPost_Works() - { - await this.client.Worker.V1.ProxyPost( - "workerPath", - new() { ID = "id" }, - TestContext.Current.CancellationToken - ); - } - - [Fact] - public async Task ProxyPut_Works() - { - await this.client.Worker.V1.ProxyPut( - "workerPath", - new() { ID = "id" }, - TestContext.Current.CancellationToken - ); - } -} diff --git a/src/Casedev/Casedev.csproj b/src/Casedev/Casedev.csproj index 9f5e5ebf..768dd054 100644 --- a/src/Casedev/Casedev.csproj +++ b/src/Casedev/Casedev.csproj @@ -3,7 +3,7 @@ Casedev C# Casedev - 0.39.0 + 0.40.0 The official .NET library for the Casedev API. Library README.md diff --git a/src/Casedev/CasedevClient.cs b/src/Casedev/CasedevClient.cs index b827a3e4..86734e4b 100644 --- a/src/Casedev/CasedevClient.cs +++ b/src/Casedev/CasedevClient.cs @@ -84,12 +84,6 @@ public ISystemService System get { return _system.Value; } } - readonly Lazy _worker; - public IWorkerService Worker - { - get { return _worker.Value; } - } - readonly Lazy _compute; public IComputeService Compute { @@ -207,7 +201,6 @@ public CasedevClient() _withRawResponse = new(() => new CasedevClientWithRawResponse(this._options)); _agent = new(() => new AgentService(this)); _system = new(() => new SystemService(this)); - _worker = new(() => new WorkerService(this)); _compute = new(() => new ComputeService(this)); _database = new(() => new DatabaseService(this)); _format = new(() => new FormatService(this)); @@ -313,12 +306,6 @@ public ISystemServiceWithRawResponse System get { return _system.Value; } } - readonly Lazy _worker; - public IWorkerServiceWithRawResponse Worker - { - get { return _worker.Value; } - } - readonly Lazy _compute; public IComputeServiceWithRawResponse Compute { @@ -627,7 +614,6 @@ public CasedevClientWithRawResponse() _agent = new(() => new AgentServiceWithRawResponse(this)); _system = new(() => new SystemServiceWithRawResponse(this)); - _worker = new(() => new WorkerServiceWithRawResponse(this)); _compute = new(() => new ComputeServiceWithRawResponse(this)); _database = new(() => new DatabaseServiceWithRawResponse(this)); _format = new(() => new FormatServiceWithRawResponse(this)); diff --git a/src/Casedev/Core/ModelBase.cs b/src/Casedev/Core/ModelBase.cs index 6d926316..0a3af2bc 100644 --- a/src/Casedev/Core/ModelBase.cs +++ b/src/Casedev/Core/ModelBase.cs @@ -1,5 +1,6 @@ using System.Text.Json; using Casedev.Exceptions; +using Casedev.Models.Agent.Skills.Namespaces; using Casedev.Models.Agent.V1.Run; using Casedev.Models.Format.V1; using Casedev.Models.Llm.V1; @@ -56,6 +57,7 @@ protected ModelBase(ModelBase modelBase) Converters = { new FrozenDictionaryConverterFactory(), + new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), diff --git a/src/Casedev/ICasedevClient.cs b/src/Casedev/ICasedevClient.cs index 2c892176..2c2d6735 100644 --- a/src/Casedev/ICasedevClient.cs +++ b/src/Casedev/ICasedevClient.cs @@ -58,8 +58,6 @@ public interface ICasedevClient : IDisposable ISystemService System { get; } - IWorkerService Worker { get; } - IComputeService Compute { get; } IDatabaseService Database { get; } @@ -133,8 +131,6 @@ public interface ICasedevClientWithRawResponse : IDisposable ISystemServiceWithRawResponse System { get; } - IWorkerServiceWithRawResponse Worker { get; } - IComputeServiceWithRawResponse Compute { get; } IDatabaseServiceWithRawResponse Database { get; } diff --git a/src/Casedev/Models/Agent/Skills/Namespaces/NamespaceCreateParams.cs b/src/Casedev/Models/Agent/Skills/Namespaces/NamespaceCreateParams.cs new file mode 100644 index 00000000..af35de22 --- /dev/null +++ b/src/Casedev/Models/Agent/Skills/Namespaces/NamespaceCreateParams.cs @@ -0,0 +1,180 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using Casedev.Core; +using Text = System.Text; + +namespace Casedev.Models.Agent.Skills.Namespaces; + +/// +/// Create a private skill namespace owned by the authenticated org and receive a +/// one-time bearer token used by the case-skills publisher. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class NamespaceCreateParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + /// + /// URL-safe slug, e.g. "curi" or "client-firm-abc". Lowercase alphanumeric with + /// single hyphens, 2-64 chars. + /// + public required string NamespaceID + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("namespaceId"); + } + init { this._rawBodyData.Set("namespaceId", value); } + } + + public string? Description + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("description"); + } + init { this._rawBodyData.Set("description", value); } + } + + public string? Label + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("label"); + } + init { this._rawBodyData.Set("label", value); } + } + + public JsonElement? Metadata + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("metadata"); + } + init { this._rawBodyData.Set("metadata", value); } + } + + public NamespaceCreateParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public NamespaceCreateParams(NamespaceCreateParams namespaceCreateParams) + : base(namespaceCreateParams) + { + this._rawBodyData = new(namespaceCreateParams._rawBodyData); + } +#pragma warning restore CS8618 + + public NamespaceCreateParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + NamespaceCreateParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static NamespaceCreateParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(NamespaceCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/agent/skills/namespaces") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Casedev/Models/Worker/V1/V1BootParams.cs b/src/Casedev/Models/Agent/Skills/Namespaces/NamespaceDeleteParams.cs similarity index 80% rename from src/Casedev/Models/Worker/V1/V1BootParams.cs rename to src/Casedev/Models/Agent/Skills/Namespaces/NamespaceDeleteParams.cs index 0949f1b0..3fb3d556 100644 --- a/src/Casedev/Models/Worker/V1/V1BootParams.cs +++ b/src/Casedev/Models/Agent/Skills/Namespaces/NamespaceDeleteParams.cs @@ -6,32 +6,31 @@ using System.Text.Json; using Casedev.Core; -namespace Casedev.Models.Worker.V1; +namespace Casedev.Models.Agent.Skills.Namespaces; /// -/// Starts or resumes the worker sandbox and OpenCode server. Native /worker/v1/:id/* -/// proxy routes require this lifecycle primitive to have completed first. +/// Delete skill namespace /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with /// breaking changes in non-major versions. We may add new methods in the future that /// cause existing derived classes to break. /// -public record class V1BootParams : ParamsBase +public record class NamespaceDeleteParams : ParamsBase { public string? ID { get; init; } - public V1BootParams() { } + public NamespaceDeleteParams() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public V1BootParams(V1BootParams v1BootParams) - : base(v1BootParams) + public NamespaceDeleteParams(NamespaceDeleteParams namespaceDeleteParams) + : base(namespaceDeleteParams) { - this.ID = v1BootParams.ID; + this.ID = namespaceDeleteParams.ID; } #pragma warning restore CS8618 - public V1BootParams( + public NamespaceDeleteParams( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData ) @@ -42,7 +41,7 @@ IReadOnlyDictionary rawQueryData #pragma warning disable CS8618 [SetsRequiredMembers] - V1BootParams( + NamespaceDeleteParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, string id @@ -55,7 +54,7 @@ string id #pragma warning restore CS8618 /// - public static V1BootParams FromRawUnchecked( + public static NamespaceDeleteParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, string id @@ -85,7 +84,7 @@ public override string ToString() => ModelBase.ToStringSerializerOptions ); - public virtual bool Equals(V1BootParams? other) + public virtual bool Equals(NamespaceDeleteParams? other) { if (other == null) { @@ -99,7 +98,8 @@ public virtual bool Equals(V1BootParams? other) public override Uri Url(ClientOptions options) { return new UriBuilder( - options.BaseUrl.ToString().TrimEnd('/') + string.Format("/worker/v1/{0}/boot", this.ID) + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/agent/skills/namespaces/{0}", this.ID) ) { Query = this.QueryString(options), diff --git a/src/Casedev/Models/Worker/V1/V1CreateParams.cs b/src/Casedev/Models/Agent/Skills/Namespaces/NamespaceListParams.cs similarity index 81% rename from src/Casedev/Models/Worker/V1/V1CreateParams.cs rename to src/Casedev/Models/Agent/Skills/Namespaces/NamespaceListParams.cs index f5c900f8..083e11a6 100644 --- a/src/Casedev/Models/Worker/V1/V1CreateParams.cs +++ b/src/Casedev/Models/Agent/Skills/Namespaces/NamespaceListParams.cs @@ -6,27 +6,26 @@ using System.Text.Json; using Casedev.Core; -namespace Casedev.Models.Worker.V1; +namespace Casedev.Models.Agent.Skills.Namespaces; /// -/// Creates a Daytona-backed worker runtime. The worker exposes its native runtime -/// API through /worker/v1/:id/* without reshaping payloads or events. +/// List all active skill namespaces owned by the authenticated organization. /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with /// breaking changes in non-major versions. We may add new methods in the future that /// cause existing derived classes to break. /// -public record class V1CreateParams : ParamsBase +public record class NamespaceListParams : ParamsBase { - public V1CreateParams() { } + public NamespaceListParams() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public V1CreateParams(V1CreateParams v1CreateParams) - : base(v1CreateParams) { } + public NamespaceListParams(NamespaceListParams namespaceListParams) + : base(namespaceListParams) { } #pragma warning restore CS8618 - public V1CreateParams( + public NamespaceListParams( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData ) @@ -37,7 +36,7 @@ IReadOnlyDictionary rawQueryData #pragma warning disable CS8618 [SetsRequiredMembers] - V1CreateParams( + NamespaceListParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData ) @@ -48,7 +47,7 @@ FrozenDictionary rawQueryData #pragma warning restore CS8618 /// - public static V1CreateParams FromRawUnchecked( + public static NamespaceListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData ) @@ -75,7 +74,7 @@ public override string ToString() => ModelBase.ToStringSerializerOptions ); - public virtual bool Equals(V1CreateParams? other) + public virtual bool Equals(NamespaceListParams? other) { if (other == null) { @@ -87,7 +86,7 @@ public virtual bool Equals(V1CreateParams? other) public override Uri Url(ClientOptions options) { - return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/worker/v1") + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/agent/skills/namespaces") { Query = this.QueryString(options), }.Uri; diff --git a/src/Casedev/Models/Agent/Skills/Namespaces/NamespacePublishParams.cs b/src/Casedev/Models/Agent/Skills/Namespaces/NamespacePublishParams.cs new file mode 100644 index 00000000..d93e76f4 --- /dev/null +++ b/src/Casedev/Models/Agent/Skills/Namespaces/NamespacePublishParams.cs @@ -0,0 +1,296 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using System.Text.Json.Serialization; +using Casedev.Core; +using Casedev.Exceptions; +using Text = System.Text; + +namespace Casedev.Models.Agent.Skills.Namespaces; + +/// +/// Upload a tree of skill files for the namespace. Authenticated by the namespace +/// bearer token. Atomic at the version-bump level: a partial upload leaves the namespace +/// pinned to the previous version. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class NamespacePublishParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + public string? ID { get; init; } + + public required IReadOnlyList Files + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullStruct>("files"); + } + init + { + this._rawBodyData.Set>( + "files", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + public NamespacePublishParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public NamespacePublishParams(NamespacePublishParams namespacePublishParams) + : base(namespacePublishParams) + { + this.ID = namespacePublishParams.ID; + + this._rawBodyData = new(namespacePublishParams._rawBodyData); + } +#pragma warning restore CS8618 + + public NamespacePublishParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + NamespacePublishParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData, + string id + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + this.ID = id; + } +#pragma warning restore CS8618 + + /// + public static NamespacePublishParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData, + string id + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData), + id + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ID"] = JsonSerializer.SerializeToElement(this.ID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(NamespacePublishParams? other) + { + if (other == null) + { + return false; + } + return (this.ID?.Equals(other.ID) ?? other.ID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/agent/skills/namespaces/{0}/publish", this.ID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Text::Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class File : JsonModel +{ + public required string Content + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("content"); + } + init { this._rawData.Set("content", value); } + } + + public required ApiEnum Encoding + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>("encoding"); + } + init { this._rawData.Set("encoding", value); } + } + + public required string Path + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("path"); + } + init { this._rawData.Set("path", value); } + } + + public string? ContentType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("contentType"); + } + init { this._rawData.Set("contentType", value); } + } + + /// + public override void Validate() + { + _ = this.Content; + this.Encoding.Validate(); + _ = this.Path; + _ = this.ContentType; + } + + public File() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public File(File file) + : base(file) { } +#pragma warning restore CS8618 + + public File(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + File(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static File FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class FileFromRaw : IFromRawJson +{ + /// + public File FromRawUnchecked(IReadOnlyDictionary rawData) => + File.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(EncodingConverter))] +public enum Encoding +{ + Utf8, + Base64, +} + +sealed class EncodingConverter : JsonConverter +{ + public override Encoding Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "utf8" => Encoding.Utf8, + "base64" => Encoding.Base64, + _ => (Encoding)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Encoding value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Encoding.Utf8 => "utf8", + Encoding.Base64 => "base64", + _ => throw new CasedevInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/Casedev/Models/Worker/V1/V1ProxyPutParams.cs b/src/Casedev/Models/Agent/Skills/Namespaces/NamespacePullParams.cs similarity index 70% rename from src/Casedev/Models/Worker/V1/V1ProxyPutParams.cs rename to src/Casedev/Models/Agent/Skills/Namespaces/NamespacePullParams.cs index 4aa7eaf7..6d1411a7 100644 --- a/src/Casedev/Models/Worker/V1/V1ProxyPutParams.cs +++ b/src/Casedev/Models/Agent/Skills/Namespaces/NamespacePullParams.cs @@ -6,34 +6,33 @@ using System.Text.Json; using Casedev.Core; -namespace Casedev.Models.Worker.V1; +namespace Casedev.Models.Agent.Skills.Namespaces; /// -/// Forwards a PUT request to the worker runtime without translating request or response shapes. +/// Returns the active version's file manifest with short-lived presigned S3 URLs. +/// Sandboxes use this to materialize the tree at /workspace/.agents/skills/ before +/// opencode boots. /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with /// breaking changes in non-major versions. We may add new methods in the future that /// cause existing derived classes to break. /// -public record class V1ProxyPutParams : ParamsBase +public record class NamespacePullParams : ParamsBase { - public required string ID { get; init; } + public string? ID { get; init; } - public string? WorkerPath { get; init; } - - public V1ProxyPutParams() { } + public NamespacePullParams() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public V1ProxyPutParams(V1ProxyPutParams v1ProxyPutParams) - : base(v1ProxyPutParams) + public NamespacePullParams(NamespacePullParams namespacePullParams) + : base(namespacePullParams) { - this.ID = v1ProxyPutParams.ID; - this.WorkerPath = v1ProxyPutParams.WorkerPath; + this.ID = namespacePullParams.ID; } #pragma warning restore CS8618 - public V1ProxyPutParams( + public NamespacePullParams( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData ) @@ -44,33 +43,29 @@ IReadOnlyDictionary rawQueryData #pragma warning disable CS8618 [SetsRequiredMembers] - V1ProxyPutParams( + NamespacePullParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - string id, - string workerPath + string id ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this.ID = id; - this.WorkerPath = workerPath; } #pragma warning restore CS8618 /// - public static V1ProxyPutParams FromRawUnchecked( + public static NamespacePullParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - string id, - string workerPath + string id ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - id, - workerPath + id ); } @@ -80,7 +75,6 @@ public override string ToString() => new Dictionary() { ["ID"] = JsonSerializer.SerializeToElement(this.ID), - ["WorkerPath"] = JsonSerializer.SerializeToElement(this.WorkerPath), ["HeaderData"] = FriendlyJsonPrinter.PrintValue( JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) ), @@ -92,14 +86,13 @@ public override string ToString() => ModelBase.ToStringSerializerOptions ); - public virtual bool Equals(V1ProxyPutParams? other) + public virtual bool Equals(NamespacePullParams? other) { if (other == null) { return false; } - return this.ID.Equals(other.ID) - && (this.WorkerPath?.Equals(other.WorkerPath) ?? other.WorkerPath == null) + return (this.ID?.Equals(other.ID) ?? other.ID == null) && this._rawHeaderData.Equals(other._rawHeaderData) && this._rawQueryData.Equals(other._rawQueryData); } @@ -108,7 +101,7 @@ public override Uri Url(ClientOptions options) { return new UriBuilder( options.BaseUrl.ToString().TrimEnd('/') - + string.Format("/worker/v1/{0}/{1}", this.ID, this.WorkerPath) + + string.Format("/agent/skills/namespaces/{0}/pull", this.ID) ) { Query = this.QueryString(options), diff --git a/src/Casedev/Models/Worker/V1/V1RetrieveParams.cs b/src/Casedev/Models/Agent/Skills/Namespaces/NamespaceRetrieveParams.cs similarity index 80% rename from src/Casedev/Models/Worker/V1/V1RetrieveParams.cs rename to src/Casedev/Models/Agent/Skills/Namespaces/NamespaceRetrieveParams.cs index 5c04c1fe..ece422c7 100644 --- a/src/Casedev/Models/Worker/V1/V1RetrieveParams.cs +++ b/src/Casedev/Models/Agent/Skills/Namespaces/NamespaceRetrieveParams.cs @@ -6,31 +6,31 @@ using System.Text.Json; using Casedev.Core; -namespace Casedev.Models.Worker.V1; +namespace Casedev.Models.Agent.Skills.Namespaces; /// -/// Get worker +/// Read skill namespace /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with /// breaking changes in non-major versions. We may add new methods in the future that /// cause existing derived classes to break. /// -public record class V1RetrieveParams : ParamsBase +public record class NamespaceRetrieveParams : ParamsBase { public string? ID { get; init; } - public V1RetrieveParams() { } + public NamespaceRetrieveParams() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public V1RetrieveParams(V1RetrieveParams v1RetrieveParams) - : base(v1RetrieveParams) + public NamespaceRetrieveParams(NamespaceRetrieveParams namespaceRetrieveParams) + : base(namespaceRetrieveParams) { - this.ID = v1RetrieveParams.ID; + this.ID = namespaceRetrieveParams.ID; } #pragma warning restore CS8618 - public V1RetrieveParams( + public NamespaceRetrieveParams( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData ) @@ -41,7 +41,7 @@ IReadOnlyDictionary rawQueryData #pragma warning disable CS8618 [SetsRequiredMembers] - V1RetrieveParams( + NamespaceRetrieveParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, string id @@ -54,7 +54,7 @@ string id #pragma warning restore CS8618 /// - public static V1RetrieveParams FromRawUnchecked( + public static NamespaceRetrieveParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, string id @@ -84,7 +84,7 @@ public override string ToString() => ModelBase.ToStringSerializerOptions ); - public virtual bool Equals(V1RetrieveParams? other) + public virtual bool Equals(NamespaceRetrieveParams? other) { if (other == null) { @@ -98,7 +98,8 @@ public virtual bool Equals(V1RetrieveParams? other) public override Uri Url(ClientOptions options) { return new UriBuilder( - options.BaseUrl.ToString().TrimEnd('/') + string.Format("/worker/v1/{0}", this.ID) + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/agent/skills/namespaces/{0}", this.ID) ) { Query = this.QueryString(options), diff --git a/src/Casedev/Models/Worker/V1/V1DeleteParams.cs b/src/Casedev/Models/Agent/Skills/Namespaces/NamespaceRotateTokenParams.cs similarity index 79% rename from src/Casedev/Models/Worker/V1/V1DeleteParams.cs rename to src/Casedev/Models/Agent/Skills/Namespaces/NamespaceRotateTokenParams.cs index 0b5ffc02..38ff5860 100644 --- a/src/Casedev/Models/Worker/V1/V1DeleteParams.cs +++ b/src/Casedev/Models/Agent/Skills/Namespaces/NamespaceRotateTokenParams.cs @@ -6,31 +6,31 @@ using System.Text.Json; using Casedev.Core; -namespace Casedev.Models.Worker.V1; +namespace Casedev.Models.Agent.Skills.Namespaces; /// -/// End worker +/// Rotate skill namespace token /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with /// breaking changes in non-major versions. We may add new methods in the future that /// cause existing derived classes to break. /// -public record class V1DeleteParams : ParamsBase +public record class NamespaceRotateTokenParams : ParamsBase { public string? ID { get; init; } - public V1DeleteParams() { } + public NamespaceRotateTokenParams() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public V1DeleteParams(V1DeleteParams v1DeleteParams) - : base(v1DeleteParams) + public NamespaceRotateTokenParams(NamespaceRotateTokenParams namespaceRotateTokenParams) + : base(namespaceRotateTokenParams) { - this.ID = v1DeleteParams.ID; + this.ID = namespaceRotateTokenParams.ID; } #pragma warning restore CS8618 - public V1DeleteParams( + public NamespaceRotateTokenParams( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData ) @@ -41,7 +41,7 @@ IReadOnlyDictionary rawQueryData #pragma warning disable CS8618 [SetsRequiredMembers] - V1DeleteParams( + NamespaceRotateTokenParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, string id @@ -54,7 +54,7 @@ string id #pragma warning restore CS8618 /// - public static V1DeleteParams FromRawUnchecked( + public static NamespaceRotateTokenParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, string id @@ -84,7 +84,7 @@ public override string ToString() => ModelBase.ToStringSerializerOptions ); - public virtual bool Equals(V1DeleteParams? other) + public virtual bool Equals(NamespaceRotateTokenParams? other) { if (other == null) { @@ -98,7 +98,8 @@ public virtual bool Equals(V1DeleteParams? other) public override Uri Url(ClientOptions options) { return new UriBuilder( - options.BaseUrl.ToString().TrimEnd('/') + string.Format("/worker/v1/{0}", this.ID) + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/agent/skills/namespaces/{0}/rotate-token", this.ID) ) { Query = this.QueryString(options), diff --git a/src/Casedev/Models/Compute/V1/Instances/InstanceCreateParams.cs b/src/Casedev/Models/Compute/V1/Instances/InstanceCreateParams.cs index 772d6077..eaafe2ea 100644 --- a/src/Casedev/Models/Compute/V1/Instances/InstanceCreateParams.cs +++ b/src/Casedev/Models/Compute/V1/Instances/InstanceCreateParams.cs @@ -12,9 +12,8 @@ namespace Casedev.Models.Compute.V1.Instances; /// /// Launches a new GPU compute instance with automatic SSH key generation. Supports -/// mounting Case.dev Vaults as filesystems and configurable auto-shutdown. Instance -/// boots in ~2-5 minutes. Perfect for batch OCR processing, AI model training, and -/// intensive document analysis workloads. +/// mounting Case.dev Vaults as filesystems. Instance boots in ~2-5 minutes. Perfect +/// for batch OCR processing, AI model training, and intensive document analysis workloads. /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with /// breaking changes in non-major versions. We may add new methods in the future that @@ -67,19 +66,6 @@ public required string Region init { this._rawBodyData.Set("region", value); } } - /// - /// Auto-shutdown timer (null = never) - /// - public long? AutoShutdownMinutes - { - get - { - this._rawBodyData.Freeze(); - return this._rawBodyData.GetNullableStruct("autoShutdownMinutes"); - } - init { this._rawBodyData.Set("autoShutdownMinutes", value); } - } - /// /// Vault IDs to mount /// diff --git a/src/Casedev/Models/Compute/V1/Instances/InstanceCreateResponse.cs b/src/Casedev/Models/Compute/V1/Instances/InstanceCreateResponse.cs index d4c9d44f..a320384f 100644 --- a/src/Casedev/Models/Compute/V1/Instances/InstanceCreateResponse.cs +++ b/src/Casedev/Models/Compute/V1/Instances/InstanceCreateResponse.cs @@ -29,16 +29,6 @@ public string? ID } } - public long? AutoShutdownMinutes - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("autoShutdownMinutes"); - } - init { this._rawData.Set("autoShutdownMinutes", value); } - } - public string? CreatedAt { get @@ -226,7 +216,6 @@ public IReadOnlyList? Vaults public override void Validate() { _ = this.ID; - _ = this.AutoShutdownMinutes; _ = this.CreatedAt; _ = this.Gpu; _ = this.InstanceType; diff --git a/src/Casedev/Models/Compute/V1/Instances/InstanceListParams.cs b/src/Casedev/Models/Compute/V1/Instances/InstanceListParams.cs index fa6f8524..b2bae6bf 100644 --- a/src/Casedev/Models/Compute/V1/Instances/InstanceListParams.cs +++ b/src/Casedev/Models/Compute/V1/Instances/InstanceListParams.cs @@ -10,9 +10,8 @@ namespace Casedev.Models.Compute.V1.Instances; /// /// Retrieves all GPU compute instances for your organization with real-time status -/// updates from Lambda Labs. Includes pricing, runtime metrics, and auto-shutdown -/// configuration. Perfect for monitoring AI workloads, document processing jobs, -/// and cost tracking. +/// updates from Lambda Labs. Includes pricing and runtime metrics. Perfect for monitoring +/// AI workloads, document processing jobs, and cost tracking. /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with /// breaking changes in non-major versions. We may add new methods in the future that diff --git a/src/Casedev/Models/Compute/V1/Instances/InstanceListResponse.cs b/src/Casedev/Models/Compute/V1/Instances/InstanceListResponse.cs index 17183f50..d1c6b796 100644 --- a/src/Casedev/Models/Compute/V1/Instances/InstanceListResponse.cs +++ b/src/Casedev/Models/Compute/V1/Instances/InstanceListResponse.cs @@ -121,16 +121,6 @@ public string? ID } } - public long? AutoShutdownMinutes - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("autoShutdownMinutes"); - } - init { this._rawData.Set("autoShutdownMinutes", value); } - } - public DateTimeOffset? CreatedAt { get @@ -317,7 +307,6 @@ public long? TotalRuntimeSeconds public override void Validate() { _ = this.ID; - _ = this.AutoShutdownMinutes; _ = this.CreatedAt; _ = this.Gpu; _ = this.InstanceType; diff --git a/src/Casedev/Models/Compute/V1/Instances/InstanceRetrieveResponse.cs b/src/Casedev/Models/Compute/V1/Instances/InstanceRetrieveResponse.cs index 481dc420..2bf60b18 100644 --- a/src/Casedev/Models/Compute/V1/Instances/InstanceRetrieveResponse.cs +++ b/src/Casedev/Models/Compute/V1/Instances/InstanceRetrieveResponse.cs @@ -31,16 +31,6 @@ public string? ID } } - public long? AutoShutdownMinutes - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("autoShutdownMinutes"); - } - init { this._rawData.Set("autoShutdownMinutes", value); } - } - public string? CreatedAt { get @@ -265,7 +255,6 @@ public JsonElement? VaultMounts public override void Validate() { _ = this.ID; - _ = this.AutoShutdownMinutes; _ = this.CreatedAt; _ = this.CurrentCost; _ = this.CurrentRuntimeSeconds; diff --git a/src/Casedev/Models/Worker/V1/V1ProxyDeleteParams.cs b/src/Casedev/Models/Worker/V1/V1ProxyDeleteParams.cs deleted file mode 100644 index 52bfb682..00000000 --- a/src/Casedev/Models/Worker/V1/V1ProxyDeleteParams.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System; -using System.Collections.Frozen; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Net.Http; -using System.Text.Json; -using Casedev.Core; - -namespace Casedev.Models.Worker.V1; - -/// -/// Forwards a DELETE request to the worker runtime without translating response shapes. -/// -/// NOTE: Do not inherit from this type outside the SDK unless you're okay with -/// breaking changes in non-major versions. We may add new methods in the future that -/// cause existing derived classes to break. -/// -public record class V1ProxyDeleteParams : ParamsBase -{ - public required string ID { get; init; } - - public string? WorkerPath { get; init; } - - public V1ProxyDeleteParams() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - public V1ProxyDeleteParams(V1ProxyDeleteParams v1ProxyDeleteParams) - : base(v1ProxyDeleteParams) - { - this.ID = v1ProxyDeleteParams.ID; - this.WorkerPath = v1ProxyDeleteParams.WorkerPath; - } -#pragma warning restore CS8618 - - public V1ProxyDeleteParams( - IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData - ) - { - this._rawHeaderData = new(rawHeaderData); - this._rawQueryData = new(rawQueryData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - V1ProxyDeleteParams( - FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData, - string id, - string workerPath - ) - { - this._rawHeaderData = new(rawHeaderData); - this._rawQueryData = new(rawQueryData); - this.ID = id; - this.WorkerPath = workerPath; - } -#pragma warning restore CS8618 - - /// - public static V1ProxyDeleteParams FromRawUnchecked( - IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData, - string id, - string workerPath - ) - { - return new( - FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData), - id, - workerPath - ); - } - - public override string ToString() => - JsonSerializer.Serialize( - FriendlyJsonPrinter.PrintValue( - new Dictionary() - { - ["ID"] = JsonSerializer.SerializeToElement(this.ID), - ["WorkerPath"] = JsonSerializer.SerializeToElement(this.WorkerPath), - ["HeaderData"] = FriendlyJsonPrinter.PrintValue( - JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) - ), - ["QueryData"] = FriendlyJsonPrinter.PrintValue( - JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) - ), - } - ), - ModelBase.ToStringSerializerOptions - ); - - public virtual bool Equals(V1ProxyDeleteParams? other) - { - if (other == null) - { - return false; - } - return this.ID.Equals(other.ID) - && (this.WorkerPath?.Equals(other.WorkerPath) ?? other.WorkerPath == null) - && this._rawHeaderData.Equals(other._rawHeaderData) - && this._rawQueryData.Equals(other._rawQueryData); - } - - public override Uri Url(ClientOptions options) - { - return new UriBuilder( - options.BaseUrl.ToString().TrimEnd('/') - + string.Format("/worker/v1/{0}/{1}", this.ID, this.WorkerPath) - ) - { - Query = this.QueryString(options), - }.Uri; - } - - internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) - { - ParamsBase.AddDefaultHeaders(request, options); - foreach (var item in this.RawHeaderData) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } - - public override int GetHashCode() - { - return 0; - } -} diff --git a/src/Casedev/Models/Worker/V1/V1ProxyGetParams.cs b/src/Casedev/Models/Worker/V1/V1ProxyGetParams.cs deleted file mode 100644 index 8a4b2d25..00000000 --- a/src/Casedev/Models/Worker/V1/V1ProxyGetParams.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System; -using System.Collections.Frozen; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Net.Http; -using System.Text.Json; -using Casedev.Core; - -namespace Casedev.Models.Worker.V1; - -/// -/// Forwards a GET request to the worker runtime without translating response or -/// SSE event shapes. -/// -/// NOTE: Do not inherit from this type outside the SDK unless you're okay with -/// breaking changes in non-major versions. We may add new methods in the future that -/// cause existing derived classes to break. -/// -public record class V1ProxyGetParams : ParamsBase -{ - public required string ID { get; init; } - - public string? WorkerPath { get; init; } - - public V1ProxyGetParams() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - public V1ProxyGetParams(V1ProxyGetParams v1ProxyGetParams) - : base(v1ProxyGetParams) - { - this.ID = v1ProxyGetParams.ID; - this.WorkerPath = v1ProxyGetParams.WorkerPath; - } -#pragma warning restore CS8618 - - public V1ProxyGetParams( - IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData - ) - { - this._rawHeaderData = new(rawHeaderData); - this._rawQueryData = new(rawQueryData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - V1ProxyGetParams( - FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData, - string id, - string workerPath - ) - { - this._rawHeaderData = new(rawHeaderData); - this._rawQueryData = new(rawQueryData); - this.ID = id; - this.WorkerPath = workerPath; - } -#pragma warning restore CS8618 - - /// - public static V1ProxyGetParams FromRawUnchecked( - IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData, - string id, - string workerPath - ) - { - return new( - FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData), - id, - workerPath - ); - } - - public override string ToString() => - JsonSerializer.Serialize( - FriendlyJsonPrinter.PrintValue( - new Dictionary() - { - ["ID"] = JsonSerializer.SerializeToElement(this.ID), - ["WorkerPath"] = JsonSerializer.SerializeToElement(this.WorkerPath), - ["HeaderData"] = FriendlyJsonPrinter.PrintValue( - JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) - ), - ["QueryData"] = FriendlyJsonPrinter.PrintValue( - JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) - ), - } - ), - ModelBase.ToStringSerializerOptions - ); - - public virtual bool Equals(V1ProxyGetParams? other) - { - if (other == null) - { - return false; - } - return this.ID.Equals(other.ID) - && (this.WorkerPath?.Equals(other.WorkerPath) ?? other.WorkerPath == null) - && this._rawHeaderData.Equals(other._rawHeaderData) - && this._rawQueryData.Equals(other._rawQueryData); - } - - public override Uri Url(ClientOptions options) - { - return new UriBuilder( - options.BaseUrl.ToString().TrimEnd('/') - + string.Format("/worker/v1/{0}/{1}", this.ID, this.WorkerPath) - ) - { - Query = this.QueryString(options), - }.Uri; - } - - internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) - { - ParamsBase.AddDefaultHeaders(request, options); - foreach (var item in this.RawHeaderData) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } - - public override int GetHashCode() - { - return 0; - } -} diff --git a/src/Casedev/Models/Worker/V1/V1ProxyPatchParams.cs b/src/Casedev/Models/Worker/V1/V1ProxyPatchParams.cs deleted file mode 100644 index a5c5c32a..00000000 --- a/src/Casedev/Models/Worker/V1/V1ProxyPatchParams.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System; -using System.Collections.Frozen; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Net.Http; -using System.Text.Json; -using Casedev.Core; - -namespace Casedev.Models.Worker.V1; - -/// -/// Forwards a PATCH request to the worker runtime without translating request or -/// response shapes. -/// -/// NOTE: Do not inherit from this type outside the SDK unless you're okay with -/// breaking changes in non-major versions. We may add new methods in the future that -/// cause existing derived classes to break. -/// -public record class V1ProxyPatchParams : ParamsBase -{ - public required string ID { get; init; } - - public string? WorkerPath { get; init; } - - public V1ProxyPatchParams() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - public V1ProxyPatchParams(V1ProxyPatchParams v1ProxyPatchParams) - : base(v1ProxyPatchParams) - { - this.ID = v1ProxyPatchParams.ID; - this.WorkerPath = v1ProxyPatchParams.WorkerPath; - } -#pragma warning restore CS8618 - - public V1ProxyPatchParams( - IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData - ) - { - this._rawHeaderData = new(rawHeaderData); - this._rawQueryData = new(rawQueryData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - V1ProxyPatchParams( - FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData, - string id, - string workerPath - ) - { - this._rawHeaderData = new(rawHeaderData); - this._rawQueryData = new(rawQueryData); - this.ID = id; - this.WorkerPath = workerPath; - } -#pragma warning restore CS8618 - - /// - public static V1ProxyPatchParams FromRawUnchecked( - IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData, - string id, - string workerPath - ) - { - return new( - FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData), - id, - workerPath - ); - } - - public override string ToString() => - JsonSerializer.Serialize( - FriendlyJsonPrinter.PrintValue( - new Dictionary() - { - ["ID"] = JsonSerializer.SerializeToElement(this.ID), - ["WorkerPath"] = JsonSerializer.SerializeToElement(this.WorkerPath), - ["HeaderData"] = FriendlyJsonPrinter.PrintValue( - JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) - ), - ["QueryData"] = FriendlyJsonPrinter.PrintValue( - JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) - ), - } - ), - ModelBase.ToStringSerializerOptions - ); - - public virtual bool Equals(V1ProxyPatchParams? other) - { - if (other == null) - { - return false; - } - return this.ID.Equals(other.ID) - && (this.WorkerPath?.Equals(other.WorkerPath) ?? other.WorkerPath == null) - && this._rawHeaderData.Equals(other._rawHeaderData) - && this._rawQueryData.Equals(other._rawQueryData); - } - - public override Uri Url(ClientOptions options) - { - return new UriBuilder( - options.BaseUrl.ToString().TrimEnd('/') - + string.Format("/worker/v1/{0}/{1}", this.ID, this.WorkerPath) - ) - { - Query = this.QueryString(options), - }.Uri; - } - - internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) - { - ParamsBase.AddDefaultHeaders(request, options); - foreach (var item in this.RawHeaderData) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } - - public override int GetHashCode() - { - return 0; - } -} diff --git a/src/Casedev/Models/Worker/V1/V1ProxyPostParams.cs b/src/Casedev/Models/Worker/V1/V1ProxyPostParams.cs deleted file mode 100644 index 585a2a09..00000000 --- a/src/Casedev/Models/Worker/V1/V1ProxyPostParams.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System; -using System.Collections.Frozen; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Net.Http; -using System.Text.Json; -using Casedev.Core; - -namespace Casedev.Models.Worker.V1; - -/// -/// Forwards a POST request to the worker runtime without translating request, response, -/// or SSE event shapes. -/// -/// NOTE: Do not inherit from this type outside the SDK unless you're okay with -/// breaking changes in non-major versions. We may add new methods in the future that -/// cause existing derived classes to break. -/// -public record class V1ProxyPostParams : ParamsBase -{ - public required string ID { get; init; } - - public string? WorkerPath { get; init; } - - public V1ProxyPostParams() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - public V1ProxyPostParams(V1ProxyPostParams v1ProxyPostParams) - : base(v1ProxyPostParams) - { - this.ID = v1ProxyPostParams.ID; - this.WorkerPath = v1ProxyPostParams.WorkerPath; - } -#pragma warning restore CS8618 - - public V1ProxyPostParams( - IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData - ) - { - this._rawHeaderData = new(rawHeaderData); - this._rawQueryData = new(rawQueryData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - V1ProxyPostParams( - FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData, - string id, - string workerPath - ) - { - this._rawHeaderData = new(rawHeaderData); - this._rawQueryData = new(rawQueryData); - this.ID = id; - this.WorkerPath = workerPath; - } -#pragma warning restore CS8618 - - /// - public static V1ProxyPostParams FromRawUnchecked( - IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData, - string id, - string workerPath - ) - { - return new( - FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData), - id, - workerPath - ); - } - - public override string ToString() => - JsonSerializer.Serialize( - FriendlyJsonPrinter.PrintValue( - new Dictionary() - { - ["ID"] = JsonSerializer.SerializeToElement(this.ID), - ["WorkerPath"] = JsonSerializer.SerializeToElement(this.WorkerPath), - ["HeaderData"] = FriendlyJsonPrinter.PrintValue( - JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) - ), - ["QueryData"] = FriendlyJsonPrinter.PrintValue( - JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) - ), - } - ), - ModelBase.ToStringSerializerOptions - ); - - public virtual bool Equals(V1ProxyPostParams? other) - { - if (other == null) - { - return false; - } - return this.ID.Equals(other.ID) - && (this.WorkerPath?.Equals(other.WorkerPath) ?? other.WorkerPath == null) - && this._rawHeaderData.Equals(other._rawHeaderData) - && this._rawQueryData.Equals(other._rawQueryData); - } - - public override Uri Url(ClientOptions options) - { - return new UriBuilder( - options.BaseUrl.ToString().TrimEnd('/') - + string.Format("/worker/v1/{0}/{1}", this.ID, this.WorkerPath) - ) - { - Query = this.QueryString(options), - }.Uri; - } - - internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) - { - ParamsBase.AddDefaultHeaders(request, options); - foreach (var item in this.RawHeaderData) - { - ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); - } - } - - public override int GetHashCode() - { - return 0; - } -} diff --git a/src/Casedev/Services/IWorkerService.cs b/src/Casedev/Services/Agent/ISkillService.cs similarity index 59% rename from src/Casedev/Services/IWorkerService.cs rename to src/Casedev/Services/Agent/ISkillService.cs index d0451b48..58ee801f 100644 --- a/src/Casedev/Services/IWorkerService.cs +++ b/src/Casedev/Services/Agent/ISkillService.cs @@ -1,44 +1,44 @@ using System; using Casedev.Core; -using Casedev.Services.Worker; +using Casedev.Services.Agent.Skills; -namespace Casedev.Services; +namespace Casedev.Services.Agent; /// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking /// changes in non-major versions. We may add new methods in the future that cause /// existing derived classes to break. /// -public interface IWorkerService +public interface ISkillService { /// /// Returns a view of this service that provides access to raw HTTP responses /// for each method. /// - IWorkerServiceWithRawResponse WithRawResponse { get; } + ISkillServiceWithRawResponse WithRawResponse { get; } /// /// Returns a view of this service with the given option modifications applied. /// /// The original service is not modified. /// - IWorkerService WithOptions(Func modifier); + ISkillService WithOptions(Func modifier); - IV1Service V1 { get; } + INamespaceService Namespaces { get; } } /// -/// A view of that provides access to raw +/// A view of that provides access to raw /// HTTP responses for each method. /// -public interface IWorkerServiceWithRawResponse +public interface ISkillServiceWithRawResponse { /// /// Returns a view of this service with the given option modifications applied. /// /// The original service is not modified. /// - IWorkerServiceWithRawResponse WithOptions(Func modifier); + ISkillServiceWithRawResponse WithOptions(Func modifier); - IV1ServiceWithRawResponse V1 { get; } + INamespaceServiceWithRawResponse Namespaces { get; } } diff --git a/src/Casedev/Services/Agent/SkillService.cs b/src/Casedev/Services/Agent/SkillService.cs new file mode 100644 index 00000000..3178e819 --- /dev/null +++ b/src/Casedev/Services/Agent/SkillService.cs @@ -0,0 +1,64 @@ +using System; +using Casedev.Core; +using Casedev.Services.Agent.Skills; + +namespace Casedev.Services.Agent; + +/// +public sealed class SkillService : ISkillService +{ + readonly Lazy _withRawResponse; + + /// + public ISkillServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly ICasedevClient _client; + + /// + public ISkillService WithOptions(Func modifier) + { + return new SkillService(this._client.WithOptions(modifier)); + } + + public SkillService(ICasedevClient client) + { + _client = client; + + _withRawResponse = new(() => new SkillServiceWithRawResponse(client.WithRawResponse)); + _namespaces = new(() => new NamespaceService(client)); + } + + readonly Lazy _namespaces; + public INamespaceService Namespaces + { + get { return _namespaces.Value; } + } +} + +/// +public sealed class SkillServiceWithRawResponse : ISkillServiceWithRawResponse +{ + readonly ICasedevClientWithRawResponse _client; + + /// + public ISkillServiceWithRawResponse WithOptions(Func modifier) + { + return new SkillServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public SkillServiceWithRawResponse(ICasedevClientWithRawResponse client) + { + _client = client; + + _namespaces = new(() => new NamespaceServiceWithRawResponse(client)); + } + + readonly Lazy _namespaces; + public INamespaceServiceWithRawResponse Namespaces + { + get { return _namespaces.Value; } + } +} diff --git a/src/Casedev/Services/Agent/Skills/INamespaceService.cs b/src/Casedev/Services/Agent/Skills/INamespaceService.cs new file mode 100644 index 00000000..ff1ac8dd --- /dev/null +++ b/src/Casedev/Services/Agent/Skills/INamespaceService.cs @@ -0,0 +1,227 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Casedev.Core; +using Casedev.Models.Agent.Skills.Namespaces; + +namespace Casedev.Services.Agent.Skills; + +/// +/// Create, manage, and execute AI agents with tool access, sandbox environments, +/// and async run workflows +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public interface INamespaceService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + INamespaceServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + INamespaceService WithOptions(Func modifier); + + /// + /// Create a private skill namespace owned by the authenticated org and receive a + /// one-time bearer token used by the case-skills publisher. + /// + Task Create(NamespaceCreateParams parameters, CancellationToken cancellationToken = default); + + /// + /// Read skill namespace + /// + Task Retrieve( + NamespaceRetrieveParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Retrieve( + string id, + NamespaceRetrieveParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// List all active skill namespaces owned by the authenticated organization. + /// + Task List( + NamespaceListParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// Delete skill namespace + /// + Task Delete(NamespaceDeleteParams parameters, CancellationToken cancellationToken = default); + + /// + Task Delete( + string id, + NamespaceDeleteParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// Upload a tree of skill files for the namespace. Authenticated by the namespace + /// bearer token. Atomic at the version-bump level: a partial upload leaves the + /// namespace pinned to the previous version. + /// + Task Publish(NamespacePublishParams parameters, CancellationToken cancellationToken = default); + + /// + Task Publish( + string id, + NamespacePublishParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns the active version's file manifest with short-lived presigned S3 URLs. + /// Sandboxes use this to materialize the tree at /workspace/.agents/skills/ before + /// opencode boots. + /// + Task Pull(NamespacePullParams parameters, CancellationToken cancellationToken = default); + + /// + Task Pull( + string id, + NamespacePullParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// Rotate skill namespace token + /// + Task RotateToken( + NamespaceRotateTokenParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task RotateToken( + string id, + NamespaceRotateTokenParams? parameters = null, + CancellationToken cancellationToken = default + ); +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface INamespaceServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + INamespaceServiceWithRawResponse WithOptions(Func modifier); + + /// + /// Returns a raw HTTP response for post /agent/skills/namespaces, but is otherwise the + /// same as . + /// + Task Create( + NamespaceCreateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for get /agent/skills/namespaces/{id}, but is otherwise the + /// same as . + /// + Task Retrieve( + NamespaceRetrieveParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Retrieve( + string id, + NamespaceRetrieveParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for get /agent/skills/namespaces, but is otherwise the + /// same as . + /// + Task List( + NamespaceListParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for delete /agent/skills/namespaces/{id}, but is otherwise the + /// same as . + /// + Task Delete( + NamespaceDeleteParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Delete( + string id, + NamespaceDeleteParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for post /agent/skills/namespaces/{id}/publish, but is otherwise the + /// same as . + /// + Task Publish( + NamespacePublishParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Publish( + string id, + NamespacePublishParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for get /agent/skills/namespaces/{id}/pull, but is otherwise the + /// same as . + /// + Task Pull( + NamespacePullParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Pull( + string id, + NamespacePullParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for post /agent/skills/namespaces/{id}/rotate-token, but is otherwise the + /// same as . + /// + Task RotateToken( + NamespaceRotateTokenParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task RotateToken( + string id, + NamespaceRotateTokenParams? parameters = null, + CancellationToken cancellationToken = default + ); +} diff --git a/src/Casedev/Services/Agent/Skills/NamespaceService.cs b/src/Casedev/Services/Agent/Skills/NamespaceService.cs new file mode 100644 index 00000000..08c10966 --- /dev/null +++ b/src/Casedev/Services/Agent/Skills/NamespaceService.cs @@ -0,0 +1,355 @@ +using System; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Casedev.Core; +using Casedev.Exceptions; +using Casedev.Models.Agent.Skills.Namespaces; + +namespace Casedev.Services.Agent.Skills; + +/// +public sealed class NamespaceService : INamespaceService +{ + readonly Lazy _withRawResponse; + + /// + public INamespaceServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly ICasedevClient _client; + + /// + public INamespaceService WithOptions(Func modifier) + { + return new NamespaceService(this._client.WithOptions(modifier)); + } + + public NamespaceService(ICasedevClient client) + { + _client = client; + + _withRawResponse = new(() => new NamespaceServiceWithRawResponse(client.WithRawResponse)); + } + + /// + public Task Create( + NamespaceCreateParams parameters, + CancellationToken cancellationToken = default + ) + { + return this.WithRawResponse.Create(parameters, cancellationToken); + } + + /// + public Task Retrieve( + NamespaceRetrieveParams parameters, + CancellationToken cancellationToken = default + ) + { + return this.WithRawResponse.Retrieve(parameters, cancellationToken); + } + + /// + public async Task Retrieve( + string id, + NamespaceRetrieveParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + await this.Retrieve(parameters with { ID = id }, cancellationToken).ConfigureAwait(false); + } + + /// + public Task List( + NamespaceListParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + return this.WithRawResponse.List(parameters, cancellationToken); + } + + /// + public Task Delete( + NamespaceDeleteParams parameters, + CancellationToken cancellationToken = default + ) + { + return this.WithRawResponse.Delete(parameters, cancellationToken); + } + + /// + public async Task Delete( + string id, + NamespaceDeleteParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + await this.Delete(parameters with { ID = id }, cancellationToken).ConfigureAwait(false); + } + + /// + public Task Publish( + NamespacePublishParams parameters, + CancellationToken cancellationToken = default + ) + { + return this.WithRawResponse.Publish(parameters, cancellationToken); + } + + /// + public async Task Publish( + string id, + NamespacePublishParams parameters, + CancellationToken cancellationToken = default + ) + { + await this.Publish(parameters with { ID = id }, cancellationToken).ConfigureAwait(false); + } + + /// + public Task Pull(NamespacePullParams parameters, CancellationToken cancellationToken = default) + { + return this.WithRawResponse.Pull(parameters, cancellationToken); + } + + /// + public async Task Pull( + string id, + NamespacePullParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + await this.Pull(parameters with { ID = id }, cancellationToken).ConfigureAwait(false); + } + + /// + public Task RotateToken( + NamespaceRotateTokenParams parameters, + CancellationToken cancellationToken = default + ) + { + return this.WithRawResponse.RotateToken(parameters, cancellationToken); + } + + /// + public async Task RotateToken( + string id, + NamespaceRotateTokenParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + await this.RotateToken(parameters with { ID = id }, cancellationToken) + .ConfigureAwait(false); + } +} + +/// +public sealed class NamespaceServiceWithRawResponse : INamespaceServiceWithRawResponse +{ + readonly ICasedevClientWithRawResponse _client; + + /// + public INamespaceServiceWithRawResponse WithOptions(Func modifier) + { + return new NamespaceServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public NamespaceServiceWithRawResponse(ICasedevClientWithRawResponse client) + { + _client = client; + } + + /// + public Task Create( + NamespaceCreateParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + return this._client.Execute(request, cancellationToken); + } + + /// + public Task Retrieve( + NamespaceRetrieveParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.ID == null) + { + throw new CasedevInvalidDataException("'parameters.ID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + return this._client.Execute(request, cancellationToken); + } + + /// + public Task Retrieve( + string id, + NamespaceRetrieveParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Retrieve(parameters with { ID = id }, cancellationToken); + } + + /// + public Task List( + NamespaceListParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + return this._client.Execute(request, cancellationToken); + } + + /// + public Task Delete( + NamespaceDeleteParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.ID == null) + { + throw new CasedevInvalidDataException("'parameters.ID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Delete, + Params = parameters, + }; + return this._client.Execute(request, cancellationToken); + } + + /// + public Task Delete( + string id, + NamespaceDeleteParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Delete(parameters with { ID = id }, cancellationToken); + } + + /// + public Task Publish( + NamespacePublishParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.ID == null) + { + throw new CasedevInvalidDataException("'parameters.ID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + return this._client.Execute(request, cancellationToken); + } + + /// + public Task Publish( + string id, + NamespacePublishParams parameters, + CancellationToken cancellationToken = default + ) + { + return this.Publish(parameters with { ID = id }, cancellationToken); + } + + /// + public Task Pull( + NamespacePullParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.ID == null) + { + throw new CasedevInvalidDataException("'parameters.ID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + return this._client.Execute(request, cancellationToken); + } + + /// + public Task Pull( + string id, + NamespacePullParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Pull(parameters with { ID = id }, cancellationToken); + } + + /// + public Task RotateToken( + NamespaceRotateTokenParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.ID == null) + { + throw new CasedevInvalidDataException("'parameters.ID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + return this._client.Execute(request, cancellationToken); + } + + /// + public Task RotateToken( + string id, + NamespaceRotateTokenParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.RotateToken(parameters with { ID = id }, cancellationToken); + } +} diff --git a/src/Casedev/Services/AgentService.cs b/src/Casedev/Services/AgentService.cs index a695181c..3371d5ad 100644 --- a/src/Casedev/Services/AgentService.cs +++ b/src/Casedev/Services/AgentService.cs @@ -1,6 +1,6 @@ using System; using Casedev.Core; -using Casedev.Services.Agent; +using Agent = Casedev.Services.Agent; namespace Casedev.Services; @@ -28,11 +28,18 @@ public AgentService(ICasedevClient client) _client = client; _withRawResponse = new(() => new AgentServiceWithRawResponse(client.WithRawResponse)); - _v1 = new(() => new V1Service(client)); + _skills = new(() => new Agent::SkillService(client)); + _v1 = new(() => new Agent::V1Service(client)); } - readonly Lazy _v1; - public IV1Service V1 + readonly Lazy _skills; + public Agent::ISkillService Skills + { + get { return _skills.Value; } + } + + readonly Lazy _v1; + public Agent::IV1Service V1 { get { return _v1.Value; } } @@ -53,11 +60,18 @@ public AgentServiceWithRawResponse(ICasedevClientWithRawResponse client) { _client = client; - _v1 = new(() => new V1ServiceWithRawResponse(client)); + _skills = new(() => new Agent::SkillServiceWithRawResponse(client)); + _v1 = new(() => new Agent::V1ServiceWithRawResponse(client)); + } + + readonly Lazy _skills; + public Agent::ISkillServiceWithRawResponse Skills + { + get { return _skills.Value; } } - readonly Lazy _v1; - public IV1ServiceWithRawResponse V1 + readonly Lazy _v1; + public Agent::IV1ServiceWithRawResponse V1 { get { return _v1.Value; } } diff --git a/src/Casedev/Services/Compute/V1/IInstanceService.cs b/src/Casedev/Services/Compute/V1/IInstanceService.cs index b9e990f5..bfb37186 100644 --- a/src/Casedev/Services/Compute/V1/IInstanceService.cs +++ b/src/Casedev/Services/Compute/V1/IInstanceService.cs @@ -30,9 +30,9 @@ public interface IInstanceService /// /// Launches a new GPU compute instance with automatic SSH key generation. Supports - /// mounting Case.dev Vaults as filesystems and configurable auto-shutdown. Instance - /// boots in ~2-5 minutes. Perfect for batch OCR processing, AI model training, and - /// intensive document analysis workloads. + /// mounting Case.dev Vaults as filesystems. Instance boots in ~2-5 minutes. Perfect + /// for batch OCR processing, AI model training, and intensive document analysis + /// workloads. /// Task Create( InstanceCreateParams parameters, @@ -58,9 +58,8 @@ Task Retrieve( /// /// Retrieves all GPU compute instances for your organization with real-time status - /// updates from Lambda Labs. Includes pricing, runtime metrics, and auto-shutdown - /// configuration. Perfect for monitoring AI workloads, document processing jobs, - /// and cost tracking. + /// updates from Lambda Labs. Includes pricing and runtime metrics. Perfect for + /// monitoring AI workloads, document processing jobs, and cost tracking. /// Task List( InstanceListParams? parameters = null, diff --git a/src/Casedev/Services/IAgentService.cs b/src/Casedev/Services/IAgentService.cs index 88869274..96b2a1cf 100644 --- a/src/Casedev/Services/IAgentService.cs +++ b/src/Casedev/Services/IAgentService.cs @@ -1,6 +1,6 @@ using System; using Casedev.Core; -using Casedev.Services.Agent; +using Agent = Casedev.Services.Agent; namespace Casedev.Services; @@ -24,7 +24,9 @@ public interface IAgentService /// IAgentService WithOptions(Func modifier); - IV1Service V1 { get; } + Agent::ISkillService Skills { get; } + + Agent::IV1Service V1 { get; } } /// @@ -40,5 +42,7 @@ public interface IAgentServiceWithRawResponse /// IAgentServiceWithRawResponse WithOptions(Func modifier); - IV1ServiceWithRawResponse V1 { get; } + Agent::ISkillServiceWithRawResponse Skills { get; } + + Agent::IV1ServiceWithRawResponse V1 { get; } } diff --git a/src/Casedev/Services/Worker/IV1Service.cs b/src/Casedev/Services/Worker/IV1Service.cs deleted file mode 100644 index cfefd48e..00000000 --- a/src/Casedev/Services/Worker/IV1Service.cs +++ /dev/null @@ -1,285 +0,0 @@ -using System; -using System.Threading; -using System.Threading.Tasks; -using Casedev.Core; -using Casedev.Models.Worker.V1; - -namespace Casedev.Services.Worker; - -/// -/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking -/// changes in non-major versions. We may add new methods in the future that cause -/// existing derived classes to break. -/// -public interface IV1Service -{ - /// - /// Returns a view of this service that provides access to raw HTTP responses - /// for each method. - /// - IV1ServiceWithRawResponse WithRawResponse { get; } - - /// - /// Returns a view of this service with the given option modifications applied. - /// - /// The original service is not modified. - /// - IV1Service WithOptions(Func modifier); - - /// - /// Creates a Daytona-backed worker runtime. The worker exposes its native runtime - /// API through /worker/v1/:id/* without reshaping payloads or events. - /// - Task Create(V1CreateParams? parameters = null, CancellationToken cancellationToken = default); - - /// - /// Get worker - /// - Task Retrieve(V1RetrieveParams parameters, CancellationToken cancellationToken = default); - - /// - Task Retrieve( - string id, - V1RetrieveParams? parameters = null, - CancellationToken cancellationToken = default - ); - - /// - /// End worker - /// - Task Delete(V1DeleteParams parameters, CancellationToken cancellationToken = default); - - /// - Task Delete( - string id, - V1DeleteParams? parameters = null, - CancellationToken cancellationToken = default - ); - - /// - /// Starts or resumes the worker sandbox and OpenCode server. Native - /// /worker/v1/:id/* proxy routes require this lifecycle primitive to have completed - /// first. - /// - Task Boot(V1BootParams parameters, CancellationToken cancellationToken = default); - - /// - Task Boot( - string id, - V1BootParams? parameters = null, - CancellationToken cancellationToken = default - ); - - /// - /// Forwards a DELETE request to the worker runtime without translating response - /// shapes. - /// - Task ProxyDelete(V1ProxyDeleteParams parameters, CancellationToken cancellationToken = default); - - /// - Task ProxyDelete( - string workerPath, - V1ProxyDeleteParams parameters, - CancellationToken cancellationToken = default - ); - - /// - /// Forwards a GET request to the worker runtime without translating response or SSE - /// event shapes. - /// - Task ProxyGet(V1ProxyGetParams parameters, CancellationToken cancellationToken = default); - - /// - Task ProxyGet( - string workerPath, - V1ProxyGetParams parameters, - CancellationToken cancellationToken = default - ); - - /// - /// Forwards a PATCH request to the worker runtime without translating request or - /// response shapes. - /// - Task ProxyPatch(V1ProxyPatchParams parameters, CancellationToken cancellationToken = default); - - /// - Task ProxyPatch( - string workerPath, - V1ProxyPatchParams parameters, - CancellationToken cancellationToken = default - ); - - /// - /// Forwards a POST request to the worker runtime without translating request, - /// response, or SSE event shapes. - /// - Task ProxyPost(V1ProxyPostParams parameters, CancellationToken cancellationToken = default); - - /// - Task ProxyPost( - string workerPath, - V1ProxyPostParams parameters, - CancellationToken cancellationToken = default - ); - - /// - /// Forwards a PUT request to the worker runtime without translating request or - /// response shapes. - /// - Task ProxyPut(V1ProxyPutParams parameters, CancellationToken cancellationToken = default); - - /// - Task ProxyPut( - string workerPath, - V1ProxyPutParams parameters, - CancellationToken cancellationToken = default - ); -} - -/// -/// A view of that provides access to raw -/// HTTP responses for each method. -/// -public interface IV1ServiceWithRawResponse -{ - /// - /// Returns a view of this service with the given option modifications applied. - /// - /// The original service is not modified. - /// - IV1ServiceWithRawResponse WithOptions(Func modifier); - - /// - /// Returns a raw HTTP response for post /worker/v1, but is otherwise the - /// same as . - /// - Task Create( - V1CreateParams? parameters = null, - CancellationToken cancellationToken = default - ); - - /// - /// Returns a raw HTTP response for get /worker/v1/{id}, but is otherwise the - /// same as . - /// - Task Retrieve( - V1RetrieveParams parameters, - CancellationToken cancellationToken = default - ); - - /// - Task Retrieve( - string id, - V1RetrieveParams? parameters = null, - CancellationToken cancellationToken = default - ); - - /// - /// Returns a raw HTTP response for delete /worker/v1/{id}, but is otherwise the - /// same as . - /// - Task Delete( - V1DeleteParams parameters, - CancellationToken cancellationToken = default - ); - - /// - Task Delete( - string id, - V1DeleteParams? parameters = null, - CancellationToken cancellationToken = default - ); - - /// - /// Returns a raw HTTP response for post /worker/v1/{id}/boot, but is otherwise the - /// same as . - /// - Task Boot(V1BootParams parameters, CancellationToken cancellationToken = default); - - /// - Task Boot( - string id, - V1BootParams? parameters = null, - CancellationToken cancellationToken = default - ); - - /// - /// Returns a raw HTTP response for delete /worker/v1/{id}/{workerPath}, but is otherwise the - /// same as . - /// - Task ProxyDelete( - V1ProxyDeleteParams parameters, - CancellationToken cancellationToken = default - ); - - /// - Task ProxyDelete( - string workerPath, - V1ProxyDeleteParams parameters, - CancellationToken cancellationToken = default - ); - - /// - /// Returns a raw HTTP response for get /worker/v1/{id}/{workerPath}, but is otherwise the - /// same as . - /// - Task ProxyGet( - V1ProxyGetParams parameters, - CancellationToken cancellationToken = default - ); - - /// - Task ProxyGet( - string workerPath, - V1ProxyGetParams parameters, - CancellationToken cancellationToken = default - ); - - /// - /// Returns a raw HTTP response for patch /worker/v1/{id}/{workerPath}, but is otherwise the - /// same as . - /// - Task ProxyPatch( - V1ProxyPatchParams parameters, - CancellationToken cancellationToken = default - ); - - /// - Task ProxyPatch( - string workerPath, - V1ProxyPatchParams parameters, - CancellationToken cancellationToken = default - ); - - /// - /// Returns a raw HTTP response for post /worker/v1/{id}/{workerPath}, but is otherwise the - /// same as . - /// - Task ProxyPost( - V1ProxyPostParams parameters, - CancellationToken cancellationToken = default - ); - - /// - Task ProxyPost( - string workerPath, - V1ProxyPostParams parameters, - CancellationToken cancellationToken = default - ); - - /// - /// Returns a raw HTTP response for put /worker/v1/{id}/{workerPath}, but is otherwise the - /// same as . - /// - Task ProxyPut( - V1ProxyPutParams parameters, - CancellationToken cancellationToken = default - ); - - /// - Task ProxyPut( - string workerPath, - V1ProxyPutParams parameters, - CancellationToken cancellationToken = default - ); -} diff --git a/src/Casedev/Services/Worker/V1Service.cs b/src/Casedev/Services/Worker/V1Service.cs deleted file mode 100644 index 8b66d950..00000000 --- a/src/Casedev/Services/Worker/V1Service.cs +++ /dev/null @@ -1,460 +0,0 @@ -using System; -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; -using Casedev.Core; -using Casedev.Exceptions; -using Casedev.Models.Worker.V1; - -namespace Casedev.Services.Worker; - -/// -public sealed class V1Service : IV1Service -{ - readonly Lazy _withRawResponse; - - /// - public IV1ServiceWithRawResponse WithRawResponse - { - get { return _withRawResponse.Value; } - } - - readonly ICasedevClient _client; - - /// - public IV1Service WithOptions(Func modifier) - { - return new V1Service(this._client.WithOptions(modifier)); - } - - public V1Service(ICasedevClient client) - { - _client = client; - - _withRawResponse = new(() => new V1ServiceWithRawResponse(client.WithRawResponse)); - } - - /// - public Task Create( - V1CreateParams? parameters = null, - CancellationToken cancellationToken = default - ) - { - return this.WithRawResponse.Create(parameters, cancellationToken); - } - - /// - public Task Retrieve(V1RetrieveParams parameters, CancellationToken cancellationToken = default) - { - return this.WithRawResponse.Retrieve(parameters, cancellationToken); - } - - /// - public async Task Retrieve( - string id, - V1RetrieveParams? parameters = null, - CancellationToken cancellationToken = default - ) - { - parameters ??= new(); - - await this.Retrieve(parameters with { ID = id }, cancellationToken).ConfigureAwait(false); - } - - /// - public Task Delete(V1DeleteParams parameters, CancellationToken cancellationToken = default) - { - return this.WithRawResponse.Delete(parameters, cancellationToken); - } - - /// - public async Task Delete( - string id, - V1DeleteParams? parameters = null, - CancellationToken cancellationToken = default - ) - { - parameters ??= new(); - - await this.Delete(parameters with { ID = id }, cancellationToken).ConfigureAwait(false); - } - - /// - public Task Boot(V1BootParams parameters, CancellationToken cancellationToken = default) - { - return this.WithRawResponse.Boot(parameters, cancellationToken); - } - - /// - public async Task Boot( - string id, - V1BootParams? parameters = null, - CancellationToken cancellationToken = default - ) - { - parameters ??= new(); - - await this.Boot(parameters with { ID = id }, cancellationToken).ConfigureAwait(false); - } - - /// - public Task ProxyDelete( - V1ProxyDeleteParams parameters, - CancellationToken cancellationToken = default - ) - { - return this.WithRawResponse.ProxyDelete(parameters, cancellationToken); - } - - /// - public async Task ProxyDelete( - string workerPath, - V1ProxyDeleteParams parameters, - CancellationToken cancellationToken = default - ) - { - await this.ProxyDelete(parameters with { WorkerPath = workerPath }, cancellationToken) - .ConfigureAwait(false); - } - - /// - public Task ProxyGet(V1ProxyGetParams parameters, CancellationToken cancellationToken = default) - { - return this.WithRawResponse.ProxyGet(parameters, cancellationToken); - } - - /// - public async Task ProxyGet( - string workerPath, - V1ProxyGetParams parameters, - CancellationToken cancellationToken = default - ) - { - await this.ProxyGet(parameters with { WorkerPath = workerPath }, cancellationToken) - .ConfigureAwait(false); - } - - /// - public Task ProxyPatch( - V1ProxyPatchParams parameters, - CancellationToken cancellationToken = default - ) - { - return this.WithRawResponse.ProxyPatch(parameters, cancellationToken); - } - - /// - public async Task ProxyPatch( - string workerPath, - V1ProxyPatchParams parameters, - CancellationToken cancellationToken = default - ) - { - await this.ProxyPatch(parameters with { WorkerPath = workerPath }, cancellationToken) - .ConfigureAwait(false); - } - - /// - public Task ProxyPost( - V1ProxyPostParams parameters, - CancellationToken cancellationToken = default - ) - { - return this.WithRawResponse.ProxyPost(parameters, cancellationToken); - } - - /// - public async Task ProxyPost( - string workerPath, - V1ProxyPostParams parameters, - CancellationToken cancellationToken = default - ) - { - await this.ProxyPost(parameters with { WorkerPath = workerPath }, cancellationToken) - .ConfigureAwait(false); - } - - /// - public Task ProxyPut(V1ProxyPutParams parameters, CancellationToken cancellationToken = default) - { - return this.WithRawResponse.ProxyPut(parameters, cancellationToken); - } - - /// - public async Task ProxyPut( - string workerPath, - V1ProxyPutParams parameters, - CancellationToken cancellationToken = default - ) - { - await this.ProxyPut(parameters with { WorkerPath = workerPath }, cancellationToken) - .ConfigureAwait(false); - } -} - -/// -public sealed class V1ServiceWithRawResponse : IV1ServiceWithRawResponse -{ - readonly ICasedevClientWithRawResponse _client; - - /// - public IV1ServiceWithRawResponse WithOptions(Func modifier) - { - return new V1ServiceWithRawResponse(this._client.WithOptions(modifier)); - } - - public V1ServiceWithRawResponse(ICasedevClientWithRawResponse client) - { - _client = client; - } - - /// - public Task Create( - V1CreateParams? parameters = null, - CancellationToken cancellationToken = default - ) - { - parameters ??= new(); - - HttpRequest request = new() - { - Method = HttpMethod.Post, - Params = parameters, - }; - return this._client.Execute(request, cancellationToken); - } - - /// - public Task Retrieve( - V1RetrieveParams parameters, - CancellationToken cancellationToken = default - ) - { - if (parameters.ID == null) - { - throw new CasedevInvalidDataException("'parameters.ID' cannot be null"); - } - - HttpRequest request = new() - { - Method = HttpMethod.Get, - Params = parameters, - }; - return this._client.Execute(request, cancellationToken); - } - - /// - public Task Retrieve( - string id, - V1RetrieveParams? parameters = null, - CancellationToken cancellationToken = default - ) - { - parameters ??= new(); - - return this.Retrieve(parameters with { ID = id }, cancellationToken); - } - - /// - public Task Delete( - V1DeleteParams parameters, - CancellationToken cancellationToken = default - ) - { - if (parameters.ID == null) - { - throw new CasedevInvalidDataException("'parameters.ID' cannot be null"); - } - - HttpRequest request = new() - { - Method = HttpMethod.Delete, - Params = parameters, - }; - return this._client.Execute(request, cancellationToken); - } - - /// - public Task Delete( - string id, - V1DeleteParams? parameters = null, - CancellationToken cancellationToken = default - ) - { - parameters ??= new(); - - return this.Delete(parameters with { ID = id }, cancellationToken); - } - - /// - public Task Boot( - V1BootParams parameters, - CancellationToken cancellationToken = default - ) - { - if (parameters.ID == null) - { - throw new CasedevInvalidDataException("'parameters.ID' cannot be null"); - } - - HttpRequest request = new() { Method = HttpMethod.Post, Params = parameters }; - return this._client.Execute(request, cancellationToken); - } - - /// - public Task Boot( - string id, - V1BootParams? parameters = null, - CancellationToken cancellationToken = default - ) - { - parameters ??= new(); - - return this.Boot(parameters with { ID = id }, cancellationToken); - } - - /// - public Task ProxyDelete( - V1ProxyDeleteParams parameters, - CancellationToken cancellationToken = default - ) - { - if (parameters.WorkerPath == null) - { - throw new CasedevInvalidDataException("'parameters.WorkerPath' cannot be null"); - } - - HttpRequest request = new() - { - Method = HttpMethod.Delete, - Params = parameters, - }; - return this._client.Execute(request, cancellationToken); - } - - /// - public Task ProxyDelete( - string workerPath, - V1ProxyDeleteParams parameters, - CancellationToken cancellationToken = default - ) - { - return this.ProxyDelete(parameters with { WorkerPath = workerPath }, cancellationToken); - } - - /// - public Task ProxyGet( - V1ProxyGetParams parameters, - CancellationToken cancellationToken = default - ) - { - if (parameters.WorkerPath == null) - { - throw new CasedevInvalidDataException("'parameters.WorkerPath' cannot be null"); - } - - HttpRequest request = new() - { - Method = HttpMethod.Get, - Params = parameters, - }; - return this._client.Execute(request, cancellationToken); - } - - /// - public Task ProxyGet( - string workerPath, - V1ProxyGetParams parameters, - CancellationToken cancellationToken = default - ) - { - return this.ProxyGet(parameters with { WorkerPath = workerPath }, cancellationToken); - } - - /// - public Task ProxyPatch( - V1ProxyPatchParams parameters, - CancellationToken cancellationToken = default - ) - { - if (parameters.WorkerPath == null) - { - throw new CasedevInvalidDataException("'parameters.WorkerPath' cannot be null"); - } - - HttpRequest request = new() - { - Method = CasedevClientWithRawResponse.PatchMethod, - Params = parameters, - }; - return this._client.Execute(request, cancellationToken); - } - - /// - public Task ProxyPatch( - string workerPath, - V1ProxyPatchParams parameters, - CancellationToken cancellationToken = default - ) - { - return this.ProxyPatch(parameters with { WorkerPath = workerPath }, cancellationToken); - } - - /// - public Task ProxyPost( - V1ProxyPostParams parameters, - CancellationToken cancellationToken = default - ) - { - if (parameters.WorkerPath == null) - { - throw new CasedevInvalidDataException("'parameters.WorkerPath' cannot be null"); - } - - HttpRequest request = new() - { - Method = HttpMethod.Post, - Params = parameters, - }; - return this._client.Execute(request, cancellationToken); - } - - /// - public Task ProxyPost( - string workerPath, - V1ProxyPostParams parameters, - CancellationToken cancellationToken = default - ) - { - return this.ProxyPost(parameters with { WorkerPath = workerPath }, cancellationToken); - } - - /// - public Task ProxyPut( - V1ProxyPutParams parameters, - CancellationToken cancellationToken = default - ) - { - if (parameters.WorkerPath == null) - { - throw new CasedevInvalidDataException("'parameters.WorkerPath' cannot be null"); - } - - HttpRequest request = new() - { - Method = HttpMethod.Put, - Params = parameters, - }; - return this._client.Execute(request, cancellationToken); - } - - /// - public Task ProxyPut( - string workerPath, - V1ProxyPutParams parameters, - CancellationToken cancellationToken = default - ) - { - return this.ProxyPut(parameters with { WorkerPath = workerPath }, cancellationToken); - } -} diff --git a/src/Casedev/Services/WorkerService.cs b/src/Casedev/Services/WorkerService.cs deleted file mode 100644 index c1787ceb..00000000 --- a/src/Casedev/Services/WorkerService.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using Casedev.Core; -using Casedev.Services.Worker; - -namespace Casedev.Services; - -/// -public sealed class WorkerService : IWorkerService -{ - readonly Lazy _withRawResponse; - - /// - public IWorkerServiceWithRawResponse WithRawResponse - { - get { return _withRawResponse.Value; } - } - - readonly ICasedevClient _client; - - /// - public IWorkerService WithOptions(Func modifier) - { - return new WorkerService(this._client.WithOptions(modifier)); - } - - public WorkerService(ICasedevClient client) - { - _client = client; - - _withRawResponse = new(() => new WorkerServiceWithRawResponse(client.WithRawResponse)); - _v1 = new(() => new V1Service(client)); - } - - readonly Lazy _v1; - public IV1Service V1 - { - get { return _v1.Value; } - } -} - -/// -public sealed class WorkerServiceWithRawResponse : IWorkerServiceWithRawResponse -{ - readonly ICasedevClientWithRawResponse _client; - - /// - public IWorkerServiceWithRawResponse WithOptions(Func modifier) - { - return new WorkerServiceWithRawResponse(this._client.WithOptions(modifier)); - } - - public WorkerServiceWithRawResponse(ICasedevClientWithRawResponse client) - { - _client = client; - - _v1 = new(() => new V1ServiceWithRawResponse(client)); - } - - readonly Lazy _v1; - public IV1ServiceWithRawResponse V1 - { - get { return _v1.Value; } - } -}