This is a c# counterpart to a similar astrapy issue, plus this extension to create_database.
Specs
CreateDatabase (and async) new fields + validation of pcu group id if passed to CreateDatabase + classes to describe pcu groups + method to retrieve pcu groups.
CreateDatabase
The CreateDatabaseOptions gets new optional fields which map to payload fields:
Tier, serializes as tier, defaults to "serverless"
CapacityUnits, serializes as capacityUnits, defaults to 1
DBType, serializes as dbType, defaults to "vector"
PCUGroupID, serializes as pcuGroupUUID, absent by default (i.e. null and therefore not serialized to payload)
Validation
If a non-null PCUGroupId is passed in the CreateDatabaseOptions parameter to CreateDatabase, a pre-check on the client side is done to ensure the PCU Group exists. If not, an Error is raised right away and no create-db request is fired.
(actually two different errors: (1) pcu group does not exist, (2) pcu group is in a different cloudprovider/region setting).
Listing PCU Groups
AstraDatabasesAdmin must offer a method to list the PCU Groups for the current org, following the corresponding POST /v2/pcu/actions/get DevOps API endpoint.
According to the yellow doc, clients may add a filtering: this requires a ListPCUGroupsOptions: CommandOptions
(if passed, both CloudProvider and Region are required): so,
public List<PCUGroup> ListPCUGroups(ListPCUGroupsOptions options = null)
public Task<List<PCUGroup>> ListPCUGroupsAsync(ListPCUGroupsOptions options = null)
PCU descriptor classes
all must come with unmarshaling capabilities and tolerating missing/null fields in the responses. As the only one directly mentioned in the above methods, it is ok to just have the three of them into a single, src/DataStax.AstraDB.DataApi/Core/PCUGroup.cs.
Below is a stub - there is additional care involved, such as:
- missing fields (strings, subobjects, instances of AstraDatabaseCloudProvider)
- parsing of DateTime
- unmarshaling into the cloud provider enum (like is done elsewhere)
- missing integers unmarshal as zeroes
public class PCUGroup
{
[JsonPropertyName("uuid")]
public string Id { get; set; }
[JsonPropertyName("orgId")]
public string OrgId { get; set; }
[JsonPropertyName("title")]
public string Title { get; set; }
[JsonPropertyName("cloudProvider")]
public AstraDatabaseCloudProvider CloudProvider { get; set; }
[JsonPropertyName("region")]
public string Region { get; set; }
[JsonPropertyName("instanceType")]
public string InstanceType { get; set; }
[JsonPropertyName("pcuType")]
public PCUType? PCUType { get; set; }
[JsonPropertyName("provisionType")]
public string ProvisionType { get; set; }
[JsonPropertyName("min")]
public int Min { get; set; }
[JsonPropertyName("max")]
public int Max { get; set; }
[JsonPropertyName("reserved")]
public int Reserved { get; set; }
[JsonPropertyName("description")]
public string Description { get; set; }
[JsonPropertyName("createdAt")]
public DateTime CreatedAt { get; set; }
[JsonPropertyName("updatedAt")]
public DateTime UpdatedAt { get; set; }
[JsonPropertyName("createdBy")]
public string CreatedBy { get; set; }
[JsonPropertyName("updatedBy")]
public string UpdatedBy { get; set; }
[JsonPropertyName("status")]
public string Status { get; set; }
}
public class PCUType
{
[JsonPropertyName("type")]
public string type { get; set; }
[JsonPropertyName("region")]
public string region { get; set; }
[JsonPropertyName("provider")]
public AstraDatabaseCloudProvider CloudProvider { get; set; }
[JsonPropertyName("details")]
public PCUTypeDetails Details { get; set; }
}
public class PCUTypeDetails
{
[JsonPropertyName("vCPU")]
public int VCpu { get; set; }
[JsonPropertyName("memory")]
public string Memory { get; set; }
[JsonPropertyName("disk_cache")]
public string DiskCache { get; set; }
}
This is a c# counterpart to a similar astrapy issue, plus this extension to create_database.
Specs
CreateDatabase (and async) new fields + validation of pcu group id if passed to CreateDatabase + classes to describe pcu groups + method to retrieve pcu groups.
CreateDatabase
The
CreateDatabaseOptionsgets new optional fields which map to payload fields:Tier, serializes astier, defaults to"serverless"CapacityUnits, serializes ascapacityUnits, defaults to1DBType, serializes asdbType, defaults to"vector"PCUGroupID, serializes aspcuGroupUUID, absent by default (i.e. null and therefore not serialized to payload)Validation
If a non-null
PCUGroupIdis passed in theCreateDatabaseOptionsparameter toCreateDatabase, a pre-check on the client side is done to ensure the PCU Group exists. If not, anErroris raised right away and no create-db request is fired.(actually two different errors: (1) pcu group does not exist, (2) pcu group is in a different cloudprovider/region setting).
Listing PCU Groups
AstraDatabasesAdminmust offer a method to list the PCU Groups for the current org, following the corresponding POST /v2/pcu/actions/get DevOps API endpoint.According to the yellow doc, clients may add a filtering: this requires a
ListPCUGroupsOptions: CommandOptions(if passed, both CloudProvider and Region are required): so,
PCU descriptor classes
all must come with unmarshaling capabilities and tolerating missing/null fields in the responses. As the only one directly mentioned in the above methods, it is ok to just have the three of them into a single,
src/DataStax.AstraDB.DataApi/Core/PCUGroup.cs.Below is a stub - there is additional care involved, such as: