From 6a88fcbc438fad45aafd6b09776c6df5900762ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serge=20H=C3=A4nni?= Date: Thu, 11 Jun 2026 17:23:47 +0200 Subject: [PATCH] Add operator reporting dashboards client Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- lib/ioki/apis/operator_api.rb | 6 ++ .../operator/reporting/report_dashboard.rb | 28 ++++++++ .../reporting/report_dashboard_widget.rb | 71 +++++++++++++++++++ .../report_dashboard_widget_group.rb | 28 ++++++++ spec/ioki/operator_api_spec.rb | 14 ++++ 5 files changed, 147 insertions(+) create mode 100644 lib/ioki/model/operator/reporting/report_dashboard.rb create mode 100644 lib/ioki/model/operator/reporting/report_dashboard_widget.rb create mode 100644 lib/ioki/model/operator/reporting/report_dashboard_widget_group.rb diff --git a/lib/ioki/apis/operator_api.rb b/lib/ioki/apis/operator_api.rb index c8532bf2..a31a2e60 100644 --- a/lib/ioki/apis/operator_api.rb +++ b/lib/ioki/apis/operator_api.rb @@ -463,6 +463,12 @@ class OperatorApi path: 'aggregations', model_class: Ioki::Model::Operator::Reporting::ReportAggregation ), + Endpoints::Index.new( + :reporting_dashboards, + base_path: [API_BASE_PATH, 'reporting', 'report', 'scopes', :scope], + path: 'dashboards', + model_class: Ioki::Model::Operator::Reporting::ReportDashboard + ), Endpoints::Create.new( :reporting_aggregation_series, base_path: [ diff --git a/lib/ioki/model/operator/reporting/report_dashboard.rb b/lib/ioki/model/operator/reporting/report_dashboard.rb new file mode 100644 index 00000000..bcf0d6a5 --- /dev/null +++ b/lib/ioki/model/operator/reporting/report_dashboard.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Ioki + module Model + module Operator + module Reporting + class ReportDashboard < Base + attribute :type, + on: :read, + type: :string + + attribute :name, + on: :read, + type: :string + + attribute :localized_name, + on: :read, + type: :string + + attribute :groups, + on: :read, + type: :array, + class_name: 'ReportDashboardWidgetGroup' + end + end + end + end +end diff --git a/lib/ioki/model/operator/reporting/report_dashboard_widget.rb b/lib/ioki/model/operator/reporting/report_dashboard_widget.rb new file mode 100644 index 00000000..a3837122 --- /dev/null +++ b/lib/ioki/model/operator/reporting/report_dashboard_widget.rb @@ -0,0 +1,71 @@ +# frozen_string_literal: true + +module Ioki + module Model + module Operator + module Reporting + class ReportDashboardWidget < Base + attribute :type, + on: :read, + type: :string + + attribute :name, + on: :read, + type: :string + + attribute :localized_name, + on: :read, + type: :string + + attribute :report_name, + on: :read, + type: :string + + attribute :aggregation_name, + on: :read, + type: :string + + attribute :localized_aggregation_name, + on: :read, + type: :string + + attribute :query_type, + on: :read, + type: :string + + attribute :default_preset, + on: :read, + type: :string + + attribute :default_bucket, + on: :read, + type: :string + + attribute :visualization, + on: :read, + type: :string + + attribute :bucket, + on: :read, + type: :object, + class_name: 'ReportAggregationBucket' + + attribute :measures, + on: :read, + type: :array, + class_name: 'ReportAggregationMeasure' + + attribute :dimensions, + on: :read, + type: :array, + class_name: 'ReportAggregationDimension' + + attribute :filters, + on: :read, + type: :array, + class_name: 'ReportAggregationFilter' + end + end + end + end +end diff --git a/lib/ioki/model/operator/reporting/report_dashboard_widget_group.rb b/lib/ioki/model/operator/reporting/report_dashboard_widget_group.rb new file mode 100644 index 00000000..8299b37b --- /dev/null +++ b/lib/ioki/model/operator/reporting/report_dashboard_widget_group.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Ioki + module Model + module Operator + module Reporting + class ReportDashboardWidgetGroup < Base + attribute :type, + on: :read, + type: :string + + attribute :group_name, + on: :read, + type: :string + + attribute :localized_group_name, + on: :read, + type: :string + + attribute :widgets, + on: :read, + type: :array, + class_name: 'ReportDashboardWidget' + end + end + end + end +end diff --git a/spec/ioki/operator_api_spec.rb b/spec/ioki/operator_api_spec.rb index a3cb2cbc..85d01886 100644 --- a/spec/ioki/operator_api_spec.rb +++ b/spec/ioki/operator_api_spec.rb @@ -1948,6 +1948,20 @@ end end + describe '#reporting_dashboards(scope)' do + it 'calls request on the client with expected params' do + expect(operator_client).to receive(:request) do |params| + expect(params[:url].to_s) + .to eq('operator/reporting/report/scopes/myscope/dashboards') + result_with_index_data + end + + dashboards = operator_client.reporting_dashboards('myscope', options) + + expect(dashboards).to all(be_a(Ioki::Model::Operator::Reporting::ReportDashboard)) + end + end + describe '#create_reporting_aggregation_series(scope, name, aggregation_name, query)' do let(:query) do Ioki::Model::Operator::Reporting::ReportAggregationSeriesQuery.new(