Azure / azure-sdk-for-go

This repository is for active development of the Azure SDK for Go. For consumers of the SDK we recommend visiting our public developer docs at:
https://docs.microsoft.com/azure/developer/go/
MIT License
1.59k stars 821 forks source link

Get the available UltraDisk usage for an Azure Subscription #21759

Closed skywalker2909 closed 10 months ago

skywalker2909 commented 11 months ago

Feature Request

I've tried going through the sdk docs to search for a way to get the available ultra disk usage for an azure subscription but can't seem to find anything useful.

Does the current sdk version have this functionality? If not, then are there any plans to make it available in the go sdk?

jhendrixMSFT commented 11 months ago

You'll likely want to use the armcompute module for this.

I took a quick look, maybe DisksClient.NewListPager will do what you're looking for.

skywalker2909 commented 10 months ago

Thanks @jhendrixMSFT appreciate the help!

The one you provided is most likely for disks that are already attached to compute instances.

What i was looking for is how many ultra disks are allowed per azure subscription / quota which i managed to find here Quota - Get - REST API

package armquota_test

import (
    "context"
    "log"

    "github.com/Azure/azure-sdk-for-go/sdk/azidentity"
    "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/quota/armquota"
)

// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/quota/resource-manager/Microsoft.Quota/preview/2021-03-15-preview/examples/getComputeOneSkuQuotaLimit.json
func ExampleClient_Get_quotasGetRequestForCompute() {
    cred, err := azidentity.NewDefaultAzureCredential(nil)
    if err != nil {
        log.Fatalf("failed to obtain a credential: %v", err)
    }
    ctx := context.Background()
    clientFactory, err := armquota.NewClientFactory(cred, nil)
    if err != nil {
        log.Fatalf("failed to create client: %v", err)
    }
    res, err := clientFactory.NewClient().Get(ctx, "standardNDSFamily", "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus", nil)
    if err != nil {
        log.Fatalf("failed to finish the request: %v", err)
    }
    // You could use response here. We use blank identifier for just demo purposes.
    _ = res
    // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
    // res.CurrentQuotaLimitBase = armquota.CurrentQuotaLimitBase{
    //  Name: to.Ptr("standardNDSFamily"),
    //  Type: to.Ptr("Microsoft.Quota/Quotas"),
    //  ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus/providers/Microsoft.Quota/Quotas/standardNDSFamily"),
    //  Properties: &armquota.Properties{
    //      Name: &armquota.ResourceName{
    //          LocalizedValue: to.Ptr("Standard NDS Family vCPUs"),
    //          Value: to.Ptr("standardNDSFamily"),
    //      },
    //      IsQuotaApplicable: to.Ptr(true),
    //      Limit: &armquota.LimitObject{
    //          LimitObjectType: to.Ptr(armquota.LimitTypeLimitValue),
    //          LimitType: to.Ptr(armquota.QuotaLimitTypesIndependent),
    //          Value: to.Ptr[int32](100),
    //      },
    //      Unit: to.Ptr("Count"),
    //  },
    // }
}
github-actions[bot] commented 10 months ago

Hi @skywalker2909. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text "/unresolve" to remove the "issue-addressed" label and continue the conversation.

github-actions[bot] commented 10 months ago

Hi @skywalker2909, since you haven’t asked that we /unresolve the issue, we’ll close this out. If you believe further discussion is needed, please add a comment /unresolve to reopen the issue.