Skip to content
Draft
  •  
  •  
  •  
71 changes: 71 additions & 0 deletions specification/cost-management/CostManagement.Management/Alert.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/openapi";
import "@typespec/rest";
import "./models.tsp";

using TypeSpec.Rest;
using Azure.ResourceManager;
using TypeSpec.Http;
using TypeSpec.OpenAPI;

namespace Microsoft.CostManagement;
/**
* An individual alert.
*/
model Alert is Azure.ResourceManager.ExtensionResource<AlertProperties> {
...ResourceNameParameter<
Resource = Alert,
KeyName = "alertId",
SegmentName = "alerts",
NamePattern = ""
>;

/**
* eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not.
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
eTag?: Azure.Core.eTag;
}

@armResourceOperations
interface Alerts {
/**
* Gets the alert for the scope by alert ID.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@externalDocs("https://docs.microsoft.com/en-us/rest/api/costmanagement/")
get is Extension.Read<Extension.ScopeParameter, Alert, Error = ErrorResponse>;

/**
* Dismisses the specified alert
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@patch(#{ implicitOptionality: false })
@externalDocs("https://docs.microsoft.com/en-us/rest/api/costmanagement/")
dismiss is Extension.CustomPatchSync<
Extension.ScopeParameter,
Alert,
PatchModel = DismissAlertPayload,
Error = ErrorResponse
>;

/**
* Lists the alerts for scope defined.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@externalDocs("https://docs.microsoft.com/en-us/rest/api/costmanagement/")
list is Extension.ListByTarget<
Extension.ScopeParameter,
Alert,
Response = ArmResponse<AlertsResult>,
Error = ErrorResponse
>;
}

@@doc(Alert.name, "Alert ID");
@@doc(Alert.properties, "Alert properties.");
@@doc(Alerts.dismiss::parameters.properties,
"Parameters supplied to the Dismiss Alert operation."
);
@@path(Alert.name, #{ allowReserved: true });
94 changes: 94 additions & 0 deletions specification/cost-management/CostManagement.Management/Budget.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/openapi";
import "@typespec/rest";
import "./models.tsp";

using TypeSpec.Rest;
using Azure.ResourceManager;
using TypeSpec.Http;
using TypeSpec.OpenAPI;

namespace Microsoft.CostManagement;
/**
* A budget resource.
*/
model Budget is Azure.ResourceManager.ExtensionResource<BudgetProperties> {
...ResourceNameParameter<
Resource = Budget,
KeyName = "budgetName",
SegmentName = "budgets",
NamePattern = "^[a-zA-Z0-9_-]+$"
>;

/**
* eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not.
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
eTag?: Azure.Core.eTag;
}

@armResourceOperations
interface Budgets {
/**
* Gets the budget for the scope by budget name.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@externalDocs("https://docs.microsoft.com/en-us/rest/api/CostManagement/")
get is Extension.Read<
Extension.ScopeParameter,
Budget,
Error = ErrorResponse
>;

/**
* The operation to create or update a budget. You can optionally provide an eTag if desired as a form of concurrency control. To obtain the latest eTag for a given budget, perform a get operation prior to your put operation.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@externalDocs("https://docs.microsoft.com/en-us/rest/api/CostManagement/")
createOrUpdate is Extension.CreateOrReplaceSync<
Extension.ScopeParameter,
Budget,
Error = ErrorResponse
>;

/**
* The operation to delete a budget.
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@externalDocs("https://docs.microsoft.com/en-us/rest/api/CostManagement/")
delete is Extension.DeleteSync<
Extension.ScopeParameter,
Budget,
Response = ArmDeletedResponse,
Error = ErrorResponse
>;

/**
* Lists all budgets for the defined scope.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@externalDocs("https://docs.microsoft.com/en-us/rest/api/CostManagement/")
list is Extension.ListByTarget<
Extension.ScopeParameter,
Budget,
Parameters = {
/**
* OData filter option. May be used to filter budgets by properties/category. The filter supports 'eq' only.
*/
@query("$filter")
$filter?: string;
},
Response = ArmResponse<BudgetsListResult>,
Error = ErrorResponse
>;
}

