diff --git a/.gitignore b/.gitignore index e6c8f4ea..ca4a25fe 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ .gradle/ .idea/ +.project/ build/ generated-protos/ diff --git a/.settings/org.eclipse.buildship.core.prefs b/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 00000000..656b35a5 --- /dev/null +++ b/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,13 @@ +arguments= +auto.sync=false +build.scans.enabled=false +connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) +connection.project.dir= +eclipse.preferences.version=1 +gradle.user.home= +java.home=/usr/local/Cellar/openjdk/16.0.2/libexec/openjdk.jdk/Contents/Home +jvm.arguments= +offline.mode=false +override.workspace.settings=true +show.console.view=true +show.executions.view=true diff --git a/odpf/assets/bucket.proto b/odpf/assets/bucket.proto new file mode 100644 index 00000000..a1fa851d --- /dev/null +++ b/odpf/assets/bucket.proto @@ -0,0 +1,94 @@ +syntax = "proto3"; + +package odpf.assets; + +option java_package = "io.odpf.assets"; +option java_outer_classname = "BucketProto"; +option go_package = "github.com/odpf/proton/assets"; + +import "google/protobuf/timestamp.proto"; + +import "odpf/assets/facets/ownership.proto"; +import "odpf/assets/facets/lineage.proto"; +import "odpf/assets/facets/properties.proto"; + +import "odpf/assets/common/resource.proto"; +import "odpf/assets/common/timestamp.proto"; +import "odpf/assets/common/event.proto"; + +message Bucket { + // Representation of the resource + odpf.assets.common.Resource resource = 1; + + // The description of the bucket. + // Example: `This bucket was created by the product team.` + string description = 4; + + // The location of the bucket. Can differ based on cloud storage used. (e.g. GCS, S3, etc) + // Example: `ASIA` + string location = 5; + + // The type of the storage. Can differ based on cloud storage used. (e.g. GCS, S3, etc) + // Example: `STANDARD` + string storage_type = 6; + + // List of blobs in the bucket. + repeated Blob blobs = 7; + + // The ownership of the bucket. + // For an example check out ownership. + odpf.assets.facets.Ownership ownership = 31; + + // List of the user's custom properties. + // Properties facet can be used to set custom properties, tags and labels for a user. + odpf.assets.facets.Properties properties = 32; + + // The timestamp of the bucket's creation. + // Timstamp facet can be used to set the creation and updation timestamp of a bucket. + odpf.assets.common.Timestamp timestamps = 33; + + // The timestamp of the generated event. + // Event schemas is defined in the common event schema. + odpf.assets.common.Event event = 100; + +} + +message Blob { + // The URN of the blob. + // Example: `location/bucket-name/file-name`. + string urn = 1; + + // The name of the blob. + // Example: `file-name`. + string name = 2; + + // The source of the blob. + // Example: `gcs`. + string source = 3; + + // The description of the blob. + // Example: `This is a config file for x app` + string description = 4; + + // The length of the object content. + // Example: `300` + int64 size = 5; + + // Delete time of the blob object. + google.protobuf.Timestamp delete_time = 6; + + // Expire time of the blob object. + google.protobuf.Timestamp expire_time = 7; + + // The ownership of the blob. + // For an example check out ownership. + odpf.assets.facets.Ownership ownership = 31; + + // List of the user's custom properties. + // Properties facet can be used to set custom properties, tags and labels for a user. + odpf.assets.facets.Properties properties = 32; + + // The timestamp of the blob's creation. + // Timstamp facet can be used to set the creation and updation timestamp of a blob. + odpf.assets.common.Timestamp timestamps = 33; +} \ No newline at end of file diff --git a/odpf/assets/common/event.proto b/odpf/assets/common/event.proto new file mode 100644 index 00000000..ea8ffc87 --- /dev/null +++ b/odpf/assets/common/event.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; + +package odpf.assets.common; + +option java_package = "io.odpf.assets.common"; +option java_outer_classname = "EventProto"; +option go_package = "github.com/odpf/proton/assets/common"; + +import "google/protobuf/timestamp.proto"; + +// Event represents an event in the system. +// Event is majorly used to represent the state of the system in the form of events. +// It can be used in any schema which intend to produce events to message bus. +message Event { + // The timestamp of the event. + // Example: `2018-01-01T00:00:00Z`. + google.protobuf.Timestamp timestamp = 1; + + // The activity that created the event. + // Example: `create`, `update`. + string action = 2; + + // The description of the event. + // Example: `user is created from signup form`. + string description = 3; +} diff --git a/odpf/assets/common/resource.proto b/odpf/assets/common/resource.proto new file mode 100644 index 00000000..405ff02e --- /dev/null +++ b/odpf/assets/common/resource.proto @@ -0,0 +1,32 @@ +syntax = "proto3"; + +package odpf.assets.common; + +option java_package = "io.odpf.assets.common"; +option java_outer_classname = "ResourceProto"; +option go_package = "github.com/odpf/proton/assets/common"; + + +// Resource is a generic resource that represents a file or other resource. +// It can be a table, job, user or group. +message Resource { + // The unique identifier of the resource. + // Example: `user:jdoe` or `group:accounting`. + string urn = 1; + + // The name of the resource. + // Example: `John Doe` or `Accounting`. + string name = 2; + + // The source of the resource. + // Example: `github` or `bigquery`. + string service = 3; + + // The type of the asset. + // Example: `user` or `group`. + string type = 4; + + // The REST URL for accessing the resource. URL returns the resource itself. + // Example: `https://xyz.com/v1/users/user-123` + string url = 5; +} diff --git a/odpf/assets/common/timestamp.proto b/odpf/assets/common/timestamp.proto new file mode 100644 index 00000000..df0e81d7 --- /dev/null +++ b/odpf/assets/common/timestamp.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; + +package odpf.assets.common; + +option java_package = "io.odpf.assets.common"; +option java_outer_classname = "TimestampProto"; +option go_package = "github.com/odpf/proton/assets/common"; + +import "google/protobuf/timestamp.proto"; + +// Timestamp represents created and modified timestamps. +message Timestamp { + // The timestamp when the object was created. + google.protobuf.Timestamp create_time = 1; + + // The timestamp when the object was last modified. + google.protobuf.Timestamp update_time = 2; +} + +// A time window specified by its `start_time` and `end_time`. +message TimeWindow { + // Start time of the time window (exclusive). + google.protobuf.Timestamp start_time = 1; + + // End time of the time window (inclusive). If not specified, the current + // timestamp is used instead. + google.protobuf.Timestamp end_time = 2; +} \ No newline at end of file diff --git a/odpf/assets/dashboard.proto b/odpf/assets/dashboard.proto new file mode 100644 index 00000000..ea53be05 --- /dev/null +++ b/odpf/assets/dashboard.proto @@ -0,0 +1,109 @@ +syntax = "proto3"; + +package odpf.assets; + +option java_package = "io.odpf.assets"; +option java_outer_classname = "DashboardProto"; +option go_package = "github.com/odpf/proton/assets"; + +import "odpf/assets/facets/ownership.proto"; +import "odpf/assets/facets/lineage.proto"; +import "odpf/assets/facets/properties.proto"; + +import "odpf/assets/common/resource.proto"; +import "odpf/assets/common/timestamp.proto"; +import "odpf/assets/common/event.proto"; + +// Dashboard is a resource that represents a dashboard. +message Dashboard { + // Representation of the resource + odpf.assets.common.Resource resource = 1; + + // The description of the dashboard. + // Example: "This dashboard was created by the Metabase team." + string description = 4; + + // The list of the charts in the dashboard. + // For an example, check the schema of the chart. + repeated Chart charts = 21; + + // The ownership of the topic. + // For an example check out ownership. + odpf.assets.facets.Ownership ownership = 31; + + // List of the user's custom properties. + // Properties facet can be used to set custom properties, tags and labels for a user. + odpf.assets.facets.Properties properties = 32; + + // The timestamp of the user's creation. + // Timstamp facet can be used to set the creation and updation timestamp of a user. + odpf.assets.common.Timestamp timestamps = 33; + + // The timestamp of the generated event. + // Event schemas is defined in the common event schema. + odpf.assets.common.Event event = 100; + +} + +message Chart { + // The URN of the chart. + // Example: `chart:1`. + string urn = 1; + + // The name of the chart. + // Example: `My Chart`. + string name = 2; + + // The type of the chart. + // Example: `line`. + string type = 3; + + // The source of the chart. + // Example: `metabase`. + string source = 4; + + // The description of the chart. + // Example: `This is a chart for my dashboard.` + string description = 5; + + // The url of the chart. + // Example: `http://metabase.com/charts/mychart`. + string url = 6; + + // The raw query of the chart. + // Example: `SELECT * FROM my_table`. + string raw_query = 7; + + // The source of the data. + // Example: `bigquery,graphite`. + string data_source = 8; + + // The dashboard ur of the chart. + // Example: `dashboard:1`. + string dashboard_urn = 9; + + // The source of the dashboard of the chart. + // Example: `metabase`. + string dashboard_source = 10; + + // The ownership of the dashboard. + // For an example check out ownership. + odpf.assets.facets.Ownership ownership = 31; + + // The lineage of the dashboard. + // For an example check out lineage schema. + odpf.assets.facets.Lineage lineage = 32; + + // List of the user's custom properties. + // Properties facet can be used to set custom properties, tags and labels for a dashboard. + odpf.assets.facets.Properties properties = 33; + + // The timestamp of the user's creation. + // Timstamp facet can be used to set the creation and updation timestamp of a dashboard. + odpf.assets.common.Timestamp timestamps = 34; + + // The timestamp of the generated event. + // Event schemas is defined in the common event schema. + odpf.assets.common.Event event = 100; + +} diff --git a/odpf/assets/facets/lineage.proto b/odpf/assets/facets/lineage.proto new file mode 100644 index 00000000..05366106 --- /dev/null +++ b/odpf/assets/facets/lineage.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; + +package odpf.assets.facets; + +option java_package = "io.odpf.assets.facets"; +option java_outer_classname = "LineageProto"; +option go_package = "github.com/odpf/proton/assets/facets"; + +import "odpf/assets/common/resource.proto"; + +// Linage reprsents the relationship of resource to other resources. +// Relation is way of describing the relationship between two resources. +message Lineage { + // The resource that is the source of the relationship. + // Example: a resource that is the parent of another resource. + repeated odpf.assets.common.Resource upstreams = 1; + + // The resource that is the destination of the relationship. + // Example: a resource that is the child of another resource. + repeated odpf.assets.common.Resource downstreams = 2; +} diff --git a/odpf/assets/facets/ownership.proto b/odpf/assets/facets/ownership.proto new file mode 100644 index 00000000..a3f57e21 --- /dev/null +++ b/odpf/assets/facets/ownership.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; + +package odpf.assets.facets; + +option java_package = "io.odpf.assets.facets"; +option java_outer_classname = "OwnershipProto"; +option go_package = "github.com/odpf/proton/assets/facets"; + +import "odpf/assets/common/resource.proto"; + +// Ownership is a facet that describes the ownership of a resource. +message Ownership { + // Requird: The list of owners of the resource. + // For an example check the owner schema. + repeated Owner owners = 7; +} + +// Owner is a facet that describes the owner of a resource. +message Owner { + // The name of the owner. + // Example: `user:johndoe`. + + string urn = 1; + // The name of the owner. + // Example: `John Doe`. + string name = 2; + + // The role of the owner. + // Example: `admin`, `steward`. + string role = 3; +} \ No newline at end of file diff --git a/odpf/assets/facets/properties.proto b/odpf/assets/facets/properties.proto new file mode 100644 index 00000000..1fc71522 --- /dev/null +++ b/odpf/assets/facets/properties.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +package odpf.assets.facets; + +option java_package = "io.odpf.assets.facets"; +option java_outer_classname = "PropertiesProto"; +option go_package = "github.com/odpf/proton/assets/facets"; + +import "google/protobuf/struct.proto"; + +message Properties { + + // Optional: List of tags the user has. + repeated string tags = 1; + + //Optional. List of labels the user has. + map labels = 2; + + // Optional: List of properties the user has. + google.protobuf.Struct attributes = 3; + +} \ No newline at end of file diff --git a/odpf/assets/facets/schema.proto b/odpf/assets/facets/schema.proto new file mode 100644 index 00000000..276c4b00 --- /dev/null +++ b/odpf/assets/facets/schema.proto @@ -0,0 +1,64 @@ +syntax = "proto3"; + +package odpf.assets.facets; + +option java_package = "io.odpf.assets.facets"; +option java_outer_classname = "SchemaProto"; +option go_package = "github.com/odpf/proton/assets/facets"; + + +import "odpf/assets/facets/properties.proto"; + +// Columns represents a list of columns. +// It is facet used to specify the schema of a table or a file. +message Columns { + // The list of columns. + repeated Column columns = 1; +} + +// Column represents a column in a table or a file. +message Column { + // The name of the column. + // Example: `customer_id`. + string name = 1; + + // The description of the column. + // Example: `The unique id of the customer` + string description = 2; + + // The data type of the column. + // Example: `INT64`. + + string data_type = 3; + // The format of the column. + // Example: `true`. + bool is_nullable = 4; + + // The length of the column. + // Example: `10`. + int64 length = 5; + + // The profile of the column. + ColumnProfile profile = 6; + + // Representation of the column properties. + // Properties facet can be used to set custom properties, tags and labels for a column. + odpf.assets.facets.Properties properties = 31; +} + +message ColumnProfile { + string min = 1; + string max = 2; + double avg = 3; + double med = 4; + int64 unique = 5; + int64 count = 6; + string top = 7; +} + +// TopicSchema represents a schema for message bus. +// It is facet used to specify the schema of a message bus. +message TopicSchema { + string schema_url = 1; + string format = 2; +} diff --git a/odpf/assets/group.proto b/odpf/assets/group.proto new file mode 100644 index 00000000..b17678b4 --- /dev/null +++ b/odpf/assets/group.proto @@ -0,0 +1,50 @@ +syntax = "proto3"; + +package odpf.assets; + +option java_package = "io.odpf.assets"; +option java_outer_classname = "GroupProto"; +option go_package = "github.com/odpf/proton/assets"; + + +import "odpf/assets/common/timestamp.proto"; +import "odpf/assets/common/event.proto"; +import "odpf/assets/common/resource.proto"; + +import "odpf/assets/facets/properties.proto"; + +// Group represents a group of users and resources. +message Group { + // Representation of the resource + odpf.assets.common.Resource resource = 1; + + // The email of the group. + // Example: `xyz@xyz.com` + string email = 3; + + // The members of the group. + // For example look at schema of the member. + repeated Member members = 21; + + // List of the user's custom properties. + // Properties facet can be used to set custom properties, tags and labels for a user. + odpf.assets.facets.Properties properties = 31; + + // The timestamp of the user's creation. + // Timstamp facet can be used to set the creation and updation timestamp of a user. + odpf.assets.common.Timestamp timestamps = 32; + + // The timestamp of the generated event. + // Event schemas is defined in the common event schema. + odpf.assets.common.Event event = 100; +} + +// Member represents a user. +message Member { + // The unique identifier for the user. + // Example: `user:example`. + string urn = 1; + // The role of the user. + // Example: `owner`. + string role = 2; +} \ No newline at end of file diff --git a/odpf/assets/job.proto b/odpf/assets/job.proto new file mode 100644 index 00000000..718315f9 --- /dev/null +++ b/odpf/assets/job.proto @@ -0,0 +1,45 @@ +syntax = "proto3"; + +package odpf.assets; + +option java_package = "io.odpf.assets"; +option java_outer_classname = "JobProto"; +option go_package = "github.com/odpf/proton/assets"; + +import "odpf/assets/facets/ownership.proto"; +import "odpf/assets/facets/lineage.proto"; +import "odpf/assets/facets/properties.proto"; + +import "odpf/assets/common/resource.proto"; +import "odpf/assets/common/timestamp.proto"; +import "odpf/assets/common/event.proto"; + +// Job is a resource that represents a job. +message Job { + // Representation of the resource + odpf.assets.common.Resource resource = 1; + + // The description of the job. + // Example: 'This job is used to process data from a stream.' + string description = 5; + + // The ownership of the topic. + // For an example check out ownership. + odpf.assets.facets.Ownership ownership = 31; + + // The lineage of the topic. + // For an example check out lineage schema. + odpf.assets.facets.Lineage lineage = 32; + + // List of the user's custom properties. + // Properties facet can be used to set custom properties, tags and labels for a user. + odpf.assets.facets.Properties properties = 33; + + // The timestamp of the user's creation. + // Timstamp facet can be used to set the creation and updation timestamp of a user. + odpf.assets.common.Timestamp timestamps = 34; + + // The timestamp of the generated event. + // Event schemas is defined in the common event schema. + odpf.assets.common.Event event = 100; +} \ No newline at end of file diff --git a/odpf/assets/table.proto b/odpf/assets/table.proto new file mode 100644 index 00000000..f42b7581 --- /dev/null +++ b/odpf/assets/table.proto @@ -0,0 +1,68 @@ +syntax = "proto3"; + +package odpf.assets; + +option java_package = "io.odpf.assets"; +option java_outer_classname = "TableProto"; +option go_package = "github.com/odpf/proton/assets"; + +import "odpf/assets/facets/schema.proto"; +import "odpf/assets/facets/ownership.proto"; +import "odpf/assets/facets/lineage.proto"; +import "odpf/assets/facets/properties.proto"; + +import "odpf/assets/common/resource.proto"; +import "odpf/assets/common/timestamp.proto"; +import "odpf/assets/common/event.proto"; + +// Table is a table in a database. +// It can be a file, a table, a view, a materialized view, a temporary table, or a virtual table. +message Table { + // Representation of the resource + odpf.assets.common.Resource resource = 1; + + // The description of the table. + // Example: 'My User table'. + string description = 4; + + // The metrics about the table. + // For example check the profile schem. + TableProfile profile = 21; + + // The columns of the table. + // Example: 'id', `name`, `age'. + odpf.assets.facets.Columns schema = 22; + + // The ownership of the topic. + // For an example check out ownership. + odpf.assets.facets.Ownership ownership = 31; + + // The lineage of the topic. + // For an example check out lineage schema. + odpf.assets.facets.Lineage lineage = 32; + + // List of the user's custom properties. + // Properties facet can be used to set custom properties, tags and labels for a user. + odpf.assets.facets.Properties properties = 33; + + // The timestamp of the user's creation. + // Timstamp facet can be used to set the creation and updation timestamp of a user. + odpf.assets.common.Timestamp timestamps = 34; + + // The timestamp of the generated event. + // Event schemas is defined in the common event schema. + odpf.assets.common.Event event = 100; +} + +// TableProfile is the metrics about the table. +message TableProfile { + // The number of rows in the table. + // Example: `100`. + int64 total_rows = 1; + + // The number of rows in the table that are not deleted. + // Example: `event_timestamp`. + string partition_key = 2; + + string partition_value = 3; +} diff --git a/odpf/assets/topic.proto b/odpf/assets/topic.proto new file mode 100644 index 00000000..dbcdf703 --- /dev/null +++ b/odpf/assets/topic.proto @@ -0,0 +1,66 @@ +syntax = "proto3"; + +package odpf.assets; + +option java_package = "io.odpf.assets"; +option java_outer_classname = "TopicProto"; +option go_package = "github.com/odpf/proton/assets"; + +import "odpf/assets/facets/schema.proto"; +import "odpf/assets/facets/ownership.proto"; +import "odpf/assets/facets/lineage.proto"; +import "odpf/assets/facets/properties.proto"; + +import "odpf/assets/common/resource.proto"; +import "odpf/assets/common/timestamp.proto"; +import "odpf/assets/common/event.proto"; + +// Topic is resource that represents a logical group of messages +// in message bus like kafka, pubsub, pulsar etc. +message Topic { + // Representation of the resource + odpf.assets.common.Resource resource = 1; + + // The description of the topic. + // Example: 'This is a topic for my application'. + string description = 4; + + // The metrics of the topic. + // For an example check out topic profile schema. + TopicProfile profile = 21; + + // The schama of the topic. + // For an example check out topic schema. + odpf.assets.facets.TopicSchema schema = 31; + + // The ownership of the topic. + // For an example check out ownership. + odpf.assets.facets.Ownership ownership = 32; + + // The lineage of the topic. + // For an example check out lineage schema. + odpf.assets.facets.Lineage lineage = 33; + + // List of the user's custom properties. + // Properties facet can be used to set custom properties, tags and labels for a user. + odpf.assets.facets.Properties properties = 34; + + // The timestamp of the user's creation. + // Timstamp facet can be used to set the creation and updation timestamp of a user. + odpf.assets.common.Timestamp timestamps = 35; + + // The timestamp of the generated event. + // Event schemas is defined in the common event schema. + odpf.assets.common.Event event = 100; +} + +// TopicProfile is the profile of the topic. +message TopicProfile { + // The thrroughput of the topic. + // Example: `1m/minute`. + string throughput = 1; + + // The number of partitions in the topic. + // Example: `12`. + int64 number_of_partitions = 2; +} diff --git a/odpf/assets/user.proto b/odpf/assets/user.proto new file mode 100644 index 00000000..1a18db0c --- /dev/null +++ b/odpf/assets/user.proto @@ -0,0 +1,104 @@ +syntax = "proto3"; + +package odpf.assets; + +option java_package = "io.odpf.assets"; +option java_outer_classname = "UserProto"; +option go_package = "github.com/odpf/proton/assets"; + + +import "odpf/assets/common/timestamp.proto"; +import "odpf/assets/common/event.proto"; +import "odpf/assets/common/resource.proto"; + +import "odpf/assets/facets/properties.proto"; + +// User is a person who uses or operates something. +// It can be a user of the system, or a user of a device. +// User is a resource that represents a user. +message User { + // Representation of the resource + odpf.assets.common.Resource resource = 1; + + // The emai address of the user. + // Example: `job.deo@gmail.com` + string email = 3; + + // The username of the user. + // Example: `johndoe` + string username = 4; + + // The first name of the user. + // Example: `john` + string first_name = 5; + + // The last name of the user. + // Example: `doe` + string last_name = 6; + + // The full name of the user. + // Example: `john mayer doe` + string full_name = 7; + + // The display name of the user. + // Example: `John M. Doe` + string display_name = 8; + + // The job title of the user, + // Example: `data engineer` + string title = 9; + + // The status of the user. + // Example: `active` + string status = 10; + + // The email of the manger of the user. + // Example: `rambo.ryan@gmail.com` + string manager_email = 11; + + // List of the user social media accounts. + // For an example check out the profile schema. + repeated Profile profiles = 21; + + // List of the groups user belongs to. + // A user can be part of multiple groups and have a different role in every group. + repeated Membership memberships = 22; + + // Representation of custom properties of user. + // Properties facet can be used to set custom properties, tags and labels for a user. + odpf.assets.facets.Properties properties = 31; + + // The timestamp of the user's creation. + // Timstamp facet can be used to set the creation and updation timestamp of a user. + odpf.assets.common.Timestamp timestamps = 32; + + // The timestamp of the generated event. + // Event schemas is defined in the common event schema. + odpf.assets.common.Event event = 100; +} + +// Membership is a relationship between a user and a group. +message Membership { + // The unique identifier of the group. + // Example: `group:mygroup` + string group_urn = 1; + + // The role user has in the group. + // Example: "owner" + repeated string role = 2; +} + +// Profile is a social media account of the user. +message Profile { + // The unique identifier of the profile. + // Example: `profile:jdoe` + string id = 1; + + // The type of the profile. + // Example: `github` + string platform = 2; + + // The url of the profile. + // Example: `http://github.com/jdoe` + string url = 3; +} diff --git a/odpf/guardian/guardian.proto b/odpf/guardian/guardian.proto new file mode 100644 index 00000000..b6aed6df --- /dev/null +++ b/odpf/guardian/guardian.proto @@ -0,0 +1,375 @@ +syntax = "proto3"; +package odpf.guardian; + +import "odpf/third_party/googleapis/google/api/annotations.proto"; +import "odpf/third_party/grpc-gateway/protoc-gen-openapiv2/options/annotations.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/odpf/proton/guardian"; +option java_multiple_files = true; +option java_package = "io.odpf.proton.guardian"; +option java_outer_classname = "ServiceManager"; + +// These annotations are used when generating the OpenAPI file. +option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { + info: { + version: "0.1"; + }; + external_docs: { + description: "Guardian server"; + } + schemes: HTTP; +}; + +// WARNING: This is still in active development and can have breaking changes +service Guardian { + rpc ListProviders(ListProvidersRequest) returns (ListProvidersResponse) { + option (google.api.http) = { + get: "/providers" + }; + } + + rpc CreateProvider(CreateProviderRequest) returns (CreateProviderResponse) { + option (google.api.http) = { + post: "/providers" + body: "*" + }; + } + + rpc UpdateProvider(UpdateProviderRequest) returns (UpdateProviderResponse) { + option (google.api.http) = { + put: "/providers/{id}" + body: "*" + }; + } + + rpc ListPolicies(ListPoliciesRequest) returns (ListPoliciesResponse) { + option (google.api.http) = { + get: "/policies" + }; + } + + rpc CreatePolicy(CreatePolicyRequest) returns (CreatePolicyResponse) { + option (google.api.http) = { + post: "/policies" + body: "*" + }; + } + + rpc UpdatePolicy(UpdatePolicyRequest) returns (UpdatePolicyResponse) { + option (google.api.http) = { + put: "/policies/{id}" + body: "*" + }; + } + + rpc ListResources(ListResourcesRequest) returns (ListResourcesResponse) { + option (google.api.http) = { + get: "/resources" + }; + } + + rpc UpdateResource(UpdateResourceRequest) returns (Resource) { + option (google.api.http) = { + put: "/resources/{id}" + body: "*" + }; + } + + rpc ListAppeals(ListAppealsRequest) returns (ListAppealsResponse) { + option (google.api.http) = { + get: "/appeals" + }; + } + + rpc GetAppeal(GetAppealRequest) returns (GetAppealResponse) { + option (google.api.http) = { + get: "/appeals/{id}" + }; + } + + rpc CancelAppeal(CancelAppealRequest) returns (CancelAppealResponse) { + option (google.api.http) = { + put: "/appeals/{id}/cancel" + }; + } + + rpc RevokeAppeal(RevokeAppealRequest) returns (RevokeAppealResponse) { + option (google.api.http) = { + put: "/appeals/{id}/revoke" + }; + } + + rpc CreateAppeal(CreateAppealRequest) returns (CreateAppealResponse) { + option (google.api.http) = { + post: "/appeals" + body: "*" + }; + } + + rpc ListApprovals(ListApprovalsRequest) returns (ListApprovalsResponse) { + option (google.api.http) = { + get: "/appeals/approvals" + }; + } + + rpc UpdateApproval(UpdateApprovalRequest) returns (UpdateApprovalResponse) { + option (google.api.http) = { + post: "/appeals/{id}/approvals/{approval_name}" + body: "*" + }; + } +} + +message ListProvidersRequest {} + +message ListProvidersResponse { + repeated Provider providers = 1; +} + +message CreateProviderRequest { + Provider provider = 1; +} + +message CreateProviderResponse { + Provider provider = 1; +} + +message UpdateProviderRequest { + uint32 id = 1; + Provider provider = 2; +} + +message UpdateProviderResponse { + Provider provider = 1; +} + +message ListPoliciesRequest {} + +message ListPoliciesResponse { + repeated Policy policies = 1; +} + +message CreatePolicyRequest { + Policy policy = 1; +} + +message CreatePolicyResponse { + Policy policy = 1; +} + +message UpdatePolicyRequest { + string id = 1; + Policy policy = 2; +} + +message UpdatePolicyResponse { + Policy policy = 1; +} + +message ListResourcesRequest {} + +message ListResourcesResponse { + repeated Resource resources = 1; +} + +message UpdateResourceRequest { + uint32 id = 1; + Resource resource = 2; +} + +message ListAppealsRequest { + string user = 1; +} + +message ListAppealsResponse { + repeated Appeal appeals = 1; +} + +message GetAppealRequest { + uint32 id = 1; +} + +message GetAppealResponse { + Appeal appeal = 1; +} + +message CancelAppealRequest { + uint32 id = 1; +} + +message CancelAppealResponse { + Appeal appeal = 1; +} + +message RevokeAppealRequest { + uint32 id = 1; +} + +message RevokeAppealResponse { + Appeal appeal = 1; +} + +message CreateAppealRequest { + string user = 1; + + message Resource { + uint32 id = 1; + string role = 2; + google.protobuf.Struct options = 3; + } + repeated Resource resources = 2; +} + +message CreateAppealResponse { + repeated Appeal appeals = 1; +} + +message ListApprovalsRequest { + string user = 1; +} + +message ListApprovalsResponse { + repeated Approval approvals = 1; +} + +message UpdateApprovalRequest { + uint32 id = 1; + string approval_name = 2; + + message Action { + string action = 1; + } + Action action = 3; +} + +message UpdateApprovalResponse { + Appeal appeal = 1; +} + +// Provider contains information about external data provider such as BigQuery, Metabase, etc., credentials, policy, and allowed roles +message Provider { + uint32 id = 1; + string type = 2; + string urn = 3; + + message ProviderConfig { + string type = 1; + string urn = 2; + google.protobuf.Struct labels = 3; + google.protobuf.Value credentials = 4; + + message AppealConfig { + bool allow_permanent_access = 1; + string allow_active_access_extension_in = 2; + } + AppealConfig appeal = 5; + + message ResourceConfig { + string type = 1; + + message PolicyConfig { + string id = 1; + int32 version = 2; + } + PolicyConfig policy = 2; + + message RoleConfig { + string id = 1; + string name = 2; + string description = 3; + repeated google.protobuf.Value permissions = 4; + } + repeated RoleConfig roles = 3; + } + ResourceConfig resources = 6; + } + ProviderConfig config = 4; + + google.protobuf.Timestamp created_at = 5; + google.protobuf.Timestamp updated_at = 6; +} + +// Policy is a configurable steps for appeal's approval +message Policy { + string id = 1; + uint32 version = 2; + string description = 3; + + message ApprovalStep { + string name = 1; + string description = 2; // optional + + message Condition { + string field = 1; + + message MatchCondition { + google.protobuf.Value eq = 1; + } + MatchCondition match = 2; + } + repeated Condition conditions = 3; // optional + + bool allow_failed = 4; // optional + repeated string dependencies = 5; // optional + string approvers = 6; // optional + } + repeated ApprovalStep steps = 4; + + google.protobuf.Struct labels = 5; + google.protobuf.Timestamp created_at = 6; + google.protobuf.Timestamp updated_at = 7; +} + +// Appeal is created by user to get access to one or more resources +message Appeal { + uint32 id = 1; + uint32 resource_id = 2; + string policy_id = 3; + uint32 policy_version = 4; + string status = 5; + string user = 6; + string role = 7; + + message AppealOptions { + google.protobuf.Timestamp expiration_date = 1; // optional + } + AppealOptions options = 8; // optional + + google.protobuf.Struct labels = 9; + Resource resource = 10; // optional + repeated Approval approvals = 11; + + google.protobuf.Timestamp created_at = 12; + google.protobuf.Timestamp updated_at = 13; +} + +// Approval is an approval item that generated in an appeal based on the selected policy +message Approval { + uint32 id = 1; + string name = 2; + uint32 appeal_id = 3; + string status = 4; + string actor = 5; + string policy_id = 6; + uint32 policy_version = 7; + repeated string approvers = 8; + Appeal appeal = 9; + google.protobuf.Timestamp created_at = 10; + google.protobuf.Timestamp updated_at = 11; +} + +// Resource contains information of resource from providers +message Resource { + uint32 id = 1; + string provider_type = 2; + string provider_urn = 3; + string type = 4; + string urn = 5; + string name = 6; + google.protobuf.Struct details = 7; + google.protobuf.Struct labels = 8; + google.protobuf.Timestamp created_at = 9; + google.protobuf.Timestamp updated_at = 10; +} \ No newline at end of file diff --git a/odpf/metadata/dataset.proto b/odpf/metadata/dataset.proto new file mode 100644 index 00000000..9cb3617b --- /dev/null +++ b/odpf/metadata/dataset.proto @@ -0,0 +1,5 @@ +syntax = "proto3"; + +message Dataset { + +} \ No newline at end of file