CoreService

<back to all web services

GetBillableResources

Statistics

Returns billable resource counts

Requires Authentication
Required role:TenantReader
The following routes are available for this service:
GET/api/statistics/billableresourcesReturns billable resource counts
GET/statistics/billableresourcesReturns billable resource counts
<?php namespace dtos;

use DateTime;
use Exception;
use DateInterval;
use JsonSerializable;
use ServiceStack\{IReturn,IReturnVoid,IGet,IPost,IPut,IDelete,IPatch,IMeta,IHasSessionId,IHasBearerToken,IHasVersion};
use ServiceStack\{ICrud,ICreateDb,IUpdateDb,IPatchDb,IDeleteDb,ISaveDb,AuditBase,QueryDb,QueryDb2,QueryData,QueryData2,QueryResponse};
use ServiceStack\{ResponseStatus,ResponseError,EmptyResponse,IdResponse,ArrayList,KeyValuePair2,StringResponse,StringsResponse,Tuple2,Tuple3,ByteArray};
use ServiceStack\{JsonConverters,Returns,TypeContext};


enum ObjectTypes : string
{
    case None = 'None';
    case ConfigItem = 'ConfigItem';
    case Tenant = 'Tenant';
    case Collection = 'Collection';
    case Resource = 'Resource';
    case ComputeNode = 'ComputeNode';
    case VirtualMachine = 'VirtualMachine';
    case PhysicalMachine = 'PhysicalMachine';
    case Disk = 'Disk';
    case Subnet = 'Subnet';
    case IPAddress = 'IPAddress';
    case Job = 'Job';
    case JobEvent = 'JobEvent';
    case FreezePeriod = 'FreezePeriod';
    case ResourceGroup = 'ResourceGroup';
    case Deployment = 'Deployment';
    case ResourceGroupTemplate = 'ResourceGroupTemplate';
    case DeploymentTemplate = 'DeploymentTemplate';
    case ResourceProvider = 'ResourceProvider';
    case GenericResource = 'GenericResource';
    case Role = 'Role';
    case Permission = 'Permission';
    case User = 'User';
    case PatchingWindow = 'PatchingWindow';
    case Update = 'Update';
    case ReportDefinition = 'ReportDefinition';
    case TimeSeries = 'TimeSeries';
    case DataPoint = 'DataPoint';
    case Action = 'Action';
    case ActionAssignment = 'ActionAssignment';
    case UserNote = 'UserNote';
}

class HeaderDto implements IHasIdName, IHasObjectType, JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $id='',
        /** @var string */
        public string $name='',
        /** @var string */
        public string $displayName='',
        /** @var ObjectTypes|null */
        public ?ObjectTypes $objectType=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['name'])) $this->name = $o['name'];
        if (isset($o['displayName'])) $this->displayName = $o['displayName'];
        if (isset($o['objectType'])) $this->objectType = JsonConverters::from('ObjectTypes', $o['objectType']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->name)) $o['name'] = $this->name;
        if (isset($this->displayName)) $o['displayName'] = $this->displayName;
        if (isset($this->objectType)) $o['objectType'] = JsonConverters::to('ObjectTypes', $this->objectType);
        return empty($o) ? new class(){} : $o;
    }
}

class BillableResourceDto implements JsonSerializable
{
    public function __construct(
        /** @var ObjectTypes|null */
        public ?ObjectTypes $type=null,
        /** @var int */
        public int $totalCount=0,
        /** @var int */
        public int $billableCount=0,
        /** @var array<HeaderDto>|null */
        public ?array $billableResources=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['type'])) $this->type = JsonConverters::from('ObjectTypes', $o['type']);
        if (isset($o['totalCount'])) $this->totalCount = $o['totalCount'];
        if (isset($o['billableCount'])) $this->billableCount = $o['billableCount'];
        if (isset($o['billableResources'])) $this->billableResources = JsonConverters::fromArray('HeaderDto', $o['billableResources']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->type)) $o['type'] = JsonConverters::to('ObjectTypes', $this->type);
        if (isset($this->totalCount)) $o['totalCount'] = $this->totalCount;
        if (isset($this->billableCount)) $o['billableCount'] = $this->billableCount;
        if (isset($this->billableResources)) $o['billableResources'] = JsonConverters::toArray('HeaderDto', $this->billableResources);
        return empty($o) ? new class(){} : $o;
    }
}

class BillableResourceSummaryDto implements JsonSerializable
{
    public function __construct(
        /** @var DateTime */
        public DateTime $generatedOn=new DateTime(),
        /** @var array<string,BillableResourceDto>|null */
        public ?array $billableResources=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['generatedOn'])) $this->generatedOn = JsonConverters::from('DateTime', $o['generatedOn']);
        if (isset($o['billableResources'])) $this->billableResources = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','BillableResourceDto']), $o['billableResources']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->generatedOn)) $o['generatedOn'] = JsonConverters::to('DateTime', $this->generatedOn);
        if (isset($this->billableResources)) $o['billableResources'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','BillableResourceDto']), $this->billableResources);
        return empty($o) ? new class(){} : $o;
    }
}

/** @description Returns billable resource counts */
// @Api(Description="Returns billable resource counts")
// @ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType="typeof(CoreService.ServiceModel.Dtos.Statistics.Responses.BillableResourceSummaryDto)", StatusCode=200)
class GetBillableResources implements IBaseRequest, IHasTenantName, IGet, JsonSerializable
{
    public function __construct(
        // @ApiMember(DataType="string", IsRequired=true, ParameterType="header")
        // @Validate(Validator="NotEmpty")
        /** @var string */
        public string $tenantName=''
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['tenantName'])) $this->tenantName = $o['tenantName'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->tenantName)) $o['tenantName'] = $this->tenantName;
        return empty($o) ? new class(){} : $o;
    }
}

PHP GetBillableResources DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json

To embed the response in a jsonp callback, append ?callback=myCallback

HTTP + JSON

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

GET /api/statistics/billableresources HTTP/1.1 
Host: core.starburst.svc 
Accept: application/json
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"generatedOn":"0001-01-01T00:00:00.0000000Z","billableResources":{"String":{"type":"None","totalCount":0,"billableCount":0,"billableResources":[{"id":"00000000-0000-0000-0000-000000000000","name":"String","displayName":"String","objectType":"None"}]}}}