@@maxLength(Budget.name, 63);
@@minLength(Budget.name, 1);
@@doc(Budget.name, "Budget Name.");
@@doc(Budget.properties, "The properties of the budget.");
@@doc(Budgets.createOrUpdate::parameters.resource,
"Parameters supplied to the Create Budget operation."
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/openapi";
import "@typespec/rest";
import "./models.tsp";

using TypeSpec.Rest;
using Azure.ResourceManager;
using TypeSpec.Http;
using TypeSpec.OpenAPI;

namespace Microsoft.CostManagement;
/**
* The cost allocation rule model definition
*/
@tenantResource
model CostAllocationRuleDefinition
is Azure.ResourceManager.ProxyResource<CostAllocationRuleProperties> {
...ResourceNameParameter<
Resource = CostAllocationRuleDefinition,
KeyName = "ruleName",
SegmentName = "costAllocationRules",
NamePattern = "[A-Za-z0-9\\-_]+"
>;
}

alias CostAllocationRuleDefinitionsOps = Azure.ResourceManager.Legacy.ExtensionOperations<
{
...ApiVersionParameter;

/** the provider namespace */
@path
@segment("providers")
@key
providerNamespace: "microsoft.Billing";

/**
* BillingAccount ID
*/
@path
@segment("billingAccounts")
billingAccountId: string;
},
{
...Azure.ResourceManager.Legacy.Provider;
},
{
...Azure.ResourceManager.Legacy.Provider;

/**
* Cost allocation rule name. The name cannot include spaces or any non alphanumeric characters other than '_' and '-'. The max length is 260 characters.
*/
@path
@segment("costAllocationRules")
@pattern("[A-Za-z0-9\\-_]+")
ruleName: string;
}
>;

@armResourceOperations
interface CostAllocationRuleDefinitions {
/**
* Get a cost allocation rule by rule name and billing account or enterprise enrollment.
*/
get is CostAllocationRuleDefinitionsOps.Read<
CostAllocationRuleDefinition,
ErrorType = ErrorResponse
>;

/**
* Create/Update a rule to allocate cost between different resources within a billing account or enterprise enrollment.
*/
createOrUpdate is CostAllocationRuleDefinitionsOps.CreateOrUpdateSync<
CostAllocationRuleDefinition,
ErrorType = ErrorResponse
>;

/**
* Delete cost allocation rule for billing account or enterprise enrollment.
*/
delete is CostAllocationRuleDefinitionsOps.DeleteSync<
CostAllocationRuleDefinition,
ErrorType = ErrorResponse
>;

/**
* Get the list of all cost allocation rules for a billing account or enterprise enrollment.
*/
list is CostAllocationRuleDefinitionsOps.List<
CostAllocationRuleDefinition,
Response = ArmResponse<CostAllocationRuleList>,
ErrorType = ErrorResponse
>;
}

@@doc(CostAllocationRuleDefinition.name,
"Cost allocation rule name. The name cannot include spaces or any non alphanumeric characters other than '_' and '-'. The max length is 260 characters."
);
@@doc(CostAllocationRuleDefinition.properties,
"Cost allocation rule properties"
);
@@doc(CostAllocationRuleDefinitions.createOrUpdate::parameters.resource,
"Cost allocation rule to be created or updated"
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/openapi";
import "@typespec/rest";
import "./models.tsp";

using TypeSpec.Rest;
using Azure.ResourceManager;
using TypeSpec.Http;
using TypeSpec.OpenAPI;

namespace Microsoft.CostManagement;
// FIXME: CostDetailsOperationResults has no properties property
/**
* The result of the long running operation for cost details Api.
*/
model CostDetailsOperationResults
is Azure.ResourceManager.ExtensionResource<never> {
...ResourceNameParameter<
Resource = CostDetailsOperationResults,
KeyName = "operationId",
SegmentName = "costDetailsOperationResults",
NamePattern = ""
>;

/**
* The status of the cost details operation
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
status?: CostDetailsStatusType;

/**
* The manifest of the report generated by the operation.
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
manifest?: ReportManifest;

/**
* The time at which report URL becomes invalid/expires in UTC e.g. 2020-12-08T05:55:59.4394737Z.
*/
// FIXME: (utcDateTime) Please double check that this is the correct type for your scenario.
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
validTill?: utcDateTime;

/**
* The details of the error.
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
error?: ErrorDetails;
}

@armResourceOperations
interface GenerateCostDetailsReport {
/**
* Get the result of the specified operation. This link is provided in the CostDetails creation request response Location header.
*/
getOperationResults is Extension.Read<
Extension.ScopeParameter,
CostDetailsOperationResults,
Response = ArmResponse<CostDetailsOperationResults> | ArmAcceptedLroResponse<LroHeaders = ArmLroLocationHeader<FinalResult = CostDetailsOperationResults>>,
Error = ErrorResponse
>;
}

@@doc(CostDetailsOperationResults.name, "The target operation Id.");
Loading
Loading