diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index f9d326d..f51d1e3 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,18 +1,10 @@ **Fixes: #Issue** -**Checklist** - - -- [ ] Commit messages follow conventionalcommits.org - - **Changes** - diff --git a/.travis.yml b/.travis.yml index 4d90ea8..eb39b4b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ script: - docker run --rm -v $(pwd):$(pwd) -w $(pwd) - thethingsindustries/protoc + thethingsindustries/protoc:3.1.18 --plugin=protoc-gen-grpc=/usr/bin/protoc-gen-grpc-java --java_out=./hpi-cloud-apis/src/main/java --grpc_out=./hpi-cloud-apis/src/main/java diff --git a/build.gradle b/build.gradle index a742105..3e18774 100644 --- a/build.gradle +++ b/build.gradle @@ -11,10 +11,10 @@ repositories { dependencies { api("com.google.protobuf:protobuf-java:3.8.0") // implementation as Android clients will replace this with grpc-protobuf-lite - implementation("io.grpc:grpc-protobuf:1.21.0") - api("io.grpc:grpc-stub:1.21.0") + implementation("io.grpc:grpc-protobuf:1.26.0") + api("io.grpc:grpc-stub:1.26.0") // implementation as Android clients will replace this with grpc-okhttp - implementation("io.grpc:grpc-netty:1.21.0") + implementation("io.grpc:grpc-netty:1.26.0") } // Publishing config diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b0acbdc..e0c4de3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/hpi/cloud/common/v1test/entity_creation_metadata.proto b/hpi/cloud/common/v1test/entity_creation_metadata.proto new file mode 100644 index 0000000..4f4bfa8 --- /dev/null +++ b/hpi/cloud/common/v1test/entity_creation_metadata.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; + +package hpi.cloud.common.v1test; + +import "hpi/cloud/common/v1test/l10n_string.proto"; +import "hpi/cloud/common/v1test/permission.proto"; + +option java_multiple_files = true; +option java_outer_classname = "EntityCreationMetadataProto"; +option java_package = "de.hpi.cloud.common.v1test"; + +message EntityCreationMetadata { + // A list of (localized) sources of this entity, e.g. the original URL for an + // article. + repeated L10nString sources = 1; + + // A list of (additional) permissions. The author implicitly has write access + // and collection permissions (applicable e.g. for all articles) apply. + map permissions = 2; + + // Setting this field generates an initial PublishedChangeEvent meaning + // everyone with (implicit) access can see (and potentially edit) it. See + // [PublishedChangeEvent](hpi.cloud.sudo.v1test.PublishedChangeEvent) for more + // information + bool is_published = 3; +} diff --git a/hpi/cloud/common/v1test/l10n_string.proto b/hpi/cloud/common/v1test/l10n_string.proto new file mode 100644 index 0000000..c44143e --- /dev/null +++ b/hpi/cloud/common/v1test/l10n_string.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; + +package hpi.cloud.common.v1test; + +import "google/protobuf/wrappers.proto"; + +option java_multiple_files = true; +option java_outer_classname = "L10nStringProto"; +option java_package = "de.hpi.cloud.common.v1test"; + +// A string with values for differrent locales. +message L10nString { + // Required. A map of locales to the corresponding (localized) string value. + map strings = 1; +} diff --git a/hpi/cloud/sudo/v1test/common.proto b/hpi/cloud/common/v1test/permission.proto similarity index 69% rename from hpi/cloud/sudo/v1test/common.proto rename to hpi/cloud/common/v1test/permission.proto index a0d04fd..683077c 100644 --- a/hpi/cloud/sudo/v1test/common.proto +++ b/hpi/cloud/common/v1test/permission.proto @@ -1,12 +1,12 @@ syntax = "proto3"; -package hpi.cloud.sudo.v1test; +package hpi.cloud.common.v1test; import "google/protobuf/wrappers.proto"; option java_multiple_files = true; -option java_outer_classname = "CommonProto"; -option java_package = "de.hpi.cloud.sudo.v1test"; +option java_outer_classname = "PermissionProto"; +option java_package = "de.hpi.cloud.common.v1test"; // Describes additional permissions on a single entity or on a party for a whole // collection. @@ -23,9 +23,3 @@ message Permission { // Can only be used on a party for a whole collection. google.protobuf.BoolValue create = 3; } - -// A string with values for differrent locales. -message L10nString { - // Required. A map of locales to the corresponding (localized) string value. - map strings = 1; -} diff --git a/hpi/cloud/myhpi/v1test/info_bit.proto b/hpi/cloud/myhpi/v1test/info_bit.proto index ce21b9e..92f7434 100644 --- a/hpi/cloud/myhpi/v1test/info_bit.proto +++ b/hpi/cloud/myhpi/v1test/info_bit.proto @@ -11,7 +11,7 @@ option java_package = "de.hpi.cloud.myhpi.v1test"; // A bit of information to show in a MyHPI context. message InfoBit { - // Required, output only. The unique ID of this info bit. + // Required. The unique ID of this info bit. string id = 1; // ID of the parent info bit. diff --git a/hpi/cloud/myhpi/v1test/myhpi_service.proto b/hpi/cloud/myhpi/v1test/myhpi_service.proto index 16e05b8..ed35967 100644 --- a/hpi/cloud/myhpi/v1test/myhpi_service.proto +++ b/hpi/cloud/myhpi/v1test/myhpi_service.proto @@ -2,6 +2,9 @@ syntax = "proto3"; package hpi.cloud.myhpi.v1test; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "hpi/cloud/common/v1test/entity_creation_metadata.proto"; import "hpi/cloud/myhpi/v1test/info_bit.proto"; option java_multiple_files = true; @@ -16,6 +19,15 @@ service MyHpiService { // Gets a bit of information. rpc GetInfoBit (GetInfoBitRequest) returns (InfoBit); + // Creates a new InfoBit. + rpc CreateInfoBit (CreateInfoBitRequest) returns (InfoBit); + + // Updates an InfoBit. + rpc UpdateInfoBit (UpdateInfoBitRequest) returns (InfoBit); + + // Deletes an InfoBit. + rpc DeleteInfoBit (DeleteInfoBitRequest) returns (google.protobuf.Empty); + // Lists tags. rpc ListInfoBitTags (ListInfoBitTagsRequest) returns (ListInfoBitTagsResponse); @@ -62,6 +74,33 @@ message GetInfoBitRequest { string id = 1; } +// Request message for [CreateInfoBit][hpi.cloud.myhpi.v1test.MyHpiService.CreateInfoBit]. +message CreateInfoBitRequest { + // Required. Content of the new InfoBit. Leaving the id-field empty means the + // server automatically generates a unique ID. + InfoBit info_bit = 1; + + // Initial metadata like sources and whether this InfoBit will be published. + hpi.cloud.common.v1test.EntityCreationMetadata metadata = 2; +} + +// Request message for [UpdateInfoBit][hpi.cloud.myhpi.v1test.MyHpiService.UpdateInfoBit]. +message UpdateInfoBitRequest { + // Required. New contents of the InfoBit. The id-field must be set and point + // to the InfoBit to update. + string id = 1; + + // Required. The update mask applied to the resource. This must not include + // the id-field. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for [DeleteInfoBit][hpi.cloud.myhpi.v1test.MyHpiService.DeleteInfoBit]. +message DeleteInfoBitRequest { + // Required. ID of the InfoBit to delete. + string id = 1; +} + // Request message for listing tags using [ListInfoBitTags][hpi.cloud.myhpi.v1test.MyHpiService.ListInfoBitTags]. message ListInfoBitTagsRequest { diff --git a/hpi/cloud/sudo/v1test/entity.proto b/hpi/cloud/sudo/v1test/entity.proto index df4fd50..33ddb24 100644 --- a/hpi/cloud/sudo/v1test/entity.proto +++ b/hpi/cloud/sudo/v1test/entity.proto @@ -2,7 +2,8 @@ syntax = "proto3"; package hpi.cloud.sudo.v1test; -import "hpi/cloud/sudo/v1test/common.proto"; +import "hpi/cloud/common/v1test/l10n_string.proto"; +import "hpi/cloud/common/v1test/permission.proto"; import "hpi/cloud/sudo/v1test/events.proto"; option java_multiple_files = true; @@ -33,11 +34,11 @@ message Entity { message Metadata { // A list of (localized) sources of this entity, e.g. the original URL for an // article. - repeated L10nString sources = 1; + repeated hpi.cloud.common.v1test.L10nString sources = 1; // A list of (additional) permissions. The author implicitly has write access // and collection permissions (applicable e.g. for all articles) apply. - map permissions = 2; + map permissions = 2; // A list of events that record the history of an entity. These will be // created automatically by the server and can't be overriden. diff --git a/hpi/cloud/sudo/v1test/events.proto b/hpi/cloud/sudo/v1test/events.proto index 5b3499f..29470cf 100644 --- a/hpi/cloud/sudo/v1test/events.proto +++ b/hpi/cloud/sudo/v1test/events.proto @@ -3,7 +3,8 @@ syntax = "proto3"; package hpi.cloud.sudo.v1test; import "google/protobuf/timestamp.proto"; -import "hpi/cloud/sudo/v1test/common.proto"; +import "hpi/cloud/common/v1test/l10n_string.proto"; +import "hpi/cloud/common/v1test/permission.proto"; option java_multiple_files = true; option java_outer_classname = "EventProto"; @@ -32,7 +33,7 @@ message CreateEvent {} // An event changing the actual value of an entity. The previous value is // persisted here. message UpdateEvent { - // Optional. The old value or empty if nothing changed. + // The old value or empty if nothing changed. string old_value = 1; } @@ -40,14 +41,14 @@ message UpdateEvent { // persisted here. message SourcesChangeEvent { // Required. The old sources. - repeated L10nString old_sources = 1; + repeated hpi.cloud.common.v1test.L10nString old_sources = 1; } // An event changing the permissions of an entity. The previous permissions are // persisted here. message PermissionsChangeEvent { // Required. The old permissions. - map old_permissions = 1; + map old_permissions = 1; } // An event which might have an effect only in the future, e.g. to publish an diff --git a/hpi/cloud/sudo/v1test/sudo_service.proto b/hpi/cloud/sudo/v1test/sudo_service.proto index 3413148..ae3da1b 100644 --- a/hpi/cloud/sudo/v1test/sudo_service.proto +++ b/hpi/cloud/sudo/v1test/sudo_service.proto @@ -3,7 +3,8 @@ syntax = "proto3"; package hpi.cloud.sudo.v1test; import "google/protobuf/timestamp.proto"; -import "hpi/cloud/sudo/v1test/common.proto"; +import "hpi/cloud/common/v1test/l10n_string.proto"; +import "hpi/cloud/common/v1test/permission.proto"; import "hpi/cloud/sudo/v1test/entity.proto"; option java_multiple_files = true; @@ -155,10 +156,10 @@ message CreateEntityRequest { uint32 version = 3; // The sources of this entity. - repeated L10nString sources = 4; + repeated hpi.cloud.common.v1test.L10nString sources = 4; // The permissions for accessing this entity. - map permissions = 5; + map permissions = 5; // Required. JSON-representation of the actual value. string value = 6; @@ -193,7 +194,7 @@ message UpdateSourcesRequest { string id = 3; // Required. The new sources. - repeated L10nString new_sources = 4; + repeated hpi.cloud.common.v1test.L10nString new_sources = 4; } @@ -209,7 +210,7 @@ message UpdatePermissionsRequest { string id = 3; // Required. The new permissions. - map new_permissions = 4; + map new_permissions = 4; }