// This proto file was generated from themes-service-api.yml.
// Care should be taken while both files exist to maintain backwards compatibility with the Conjure generated code.

syntax = "proto3";

package nominal.themes.v1;

import "buf/validate/validate.proto";
import "google/api/annotations.proto";
import "google/protobuf/timestamp.proto";
import "nominal/protos/conjure/v1/compat.proto";
import "nominal/protos/gen/v1/alias.proto";
import "nominal/protos/gen/v1/error.proto";

option java_multiple_files = true;
option java_package = "io.nominal.themes.v1";

message ChartTheme {
  // Unique resource identifier for the theme.
  string rid = 1 [(nominal.gen.v1.alias) = {java_name: "io.nominal.themes.api.ChartThemeRid"}];

  // The name of the theme as defined by the user.
  string name = 2;

  // The rid of the user who first created the theme.
  string created_by = 3 [(nominal.gen.v1.alias) = {java_name: "com.palantir.ri.ResourceIdentifier"}];

  // The time the theme was created.
  google.protobuf.Timestamp created_at = 4;

  // The rid of the user who last updated the theme.
  optional string updated_by = 5 [(nominal.gen.v1.alias) = {java_name: "com.palantir.ri.ResourceIdentifier"}];

  // The rid of the user who last updated the theme.
  optional google.protobuf.Timestamp updated_at = 6;

  // Specifies the chart theme styling (e.g. font, legends, axes)
  ChartThemeContent content = 7;
}

message ChartThemeContent {
  option (nominal.conjure.v1.conjure_compat) = {union_message: true};

  oneof chart_theme_content {
    option (buf.validate.oneof) = {required: true};

    ChartThemeContentV1 v1 = 1;
  }
}

message ChartThemeContentV1 {
  // Whether to show a title in the export.
  bool title_enabled = 1;

  // How to align the text of the title.
  TextAlignment title_alignment = 2;

  // Font size of the title.
  int32 title_font_size = 3;

  // Font color of the title.
  string title_font_color = 4 [(nominal.gen.v1.alias) = {java_name: "io.nominal.themes.api.HexColor"}];

  // Whether to show a caption in the export.
  bool caption_enabled = 5;

  // How to align the text of the caption.
  TextAlignment caption_alignment = 6;

  // Font size of the caption.
  int32 caption_font_size = 7;

  // Font color of the caption.
  string caption_font_color = 8 [(nominal.gen.v1.alias) = {java_name: "io.nominal.themes.api.HexColor"}];

  // Whether to include a default background with the export.
  // (`false` indicates that the background should be transparent)
  bool background_enabled = 9;

  // Whether to include a legend in the export.
  bool legend_enabled = 10;

  // Which side the legend should appear on.
  LegendPosition legend_position = 11;

  // Font size of the legend.
  int32 legend_font_size = 12;

  // Font color of the legend.
  string legend_font_color = 13 [(nominal.gen.v1.alias) = {java_name: "io.nominal.themes.api.HexColor"}];

  // Where on the chart the legend should be placed.
  LegendPlacement legend_placement = 14;

  // Whether rows will be separated.
  bool row_gap_enabled = 15;

  // The size of the row gap.
  optional int32 row_gap_size = 16;

  // The relative width of the chart export.
  int32 aspect_ratio_width = 17;

  // The relative height of the chart export.
  int32 aspect_ratio_height = 18;

  // Theme parameters specific to chart types.
  ChartTypeThemes chart_type_themes = 19;
}

// Theme parameters specific to chart types.
message ChartTypeThemes {
  // The theme specific to parameters of the time series chart.
  TimeSeriesChartTheme time_series = 1;
}

message CreateChartThemeRequest {
  // The name of the theme.
  string name = 1;

  // The theme fields.
  ChartThemeContent content = 2;

  // The workspace in which to create the theme. If not provided, the theme will be created in the default workspace for
  // the user's organization, if the default workspace for the organization is configured.
  optional string workspace = 3 [(nominal.gen.v1.alias) = {java_name: "io.nominal.api.rids.WorkspaceRid"}];
}

// buf:lint:ignore ENUM_VALUE_PREFIX
enum LegendPlacement {
  LEGEND_PLACEMENT_UNSPECIFIED = 0;
  OUTSIDE = 1;
  INSIDE = 2;
}

// buf:lint:ignore ENUM_VALUE_PREFIX
enum LegendPosition {
  LEGEND_POSITION_UNSPECIFIED = 0;
  TOP = 1;
  BOTTOM = 2;
  LEFT = 3;
  RIGHT = 4;
}

// buf:lint:ignore ENUM_VALUE_PREFIX
enum TextAlignment {
  TEXT_ALIGNMENT_UNSPECIFIED = 0;
  START = 1;
  END = 2;
  CENTER = 3;
  JUSTIFY = 4;
}

// buf:lint:ignore ENUM_VALUE_PREFIX
enum TextDirection {
  TEXT_DIRECTION_UNSPECIFIED = 0;
  HORIZONTAL = 1;
  VERTICAL = 2;
}

