@@ -35,7 +35,7 @@ import {
3535 CardinalityQueryResult ,
3636} from "SnubaAdmin/cardinality_analyzer/types" ;
3737
38- import { AllocationPolicy } from "SnubaAdmin/capacity_management/types" ;
38+ import { AllocationPolicy , Entity } from "SnubaAdmin/capacity_management/types" ;
3939
4040import { ReplayInstruction , Topic } from "SnubaAdmin/dead_letter_queue/types" ;
4141import { AutoReplacementsBypassProjectsData } from "SnubaAdmin/auto_replacements_bypass_projects/types" ;
@@ -83,17 +83,18 @@ interface Client {
8383 getAllMigrationGroups : ( ) => Promise < MigrationGroupResult [ ] > ;
8484 runMigration : ( req : RunMigrationRequest ) => Promise < RunMigrationResult > ;
8585 getAllowedTools : ( ) => Promise < AllowedTools > ;
86+ getRoutingStrategies : ( ) => Promise < string [ ] > ;
8687 getStoragesWithAllocationPolicies : ( ) => Promise < string [ ] > ;
87- getAllocationPolicies : ( storage : string ) => Promise < AllocationPolicy [ ] > ;
88+ getAllocationPolicies : ( entity : Entity ) => Promise < AllocationPolicy [ ] > ;
8889 setAllocationPolicyConfig : (
89- storage : string ,
90+ entity : Entity ,
9091 policy : string ,
9192 key : string ,
9293 value : string ,
9394 params : object ,
9495 ) => Promise < void > ;
9596 deleteAllocationPolicyConfig : (
96- storage : string ,
97+ entity_name : string ,
9798 policy : string ,
9899 key : string ,
99100 params : object ,
@@ -445,31 +446,39 @@ function Client(): Client {
445446 } ) . then ( ( resp ) => resp . json ( ) ) ;
446447 } ,
447448
449+ getRoutingStrategies : ( ) => {
450+ const url = baseUrl + "routing_strategies" ;
451+ return fetch ( url , {
452+ headers : { "Content-Type" : "application/json" } ,
453+ } ) . then ( ( resp ) => resp . json ( ) ) ;
454+ } ,
455+
448456 getStoragesWithAllocationPolicies : ( ) => {
449457 const url = baseUrl + "storages_with_allocation_policies" ;
450458 return fetch ( url , {
451459 headers : { "Content-Type" : "application/json" } ,
452460 } ) . then ( ( resp ) => resp . json ( ) ) ;
453461 } ,
454- getAllocationPolicies : ( storage : string ) => {
462+ getAllocationPolicies : ( entity : Entity ) => {
455463 const url =
456- baseUrl + "allocation_policy_configs/" + encodeURIComponent ( storage ) ;
464+ baseUrl + "allocation_policy_configs/" + entity . type + "/" + encodeURIComponent ( entity . name ) ;
457465 return fetch ( url , {
458466 headers : { "Content-Type" : "application/json" } ,
459467 } ) . then ( ( resp ) => resp . json ( ) ) ;
460468 } ,
461469 setAllocationPolicyConfig : (
462- storage : string ,
470+ entity : Entity ,
463471 policy : string ,
464472 key : string ,
465473 value : string ,
466474 params : object ,
467475 ) => {
476+ const body = entity . type === "storage" ? JSON . stringify ( { storage : entity . name , policy, key, value, params } ) : JSON . stringify ( { strategy : entity . name , policy, key, value, params } ) ;
468477 const url = baseUrl + "allocation_policy_config" ;
469478 return fetch ( url , {
470479 headers : { "Content-Type" : "application/json" } ,
471480 method : "POST" ,
472- body : JSON . stringify ( { storage , policy , key , value , params } ) ,
481+ body : body ,
473482 } ) . then ( ( res ) => {
474483 if ( res . ok ) {
475484 return ;
@@ -482,7 +491,7 @@ function Client(): Client {
482491 } ) ;
483492 } ,
484493 deleteAllocationPolicyConfig : (
485- storage : string ,
494+ entity_name : string ,
486495 policy : string ,
487496 key : string ,
488497 params : object ,
@@ -491,7 +500,7 @@ function Client(): Client {
491500 return fetch ( url , {
492501 headers : { "Content-Type" : "application/json" } ,
493502 method : "DELETE" ,
494- body : JSON . stringify ( { storage , policy, key, params } ) ,
503+ body : JSON . stringify ( { entity_name , policy, key, params } ) ,
495504 } ) . then ( ( res ) => {
496505 if ( res . ok ) {
497506 return ;
0 commit comments