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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func UnmarshalConnectionInfoImplementation(input []byte) (ConnectionInfo, error)
return out, nil
}

if strings.EqualFold(value, "MongoDbConnectionInfo") {
if strings.EqualFold(value, "mongoDbConnectionInfo") {
var out MongoDbConnectionInfo
if err := json.Unmarshal(input, &out); err != nil {
return nil, fmt.Errorf("unmarshaling into MongoDbConnectionInfo: %+v", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (s MongoDbConnectionInfo) MarshalJSON() ([]byte, error) {
return nil, fmt.Errorf("unmarshaling MongoDbConnectionInfo: %+v", err)
}

decoded["type"] = "MongoDbConnectionInfo"
decoded["type"] = "mongoDbConnectionInfo"

encoded, err = json.Marshal(decoded)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func UnmarshalConnectionInfoImplementation(input []byte) (ConnectionInfo, error)
return out, nil
}

if strings.EqualFold(value, "MongoDbConnectionInfo") {
if strings.EqualFold(value, "mongoDbConnectionInfo") {
var out MongoDbConnectionInfo
if err := json.Unmarshal(input, &out); err != nil {
return nil, fmt.Errorf("unmarshaling into MongoDbConnectionInfo: %+v", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (s MongoDbConnectionInfo) MarshalJSON() ([]byte, error) {
return nil, fmt.Errorf("unmarshaling MongoDbConnectionInfo: %+v", err)
}

decoded["type"] = "MongoDbConnectionInfo"
decoded["type"] = "mongoDbConnectionInfo"

encoded, err = json.Marshal(decoded)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func UnmarshalConnectionInfoImplementation(input []byte) (ConnectionInfo, error)
return out, nil
}

if strings.EqualFold(value, "MongoDbConnectionInfo") {
if strings.EqualFold(value, "mongoDbConnectionInfo") {
var out MongoDbConnectionInfo
if err := json.Unmarshal(input, &out); err != nil {
return nil, fmt.Errorf("unmarshaling into MongoDbConnectionInfo: %+v", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (s MongoDbConnectionInfo) MarshalJSON() ([]byte, error) {
return nil, fmt.Errorf("unmarshaling MongoDbConnectionInfo: %+v", err)
}

decoded["type"] = "MongoDbConnectionInfo"
decoded["type"] = "mongoDbConnectionInfo"

encoded, err = json.Marshal(decoded)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@

## `github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2024-12-30/advancedthreatprotectionsettings` Documentation

The `advancedthreatprotectionsettings` SDK allows for interaction with Azure Resource Manager `mysql` (API Version `2024-12-30`).

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/mysql/2024-12-30/advancedthreatprotectionsettings"
```


### Client Initialization

```go
client := advancedthreatprotectionsettings.NewAdvancedThreatProtectionSettingsClientWithBaseURI("https://management.azure.com")
client.Client.Authorizer = authorizer
```


### Example Usage: `AdvancedThreatProtectionSettingsClient.Get`

```go
ctx := context.TODO()
id := advancedthreatprotectionsettings.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName")

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: `AdvancedThreatProtectionSettingsClient.List`

```go
ctx := context.TODO()
id := advancedthreatprotectionsettings.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName")

// alternatively `client.List(ctx, id)` can be used to do batched pagination
items, err := client.ListComplete(ctx, id)
if err != nil {
// handle the error
}
for _, item := range items {
// do something
}
```


### Example Usage: `AdvancedThreatProtectionSettingsClient.Update`

```go
ctx := context.TODO()
id := advancedthreatprotectionsettings.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName")

payload := advancedthreatprotectionsettings.AdvancedThreatProtectionForUpdate{
// ...
}


if err := client.UpdateThenPoll(ctx, id, payload); err != nil {
// handle the error
}
```


### Example Usage: `AdvancedThreatProtectionSettingsClient.UpdatePut`

```go
ctx := context.TODO()
id := advancedthreatprotectionsettings.NewFlexibleServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "flexibleServerName")

payload := advancedthreatprotectionsettings.AdvancedThreatProtection{
// ...
}


if err := client.UpdatePutThenPoll(ctx, id, payload); err != nil {
// handle the error
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package advancedthreatprotectionsettings

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 AdvancedThreatProtectionSettingsClient struct {
Client *resourcemanager.Client
}

func NewAdvancedThreatProtectionSettingsClientWithBaseURI(sdkApi sdkEnv.Api) (*AdvancedThreatProtectionSettingsClient, error) {
client, err := resourcemanager.NewClient(sdkApi, "advancedthreatprotectionsettings", defaultApiVersion)
if err != nil {
return nil, fmt.Errorf("instantiating AdvancedThreatProtectionSettingsClient: %+v", err)
}

return &AdvancedThreatProtectionSettingsClient{
Client: client,
}, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package advancedthreatprotectionsettings

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 AdvancedThreatProtectionProvisioningState string

const (
AdvancedThreatProtectionProvisioningStateCanceled AdvancedThreatProtectionProvisioningState = "Canceled"
AdvancedThreatProtectionProvisioningStateFailed AdvancedThreatProtectionProvisioningState = "Failed"
AdvancedThreatProtectionProvisioningStateSucceeded AdvancedThreatProtectionProvisioningState = "Succeeded"
AdvancedThreatProtectionProvisioningStateUpdating AdvancedThreatProtectionProvisioningState = "Updating"
)

func PossibleValuesForAdvancedThreatProtectionProvisioningState() []string {
return []string{
string(AdvancedThreatProtectionProvisioningStateCanceled),
string(AdvancedThreatProtectionProvisioningStateFailed),
string(AdvancedThreatProtectionProvisioningStateSucceeded),
string(AdvancedThreatProtectionProvisioningStateUpdating),
}
}

func (s *AdvancedThreatProtectionProvisioningState) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseAdvancedThreatProtectionProvisioningState(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}

func parseAdvancedThreatProtectionProvisioningState(input string) (*AdvancedThreatProtectionProvisioningState, error) {
vals := map[string]AdvancedThreatProtectionProvisioningState{
"canceled": AdvancedThreatProtectionProvisioningStateCanceled,
"failed": AdvancedThreatProtectionProvisioningStateFailed,
"succeeded": AdvancedThreatProtectionProvisioningStateSucceeded,
"updating": AdvancedThreatProtectionProvisioningStateUpdating,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}

// otherwise presume it's an undefined value and best-effort it
out := AdvancedThreatProtectionProvisioningState(input)
return &out, nil
}

type AdvancedThreatProtectionState string

const (
AdvancedThreatProtectionStateDisabled AdvancedThreatProtectionState = "Disabled"
AdvancedThreatProtectionStateEnabled AdvancedThreatProtectionState = "Enabled"
)

func PossibleValuesForAdvancedThreatProtectionState() []string {
return []string{
string(AdvancedThreatProtectionStateDisabled),
string(AdvancedThreatProtectionStateEnabled),
}
}

func (s *AdvancedThreatProtectionState) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseAdvancedThreatProtectionState(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}

func parseAdvancedThreatProtectionState(input string) (*AdvancedThreatProtectionState, error) {
vals := map[string]AdvancedThreatProtectionState{
"disabled": AdvancedThreatProtectionStateDisabled,
"enabled": AdvancedThreatProtectionStateEnabled,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}

// otherwise presume it's an undefined value and best-effort it
out := AdvancedThreatProtectionState(input)
return &out, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package advancedthreatprotectionsettings

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(&FlexibleServerId{})
}

var _ resourceids.ResourceId = &FlexibleServerId{}

// FlexibleServerId is a struct representing the Resource ID for a Flexible Server
type FlexibleServerId struct {
SubscriptionId string
ResourceGroupName string
FlexibleServerName string
}

// NewFlexibleServerID returns a new FlexibleServerId struct
func NewFlexibleServerID(subscriptionId string, resourceGroupName string, flexibleServerName string) FlexibleServerId {
return FlexibleServerId{
SubscriptionId: subscriptionId,
ResourceGroupName: resourceGroupName,
FlexibleServerName: flexibleServerName,
}
}

// ParseFlexibleServerID parses 'input' into a FlexibleServerId
func ParseFlexibleServerID(input string) (*FlexibleServerId, error) {
parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{})
parsed, err := parser.Parse(input, false)
if err != nil {
return nil, fmt.Errorf("parsing %q: %+v", input, err)
}

id := FlexibleServerId{}
if err = id.FromParseResult(*parsed); err != nil {
return nil, err
}

return &id, nil
}

// ParseFlexibleServerIDInsensitively parses 'input' case-insensitively into a FlexibleServerId
// note: this method should only be used for API response data and not user input
func ParseFlexibleServerIDInsensitively(input string) (*FlexibleServerId, error) {
parser := resourceids.NewParserFromResourceIdType(&FlexibleServerId{})
parsed, err := parser.Parse(input, true)
if err != nil {
return nil, fmt.Errorf("parsing %q: %+v", input, err)
}

id := FlexibleServerId{}
if err = id.FromParseResult(*parsed); err != nil {
return nil, err
}

return &id, nil
}

func (id *FlexibleServerId) 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.FlexibleServerName, ok = input.Parsed["flexibleServerName"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "flexibleServerName", input)
}

return nil
}

// ValidateFlexibleServerID checks that 'input' can be parsed as a Flexible Server ID
func ValidateFlexibleServerID(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 := ParseFlexibleServerID(v); err != nil {
errors = append(errors, err)
}

return
}

// ID returns the formatted Flexible Server ID
func (id FlexibleServerId) ID() string {
fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DBforMySQL/flexibleServers/%s"
return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FlexibleServerName)
}

// Segments returns a slice of Resource ID Segments which comprise this Flexible Server ID
func (id FlexibleServerId) 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("staticMicrosoftDBforMySQL", "Microsoft.DBforMySQL", "Microsoft.DBforMySQL"),
resourceids.StaticSegment("staticFlexibleServers", "flexibleServers", "flexibleServers"),
resourceids.UserSpecifiedSegment("flexibleServerName", "flexibleServerName"),
}
}

// String returns a human-readable description of this Flexible Server ID
func (id FlexibleServerId) String() string {
components := []string{
fmt.Sprintf("Subscription: %q", id.SubscriptionId),
fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName),
fmt.Sprintf("Flexible Server Name: %q", id.FlexibleServerName),
}
return fmt.Sprintf("Flexible Server (%s)", strings.Join(components, "\n"))
}
Loading
Loading