message TimeSeriesChartTheme {
  option (nominal.conjure.v1.conjure_compat) = {union_message: true};

  oneof time_series_chart_theme {
    option (buf.validate.oneof) = {required: true};

    TimeSeriesChartThemeV1 v1 = 1;
  }
}

// Theme parameters specific to the time series chart.
message TimeSeriesChartThemeV1 {
  // The font size of the x-axis ticks.
  int32 x_axis_tick_font_size = 1;

  // The font color of the x-axis ticks.
  string x_axis_tick_font_color = 2 [(nominal.gen.v1.alias) = {java_name: "io.nominal.themes.api.HexColor"}];

  // The font size of the y-axis labels.
  int32 y_axis_title_font_size = 3;

  // The font size of the y-axis ticks.
  int32 y_axis_tick_font_size = 4;

  // The line thickness in px of the threshold line.
  optional int32 threshold_line_width = 5;
}

message UpdateChartThemeRequest {
  // The name of the theme.
  string name = 1;

  // The theme fields.
  ChartThemeContent content = 2;
}

message ListChartThemesRequest {
  // If supplied, will return only results within the supplied workspaces. If empty
  // will return all results within workspaces that the user is permitted to see.
  repeated string workspaces = 1 [(nominal.gen.v1.alias) = {java_name: "io.nominal.api.rids.WorkspaceRid"}];
}

message ListChartThemesResponse {
  repeated ChartTheme chart_themes = 1;
}

message GetChartThemeRequest {
  // The RID of chart theme.
  string chart_theme_rid = 1 [(nominal.gen.v1.alias) = {java_name: "io.nominal.themes.api.ChartThemeRid"}];
}

message GetChartThemeResponse {
  ChartTheme chart_theme = 1;
}

message CreateChartThemeResponse {
  ChartTheme chart_theme = 1;
}

message UpdateChartThemeRequestWrapper {
  // The RID of chart theme to update.
  string chart_theme_rid = 1 [(nominal.gen.v1.alias) = {java_name: "io.nominal.themes.api.ChartThemeRid"}];

  UpdateChartThemeRequest request = 2;
}

message UpdateChartThemeResponse {
  ChartTheme chart_theme = 1;
}

message DeleteChartThemeRequest {
  // The RID of chart theme to delete.
  string chart_theme_rid = 1 [(nominal.gen.v1.alias) = {java_name: "io.nominal.themes.api.ChartThemeRid"}];
}

message DeleteChartThemeResponse {}

// buf:lint:ignore ENUM_ZERO_VALUE_SUFFIX
enum ThemesError {
  THEMES_ERROR_CHART_THEME_NAME_CONFLICT = 0 [(nominal.gen.v1.error) = {
    code: "ALREADY_EXISTS"
    message: "ChartThemeNameConflict"
  }];
  THEMES_ERROR_CHART_THEME_NOT_FOUND = 1 [(nominal.gen.v1.error) = {
    code: "NOT_FOUND"
    message: "ChartThemeNotFound"
  }];
  THEMES_ERROR_INVALID_CHART_THEME = 2 [(nominal.gen.v1.error) = {
    code: "INVALID_ARGUMENT"
    message: "InvalidChartTheme"
  }];
}

// Themes service manages themes for exporting charts.
service ThemesService {
  // Get all chart themes saved to the requested workspaces.
  rpc ListChartThemes(ListChartThemesRequest) returns (ListChartThemesResponse) {
    option (google.api.http) = {
      get: "/themes/v1/chart-themes"
      response_body: "chart_themes"
    };
  }
  // Get a specific chart theme by RID.
  rpc GetChartTheme(GetChartThemeRequest) returns (GetChartThemeResponse) {
    option (google.api.http) = {
      get: "/themes/v1/chart-themes/{chart_theme_rid}"
      response_body: "chart_theme"
    };
  }
  // buf:lint:ignore RPC_REQUEST_STANDARD_NAME
  // Create a new chart theme.
  rpc CreateChartTheme(CreateChartThemeRequest) returns (CreateChartThemeResponse) {
    option (google.api.http) = {
      post: "/themes/v1/chart-themes"
      response_body: "chart_theme"
      body: "*"
    };
  }
  // buf:lint:ignore RPC_REQUEST_STANDARD_NAME
  // Update an existing chart theme.
  rpc UpdateChartTheme(UpdateChartThemeRequestWrapper) returns (UpdateChartThemeResponse) {
    option (google.api.http) = {
      response_body: "chart_theme"
      body: "request"
      put: "/themes/v1/chart-themes/{chart_theme_rid}"
    };
  }
  // Delete an existing comment.
  rpc DeleteChartTheme(DeleteChartThemeRequest) returns (DeleteChartThemeResponse) {
    option (google.api.http) = {delete: "/themes/v1/chart-themes/{chart_theme_rid}"};
  }
}
