scaleway-sdk-js icon indicating copy to clipboard operation
scaleway-sdk-js copied to clipboard

Improve locality type of an API

Open Vinzius opened this issue 2 months ago • 0 comments

Context

At the moment, the locality object of an API (example with Instance) is only providing part of the information.

What information would be useful:

  • API is zonal
  • API is regional
  • API is global (missing)
  • API is missing its locality definition (missing)

Proposition

We could upgrade the object to this:

type ApiLocality = {
  type: 'zone'
  zones: Zone[]
} | {
  type: 'region'
  regions: Region[]
} | {
  type: 'global'
}

Which could lead to this object:

export class API extends ParentAPI {
  // Case 1: zone
  public static readonly LOCALITY: ApiLocality = { type: 'zone', zones: ['fr-par-1', 'fr-par-2'] }

  // Case 2: region
  public static readonly LOCALITY: ApiLocality = { type: 'region', regions: ['fr-par'] }

  // Case 3: global
  public static readonly LOCALITY: ApiLocality = { type: 'global' }

  // Case 4: not defined
}

Migration

Both objects would be supported for a period of time (the former one with a @deprecated).

Vinzius avatar Apr 08 '24 14:04 Vinzius