diff --git a/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/README.md b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/README.md new file mode 100644 index 0000000000..20a2cc90ad --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/README.md @@ -0,0 +1,103 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles` Documentation + +The `certificateprofiles` SDK allows for interaction with Azure Resource Manager `codesigning` (API Version `2024-09-30-preview`). + +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-sdk/resource-manager/codesigning/2024-09-30-preview/certificateprofiles" +``` + + +### Client Initialization + +```go +client := certificateprofiles.NewCertificateProfilesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CertificateProfilesClient.Create` + +```go +ctx := context.TODO() +id := certificateprofiles.NewCertificateProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "codeSigningAccountName", "certificateProfileName") + +payload := certificateprofiles.CertificateProfile{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CertificateProfilesClient.Delete` + +```go +ctx := context.TODO() +id := certificateprofiles.NewCertificateProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "codeSigningAccountName", "certificateProfileName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CertificateProfilesClient.Get` + +```go +ctx := context.TODO() +id := certificateprofiles.NewCertificateProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "codeSigningAccountName", "certificateProfileName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CertificateProfilesClient.ListByCodeSigningAccount` + +```go +ctx := context.TODO() +id := certificateprofiles.NewCodeSigningAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "codeSigningAccountName") + +// alternatively `client.ListByCodeSigningAccount(ctx, id)` can be used to do batched pagination +items, err := client.ListByCodeSigningAccountComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CertificateProfilesClient.RevokeCertificate` + +```go +ctx := context.TODO() +id := certificateprofiles.NewCertificateProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "codeSigningAccountName", "certificateProfileName") + +payload := certificateprofiles.RevokeCertificate{ + // ... +} + + +read, err := client.RevokeCertificate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/client.go b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/client.go new file mode 100644 index 0000000000..e559a6f924 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/client.go @@ -0,0 +1,26 @@ +package certificateprofiles + +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 CertificateProfilesClient struct { + Client *resourcemanager.Client +} + +func NewCertificateProfilesClientWithBaseURI(sdkApi sdkEnv.Api) (*CertificateProfilesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "certificateprofiles", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CertificateProfilesClient: %+v", err) + } + + return &CertificateProfilesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/constants.go b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/constants.go new file mode 100644 index 0000000000..e3191e196a --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/constants.go @@ -0,0 +1,245 @@ +package certificateprofiles + +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 CertificateProfileStatus string + +const ( + CertificateProfileStatusActive CertificateProfileStatus = "Active" + CertificateProfileStatusDisabled CertificateProfileStatus = "Disabled" + CertificateProfileStatusSuspended CertificateProfileStatus = "Suspended" +) + +func PossibleValuesForCertificateProfileStatus() []string { + return []string{ + string(CertificateProfileStatusActive), + string(CertificateProfileStatusDisabled), + string(CertificateProfileStatusSuspended), + } +} + +func (s *CertificateProfileStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateProfileStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateProfileStatus(input string) (*CertificateProfileStatus, error) { + vals := map[string]CertificateProfileStatus{ + "active": CertificateProfileStatusActive, + "disabled": CertificateProfileStatusDisabled, + "suspended": CertificateProfileStatusSuspended, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateProfileStatus(input) + return &out, nil +} + +type CertificateStatus string + +const ( + CertificateStatusActive CertificateStatus = "Active" + CertificateStatusExpired CertificateStatus = "Expired" + CertificateStatusRevoked CertificateStatus = "Revoked" +) + +func PossibleValuesForCertificateStatus() []string { + return []string{ + string(CertificateStatusActive), + string(CertificateStatusExpired), + string(CertificateStatusRevoked), + } +} + +func (s *CertificateStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateStatus(input string) (*CertificateStatus, error) { + vals := map[string]CertificateStatus{ + "active": CertificateStatusActive, + "expired": CertificateStatusExpired, + "revoked": CertificateStatusRevoked, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateStatus(input) + return &out, nil +} + +type ProfileType string + +const ( + ProfileTypePrivateTrust ProfileType = "PrivateTrust" + ProfileTypePrivateTrustCIPolicy ProfileType = "PrivateTrustCIPolicy" + ProfileTypePublicTrust ProfileType = "PublicTrust" + ProfileTypePublicTrustTest ProfileType = "PublicTrustTest" + ProfileTypeVBSEnclave ProfileType = "VBSEnclave" +) + +func PossibleValuesForProfileType() []string { + return []string{ + string(ProfileTypePrivateTrust), + string(ProfileTypePrivateTrustCIPolicy), + string(ProfileTypePublicTrust), + string(ProfileTypePublicTrustTest), + string(ProfileTypeVBSEnclave), + } +} + +func (s *ProfileType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProfileType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProfileType(input string) (*ProfileType, error) { + vals := map[string]ProfileType{ + "privatetrust": ProfileTypePrivateTrust, + "privatetrustcipolicy": ProfileTypePrivateTrustCIPolicy, + "publictrust": ProfileTypePublicTrust, + "publictrusttest": ProfileTypePublicTrustTest, + "vbsenclave": ProfileTypeVBSEnclave, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProfileType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type RevocationStatus string + +const ( + RevocationStatusFailed RevocationStatus = "Failed" + RevocationStatusInProgress RevocationStatus = "InProgress" + RevocationStatusSucceeded RevocationStatus = "Succeeded" +) + +func PossibleValuesForRevocationStatus() []string { + return []string{ + string(RevocationStatusFailed), + string(RevocationStatusInProgress), + string(RevocationStatusSucceeded), + } +} + +func (s *RevocationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRevocationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRevocationStatus(input string) (*RevocationStatus, error) { + vals := map[string]RevocationStatus{ + "failed": RevocationStatusFailed, + "inprogress": RevocationStatusInProgress, + "succeeded": RevocationStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RevocationStatus(input) + return &out, nil +} diff --git a/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/id_certificateprofile.go b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/id_certificateprofile.go new file mode 100644 index 0000000000..dbf303fd6f --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/id_certificateprofile.go @@ -0,0 +1,139 @@ +package certificateprofiles + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CertificateProfileId{}) +} + +var _ resourceids.ResourceId = &CertificateProfileId{} + +// CertificateProfileId is a struct representing the Resource ID for a Certificate Profile +type CertificateProfileId struct { + SubscriptionId string + ResourceGroupName string + CodeSigningAccountName string + CertificateProfileName string +} + +// NewCertificateProfileID returns a new CertificateProfileId struct +func NewCertificateProfileID(subscriptionId string, resourceGroupName string, codeSigningAccountName string, certificateProfileName string) CertificateProfileId { + return CertificateProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CodeSigningAccountName: codeSigningAccountName, + CertificateProfileName: certificateProfileName, + } +} + +// ParseCertificateProfileID parses 'input' into a CertificateProfileId +func ParseCertificateProfileID(input string) (*CertificateProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCertificateProfileIDInsensitively parses 'input' case-insensitively into a CertificateProfileId +// note: this method should only be used for API response data and not user input +func ParseCertificateProfileIDInsensitively(input string) (*CertificateProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CertificateProfileId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CodeSigningAccountName, ok = input.Parsed["codeSigningAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "codeSigningAccountName", input) + } + + if id.CertificateProfileName, ok = input.Parsed["certificateProfileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateProfileName", input) + } + + return nil +} + +// ValidateCertificateProfileID checks that 'input' can be parsed as a Certificate Profile ID +func ValidateCertificateProfileID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCertificateProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate Profile ID +func (id CertificateProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CodeSigning/codeSigningAccounts/%s/certificateProfiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CodeSigningAccountName, id.CertificateProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate Profile ID +func (id CertificateProfileId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCodeSigning", "Microsoft.CodeSigning", "Microsoft.CodeSigning"), + resourceids.StaticSegment("staticCodeSigningAccounts", "codeSigningAccounts", "codeSigningAccounts"), + resourceids.UserSpecifiedSegment("codeSigningAccountName", "codeSigningAccountName"), + resourceids.StaticSegment("staticCertificateProfiles", "certificateProfiles", "certificateProfiles"), + resourceids.UserSpecifiedSegment("certificateProfileName", "certificateProfileName"), + } +} + +// String returns a human-readable description of this Certificate Profile ID +func (id CertificateProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Code Signing Account Name: %q", id.CodeSigningAccountName), + fmt.Sprintf("Certificate Profile Name: %q", id.CertificateProfileName), + } + return fmt.Sprintf("Certificate Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/id_certificateprofile_test.go b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/id_certificateprofile_test.go new file mode 100644 index 0000000000..33bba5ccef --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/id_certificateprofile_test.go @@ -0,0 +1,327 @@ +package certificateprofiles + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CertificateProfileId{} + +func TestNewCertificateProfileID(t *testing.T) { + id := NewCertificateProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "codeSigningAccountName", "certificateProfileName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CodeSigningAccountName != "codeSigningAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'CodeSigningAccountName'", id.CodeSigningAccountName, "codeSigningAccountName") + } + + if id.CertificateProfileName != "certificateProfileName" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateProfileName'", id.CertificateProfileName, "certificateProfileName") + } +} + +func TestFormatCertificateProfileID(t *testing.T) { + actual := NewCertificateProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "codeSigningAccountName", "certificateProfileName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts/codeSigningAccountName/certificateProfiles/certificateProfileName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCertificateProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateProfileId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts/codeSigningAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts/codeSigningAccountName/certificateProfiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts/codeSigningAccountName/certificateProfiles/certificateProfileName", + Expected: &CertificateProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CodeSigningAccountName: "codeSigningAccountName", + CertificateProfileName: "certificateProfileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts/codeSigningAccountName/certificateProfiles/certificateProfileName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateProfileID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CodeSigningAccountName != v.Expected.CodeSigningAccountName { + t.Fatalf("Expected %q but got %q for CodeSigningAccountName", v.Expected.CodeSigningAccountName, actual.CodeSigningAccountName) + } + + if actual.CertificateProfileName != v.Expected.CertificateProfileName { + t.Fatalf("Expected %q but got %q for CertificateProfileName", v.Expected.CertificateProfileName, actual.CertificateProfileName) + } + + } +} + +func TestParseCertificateProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateProfileId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOdEsIgNiNg", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOdEsIgNiNg/cOdEsIgNiNgAcCoUnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts/codeSigningAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOdEsIgNiNg/cOdEsIgNiNgAcCoUnTs/cOdEsIgNiNgAcCoUnTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts/codeSigningAccountName/certificateProfiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOdEsIgNiNg/cOdEsIgNiNgAcCoUnTs/cOdEsIgNiNgAcCoUnTnAmE/cErTiFiCaTePrOfIlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts/codeSigningAccountName/certificateProfiles/certificateProfileName", + Expected: &CertificateProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CodeSigningAccountName: "codeSigningAccountName", + CertificateProfileName: "certificateProfileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts/codeSigningAccountName/certificateProfiles/certificateProfileName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOdEsIgNiNg/cOdEsIgNiNgAcCoUnTs/cOdEsIgNiNgAcCoUnTnAmE/cErTiFiCaTePrOfIlEs/cErTiFiCaTePrOfIlEnAmE", + Expected: &CertificateProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CodeSigningAccountName: "cOdEsIgNiNgAcCoUnTnAmE", + CertificateProfileName: "cErTiFiCaTePrOfIlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOdEsIgNiNg/cOdEsIgNiNgAcCoUnTs/cOdEsIgNiNgAcCoUnTnAmE/cErTiFiCaTePrOfIlEs/cErTiFiCaTePrOfIlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateProfileIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CodeSigningAccountName != v.Expected.CodeSigningAccountName { + t.Fatalf("Expected %q but got %q for CodeSigningAccountName", v.Expected.CodeSigningAccountName, actual.CodeSigningAccountName) + } + + if actual.CertificateProfileName != v.Expected.CertificateProfileName { + t.Fatalf("Expected %q but got %q for CertificateProfileName", v.Expected.CertificateProfileName, actual.CertificateProfileName) + } + + } +} + +func TestSegmentsForCertificateProfileId(t *testing.T) { + segments := CertificateProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CertificateProfileId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/id_codesigningaccount.go b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/id_codesigningaccount.go new file mode 100644 index 0000000000..e62cccb18c --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/id_codesigningaccount.go @@ -0,0 +1,130 @@ +package certificateprofiles + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CodeSigningAccountId{}) +} + +var _ resourceids.ResourceId = &CodeSigningAccountId{} + +// CodeSigningAccountId is a struct representing the Resource ID for a Code Signing Account +type CodeSigningAccountId struct { + SubscriptionId string + ResourceGroupName string + CodeSigningAccountName string +} + +// NewCodeSigningAccountID returns a new CodeSigningAccountId struct +func NewCodeSigningAccountID(subscriptionId string, resourceGroupName string, codeSigningAccountName string) CodeSigningAccountId { + return CodeSigningAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CodeSigningAccountName: codeSigningAccountName, + } +} + +// ParseCodeSigningAccountID parses 'input' into a CodeSigningAccountId +func ParseCodeSigningAccountID(input string) (*CodeSigningAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&CodeSigningAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CodeSigningAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCodeSigningAccountIDInsensitively parses 'input' case-insensitively into a CodeSigningAccountId +// note: this method should only be used for API response data and not user input +func ParseCodeSigningAccountIDInsensitively(input string) (*CodeSigningAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&CodeSigningAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CodeSigningAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CodeSigningAccountId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CodeSigningAccountName, ok = input.Parsed["codeSigningAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "codeSigningAccountName", input) + } + + return nil +} + +// ValidateCodeSigningAccountID checks that 'input' can be parsed as a Code Signing Account ID +func ValidateCodeSigningAccountID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCodeSigningAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Code Signing Account ID +func (id CodeSigningAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CodeSigning/codeSigningAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CodeSigningAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Code Signing Account ID +func (id CodeSigningAccountId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCodeSigning", "Microsoft.CodeSigning", "Microsoft.CodeSigning"), + resourceids.StaticSegment("staticCodeSigningAccounts", "codeSigningAccounts", "codeSigningAccounts"), + resourceids.UserSpecifiedSegment("codeSigningAccountName", "codeSigningAccountName"), + } +} + +// String returns a human-readable description of this Code Signing Account ID +func (id CodeSigningAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Code Signing Account Name: %q", id.CodeSigningAccountName), + } + return fmt.Sprintf("Code Signing Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/id_codesigningaccount_test.go b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/id_codesigningaccount_test.go new file mode 100644 index 0000000000..0e70e4bcd6 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/id_codesigningaccount_test.go @@ -0,0 +1,282 @@ +package certificateprofiles + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CodeSigningAccountId{} + +func TestNewCodeSigningAccountID(t *testing.T) { + id := NewCodeSigningAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "codeSigningAccountName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CodeSigningAccountName != "codeSigningAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'CodeSigningAccountName'", id.CodeSigningAccountName, "codeSigningAccountName") + } +} + +func TestFormatCodeSigningAccountID(t *testing.T) { + actual := NewCodeSigningAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "codeSigningAccountName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts/codeSigningAccountName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCodeSigningAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CodeSigningAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts/codeSigningAccountName", + Expected: &CodeSigningAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CodeSigningAccountName: "codeSigningAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts/codeSigningAccountName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCodeSigningAccountID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CodeSigningAccountName != v.Expected.CodeSigningAccountName { + t.Fatalf("Expected %q but got %q for CodeSigningAccountName", v.Expected.CodeSigningAccountName, actual.CodeSigningAccountName) + } + + } +} + +func TestParseCodeSigningAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CodeSigningAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOdEsIgNiNg", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOdEsIgNiNg/cOdEsIgNiNgAcCoUnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts/codeSigningAccountName", + Expected: &CodeSigningAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CodeSigningAccountName: "codeSigningAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts/codeSigningAccountName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOdEsIgNiNg/cOdEsIgNiNgAcCoUnTs/cOdEsIgNiNgAcCoUnTnAmE", + Expected: &CodeSigningAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CodeSigningAccountName: "cOdEsIgNiNgAcCoUnTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOdEsIgNiNg/cOdEsIgNiNgAcCoUnTs/cOdEsIgNiNgAcCoUnTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCodeSigningAccountIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CodeSigningAccountName != v.Expected.CodeSigningAccountName { + t.Fatalf("Expected %q but got %q for CodeSigningAccountName", v.Expected.CodeSigningAccountName, actual.CodeSigningAccountName) + } + + } +} + +func TestSegmentsForCodeSigningAccountId(t *testing.T) { + segments := CodeSigningAccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CodeSigningAccountId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_create.go b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_create.go new file mode 100644 index 0000000000..2cca3685e9 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_create.go @@ -0,0 +1,75 @@ +package certificateprofiles + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CertificateProfile +} + +// Create ... +func (c CertificateProfilesClient) Create(ctx context.Context, id CertificateProfileId, input CertificateProfile) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c CertificateProfilesClient) CreateThenPoll(ctx context.Context, id CertificateProfileId, input CertificateProfile) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_delete.go b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_delete.go new file mode 100644 index 0000000000..058788bfe3 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_delete.go @@ -0,0 +1,70 @@ +package certificateprofiles + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c CertificateProfilesClient) Delete(ctx context.Context, id CertificateProfileId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c CertificateProfilesClient) DeleteThenPoll(ctx context.Context, id CertificateProfileId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_get.go b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_get.go new file mode 100644 index 0000000000..3f45ab3999 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_get.go @@ -0,0 +1,53 @@ +package certificateprofiles + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CertificateProfile +} + +// Get ... +func (c CertificateProfilesClient) Get(ctx context.Context, id CertificateProfileId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CertificateProfile + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_listbycodesigningaccount.go b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_listbycodesigningaccount.go new file mode 100644 index 0000000000..7c89789a79 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_listbycodesigningaccount.go @@ -0,0 +1,105 @@ +package certificateprofiles + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByCodeSigningAccountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CertificateProfile +} + +type ListByCodeSigningAccountCompleteResult struct { + LatestHttpResponse *http.Response + Items []CertificateProfile +} + +type ListByCodeSigningAccountCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByCodeSigningAccountCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByCodeSigningAccount ... +func (c CertificateProfilesClient) ListByCodeSigningAccount(ctx context.Context, id CodeSigningAccountId) (result ListByCodeSigningAccountOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByCodeSigningAccountCustomPager{}, + Path: fmt.Sprintf("%s/certificateProfiles", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CertificateProfile `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByCodeSigningAccountComplete retrieves all the results into a single object +func (c CertificateProfilesClient) ListByCodeSigningAccountComplete(ctx context.Context, id CodeSigningAccountId) (ListByCodeSigningAccountCompleteResult, error) { + return c.ListByCodeSigningAccountCompleteMatchingPredicate(ctx, id, CertificateProfileOperationPredicate{}) +} + +// ListByCodeSigningAccountCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CertificateProfilesClient) ListByCodeSigningAccountCompleteMatchingPredicate(ctx context.Context, id CodeSigningAccountId, predicate CertificateProfileOperationPredicate) (result ListByCodeSigningAccountCompleteResult, err error) { + items := make([]CertificateProfile, 0) + + resp, err := c.ListByCodeSigningAccount(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByCodeSigningAccountCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_revokecertificate.go b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_revokecertificate.go new file mode 100644 index 0000000000..b24ef796a1 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/method_revokecertificate.go @@ -0,0 +1,51 @@ +package certificateprofiles + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RevokeCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RevokeCertificate ... +func (c CertificateProfilesClient) RevokeCertificate(ctx context.Context, id CertificateProfileId, input RevokeCertificate) (result RevokeCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/revokeCertificate", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_certificate.go b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_certificate.go new file mode 100644 index 0000000000..ab301ee146 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_certificate.go @@ -0,0 +1,15 @@ +package certificateprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Certificate struct { + CreatedDate *string `json:"createdDate,omitempty"` + EnhancedKeyUsage *string `json:"enhancedKeyUsage,omitempty"` + ExpiryDate *string `json:"expiryDate,omitempty"` + Revocation *Revocation `json:"revocation,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + Status *CertificateStatus `json:"status,omitempty"` + SubjectName *string `json:"subjectName,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` +} diff --git a/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_certificateprofile.go b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_certificateprofile.go new file mode 100644 index 0000000000..2e47218eb8 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_certificateprofile.go @@ -0,0 +1,16 @@ +package certificateprofiles + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CertificateProfileProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_certificateprofileproperties.go b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_certificateprofileproperties.go new file mode 100644 index 0000000000..06390d807e --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_certificateprofileproperties.go @@ -0,0 +1,17 @@ +package certificateprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateProfileProperties struct { + Certificates *[]Certificate `json:"certificates,omitempty"` + IdentityValidationId string `json:"identityValidationId"` + IncludeCity *bool `json:"includeCity,omitempty"` + IncludeCountry *bool `json:"includeCountry,omitempty"` + IncludePostalCode *bool `json:"includePostalCode,omitempty"` + IncludeState *bool `json:"includeState,omitempty"` + IncludeStreetAddress *bool `json:"includeStreetAddress,omitempty"` + ProfileType ProfileType `json:"profileType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Status *CertificateProfileStatus `json:"status,omitempty"` +} diff --git a/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_revocation.go b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_revocation.go new file mode 100644 index 0000000000..1cd45d7441 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_revocation.go @@ -0,0 +1,43 @@ +package certificateprofiles + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Revocation struct { + EffectiveAt *string `json:"effectiveAt,omitempty"` + FailureReason *string `json:"failureReason,omitempty"` + Reason *string `json:"reason,omitempty"` + Remarks *string `json:"remarks,omitempty"` + RequestedAt *string `json:"requestedAt,omitempty"` + Status *RevocationStatus `json:"status,omitempty"` +} + +func (o *Revocation) GetEffectiveAtAsTime() (*time.Time, error) { + if o.EffectiveAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EffectiveAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *Revocation) SetEffectiveAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EffectiveAt = &formatted +} + +func (o *Revocation) GetRequestedAtAsTime() (*time.Time, error) { + if o.RequestedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RequestedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *Revocation) SetRequestedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RequestedAt = &formatted +} diff --git a/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_revokecertificate.go b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_revokecertificate.go new file mode 100644 index 0000000000..b8bea125a7 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/model_revokecertificate.go @@ -0,0 +1,27 @@ +package certificateprofiles + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RevokeCertificate struct { + EffectiveAt string `json:"effectiveAt"` + Reason string `json:"reason"` + Remarks *string `json:"remarks,omitempty"` + SerialNumber string `json:"serialNumber"` + Thumbprint string `json:"thumbprint"` +} + +func (o *RevokeCertificate) GetEffectiveAtAsTime() (*time.Time, error) { + return dates.ParseAsFormat(&o.EffectiveAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *RevokeCertificate) SetEffectiveAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EffectiveAt = formatted +} diff --git a/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/predicates.go b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/predicates.go new file mode 100644 index 0000000000..3044be14db --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/predicates.go @@ -0,0 +1,27 @@ +package certificateprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateProfileOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p CertificateProfileOperationPredicate) Matches(input CertificateProfile) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/version.go b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/version.go new file mode 100644 index 0000000000..2f1d629a00 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/certificateprofiles/version.go @@ -0,0 +1,10 @@ +package certificateprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-30-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/certificateprofiles/2024-09-30-preview" +} diff --git a/resource-manager/codesigning/2024-09-30-preview/client.go b/resource-manager/codesigning/2024-09-30-preview/client.go new file mode 100644 index 0000000000..868e723d97 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/client.go @@ -0,0 +1,37 @@ +package v2024_09_30_preview + +// 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/codesigning/2024-09-30-preview/certificateprofiles" + "github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + CertificateProfiles *certificateprofiles.CertificateProfilesClient + CodeSigningAccounts *codesigningaccounts.CodeSigningAccountsClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + certificateProfilesClient, err := certificateprofiles.NewCertificateProfilesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CertificateProfiles client: %+v", err) + } + configureFunc(certificateProfilesClient.Client) + + codeSigningAccountsClient, err := codesigningaccounts.NewCodeSigningAccountsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CodeSigningAccounts client: %+v", err) + } + configureFunc(codeSigningAccountsClient.Client) + + return &Client{ + CertificateProfiles: certificateProfilesClient, + CodeSigningAccounts: codeSigningAccountsClient, + }, nil +} diff --git a/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/README.md b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/README.md new file mode 100644 index 0000000000..914bd4802c --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/README.md @@ -0,0 +1,138 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts` Documentation + +The `codesigningaccounts` SDK allows for interaction with Azure Resource Manager `codesigning` (API Version `2024-09-30-preview`). + +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/codesigning/2024-09-30-preview/codesigningaccounts" +``` + + +### Client Initialization + +```go +client := codesigningaccounts.NewCodeSigningAccountsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CodeSigningAccountsClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := codesigningaccounts.CheckNameAvailability{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CodeSigningAccountsClient.Create` + +```go +ctx := context.TODO() +id := codesigningaccounts.NewCodeSigningAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "codeSigningAccountName") + +payload := codesigningaccounts.CodeSigningAccount{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CodeSigningAccountsClient.Delete` + +```go +ctx := context.TODO() +id := codesigningaccounts.NewCodeSigningAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "codeSigningAccountName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CodeSigningAccountsClient.Get` + +```go +ctx := context.TODO() +id := codesigningaccounts.NewCodeSigningAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "codeSigningAccountName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CodeSigningAccountsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CodeSigningAccountsClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CodeSigningAccountsClient.Update` + +```go +ctx := context.TODO() +id := codesigningaccounts.NewCodeSigningAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "codeSigningAccountName") + +payload := codesigningaccounts.CodeSigningAccountPatch{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/client.go b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/client.go new file mode 100644 index 0000000000..dabcf27b25 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/client.go @@ -0,0 +1,26 @@ +package codesigningaccounts + +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 CodeSigningAccountsClient struct { + Client *resourcemanager.Client +} + +func NewCodeSigningAccountsClientWithBaseURI(sdkApi sdkEnv.Api) (*CodeSigningAccountsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "codesigningaccounts", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CodeSigningAccountsClient: %+v", err) + } + + return &CodeSigningAccountsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/constants.go b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/constants.go new file mode 100644 index 0000000000..48cb12493f --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/constants.go @@ -0,0 +1,145 @@ +package codesigningaccounts + +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 NameUnavailabilityReason string + +const ( + NameUnavailabilityReasonAccountNameInvalid NameUnavailabilityReason = "AccountNameInvalid" + NameUnavailabilityReasonAlreadyExists NameUnavailabilityReason = "AlreadyExists" +) + +func PossibleValuesForNameUnavailabilityReason() []string { + return []string{ + string(NameUnavailabilityReasonAccountNameInvalid), + string(NameUnavailabilityReasonAlreadyExists), + } +} + +func (s *NameUnavailabilityReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNameUnavailabilityReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNameUnavailabilityReason(input string) (*NameUnavailabilityReason, error) { + vals := map[string]NameUnavailabilityReason{ + "accountnameinvalid": NameUnavailabilityReasonAccountNameInvalid, + "alreadyexists": NameUnavailabilityReasonAlreadyExists, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NameUnavailabilityReason(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type SkuName string + +const ( + SkuNameBasic SkuName = "Basic" + SkuNamePremium SkuName = "Premium" +) + +func PossibleValuesForSkuName() []string { + return []string{ + string(SkuNameBasic), + string(SkuNamePremium), + } +} + +func (s *SkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuName(input string) (*SkuName, error) { + vals := map[string]SkuName{ + "basic": SkuNameBasic, + "premium": SkuNamePremium, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuName(input) + return &out, nil +} diff --git a/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/id_codesigningaccount.go b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/id_codesigningaccount.go new file mode 100644 index 0000000000..345dd35145 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/id_codesigningaccount.go @@ -0,0 +1,130 @@ +package codesigningaccounts + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CodeSigningAccountId{}) +} + +var _ resourceids.ResourceId = &CodeSigningAccountId{} + +// CodeSigningAccountId is a struct representing the Resource ID for a Code Signing Account +type CodeSigningAccountId struct { + SubscriptionId string + ResourceGroupName string + CodeSigningAccountName string +} + +// NewCodeSigningAccountID returns a new CodeSigningAccountId struct +func NewCodeSigningAccountID(subscriptionId string, resourceGroupName string, codeSigningAccountName string) CodeSigningAccountId { + return CodeSigningAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CodeSigningAccountName: codeSigningAccountName, + } +} + +// ParseCodeSigningAccountID parses 'input' into a CodeSigningAccountId +func ParseCodeSigningAccountID(input string) (*CodeSigningAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&CodeSigningAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CodeSigningAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCodeSigningAccountIDInsensitively parses 'input' case-insensitively into a CodeSigningAccountId +// note: this method should only be used for API response data and not user input +func ParseCodeSigningAccountIDInsensitively(input string) (*CodeSigningAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&CodeSigningAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CodeSigningAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CodeSigningAccountId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CodeSigningAccountName, ok = input.Parsed["codeSigningAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "codeSigningAccountName", input) + } + + return nil +} + +// ValidateCodeSigningAccountID checks that 'input' can be parsed as a Code Signing Account ID +func ValidateCodeSigningAccountID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCodeSigningAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Code Signing Account ID +func (id CodeSigningAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CodeSigning/codeSigningAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CodeSigningAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Code Signing Account ID +func (id CodeSigningAccountId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCodeSigning", "Microsoft.CodeSigning", "Microsoft.CodeSigning"), + resourceids.StaticSegment("staticCodeSigningAccounts", "codeSigningAccounts", "codeSigningAccounts"), + resourceids.UserSpecifiedSegment("codeSigningAccountName", "codeSigningAccountName"), + } +} + +// String returns a human-readable description of this Code Signing Account ID +func (id CodeSigningAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Code Signing Account Name: %q", id.CodeSigningAccountName), + } + return fmt.Sprintf("Code Signing Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/id_codesigningaccount_test.go b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/id_codesigningaccount_test.go new file mode 100644 index 0000000000..b4e7cb0719 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/id_codesigningaccount_test.go @@ -0,0 +1,282 @@ +package codesigningaccounts + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CodeSigningAccountId{} + +func TestNewCodeSigningAccountID(t *testing.T) { + id := NewCodeSigningAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "codeSigningAccountName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CodeSigningAccountName != "codeSigningAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'CodeSigningAccountName'", id.CodeSigningAccountName, "codeSigningAccountName") + } +} + +func TestFormatCodeSigningAccountID(t *testing.T) { + actual := NewCodeSigningAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "codeSigningAccountName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts/codeSigningAccountName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCodeSigningAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CodeSigningAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts/codeSigningAccountName", + Expected: &CodeSigningAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CodeSigningAccountName: "codeSigningAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts/codeSigningAccountName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCodeSigningAccountID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CodeSigningAccountName != v.Expected.CodeSigningAccountName { + t.Fatalf("Expected %q but got %q for CodeSigningAccountName", v.Expected.CodeSigningAccountName, actual.CodeSigningAccountName) + } + + } +} + +func TestParseCodeSigningAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CodeSigningAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOdEsIgNiNg", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOdEsIgNiNg/cOdEsIgNiNgAcCoUnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts/codeSigningAccountName", + Expected: &CodeSigningAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CodeSigningAccountName: "codeSigningAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CodeSigning/codeSigningAccounts/codeSigningAccountName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOdEsIgNiNg/cOdEsIgNiNgAcCoUnTs/cOdEsIgNiNgAcCoUnTnAmE", + Expected: &CodeSigningAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CodeSigningAccountName: "cOdEsIgNiNgAcCoUnTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOdEsIgNiNg/cOdEsIgNiNgAcCoUnTs/cOdEsIgNiNgAcCoUnTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCodeSigningAccountIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CodeSigningAccountName != v.Expected.CodeSigningAccountName { + t.Fatalf("Expected %q but got %q for CodeSigningAccountName", v.Expected.CodeSigningAccountName, actual.CodeSigningAccountName) + } + + } +} + +func TestSegmentsForCodeSigningAccountId(t *testing.T) { + segments := CodeSigningAccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CodeSigningAccountId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_checknameavailability.go b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_checknameavailability.go new file mode 100644 index 0000000000..2a800d7f61 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_checknameavailability.go @@ -0,0 +1,59 @@ +package codesigningaccounts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameAvailabilityResult +} + +// CheckNameAvailability ... +func (c CodeSigningAccountsClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailability) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.CodeSigning/checkNameAvailability", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CheckNameAvailabilityResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_create.go b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_create.go new file mode 100644 index 0000000000..7d665533d7 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_create.go @@ -0,0 +1,75 @@ +package codesigningaccounts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CodeSigningAccount +} + +// Create ... +func (c CodeSigningAccountsClient) Create(ctx context.Context, id CodeSigningAccountId, input CodeSigningAccount) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c CodeSigningAccountsClient) CreateThenPoll(ctx context.Context, id CodeSigningAccountId, input CodeSigningAccount) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_delete.go b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_delete.go new file mode 100644 index 0000000000..88c7423010 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_delete.go @@ -0,0 +1,70 @@ +package codesigningaccounts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c CodeSigningAccountsClient) Delete(ctx context.Context, id CodeSigningAccountId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c CodeSigningAccountsClient) DeleteThenPoll(ctx context.Context, id CodeSigningAccountId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_get.go b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_get.go new file mode 100644 index 0000000000..f56a3fc558 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_get.go @@ -0,0 +1,53 @@ +package codesigningaccounts + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CodeSigningAccount +} + +// Get ... +func (c CodeSigningAccountsClient) Get(ctx context.Context, id CodeSigningAccountId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CodeSigningAccount + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_listbyresourcegroup.go b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_listbyresourcegroup.go new file mode 100644 index 0000000000..dcbd408709 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package codesigningaccounts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CodeSigningAccount +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []CodeSigningAccount +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c CodeSigningAccountsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.CodeSigning/codeSigningAccounts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CodeSigningAccount `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c CodeSigningAccountsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, CodeSigningAccountOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CodeSigningAccountsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate CodeSigningAccountOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]CodeSigningAccount, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_listbysubscription.go b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_listbysubscription.go new file mode 100644 index 0000000000..af7e03ceac --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_listbysubscription.go @@ -0,0 +1,106 @@ +package codesigningaccounts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CodeSigningAccount +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []CodeSigningAccount +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c CodeSigningAccountsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.CodeSigning/codeSigningAccounts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CodeSigningAccount `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c CodeSigningAccountsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, CodeSigningAccountOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CodeSigningAccountsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate CodeSigningAccountOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]CodeSigningAccount, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_update.go b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_update.go new file mode 100644 index 0000000000..d1a3d395e0 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/method_update.go @@ -0,0 +1,75 @@ +package codesigningaccounts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CodeSigningAccount +} + +// Update ... +func (c CodeSigningAccountsClient) Update(ctx context.Context, id CodeSigningAccountId, input CodeSigningAccountPatch) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c CodeSigningAccountsClient) UpdateThenPoll(ctx context.Context, id CodeSigningAccountId, input CodeSigningAccountPatch) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_accountsku.go b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_accountsku.go new file mode 100644 index 0000000000..301eca3821 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_accountsku.go @@ -0,0 +1,8 @@ +package codesigningaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccountSku struct { + Name SkuName `json:"name"` +} diff --git a/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_accountskupatch.go b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_accountskupatch.go new file mode 100644 index 0000000000..0f09a8660b --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_accountskupatch.go @@ -0,0 +1,8 @@ +package codesigningaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccountSkuPatch struct { + Name *SkuName `json:"name,omitempty"` +} diff --git a/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_checknameavailability.go b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_checknameavailability.go new file mode 100644 index 0000000000..f01c090ec6 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_checknameavailability.go @@ -0,0 +1,8 @@ +package codesigningaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailability struct { + Name string `json:"name"` +} diff --git a/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_checknameavailabilityresult.go b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_checknameavailabilityresult.go new file mode 100644 index 0000000000..9fee693bf9 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_checknameavailabilityresult.go @@ -0,0 +1,10 @@ +package codesigningaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityResult struct { + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *NameUnavailabilityReason `json:"reason,omitempty"` +} diff --git a/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccount.go b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccount.go new file mode 100644 index 0000000000..e21b9375fb --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccount.go @@ -0,0 +1,18 @@ +package codesigningaccounts + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CodeSigningAccount struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *CodeSigningAccountProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccountpatch.go b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccountpatch.go new file mode 100644 index 0000000000..704c7e4158 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccountpatch.go @@ -0,0 +1,9 @@ +package codesigningaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CodeSigningAccountPatch struct { + Properties *CodeSigningAccountPatchProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccountpatchproperties.go b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccountpatchproperties.go new file mode 100644 index 0000000000..7ddd60275f --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccountpatchproperties.go @@ -0,0 +1,8 @@ +package codesigningaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CodeSigningAccountPatchProperties struct { + Sku *AccountSkuPatch `json:"sku,omitempty"` +} diff --git a/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccountproperties.go b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccountproperties.go new file mode 100644 index 0000000000..30d1d196fb --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/model_codesigningaccountproperties.go @@ -0,0 +1,10 @@ +package codesigningaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CodeSigningAccountProperties struct { + AccountUri *string `json:"accountUri,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Sku *AccountSku `json:"sku,omitempty"` +} diff --git a/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/predicates.go b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/predicates.go new file mode 100644 index 0000000000..cea979dacf --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/predicates.go @@ -0,0 +1,32 @@ +package codesigningaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CodeSigningAccountOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p CodeSigningAccountOperationPredicate) Matches(input CodeSigningAccount) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/version.go b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/version.go new file mode 100644 index 0000000000..4f6d304868 --- /dev/null +++ b/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts/version.go @@ -0,0 +1,10 @@ +package codesigningaccounts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-30-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/codesigningaccounts/2024-09-30-preview" +}