Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

feat(myhpi): create, update and delete for InfoBits #69

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 0 additions & 8 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
**Fixes: #Issue**

<!--
- The name of this PR should follow conventionalcommits.org.
- When not using Unicorn to create PRs, please manually select a type (T: abc) label
from the right. Add the breaking label (PR: BREAKING) if applicable.
- Please enter the corresponding issue ID in the placeholder above.
-->

**Checklist**
<!-- Please check if your PR fulfills the following requirements: -->

- [ ] Commit messages follow conventionalcommits.org


**Changes**
<!-- Please summarize your changes -->

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions hpi/cloud/common/v1test/entity_creation_metadata.proto
Original file line number Diff line number Diff line change
@@ -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<string, Permission> 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;
}
15 changes: 15 additions & 0 deletions hpi/cloud/common/v1test/l10n_string.proto
Original file line number Diff line number Diff line change
@@ -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<string, string> strings = 1;
}
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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<string, string> strings = 1;
}
2 changes: 1 addition & 1 deletion hpi/cloud/myhpi/v1test/info_bit.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
39 changes: 39 additions & 0 deletions hpi/cloud/myhpi/v1test/myhpi_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions hpi/cloud/sudo/v1test/entity.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<string, Permission> permissions = 2;
map<string, hpi.cloud.common.v1test.Permission> 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.
Expand Down
9 changes: 5 additions & 4 deletions hpi/cloud/sudo/v1test/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -32,22 +33,22 @@ 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;
}

// An event changing the sources of an entity. The previous sources are
// 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<string, Permission> old_permissions = 1;
map<string, hpi.cloud.common.v1test.Permission> old_permissions = 1;
}

// An event which might have an effect only in the future, e.g. to publish an
Expand Down
11 changes: 6 additions & 5 deletions hpi/cloud/sudo/v1test/sudo_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<string, Permission> permissions = 5;
map<string, hpi.cloud.common.v1test.Permission> permissions = 5;

// Required. JSON-representation of the actual value.
string value = 6;
Expand Down Expand Up @@ -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;
}


Expand All @@ -209,7 +210,7 @@ message UpdatePermissionsRequest {
string id = 3;

// Required. The new permissions.
map<string, Permission> new_permissions = 4;
map<string, hpi.cloud.common.v1test.Permission> new_permissions = 4;
}


Expand Down