@@ -400,77 +400,6 @@ func (c *NamespaceClient) getNamespaceCapacityInfoCloudApi(namespace string) (*c
400400 return res .CapacityInfo , nil
401401}
402402
403- // NamespaceCapacityInfoOutput is a flattened version of NamespaceCapacityInfo
404- // that maintains backwards compatibility by keeping provisioned/onDemand and
405- // latestRequest at the top level while adding new fields.
406- type NamespaceCapacityInfoOutput struct {
407- Namespace string `json:"namespace,omitempty"`
408- HasLegacyLimits bool `json:"hasLegacyLimits"`
409- // CurrentMode fields - flattened from CurrentCapacity
410- Provisioned * cloudNamespace.Capacity_Provisioned `json:"provisioned,omitempty"`
411- OnDemand * cloudNamespace.Capacity_OnDemand `json:"onDemand,omitempty"`
412- // LatestRequest - flattened from CurrentCapacity
413- LatestRequest * cloudNamespace.Capacity_Request `json:"latestRequest,omitempty"`
414- // New fields
415- ModeOptions * cloudNamespace.NamespaceCapacityInfo_CapacityModeOptions `json:"modeOptions,omitempty"`
416- Stats * NamespaceCapacityInfoOutput_Stats `json:"stats,omitempty"`
417- }
418-
419- // NamespaceCapacityInfoOutput_Stats wraps the proto Stats type to ensure
420- // numeric fields are always included in JSON output (no omitempty).
421- type NamespaceCapacityInfoOutput_Stats struct {
422- Aps * NamespaceCapacityInfoOutput_Stats_Summary `json:"aps,omitempty"`
423- }
424-
425- // NamespaceCapacityInfoOutput_Stats_Summary wraps the proto Stats_Summary type
426- // to ensure numeric fields are always included in JSON output (no omitempty).
427- type NamespaceCapacityInfoOutput_Stats_Summary struct {
428- Mean float64 `json:"mean"`
429- P90 float64 `json:"p90"`
430- P99 float64 `json:"p99"`
431- }
432-
433- // transformCapacityInfoForOutput flattens the NamespaceCapacityInfo structure
434- // to maintain backwards compatibility while including new fields.
435- func transformCapacityInfoForOutput (info * cloudNamespace.NamespaceCapacityInfo ) * NamespaceCapacityInfoOutput {
436- if info == nil {
437- return nil
438- }
439-
440- output := & NamespaceCapacityInfoOutput {
441- Namespace : info .Namespace ,
442- HasLegacyLimits : info .HasLegacyLimits ,
443- ModeOptions : info .ModeOptions ,
444- }
445-
446- // Convert Stats to custom type to ensure zero values are included
447- if info .Stats != nil {
448- output .Stats = & NamespaceCapacityInfoOutput_Stats {}
449- if info .Stats .Aps != nil {
450- output .Stats .Aps = & NamespaceCapacityInfoOutput_Stats_Summary {
451- Mean : info .Stats .Aps .Mean ,
452- P90 : info .Stats .Aps .P90 ,
453- P99 : info .Stats .Aps .P99 ,
454- }
455- }
456- }
457-
458- // Flatten currentCapacity fields to top level
459- if info .CurrentCapacity != nil {
460- // Extract the current mode (provisioned or onDemand)
461- if prov := info .CurrentCapacity .GetProvisioned (); prov != nil {
462- output .Provisioned = prov
463- }
464- if od := info .CurrentCapacity .GetOnDemand (); od != nil {
465- output .OnDemand = od
466- }
467- // Extract latestRequest
468- output .LatestRequest = info .CurrentCapacity .LatestRequest
469- }
470-
471- return output
472- }
473-
474403// TODO: deprecate this and use getNamespaceCloudApi everywhere
475404func (c * NamespaceClient ) getNamespace (namespace string ) (* namespace.Namespace , error ) {
476405 res , err := c .client .GetNamespace (c .ctx , & namespaceservice.GetNamespaceRequest {
@@ -1997,7 +1926,7 @@ func NewNamespaceCommand(getNamespaceClientFn GetNamespaceClientFn) (CommandOut,
19971926 },
19981927 {
19991928 Name : "capacity" ,
2000- Usage : "Manage namespace capacity settings " ,
1929+ Usage : "Manage namespace capacity" ,
20011930 Aliases : []string {"cap" },
20021931 Subcommands : []* cli.Command {
20031932 {
@@ -2008,13 +1937,11 @@ func NewNamespaceCommand(getNamespaceClientFn GetNamespaceClientFn) (CommandOut,
20081937 NamespaceFlag ,
20091938 },
20101939 Action : func (ctx * cli.Context ) error {
2011- n , err := c .getNamespaceCapacityInfoCloudApi (ctx .String (NamespaceFlagName ))
1940+ capacityInfo , err := c .getNamespaceCapacityInfoCloudApi (ctx .String (NamespaceFlagName ))
20121941 if err != nil {
20131942 return err
20141943 }
2015- // Transform to flattened output structure for backwards compatibility
2016- output := transformCapacityInfoForOutput (n )
2017- return PrintObj (output )
1944+ return PrintProto (capacityInfo )
20181945 },
20191946 },
20201947 {
0 commit comments