// Extracted from: Spotify 1.2.52.442 (windows)

syntax = "proto3";

package spotify.remote_config.ucs.proto;

import "property_definition.proto";

option optimize_for = CODE_SIZE;

message ResolveRequest {
    reserved "custom_context";
    reserved "projection";
    reserved 4;
    reserved 5;
    string property_set_id = 1;
    Fetch fetch_type = 2;
    Context context = 11;
    oneof resolution_context {
        BackendContext backend_context = 12;
    }
}

message ResolveResponse {
    Configuration configuration = 1;
}

message Configuration {
    message AssignedValue {
        message Metadata {
            int64 policy_id = 1;
            string external_realm = 2;
            int64 external_realm_id = 3;
        }

        message BoolValue {
            bool value = 1;
        }

        message IntValue {
            int32 value = 1;
        }

        message EnumValue {
            string value = 1;
        }

        PropertyDefinition.Identifier property_id = 1;
        Metadata metadata = 2;
        oneof structured_value {
            BoolValue bool_value = 3;
            IntValue int_value = 4;
            EnumValue enum_value = 5;
        }
    }

    string configuration_assignment_id = 1;
    int64 fetch_time_millis = 2;
    repeated AssignedValue assigned_values = 3;
}

message Fetch {
    enum Type {
        BLOCKING = 0;
        BACKGROUND_SYNC = 1;
        ASYNC = 2;
        PUSH_INITIATED = 3;
        RECONNECT = 4;
    }

    Type type = 1;
}

message Context {
    message ContextEntry {
        string value = 10;
        oneof context {
            DynamicContext.KnownContext known_context = 1;
            string policy_input_name = 2;
        }
    }

    repeated ContextEntry context = 1;
}

message BackendContext {
    message StaticContext {
        string system = 1;
        string service_name = 2;
    }

    message SurfaceMetadata {
        string backend_sdk_version = 1;
    }

    string system = 1;
    string service_name = 2;
    StaticContext static_context = 3;
    DynamicContext dynamic_context = 4;
    SurfaceMetadata surface_metadata = 10;
}

message DynamicContext {
    message ContextDefinition {
        oneof context {
            KnownContext known_context = 1;
        }
    }

    enum KnownContext {
        KNOWN_CONTEXT_INVALID = 0;
        KNOWN_CONTEXT_USER_ID = 1;
        KNOWN_CONTEXT_INSTALLATION_ID = 2;
        KNOWN_CONTEXT_VERSION = 3;
    }

    repeated ContextDefinition context_definition = 1;
}
