Skip to content

Commit

Permalink
Added Items.proto, and added support for server items
Browse files Browse the repository at this point in the history
  • Loading branch information
anders617 committed Oct 10, 2019
1 parent 638731f commit 6656f47
Show file tree
Hide file tree
Showing 9 changed files with 1,381 additions and 88 deletions.
10 changes: 10 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
load("@bazel_gazelle//:def.bzl", "gazelle")

# Gazelle is used for automatically creating BUILD files and updating dependencies from go
# bazel run //:gazelle -- update
# bazel run //:gazelle -- update-repos https://github.com/link/to/repo/to/add
#
# gazelle:prefix github.com/MichiganDiningAPI
# gazelle:build_file_names BUILD,BUILD.bazel
gazelle(name = "gazelle")

load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")

# Buildifier formats BUILD files
# bazel run //:buildifier
buildifier(name = "buildifier")
19 changes: 13 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Download the Go rules
http_archive(
name = "io_bazel_rules_go",
sha256 = "513c12397db1bc9aa46dd62f02dd94b49a9b5d17444d49b5a04c5a89f3053c1c",
urls = [
"https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/rules_go/releases/download/v0.19.5/rules_go-v0.19.5.tar.gz",
"https://github.com/bazelbuild/rules_go/releases/download/v0.19.5/rules_go-v0.19.5.tar.gz",
],
sha256 = "513c12397db1bc9aa46dd62f02dd94b49a9b5d17444d49b5a04c5a89f3053c1c",
)

# Load and call the dependencies
load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains")
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

go_register_toolchains()

http_archive(
name = "bazel_gazelle",
sha256 = "7fc87f4170011201b1690326e8c16c5d802836e3a0d617d8f75c3af2b23180c4",
urls = [
"https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/bazel-gazelle/releases/download/0.18.2/bazel-gazelle-0.18.2.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/0.18.2/bazel-gazelle-0.18.2.tar.gz",
],
sha256 = "7fc87f4170011201b1690326e8c16c5d802836e3a0d617d8f75c3af2b23180c4",
)

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
Expand All @@ -48,17 +48,17 @@ protobuf_deps()

git_repository(
name = "com_googleapis_googleapis",
remote = "https://github.com/googleapis/googleapis",
commit = "fcbb13c4f84380c6546a1c78e44b241c3c8c13f4",
remote = "https://github.com/googleapis/googleapis",
)

load("@com_googleapis_googleapis//:repository_rules.bzl", "switched_rules_by_language")

switched_rules_by_language(
name = "com_google_googleapis_imports",
grpc = True,
gapic = True,
go = True,
grpc = True,
java = False,
)

Expand All @@ -70,13 +70,20 @@ http_archive(
urls = ["https://github.com/googleapis/gapic-generator/archive/5aa30f3d6850c8ebc1092d17ef471aea27a81242.zip"],
)

# bazelbuild buildtools for formatting build files
http_archive(
name = "com_github_bazelbuild_buildtools",
strip_prefix = "buildtools-master",
url = "https://github.com/bazelbuild/buildtools/archive/master.zip",
)

# Include for grpc gateway bazel rules

http_archive(
name = "build_stack_rules_proto",
urls = ["https://github.com/stackb/rules_proto/archive/b93b544f851fdcd3fc5c3d47aee3b7ca158a8841.tar.gz"],
sha256 = "c62f0b442e82a6152fcd5b1c0b7c4028233a9e314078952b6b04253421d56d61",
strip_prefix = "rules_proto-b93b544f851fdcd3fc5c3d47aee3b7ca158a8841",
urls = ["https://github.com/stackb/rules_proto/archive/b93b544f851fdcd3fc5c3d47aee3b7ca158a8841.tar.gz"],
)

# External Go Depndencies
Expand Down
46 changes: 20 additions & 26 deletions api/proto/BUILD
Original file line number Diff line number Diff line change
@@ -1,53 +1,47 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")

proto_library(
name = "dininghalls_proto",
srcs = ["dininghalls.proto"],
visibility = ["//visibility:public"],
)

proto_library(
name = "items_proto",
srcs = ["items.proto"],
visibility = ["//visibility:public"],
)

proto_library(
name = "mdining_proto",
srcs = ["mdining.proto"],
visibility = ["//visibility:public"],
deps = [
":dininghalls_proto",
":items_proto",
"@go_googleapis//google/api:annotations_proto",
],
)

# go_proto_library(
# name = "mdining_go_proto",
# compilers = [
# "@io_bazel_rules_go//proto:go_grpc",
# "@com_github_grpc_ecosystem_grpc_gateway//protoc-gen-grpc-gateway:go_gen_grpc_gateway"
# ],
# importpath = "github.com/MichiganDiningAPI/api/proto",
# proto = ":mdining_proto",
# visibility = ["//visibility:public"],
# deps = ["@go_googleapis//google/api:annotations_go_proto"],
# )

# go_library(
# name = "go_default_library",
# srcs = [""]
# embed = [":mdining_go_proto"],
# importpath = "github.com/MichiganDiningAPI/api/proto",
# visibility = ["//visibility:public"],
# )

