golem_cloud_client/
lib.rs

1use golem_common::model::plugin::ComponentPluginScope;
2use golem_common::model::{Empty, ProjectId};
3use serde::{Deserialize, Serialize};
4use std::fmt;
5use std::fmt::{Display, Formatter};
6
7include!(concat!(env!("OUT_DIR"), "/src/lib.rs"));
8
9#[cfg(test)]
10test_r::enable!();
11
12#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
13#[serde(rename_all = "camelCase")]
14pub struct ProjectPluginScope {
15    pub project_id: ProjectId,
16}
17
18#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
19#[serde(tag = "type")]
20pub enum CloudPluginScope {
21    Global(Empty),
22    Component(ComponentPluginScope),
23    Project(ProjectPluginScope),
24}
25
26impl Display for CloudPluginScope {
27    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
28        match self {
29            CloudPluginScope::Global(_) => write!(f, "global"),
30            CloudPluginScope::Component(scope) => write!(f, "component:{}", scope.component_id),
31            CloudPluginScope::Project(scope) => write!(f, "project:{}", scope.project_id),
32        }
33    }
34}
35
36impl Default for CloudPluginScope {
37    fn default() -> Self {
38        CloudPluginScope::Global(Empty {})
39    }
40}