1
+ /**
2
+ * General resource property helpers for Azure resources in Bicep.
3
+ *
4
+ * Provides common property accessors for location, SKU, and tags.
5
+ *
6
+ * Classes:
7
+ * - AzureResource: Abstract base for Azure resources, provides access to location, SKU, and tags.
8
+ * - ResourceProperties: Abstract base for resource property objects.
9
+ * - Sku: Represents the SKU of a resource, with access to name and tier.
10
+ * - Tags: Represents the tags of a resource, with access to tag values by key.
11
+ */
1
12
private import bicep
2
13
14
+ /**
15
+ * Abstract base class for Azure resources in Bicep.
16
+ * Provides accessors for common resource properties such as location, SKU, and tags.
17
+ */
3
18
abstract class AzureResource extends Resource {
4
- string resourceLocation ( ) {
5
- result = this .getProperty ( "location" ) .( StringLiteral ) .getValue ( )
6
- }
19
+ /**
20
+ * Gets the location of the resource as a string value.
21
+ * @return The Azure region/location of the resource (e.g., "eastus").
22
+ */
23
+ string resourceLocation ( ) { result = this .getProperty ( "location" ) .( StringLiteral ) .getValue ( ) }
7
24
25
+ /**
26
+ * Gets the SKU object for the resource.
27
+ * @return The SKU object representing the resource's SKU.
28
+ */
8
29
Sku getSku ( ) { result = this .getProperty ( "sku" ) }
9
30
31
+ /**
32
+ * Gets the Tags object for the resource.
33
+ * @return The Tags object representing the resource's tags.
34
+ */
10
35
Tags getTags ( ) { result = this .getProperty ( "tags" ) }
11
36
}
12
37
38
+ /**
39
+ * Abstract base class for resource property objects.
40
+ * Can be extended to provide additional property accessors for specific resource types.
41
+ */
13
42
abstract class ResourceProperties extends Object {
14
- string toString ( ) {
15
- result = super .toString ( )
16
- }
43
+ /**
44
+ * Returns a string representation of the resource properties object.
45
+ */
46
+ string toString ( ) { result = super .toString ( ) }
17
47
}
18
48
49
+ /**
50
+ * Represents the SKU of an Azure resource.
51
+ * Provides access to the SKU name and tier.
52
+ */
19
53
class Sku extends Object {
20
54
private Resource resource ;
21
55
@@ -24,19 +58,37 @@ class Sku extends Object {
24
58
*/
25
59
Sku ( ) { this = resource .getProperty ( "sku" ) }
26
60
61
+ /**
62
+ * Gets the SKU name as a StringLiteral.
63
+ * @return The SKU name property as a StringLiteral.
64
+ */
65
+ StringLiteral getName ( ) { result = this .getProperty ( "name" ) }
66
+
27
67
/**
28
68
* Returns the SKU name (e.g., Basic, Standard, Premium).
69
+ * @return The SKU name as a string.
70
+ */
71
+ string name ( ) { result = this .getName ( ) .getValue ( ) }
72
+
73
+ /**
74
+ * Gets the SKU tier as a StringLiteral.
75
+ * @return The SKU tier property as a StringLiteral.
29
76
*/
30
- string getName ( ) { result = this .getProperty ( "name" ) . ( StringLiteral ) . getValue ( ) }
77
+ StringLiteral getTier ( ) { result = this .getProperty ( "tier" ) }
31
78
32
79
/**
33
80
* Returns the SKU tier (e.g., Basic, Standard, Premium).
81
+ * @return The SKU tier as a string.
34
82
*/
35
- string getTier ( ) { result = this .getProperty ( "tier" ) . ( StringLiteral ) .getValue ( ) }
83
+ string tier ( ) { result = this .getTier ( ) .getValue ( ) }
36
84
37
85
string toString ( ) { result = "SKU" }
38
86
}
39
87
88
+ /**
89
+ * Represents the tags of an Azure resource.
90
+ * Provides access to tag values by key.
91
+ */
40
92
class Tags extends Object {
41
93
private Resource resource ;
42
94
@@ -46,7 +98,9 @@ class Tags extends Object {
46
98
Tags ( ) { this = resource .getProperty ( "tags" ) }
47
99
48
100
/**
49
- * Returns the value of a tag by its key.
101
+ * Gets the value of a tag by its key.
102
+ * @param key The tag key to look up.
103
+ * @return The value of the tag as a Literals object, or undefined if not present.
50
104
*/
51
105
Literals getTag ( string key ) { result = this .getProperty ( key ) }
52
106
0 commit comments