Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Kiota in the SDKs #5288

Merged
merged 4 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ updates:
directory: "/python-sdk"
schedule:
interval: daily
- package-ecosystem: nuget
directory: "/go-sdk"
schedule:
interval: daily

- package-ecosystem: maven
directory: "/"
Expand Down
4 changes: 2 additions & 2 deletions app/src/test/java/io/apicurio/registry/limits/LimitsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public void testLimits() throws Exception {
Assertions.assertEquals(409, exception1.getResponseStatusCode());

// schema number 3 , exceeds the max number of schemas
var exception2 = Assertions.assertThrows(io.apicurio.registry.rest.client.models.ProblemDetails.class,
() -> {
var exception2 = Assertions.assertThrows(
io.apicurio.registry.rest.client.models.RuleViolationProblemDetails.class, () -> {
CreateArtifact createArtifact = new CreateArtifact();
createArtifact.setArtifactId(artifactId);
createArtifact.setArtifactType(ArtifactType.JSON);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.apicurio.registry.noprofile.rest.v3;

import com.microsoft.kiota.ApiException;
import io.apicurio.registry.AbstractResourceTestBase;
import io.apicurio.registry.rest.client.models.ArtifactSearchResults;
import io.apicurio.registry.rest.client.models.CreateArtifact;
Expand All @@ -10,6 +11,7 @@
import io.apicurio.registry.rest.client.models.IfArtifactExists;
import io.apicurio.registry.rest.client.models.ProblemDetails;
import io.apicurio.registry.rest.client.models.RuleType;
import io.apicurio.registry.rest.client.models.RuleViolationProblemDetails;
import io.apicurio.registry.rest.client.models.VersionMetaData;
import io.apicurio.registry.rest.client.models.VersionSearchResults;
import io.apicurio.registry.rules.validity.ValidityLevel;
Expand Down Expand Up @@ -71,22 +73,23 @@ public void testCreateArtifactDryRun() throws Exception {
ArtifactSearchResults results = clientV3.groups().byGroupId(groupId).artifacts().get();
Assertions.assertEquals(0, results.getCount());
Assertions.assertEquals(0, results.getArtifacts().size());
ProblemDetails error = Assertions.assertThrows(ProblemDetails.class, () -> {
ApiException error = Assertions.assertThrows(ProblemDetails.class, () -> {
clientV3.groups().byGroupId(groupId).artifacts().byArtifactId("valid-artifact").get();
});
Assertions.assertEquals(
"No artifact with ID 'valid-artifact' in group 'testCreateArtifactDryRun' was found.",
error.getTitle());
((ProblemDetails) error).getTitle());

// Dry run: invalid artifact that should NOT be created.
error = Assertions.assertThrows(ProblemDetails.class, () -> {
error = Assertions.assertThrows(RuleViolationProblemDetails.class, () -> {
CreateArtifact ca = TestUtils.clientCreateArtifact("invalid-artifact", ArtifactType.AVRO,
INVALID_SCHEMA, ContentTypes.APPLICATION_JSON);
clientV3.groups().byGroupId(groupId).artifacts().post(ca, config -> {
config.queryParameters.dryRun = true;
});
});
Assertions.assertEquals("Syntax violation for Avro artifact.", error.getTitle());
Assertions.assertEquals("Syntax violation for Avro artifact.",
((RuleViolationProblemDetails) error).getTitle());
Assertions.assertNotNull(car);
Assertions.assertEquals(groupId, car.getArtifact().getGroupId());
Assertions.assertEquals("valid-artifact", car.getArtifact().getArtifactId());
Expand All @@ -101,7 +104,7 @@ public void testCreateArtifactDryRun() throws Exception {
});
Assertions.assertEquals(
"No artifact with ID 'invalid-artifact' in group 'testCreateArtifactDryRun' was found.",
error.getTitle());
((ProblemDetails) error).getTitle());

// Actually create an artifact in the group.
createArtifact(groupId, "actual-artifact", ArtifactType.AVRO, SCHEMA_SIMPLE,
Expand All @@ -111,7 +114,7 @@ public void testCreateArtifactDryRun() throws Exception {
Assertions.assertEquals(1, results.getArtifacts().size());

// DryRun: Try to create the *same* artifact (conflict)
error = Assertions.assertThrows(ProblemDetails.class, () -> {
error = Assertions.assertThrows(RuleViolationProblemDetails.class, () -> {
CreateArtifact ca = TestUtils.clientCreateArtifact("actual-artifact", ArtifactType.AVRO,
SCHEMA_SIMPLE, ContentTypes.APPLICATION_JSON);
clientV3.groups().byGroupId(groupId).artifacts().post(ca, config -> {
Expand All @@ -120,7 +123,7 @@ public void testCreateArtifactDryRun() throws Exception {
});
Assertions.assertEquals(
"An artifact with ID 'actual-artifact' in group 'testCreateArtifactDryRun' already exists.",
error.getTitle());
((RuleViolationProblemDetails) error).getTitle());

// DryRun: Try to create the *same* artifact but with ifExists set (success)
createArtifact = TestUtils.clientCreateArtifact("actual-artifact", ArtifactType.AVRO, SCHEMA_SIMPLE,
Expand Down Expand Up @@ -165,7 +168,7 @@ public void testCreateVersionDryRun() throws Exception {
createArtifact(groupId, artifactId, ArtifactType.AVRO, SCHEMA_SIMPLE, ContentTypes.APPLICATION_JSON);

// DryRun: try to create an invalid version
ProblemDetails error = Assertions.assertThrows(ProblemDetails.class, () -> {
RuleViolationProblemDetails error = Assertions.assertThrows(RuleViolationProblemDetails.class, () -> {
CreateVersion createVersion = TestUtils.clientCreateVersion(INVALID_SCHEMA,
ContentTypes.APPLICATION_JSON);
clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1804,10 +1804,11 @@ public void testCreateArtifactIntegrityRuleViolation() throws Exception {
createVersion.getContent().setReferences(List.of(reference));
CreateVersion f_createVersion = createVersion;

var exception_1 = assertThrows(io.apicurio.registry.rest.client.models.ProblemDetails.class, () -> {
clientV3.groups().byGroupId(GROUP).artifacts().byArtifactId(artifactId).versions()
.post(f_createVersion);
});
var exception_1 = assertThrows(
io.apicurio.registry.rest.client.models.RuleViolationProblemDetails.class, () -> {
clientV3.groups().byGroupId(GROUP).artifacts().byArtifactId(artifactId).versions()
.post(f_createVersion);
});
Assertions.assertEquals(409, exception_1.getStatus());
Assertions.assertEquals("RuleViolationException", exception_1.getName());

Expand All @@ -1830,10 +1831,11 @@ public void testCreateArtifactIntegrityRuleViolation() throws Exception {
createVersion.getContent().setReferences(List.of(validRef, invalidRef));
CreateVersion f_createVersion2 = createVersion;

var exception_2 = assertThrows(io.apicurio.registry.rest.client.models.ProblemDetails.class, () -> {
clientV3.groups().byGroupId(GROUP).artifacts().byArtifactId(artifactId).versions()
.post(f_createVersion2);
});
var exception_2 = assertThrows(
io.apicurio.registry.rest.client.models.RuleViolationProblemDetails.class, () -> {
clientV3.groups().byGroupId(GROUP).artifacts().byArtifactId(artifactId).versions()
.post(f_createVersion2);
});
Assertions.assertEquals(409, exception_2.getStatus());
Assertions.assertEquals("RuleViolationException", exception_2.getName());

Expand All @@ -1843,10 +1845,11 @@ public void testCreateArtifactIntegrityRuleViolation() throws Exception {
createVersion.getContent().setReferences(List.of(validRef, validRef));
CreateVersion f_createVersion3 = createVersion;

var exception_3 = assertThrows(io.apicurio.registry.rest.client.models.ProblemDetails.class, () -> {
clientV3.groups().byGroupId(GROUP).artifacts().byArtifactId(artifactId).versions()
.post(f_createVersion3);
});
var exception_3 = assertThrows(
io.apicurio.registry.rest.client.models.RuleViolationProblemDetails.class, () -> {
clientV3.groups().byGroupId(GROUP).artifacts().byArtifactId(artifactId).versions()
.post(f_createVersion3);
});
Assertions.assertEquals(409, exception_3.getStatus());
Assertions.assertEquals("RuleViolationException", exception_3.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public void testValidityRuleApplication() throws Exception {
clientV3.groups().byGroupId(GroupId.DEFAULT.getRawGroupIdWithDefaultString()).artifacts()
.byArtifactId(artifactId).rules().post(createRule);

var exception = Assertions.assertThrows(io.apicurio.registry.rest.client.models.ProblemDetails.class,
() -> {
var exception = Assertions.assertThrows(
io.apicurio.registry.rest.client.models.RuleViolationProblemDetails.class, () -> {
createArtifactVersion(artifactId, INVALID_SCHEMA, ContentTypes.APPLICATION_JSON);
});
assertEquals("RuleViolationException", exception.getName());
Expand All @@ -91,8 +91,8 @@ public void testValidityRuleApplication_Map() throws Exception {
clientV3.groups().byGroupId(GroupId.DEFAULT.getRawGroupIdWithDefaultString()).artifacts()
.byArtifactId(artifactId).rules().post(createRule);

var exception = Assertions.assertThrows(io.apicurio.registry.rest.client.models.ProblemDetails.class,
() -> {
var exception = Assertions.assertThrows(
io.apicurio.registry.rest.client.models.RuleViolationProblemDetails.class, () -> {
createArtifactVersion(artifactId, INVALID_SCHEMA_WITH_MAP, ContentTypes.APPLICATION_JSON);
});
assertEquals("RuleViolationException", exception.getName());
Expand All @@ -116,8 +116,8 @@ public void testValidityRuleGroupConfig() throws Exception {
clientV3.groups().byGroupId(groupId).rules().post(createRule);

// Try to create an invalid artifact in that group
var exception = Assertions.assertThrows(io.apicurio.registry.rest.client.models.ProblemDetails.class,
() -> {
var exception = Assertions.assertThrows(
io.apicurio.registry.rest.client.models.RuleViolationProblemDetails.class, () -> {
createArtifact(groupId, artifactId, ArtifactType.AVRO, INVALID_SCHEMA,
ContentTypes.APPLICATION_JSON);
});
Expand All @@ -137,8 +137,8 @@ public void testValidityRuleGlobalConfig() throws Exception {
clientV3.admin().rules().post(createRule);

// Try to create an invalid artifact
var exception = Assertions.assertThrows(io.apicurio.registry.rest.client.models.ProblemDetails.class,
() -> {
var exception = Assertions.assertThrows(
io.apicurio.registry.rest.client.models.RuleViolationProblemDetails.class, () -> {
createArtifact(groupId, artifactId, ArtifactType.AVRO, INVALID_SCHEMA,
ContentTypes.APPLICATION_JSON);
});
Expand Down
2 changes: 1 addition & 1 deletion go-sdk/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if [[ $OSTYPE == 'darwin'* ]]; then
fi

# TODO move the kiota-version.csproj to it's own folder?
VERSION=$(cat $SCRIPT_DIR/kiota-version.csproj | grep Version | sed -n 's/.*Version="\([^"]*\)".*/\1/p')
VERSION=$(cat $SCRIPT_DIR/go-sdk.csproj | grep Version | sed -n 's/.*Version="\([^"]*\)".*/\1/p')
URL="https://github.com/microsoft/kiota/releases/download/v${VERSION}/${PACKAGE_NAME}.zip"

# COMMAND="kiota"
Expand Down
12 changes: 12 additions & 0 deletions go-sdk/go-sdk.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>go_sdk</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.OpenApi.Kiota.Builder" Version="1.18.0" />
</ItemGroup>

</Project>
5 changes: 0 additions & 5 deletions go-sdk/kiota-version.csproj

This file was deleted.

6 changes: 6 additions & 0 deletions go-sdk/pkg/registryclient-v2/admin/admin_request_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ type AdminRequestBuilder struct {
}

// ArtifactTypes the list of artifact types supported by this instance of Registry.
// returns a *ArtifactTypesRequestBuilder when successful
func (m *AdminRequestBuilder) ArtifactTypes() *ArtifactTypesRequestBuilder {
return NewArtifactTypesRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter)
}

// Config the config property
// returns a *ConfigRequestBuilder when successful
func (m *AdminRequestBuilder) Config() *ConfigRequestBuilder {
return NewConfigRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter)
}
Expand All @@ -35,21 +37,25 @@ func NewAdminRequestBuilder(rawUrl string, requestAdapter i2ae4187f7daee263371cb
}

// Export provides a way to export registry data.
// returns a *ExportRequestBuilder when successful
func (m *AdminRequestBuilder) Export() *ExportRequestBuilder {
return NewExportRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter)
}

// ImportEscaped provides a way to import data into the registry.
// returns a *ImportRequestBuilder when successful
func (m *AdminRequestBuilder) ImportEscaped() *ImportRequestBuilder {
return NewImportRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter)
}

// RoleMappings collection to manage role mappings for authenticated principals
// returns a *RoleMappingsRequestBuilder when successful
func (m *AdminRequestBuilder) RoleMappings() *RoleMappingsRequestBuilder {
return NewRoleMappingsRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter)
}

// Rules manage the global rules that apply to all artifacts if not otherwise configured.
// returns a *RulesRequestBuilder when successful
func (m *AdminRequestBuilder) Rules() *RulesRequestBuilder {
return NewRulesRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter)
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ func NewArtifactTypesRequestBuilder(rawUrl string, requestAdapter i2ae4187f7daee
}

// Get gets a list of all the configured artifact types.This operation can fail for the following reasons:* A server error occurred (HTTP error `500`)
// returns a []ArtifactTypeInfoable when successful
// returns a Error error when the service returns a 500 status code
func (m *ArtifactTypesRequestBuilder) Get(ctx context.Context, requestConfiguration *ArtifactTypesRequestBuilderGetRequestConfiguration) ([]i80228d093fd3b582ec81b86f113cc707692a60cdd08bae7a390086a8438c7543.ArtifactTypeInfoable, error) {
requestInfo, err := m.ToGetRequestInformation(ctx, requestConfiguration)
if err != nil {
Expand All @@ -57,6 +59,7 @@ func (m *ArtifactTypesRequestBuilder) Get(ctx context.Context, requestConfigurat
}

// ToGetRequestInformation gets a list of all the configured artifact types.This operation can fail for the following reasons:* A server error occurred (HTTP error `500`)
// returns a *RequestInformation when successful
func (m *ArtifactTypesRequestBuilder) ToGetRequestInformation(ctx context.Context, requestConfiguration *ArtifactTypesRequestBuilderGetRequestConfiguration) (*i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestInformation, error) {
requestInfo := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.NewRequestInformationWithMethodAndUrlTemplateAndPathParameters(i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.GET, m.BaseRequestBuilder.UrlTemplate, m.BaseRequestBuilder.PathParameters)
if requestConfiguration != nil {
Expand All @@ -68,6 +71,7 @@ func (m *ArtifactTypesRequestBuilder) ToGetRequestInformation(ctx context.Contex
}

// WithUrl returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored.
// returns a *ArtifactTypesRequestBuilder when successful
func (m *ArtifactTypesRequestBuilder) WithUrl(rawUrl string) *ArtifactTypesRequestBuilder {
return NewArtifactTypesRequestBuilder(rawUrl, m.BaseRequestBuilder.RequestAdapter)
}
Loading
Loading