@@ -14,6 +14,7 @@ mod v1;
1414
1515use cidr:: Cidr ;
1616use esc_api:: resources:: MfaStatus ;
17+
1718use esc_api:: { GroupId , MemberId , OrgId } ;
1819use output:: OutputFormat ;
1920use serde:: Serialize ;
@@ -1013,6 +1014,7 @@ struct Mesdb {
10131014enum MesdbCommand {
10141015 Clusters ( Clusters ) ,
10151016 Backups ( Backups ) ,
1017+ SharedClusters ( SharedClusters ) ,
10161018}
10171019
10181020#[ derive( Debug , StructOpt ) ]
@@ -1074,7 +1076,7 @@ struct CreateCluster {
10741076
10751077 #[ structopt(
10761078 long,
1077- help = "Type of disk. For example, if you are using AWS as a provider, it could be GP2"
1079+ help = "Type of disk. For example, if you are using AWS as a provider, it could be GP2"
10781080 ) ]
10791081 disk_type : String ,
10801082
@@ -1102,6 +1104,12 @@ struct CreateCluster {
11021104
11031105 #[ structopt( long, help = "The protected flag prevents from accidental deletion" ) ]
11041106 protected : Option < bool > ,
1107+
1108+ #[ structopt( long, help = "The provider of the cluster" ) ]
1109+ provider : Option < String > ,
1110+
1111+ #[ structopt( long, help = "The region of the cluster" ) ]
1112+ region : Option < String > ,
11051113}
11061114
11071115#[ derive( Debug , StructOpt ) ]
@@ -1248,6 +1256,97 @@ struct UpgradeCluster {
12481256 target_tag : String ,
12491257}
12501258
1259+ #[ derive( Debug , StructOpt ) ]
1260+ #[ structopt( about = "Gathers shared cluster management commands" ) ]
1261+ struct SharedClusters {
1262+ #[ structopt( subcommand) ]
1263+ shared_clusters_command : SharedClustersCommand ,
1264+ }
1265+
1266+ #[ derive( Debug , StructOpt ) ]
1267+ enum SharedClustersCommand {
1268+ Create ( CreateSharedCluster ) ,
1269+ List ( ListSharedClusters ) ,
1270+ Delete ( DeleteSharedCluster ) ,
1271+ Get ( GetSharedCluster ) ,
1272+ }
1273+
1274+ #[ derive( Debug , StructOpt ) ]
1275+ struct CreateSharedCluster {
1276+ #[ structopt( long, parse( try_from_str = parse_org_id) , default_value = "" , help = "The organization id the cluster relates to" ) ]
1277+ org_id : OrgId ,
1278+
1279+ #[ structopt( long, parse( try_from_str = parse_project_id) , default_value = "" , help = "The project id the cluster relates to" ) ]
1280+ project_id : esc_api:: resources:: ProjectId ,
1281+
1282+ #[ structopt( long, parse( try_from_str = parse_acl_id) , help = "The acl id the cluster relates to" ) ]
1283+ acl_id : esc_api:: infra:: AclId ,
1284+
1285+ #[ structopt( long, help = "The name of the cluster" ) ]
1286+ name : String ,
1287+
1288+ #[ structopt( long, help = "The provider of the cluster" ) ]
1289+ provider : String ,
1290+
1291+ #[ structopt( long, help = "The region of the cluster" ) ]
1292+ region : String ,
1293+
1294+ #[ structopt( long, help = "The deployment tier of the cluster" ) ]
1295+ deployment_tier : String ,
1296+
1297+ #[ structopt( long, help = "Whether mutual TLS is enabled for the cluster" ) ]
1298+ mutual_tls_enabled : bool ,
1299+
1300+ #[ structopt(
1301+ long,
1302+ parse( try_from_str = parse_projection_level) ,
1303+ help = "The projection level of your database. Can be off, system or user "
1304+ ) ]
1305+ projection_level : esc_api:: mesdb:: ProjectionLevel ,
1306+
1307+ #[ structopt( long, help = "The server version of the cluster" ) ]
1308+ server_version : String ,
1309+
1310+ #[ structopt( long, parse( try_from_str = parse_topology) , help = "Either single-node or three-node-multi-zone" ) ]
1311+ topology : esc_api:: mesdb:: Topology ,
1312+ }
1313+
1314+ #[ derive( Debug , StructOpt ) ]
1315+ #[ structopt( about = "List all shared clusters of an organization, given a project id" ) ]
1316+ struct ListSharedClusters {
1317+ #[ structopt( long, parse( try_from_str = parse_org_id) , default_value = "" , help = "The organization id the cluster relates to" ) ]
1318+ org_id : OrgId ,
1319+
1320+ #[ structopt( long, parse( try_from_str = parse_project_id) , default_value = "" , help = "The project id the cluster relates to" ) ]
1321+ project_id : esc_api:: resources:: ProjectId ,
1322+ }
1323+
1324+ #[ derive( Debug , StructOpt ) ]
1325+ #[ structopt( about = "Delete a shared cluster" ) ]
1326+ struct DeleteSharedCluster {
1327+ #[ structopt( long, parse( try_from_str = parse_org_id) , default_value = "" , help = "The organization id the cluster relates to" ) ]
1328+ org_id : OrgId ,
1329+
1330+ #[ structopt( long, parse( try_from_str = parse_project_id) , default_value = "" , help = "The project id the cluster relates to" ) ]
1331+ project_id : esc_api:: resources:: ProjectId ,
1332+
1333+ #[ structopt( long, short, parse( try_from_str = parse_cluster_id) , help = "Id of the cluster you want to delete" ) ]
1334+ id : esc_api:: ClusterId ,
1335+ }
1336+
1337+ #[ derive( Debug , StructOpt ) ]
1338+ #[ structopt( about = "Get a shared cluster" ) ]
1339+ struct GetSharedCluster {
1340+ #[ structopt( long, parse( try_from_str = parse_org_id) , default_value = "" , help = "The organization id the cluster relates to" ) ]
1341+ org_id : OrgId ,
1342+
1343+ #[ structopt( long, parse( try_from_str = parse_project_id) , default_value = "" , help = "The project id the cluster relates to" ) ]
1344+ project_id : esc_api:: resources:: ProjectId ,
1345+
1346+ #[ structopt( long, short, parse( try_from_str = parse_cluster_id) , help = "Id of the cluster you want to get" ) ]
1347+ id : esc_api:: ClusterId ,
1348+ }
1349+
12511350#[ derive( Debug , StructOpt ) ]
12521351#[ structopt( about = "Gathers backup management commands" ) ]
12531352struct Backups {
@@ -2717,6 +2816,72 @@ async fn call_api<'a, 'b>(
27172816
27182817 Command :: Mesdb ( mesdb) => {
27192818 match mesdb. mesdb_command {
2819+ MesdbCommand :: SharedClusters ( shared_clusters) => {
2820+ match shared_clusters. shared_clusters_command {
2821+ SharedClustersCommand :: Create ( params) => {
2822+ let client = client_builder. create ( ) . await ?;
2823+ let resp = esc_api:: mesdb:: create_shared_cluster (
2824+ & client,
2825+ params. org_id ,
2826+ params. project_id ,
2827+ esc_api:: mesdb:: CreateSharedClusterDeploymentRequest {
2828+ cluster : esc_api:: mesdb:: CreateSharedClusterRequest {
2829+ name : params. name ,
2830+ provider : params. provider ,
2831+ region : params. region ,
2832+ deployment_tier : params. deployment_tier ,
2833+ mutual_tls_enabled : params. mutual_tls_enabled ,
2834+ projection_level : params. projection_level ,
2835+ server_version : params. server_version ,
2836+ topology : params. topology ,
2837+ } ,
2838+ acl : esc_api:: mesdb:: Acl :: ResourceIdentifier (
2839+ esc_api:: mesdb:: ResourceIdentifier {
2840+ id : params. acl_id . 0 ,
2841+ } ,
2842+ ) ,
2843+ } ,
2844+ )
2845+ . await ?;
2846+ printer. print ( resp) ?;
2847+ }
2848+
2849+ SharedClustersCommand :: List ( params) => {
2850+ let client = client_builder. create ( ) . await ?;
2851+ let resp = esc_api:: mesdb:: list_shared_clusters (
2852+ & client,
2853+ params. org_id ,
2854+ params. project_id ,
2855+ )
2856+ . await ?;
2857+ printer. print ( resp) ?;
2858+ }
2859+
2860+ SharedClustersCommand :: Delete ( params) => {
2861+ let client = client_builder. create ( ) . await ?;
2862+ esc_api:: mesdb:: delete_shared_cluster (
2863+ & client,
2864+ params. org_id ,
2865+ params. project_id ,
2866+ params. id ,
2867+ )
2868+ . await ?;
2869+ }
2870+
2871+ SharedClustersCommand :: Get ( params) => {
2872+ let client = client_builder. create ( ) . await ?;
2873+ let resp = esc_api:: mesdb:: get_shared_cluster (
2874+ & client,
2875+ params. org_id ,
2876+ params. project_id ,
2877+ params. id ,
2878+ )
2879+ . await ?;
2880+ printer. print ( resp) ?;
2881+ }
2882+ }
2883+ }
2884+
27202885 MesdbCommand :: Clusters ( clusters) => match clusters. clusters_command {
27212886 ClustersCommand :: Create ( params) => {
27222887 let client = client_builder. create ( ) . await ?;
@@ -2741,6 +2906,8 @@ async fn call_api<'a, 'b>(
27412906 topology : params. topology ,
27422907 protected : params. protected ,
27432908 public_access : params. public_access ,
2909+ provider : params. provider ,
2910+ region : params. region ,
27442911 } ,
27452912 )
27462913 . await ?;
0 commit comments