-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
hc-github-team-tf-azure
committed
Mar 11, 2024
1 parent
8cbe8c2
commit 92de6af
Showing
35 changed files
with
1,640 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package v2024_02_01 | ||
|
||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See NOTICE.txt in the project root for license information. | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hashicorp/go-azure-sdk/resource-manager/insights/2024-02-01/metricdefinitions" | ||
"github.com/hashicorp/go-azure-sdk/resource-manager/insights/2024-02-01/metricnamespaces" | ||
"github.com/hashicorp/go-azure-sdk/resource-manager/insights/2024-02-01/metrics" | ||
"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" | ||
sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" | ||
) | ||
|
||
type Client struct { | ||
MetricDefinitions *metricdefinitions.MetricDefinitionsClient | ||
MetricNamespaces *metricnamespaces.MetricNamespacesClient | ||
Metrics *metrics.MetricsClient | ||
} | ||
|
||
func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { | ||
metricDefinitionsClient, err := metricdefinitions.NewMetricDefinitionsClientWithBaseURI(sdkApi) | ||
if err != nil { | ||
return nil, fmt.Errorf("building MetricDefinitions client: %+v", err) | ||
} | ||
configureFunc(metricDefinitionsClient.Client) | ||
|
||
metricNamespacesClient, err := metricnamespaces.NewMetricNamespacesClientWithBaseURI(sdkApi) | ||
if err != nil { | ||
return nil, fmt.Errorf("building MetricNamespaces client: %+v", err) | ||
} | ||
configureFunc(metricNamespacesClient.Client) | ||
|
||
metricsClient, err := metrics.NewMetricsClientWithBaseURI(sdkApi) | ||
if err != nil { | ||
return nil, fmt.Errorf("building Metrics client: %+v", err) | ||
} | ||
configureFunc(metricsClient.Client) | ||
|
||
return &Client{ | ||
MetricDefinitions: metricDefinitionsClient, | ||
MetricNamespaces: metricNamespacesClient, | ||
Metrics: metricsClient, | ||
}, nil | ||
} |
53 changes: 53 additions & 0 deletions
53
resource-manager/insights/2024-02-01/metricdefinitions/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
## `github.com/hashicorp/go-azure-sdk/resource-manager/insights/2024-02-01/metricdefinitions` Documentation | ||
|
||
The `metricdefinitions` SDK allows for interaction with the Azure Resource Manager Service `insights` (API Version `2024-02-01`). | ||
|
||
This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). | ||
|
||
### Import Path | ||
|
||
```go | ||
import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" | ||
import "github.com/hashicorp/go-azure-sdk/resource-manager/insights/2024-02-01/metricdefinitions" | ||
``` | ||
|
||
|
||
### Client Initialization | ||
|
||
```go | ||
client := metricdefinitions.NewMetricDefinitionsClientWithBaseURI("https://management.azure.com") | ||
client.Client.Authorizer = authorizer | ||
``` | ||
|
||
|
||
### Example Usage: `MetricDefinitionsClient.List` | ||
|
||
```go | ||
ctx := context.TODO() | ||
id := commonids.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") | ||
|
||
read, err := client.List(ctx, id, metricdefinitions.DefaultListOperationOptions()) | ||
if err != nil { | ||
// handle the error | ||
} | ||
if model := read.Model; model != nil { | ||
// do something with the model/response object | ||
} | ||
``` | ||
|
||
|
||
### Example Usage: `MetricDefinitionsClient.ListAtSubscriptionScope` | ||
|
||
```go | ||
ctx := context.TODO() | ||
id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") | ||
|
||
read, err := client.ListAtSubscriptionScope(ctx, id, metricdefinitions.DefaultListAtSubscriptionScopeOperationOptions()) | ||
if err != nil { | ||
// handle the error | ||
} | ||
if model := read.Model; model != nil { | ||
// do something with the model/response object | ||
} | ||
``` |
26 changes: 26 additions & 0 deletions
26
resource-manager/insights/2024-02-01/metricdefinitions/client.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package metricdefinitions | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" | ||
sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" | ||
) | ||
|
||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See NOTICE.txt in the project root for license information. | ||
|
||
type MetricDefinitionsClient struct { | ||
Client *resourcemanager.Client | ||
} | ||
|
||
func NewMetricDefinitionsClientWithBaseURI(sdkApi sdkEnv.Api) (*MetricDefinitionsClient, error) { | ||
client, err := resourcemanager.NewResourceManagerClient(sdkApi, "metricdefinitions", defaultApiVersion) | ||
if err != nil { | ||
return nil, fmt.Errorf("instantiating MetricDefinitionsClient: %+v", err) | ||
} | ||
|
||
return &MetricDefinitionsClient{ | ||
Client: client, | ||
}, nil | ||
} |
240 changes: 240 additions & 0 deletions
240
resource-manager/insights/2024-02-01/metricdefinitions/constants.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,240 @@ | ||
package metricdefinitions | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See NOTICE.txt in the project root for license information. | ||
|
||
type AggregationType string | ||
|
||
const ( | ||
AggregationTypeAverage AggregationType = "Average" | ||
AggregationTypeCount AggregationType = "Count" | ||
AggregationTypeMaximum AggregationType = "Maximum" | ||
AggregationTypeMinimum AggregationType = "Minimum" | ||
AggregationTypeNone AggregationType = "None" | ||
AggregationTypeTotal AggregationType = "Total" | ||
) | ||
|
||
func PossibleValuesForAggregationType() []string { | ||
return []string{ | ||
string(AggregationTypeAverage), | ||
string(AggregationTypeCount), | ||
string(AggregationTypeMaximum), | ||
string(AggregationTypeMinimum), | ||
string(AggregationTypeNone), | ||
string(AggregationTypeTotal), | ||
} | ||
} | ||
|
||
func (s *AggregationType) UnmarshalJSON(bytes []byte) error { | ||
var decoded string | ||
if err := json.Unmarshal(bytes, &decoded); err != nil { | ||
return fmt.Errorf("unmarshaling: %+v", err) | ||
} | ||
out, err := parseAggregationType(decoded) | ||
if err != nil { | ||
return fmt.Errorf("parsing %q: %+v", decoded, err) | ||
} | ||
*s = *out | ||
return nil | ||
} | ||
|
||
func parseAggregationType(input string) (*AggregationType, error) { | ||
vals := map[string]AggregationType{ | ||
"average": AggregationTypeAverage, | ||
"count": AggregationTypeCount, | ||
"maximum": AggregationTypeMaximum, | ||
"minimum": AggregationTypeMinimum, | ||
"none": AggregationTypeNone, | ||
"total": AggregationTypeTotal, | ||
} | ||
if v, ok := vals[strings.ToLower(input)]; ok { | ||
return &v, nil | ||
} | ||
|
||
// otherwise presume it's an undefined value and best-effort it | ||
out := AggregationType(input) | ||
return &out, nil | ||
} | ||
|
||
type MetricAggregationType string | ||
|
||
const ( | ||
MetricAggregationTypeAverage MetricAggregationType = "Average" | ||
MetricAggregationTypeCount MetricAggregationType = "Count" | ||
MetricAggregationTypeMaximum MetricAggregationType = "Maximum" | ||
MetricAggregationTypeMinimum MetricAggregationType = "Minimum" | ||
MetricAggregationTypeNone MetricAggregationType = "None" | ||
MetricAggregationTypeTotal MetricAggregationType = "Total" | ||
) | ||
|
||
func PossibleValuesForMetricAggregationType() []string { | ||
return []string{ | ||
string(MetricAggregationTypeAverage), | ||
string(MetricAggregationTypeCount), | ||
string(MetricAggregationTypeMaximum), | ||
string(MetricAggregationTypeMinimum), | ||
string(MetricAggregationTypeNone), | ||
string(MetricAggregationTypeTotal), | ||
} | ||
} | ||
|
||
func (s *MetricAggregationType) UnmarshalJSON(bytes []byte) error { | ||
var decoded string | ||
if err := json.Unmarshal(bytes, &decoded); err != nil { | ||
return fmt.Errorf("unmarshaling: %+v", err) | ||
} | ||
out, err := parseMetricAggregationType(decoded) | ||
if err != nil { | ||
return fmt.Errorf("parsing %q: %+v", decoded, err) | ||
} | ||
*s = *out | ||
return nil | ||
} | ||
|
||
func parseMetricAggregationType(input string) (*MetricAggregationType, error) { | ||
vals := map[string]MetricAggregationType{ | ||
"average": MetricAggregationTypeAverage, | ||
"count": MetricAggregationTypeCount, | ||
"maximum": MetricAggregationTypeMaximum, | ||
"minimum": MetricAggregationTypeMinimum, | ||
"none": MetricAggregationTypeNone, | ||
"total": MetricAggregationTypeTotal, | ||
} | ||
if v, ok := vals[strings.ToLower(input)]; ok { | ||
return &v, nil | ||
} | ||
|
||
// otherwise presume it's an undefined value and best-effort it | ||
out := MetricAggregationType(input) | ||
return &out, nil | ||
} | ||
|
||
type MetricClass string | ||
|
||
const ( | ||
MetricClassAvailability MetricClass = "Availability" | ||
MetricClassErrors MetricClass = "Errors" | ||
MetricClassLatency MetricClass = "Latency" | ||
MetricClassSaturation MetricClass = "Saturation" | ||
MetricClassTransactions MetricClass = "Transactions" | ||
) | ||
|
||
func PossibleValuesForMetricClass() []string { | ||
return []string{ | ||
string(MetricClassAvailability), | ||
string(MetricClassErrors), | ||
string(MetricClassLatency), | ||
string(MetricClassSaturation), | ||
string(MetricClassTransactions), | ||
} | ||
} | ||
|
||
func (s *MetricClass) UnmarshalJSON(bytes []byte) error { | ||
var decoded string | ||
if err := json.Unmarshal(bytes, &decoded); err != nil { | ||
return fmt.Errorf("unmarshaling: %+v", err) | ||
} | ||
out, err := parseMetricClass(decoded) | ||
if err != nil { | ||
return fmt.Errorf("parsing %q: %+v", decoded, err) | ||
} | ||
*s = *out | ||
return nil | ||
} | ||
|
||
func parseMetricClass(input string) (*MetricClass, error) { | ||
vals := map[string]MetricClass{ | ||
"availability": MetricClassAvailability, | ||
"errors": MetricClassErrors, | ||
"latency": MetricClassLatency, | ||
"saturation": MetricClassSaturation, | ||
"transactions": MetricClassTransactions, | ||
} | ||
if v, ok := vals[strings.ToLower(input)]; ok { | ||
return &v, nil | ||
} | ||
|
||
// otherwise presume it's an undefined value and best-effort it | ||
out := MetricClass(input) | ||
return &out, nil | ||
} | ||
|
||
type MetricUnit string | ||
|
||
const ( | ||
MetricUnitBitsPerSecond MetricUnit = "BitsPerSecond" | ||
MetricUnitByteSeconds MetricUnit = "ByteSeconds" | ||
MetricUnitBytes MetricUnit = "Bytes" | ||
MetricUnitBytesPerSecond MetricUnit = "BytesPerSecond" | ||
MetricUnitCores MetricUnit = "Cores" | ||
MetricUnitCount MetricUnit = "Count" | ||
MetricUnitCountPerSecond MetricUnit = "CountPerSecond" | ||
MetricUnitMilliCores MetricUnit = "MilliCores" | ||
MetricUnitMilliSeconds MetricUnit = "MilliSeconds" | ||
MetricUnitNanoCores MetricUnit = "NanoCores" | ||
MetricUnitPercent MetricUnit = "Percent" | ||
MetricUnitSeconds MetricUnit = "Seconds" | ||
MetricUnitUnspecified MetricUnit = "Unspecified" | ||
) | ||
|
||
func PossibleValuesForMetricUnit() []string { | ||
return []string{ | ||
string(MetricUnitBitsPerSecond), | ||
string(MetricUnitByteSeconds), | ||
string(MetricUnitBytes), | ||
string(MetricUnitBytesPerSecond), | ||
string(MetricUnitCores), | ||
string(MetricUnitCount), | ||
string(MetricUnitCountPerSecond), | ||
string(MetricUnitMilliCores), | ||
string(MetricUnitMilliSeconds), | ||
string(MetricUnitNanoCores), | ||
string(MetricUnitPercent), | ||
string(MetricUnitSeconds), | ||
string(MetricUnitUnspecified), | ||
} | ||
} | ||
|
||
func (s *MetricUnit) UnmarshalJSON(bytes []byte) error { | ||
var decoded string | ||
if err := json.Unmarshal(bytes, &decoded); err != nil { | ||
return fmt.Errorf("unmarshaling: %+v", err) | ||
} | ||
out, err := parseMetricUnit(decoded) | ||
if err != nil { | ||
return fmt.Errorf("parsing %q: %+v", decoded, err) | ||
} | ||
*s = *out | ||
return nil | ||
} | ||
|
||
func parseMetricUnit(input string) (*MetricUnit, error) { | ||
vals := map[string]MetricUnit{ | ||
"bitspersecond": MetricUnitBitsPerSecond, | ||
"byteseconds": MetricUnitByteSeconds, | ||
"bytes": MetricUnitBytes, | ||
"bytespersecond": MetricUnitBytesPerSecond, | ||
"cores": MetricUnitCores, | ||
"count": MetricUnitCount, | ||
"countpersecond": MetricUnitCountPerSecond, | ||
"millicores": MetricUnitMilliCores, | ||
"milliseconds": MetricUnitMilliSeconds, | ||
"nanocores": MetricUnitNanoCores, | ||
"percent": MetricUnitPercent, | ||
"seconds": MetricUnitSeconds, | ||
"unspecified": MetricUnitUnspecified, | ||
} | ||
if v, ok := vals[strings.ToLower(input)]; ok { | ||
return &v, nil | ||
} | ||
|
||
// otherwise presume it's an undefined value and best-effort it | ||
out := MetricUnit(input) | ||
return &out, nil | ||
} |
Oops, something went wrong.