//
// Copyright 2020 The Feast Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//


syntax = "proto3";
package feast.core;

option go_package = "github.com/feast-dev/feast/sdk/go/protos/feast/core";
option java_outer_classname = "FeatureViewProto";
option java_package = "feast.proto.core";

import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
import "feast/core/DataSource.proto";
import "feast/core/Feature.proto";

message FeatureView {
    // User-specified specifications of this feature view.
    FeatureViewSpec spec = 1;

    // System-populated metadata for this feature view.
    FeatureViewMeta meta = 2;
}

message FeatureViewSpec {
    // Name of the feature view. Must be unique. Not updated.
    string name = 1;

    // Name of Feast project that this feature view belongs to.
    string project = 2;

    // List names of entities to associate with the Features defined in this 
    // Feature View. Not updatable.
    repeated string entities = 3;

    // List of features specifications for each feature defined with this feature view.
    repeated FeatureSpecV2 features = 4;

    // User defined metadata
    map<string,string> tags = 5;

    // Features in this feature view can only be retrieved from online serving
    // younger than ttl. Ttl is measured as the duration of time between
    // the feature's event timestamp and when the feature is retrieved
    // Feature values outside ttl will be returned as unset values and indicated to end user
    google.protobuf.Duration ttl = 6;

    // Batch/Offline DataSource where this view can retrieve offline feature data.
    DataSource input = 7;

    // Whether these features should be served online or not
    bool online = 8;
}

message FeatureViewMeta {
    // Time where this Feature View is created
    google.protobuf.Timestamp created_timestamp = 1;

    // Time where this Feature View is last updated
    google.protobuf.Timestamp last_updated_timestamp = 2;

    // List of pairs (start_time, end_time) for which this feature view has been materialized.
    repeated MaterializationInterval materialization_intervals = 3;
}

message MaterializationInterval {
    google.protobuf.Timestamp start_time = 1;
    google.protobuf.Timestamp end_time = 2;
}
