Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
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.AlertsManagement;
/**
* The Prometheus rule group resource.
*/
model PrometheusRuleGroupResource
is Azure.ResourceManager.TrackedResource<
PrometheusRuleGroupProperties,
false
> {
...ResourceNameParameter<
Resource = PrometheusRuleGroupResource,
KeyName = "ruleGroupName",
SegmentName = "prometheusRuleGroups",
NamePattern = "^[^:@/#{}%&+*<>?]+$"
>;
}

@armResourceOperations
interface PrometheusRuleGroupResources {
/**
* Retrieve a Prometheus rule group definition.
*/
get is ArmResourceRead<PrometheusRuleGroupResource>;

/**
* Create or update a Prometheus rule group definition.
*/
createOrUpdate is ArmResourceCreateOrReplaceSync<PrometheusRuleGroupResource>;

/**
* Update an Prometheus rule group definition.
*/
@patch(#{ implicitOptionality: false })
update is ArmCustomPatchSync<
PrometheusRuleGroupResource,
PatchModel = PrometheusRuleGroupResourcePatchParameters
>;

/**
* Delete a Prometheus rule group definition.
*/
delete is ArmResourceDeleteSync<PrometheusRuleGroupResource>;

/**
* Retrieve Prometheus rule group definitions in a resource group.
*/
listByResourceGroup is ArmResourceListByParent<
PrometheusRuleGroupResource,
Response = ArmResponse<PrometheusRuleGroupResourceCollection>
>;

/**
* Retrieve Prometheus all rule group definitions in a subscription.
*/
listBySubscription is ArmListBySubscription<
PrometheusRuleGroupResource,
Response = ArmResponse<PrometheusRuleGroupResourceCollection>
>;
}

@@doc(PrometheusRuleGroupResource.name, "The name of the rule group.");
@@doc(PrometheusRuleGroupResource.properties,
"The Prometheus rule group properties of the resource."
);
@@doc(PrometheusRuleGroupResources.createOrUpdate::parameters.resource,
"The parameters of the rule group to create or update."
);
@@doc(PrometheusRuleGroupResources.update::parameters.properties,
"The parameters of the rule group to update."
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import "@azure-tools/typespec-client-generator-core";

using Azure.ClientGenerator.Core;
using Microsoft.AlertsManagement;

#suppress "@azure-tools/typespec-azure-core/no-legacy-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@@Legacy.flattenProperty(PrometheusRuleGroupResourcePatchParameters.properties);

@@clientLocation(PrometheusRuleGroupResources.get, "PrometheusRuleGroups");
@@clientLocation(PrometheusRuleGroupResources.createOrUpdate,
"PrometheusRuleGroups"
);
@@clientName(PrometheusRuleGroupResources.createOrUpdate::parameters.resource,
"parameters"
);
@@clientLocation(PrometheusRuleGroupResources.update, "PrometheusRuleGroups");
@@clientName(PrometheusRuleGroupResources.update::parameters.properties,
"parameters"
);
@@clientLocation(PrometheusRuleGroupResources.delete, "PrometheusRuleGroups");
@@clientLocation(PrometheusRuleGroupResources.listByResourceGroup,
"PrometheusRuleGroups"
);
@@clientLocation(PrometheusRuleGroupResources.listBySubscription,
"PrometheusRuleGroups"
);
#suppress "@azure-tools/typespec-azure-core/no-legacy-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@@Legacy.flattenProperty(PrometheusRuleGroupResource.properties);
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import "./main.tsp";
import "@azure-tools/typespec-client-generator-core";

using Azure.ClientGenerator.Core;

@@clientName(Microsoft.AlertsManagement,
"PrometheusRuleGroupsMgmtClient",
"python"
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
"parameters": {
"api-version": "2023-03-01",
"parameters": {
"location": "East US",
"properties": {
"description": "This is a rule group with culster centric configuration",
"clusterName": "myClusterName",
"interval": "PT10M",
"rules": [
{
"actions": [],
"alert": "Billing_Processing_Very_Slow",
"annotations": {
"annotationName1": "annotationValue1"
},
"enabled": true,
"expression": "job_type:billing_jobs_duration_seconds:99p5m > 30",
"for": "PT5M",
"labels": {
"team": "prod"
},
"resolveConfiguration": {
"autoResolved": true,
"timeToResolve": "PT10M"
},
"severity": 2
}
],
"scopes": [
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace",
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/Microsoft.ContainerService/managedClusters/myClusterName"
]
}
},
"resourceGroupName": "promResourceGroup",
"ruleGroupName": "myPrometheusRuleGroup",
"subscriptionId": "ffffffff-ffff-ffff-ffff-ffffffffffff"
},
"responses": {
"200": {
"body": {
"type": "Microsoft.AlertsManagement/prometheusRuleGroups",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/promResourceGroup/providers/Microsoft.AlertsManagement/prometheusRuleGroups/myPrometheusRuleGroup",
"location": "East US",
"properties": {
"description": "This is a rule group with culster centric configuration",
"clusterName": "myClusterName",
"interval": "PT10M",
"rules": [
{
"actions": [],
"alert": "Billing_Processing_Very_Slow",
"annotations": {
"annotationName1": "annotationValue1"
},
"enabled": true,
"expression": "job_type:billing_jobs_duration_seconds:99p5m > 30",
"for": "PT5M",
"labels": {
"team": "prod"
},
"resolveConfiguration": {
"autoResolved": true,
"timeToResolve": "PT10M"
},
"severity": 2
}
],
"scopes": [
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace",
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/Microsoft.ContainerService/managedClusters/myClusterName"
]
}
},
"headers": {}
},
"201": {
"body": {
"type": "Microsoft.AlertsManagement/prometheusRuleGroups",
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/promResourceGroup/providers/Microsoft.AlertsManagement/prometheusRuleGroups/myPrometheusRuleGroup",
"location": "East US",
"properties": {
"description": "This is a rule group with culster centric configuration",
"clusterName": "myClusterName",
"interval": "PT10M",
"rules": [
{
"actions": [],
"alert": "Billing_Processing_Very_Slow",
"annotations": {
"annotationName1": "annotationValue1"
},
"enabled": true,
"expression": "job_type:billing_jobs_duration_seconds:99p5m > 30",
"for": "PT5M",
"labels": {
"team": "prod"
},
"resolveConfiguration": {
"autoResolved": true,
"timeToResolve": "PT10M"
},
"severity": 2
}
],
"scopes": [
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace",
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/Microsoft.ContainerService/managedClusters/myClusterName"
]
}
},
"headers": {}
}
},
"operationId": "PrometheusRuleGroups_CreateOrUpdate",
"title": "Create or Update a cluster centric PrometheusRuleGroup"
}
Loading
Loading