go_proto_library(
name = "go_default_library",
compilers = [
"@io_bazel_rules_go//proto:go_grpc",
"@grpc_ecosystem_grpc_gateway//protoc-gen-grpc-gateway:go_gen_grpc_gateway"
"@grpc_ecosystem_grpc_gateway//protoc-gen-grpc-gateway:go_gen_grpc_gateway",
],
importpath = "github.com/MichiganDiningAPI/api/proto",
proto = ":mdining_proto",
protos = [":mdining_proto", ":items_proto", ":dininghalls_proto"],
visibility = ["//visibility:public"],
deps = [
"@com_github_golang_protobuf//descriptor:go_default_library",
"@com_github_golang_protobuf//proto:go_default_library",
"@grpc_ecosystem_grpc_gateway//runtime:go_default_library",
"@grpc_ecosystem_grpc_gateway//utilities:go_default_library",
"@org_golang_google_genproto//googleapis/api/annotations:go_default_library",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//codes:go_default_library",
"@org_golang_google_grpc//grpclog:go_default_library",
"@org_golang_google_grpc//status:go_default_library",
"@grpc_ecosystem_grpc_gateway//utilities:go_default_library",
"@grpc_ecosystem_grpc_gateway//runtime:go_default_library",
"@org_golang_google_genproto//googleapis/api/annotations:go_default_library",
],
visibility = [ "//visibility:public"],
)
52 changes: 52 additions & 0 deletions api/proto/dininghalls.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
syntax = "proto3";

package mdining;

message DiningHalls { repeated DiningHall diningHalls = 1; }

message DiningHall {
string name = 1;
string campus = 2;
Building building = 3;
string type = 4;
Capacity capacity = 5;
uint32 sortPosition = 6;
repeated DayHour dayHours = 7;
repeated DayEvent dayEvents = 8;

message Building {
string name = 1;
Address address = 2;

message Address {
string city = 1;
uint32 postalCode = 2;
string state = 3;
string street1 = 4;
string street2 = 5;
}
}
message Capacity {
uint32 currentOccupancy = 1;
uint32 currentOccupancyRatio = 2;
uint32 totalCapacity = 3;
}
message DayHour {
string key = 1;
repeated string hour = 2;
}
message DayEvent {
string key = 1;
repeated CalendarEvent calendarEvent = 2;

message CalendarEvent {
string eventDayEnd = 1;
string eventDayStart = 2;
string eventDescription = 3;
string eventMapLink = 4;
string eventTimeStart = 5;
string eventTimeEnd = 6;
string eventTitle = 7;
}
}
}
24 changes: 24 additions & 0 deletions api/proto/items.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
syntax = "proto3";

package mdining;

message Items {
map<string, Item> items = 1;
}

message Item {
string name = 1;
repeated string attributes = 2;
map<string, DiningHallMatch> diningHallMatches = 3;
repeated DiningHallMatch diningHallMatchesArray = 4;
message DiningHallMatch {
string name = 1;
map<string, MealTime> mealTimes = 2;
repeated MealTime mealTimesArray = 3;
message MealTime {
string date = 1;
string formattedDate = 2;
repeated string mealNames = 3;
}
}
}
60 changes: 13 additions & 47 deletions api/proto/mdining.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@ syntax = "proto3";
package mdining;

import "google/api/annotations.proto";
import "api/proto/dininghalls.proto";
import "api/proto/items.proto";

service MDining {
rpc GetDiningHalls(DiningHallsRequest) returns (DiningHallsReply) {
option (google.api.http) = {
get: "/v1/diningHalls"
};
}

rpc GetItems(ItemsRequest) returns (ItemsReply) {
option (google.api.http) = {
get: "/v1/items"
};
}
}

message DiningHallsRequest {
Expand All @@ -19,53 +27,11 @@ message DiningHallsReply {
DiningHalls diningHalls = 1;
}

message DiningHalls {
repeated DiningHall diningHalls = 1;
message ItemsRequest {
string items = 1;
}

message DiningHall {
string name = 1;
string campus = 2;
Building building = 3;
string type = 4;
Capacity capacity = 5;
uint32 sortPosition = 6;
repeated DayHour dayHours = 7;
repeated DayEvent dayEvents = 8;

message Building {
string name = 1;
Address address = 2;

message Address {
string city = 1;
uint32 postalCode = 2;
string state = 3;
string street1 = 4;
string street2 = 5;
}
}
message Capacity {
uint32 currentOccupancy = 1;
uint32 currentOccupancyRatio = 2;
uint32 totalCapacity = 3;
}
message DayHour {
string key = 1;
repeated string hour = 2;
}
message DayEvent {
string key = 1;
repeated CalendarEvent calendarEvent = 2;

message CalendarEvent {
string eventDayEnd = 1;
string eventDayStart = 2;
string eventDescription = 3;
string eventMapLink = 4;
string eventTimeStart = 5;
string eventTimeEnd = 6;
string eventTitle = 7;
}
}
message ItemsReply {
Items items = 1;
}

11 changes: 7 additions & 4 deletions cmd/web/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ go_library(
visibility = ["//visibility:private"],
deps = [
"//api/proto:go_default_library",
"@com_github_golang_protobuf//jsonpb:go_default_library_gen",
"@com_github_golang_glog//:go_default_library",
"@org_golang_google_grpc//:go_default_library",
"@grpc_ecosystem_grpc_gateway//runtime:go_default_library",
"@com_github_golang_protobuf//jsonpb:go_default_library_gen",
"@com_github_golang_protobuf//proto:go_default_library",
"@grpc_ecosystem_grpc_gateway//runtime:go_default_library",
"@org_golang_google_grpc//:go_default_library",
],
)

go_binary(
name = "web",
data = [
"dininghalls.proto.txt",
"items.proto.txt",
],
embed = [":go_default_library"],
visibility = ["//visibility:public"],
data = ["dininghalls.proto.txt"],
)
Loading

0 comments on commit 6656f47

Please sign in to comment.