Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto PR: Regenerating the Go SDK (9eaeb3bc29618d757196bed0e2acfe3cf6d4c7ce) #928

Merged
merged 1 commit into from
Mar 15, 2024
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions resource-manager/frontdoor/2024-02-01/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package v2024_02_01

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.

import (
"github.com/Azure/go-autorest/autorest"
"github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallmanagedrulesets"
"github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies"
)

type Client struct {
WebApplicationFirewallManagedRuleSets *webapplicationfirewallmanagedrulesets.WebApplicationFirewallManagedRuleSetsClient
WebApplicationFirewallPolicies *webapplicationfirewallpolicies.WebApplicationFirewallPoliciesClient
}

func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client {

webApplicationFirewallManagedRuleSetsClient := webapplicationfirewallmanagedrulesets.NewWebApplicationFirewallManagedRuleSetsClientWithBaseURI(endpoint)
configureAuthFunc(&webApplicationFirewallManagedRuleSetsClient.Client)

webApplicationFirewallPoliciesClient := webapplicationfirewallpolicies.NewWebApplicationFirewallPoliciesClientWithBaseURI(endpoint)
configureAuthFunc(&webApplicationFirewallPoliciesClient.Client)

return Client{
WebApplicationFirewallManagedRuleSets: &webApplicationFirewallManagedRuleSetsClient,
WebApplicationFirewallPolicies: &webApplicationFirewallPoliciesClient,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

## `github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallmanagedrulesets` Documentation

The `webapplicationfirewallmanagedrulesets` SDK allows for interaction with the Azure Resource Manager Service `frontdoor` (API Version `2024-02-01`).

This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs).

### Import Path

```go
import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids"
import "github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallmanagedrulesets"
```


### Client Initialization

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


### Example Usage: `WebApplicationFirewallManagedRuleSetsClient.ManagedRuleSetsList`

```go
ctx := context.TODO()
id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012")

// alternatively `client.ManagedRuleSetsList(ctx, id)` can be used to do batched pagination
items, err := client.ManagedRuleSetsListComplete(ctx, id)
if err != nil {
// handle the error
}
for _, item := range items {
// do something
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package webapplicationfirewallmanagedrulesets

import "github.com/Azure/go-autorest/autorest"

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.

type WebApplicationFirewallManagedRuleSetsClient struct {
Client autorest.Client
baseUri string
}

func NewWebApplicationFirewallManagedRuleSetsClientWithBaseURI(endpoint string) WebApplicationFirewallManagedRuleSetsClient {
return WebApplicationFirewallManagedRuleSetsClient{
Client: autorest.NewClientWithUserAgent(userAgent()),
baseUri: endpoint,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package webapplicationfirewallmanagedrulesets

import "strings"

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.

type ActionType string

const (
ActionTypeAllow ActionType = "Allow"
ActionTypeAnomalyScoring ActionType = "AnomalyScoring"
ActionTypeBlock ActionType = "Block"
ActionTypeJSChallenge ActionType = "JSChallenge"
ActionTypeLog ActionType = "Log"
ActionTypeRedirect ActionType = "Redirect"
)

func PossibleValuesForActionType() []string {
return []string{
string(ActionTypeAllow),
string(ActionTypeAnomalyScoring),
string(ActionTypeBlock),
string(ActionTypeJSChallenge),
string(ActionTypeLog),
string(ActionTypeRedirect),
}
}

func parseActionType(input string) (*ActionType, error) {
vals := map[string]ActionType{
"allow": ActionTypeAllow,
"anomalyscoring": ActionTypeAnomalyScoring,
"block": ActionTypeBlock,
"jschallenge": ActionTypeJSChallenge,
"log": ActionTypeLog,
"redirect": ActionTypeRedirect,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}

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

type ManagedRuleEnabledState string

const (
ManagedRuleEnabledStateDisabled ManagedRuleEnabledState = "Disabled"
ManagedRuleEnabledStateEnabled ManagedRuleEnabledState = "Enabled"
)

func PossibleValuesForManagedRuleEnabledState() []string {
return []string{
string(ManagedRuleEnabledStateDisabled),
string(ManagedRuleEnabledStateEnabled),
}
}

func parseManagedRuleEnabledState(input string) (*ManagedRuleEnabledState, error) {
vals := map[string]ManagedRuleEnabledState{
"disabled": ManagedRuleEnabledStateDisabled,
"enabled": ManagedRuleEnabledStateEnabled,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}

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

import (
"context"
"fmt"
"net/http"
"net/url"

"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonids"
)

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.

type ManagedRuleSetsListOperationResponse struct {
HttpResponse *http.Response
Model *[]ManagedRuleSetDefinition

nextLink *string
nextPageFunc func(ctx context.Context, nextLink string) (ManagedRuleSetsListOperationResponse, error)
}

type ManagedRuleSetsListCompleteResult struct {
Items []ManagedRuleSetDefinition
}

func (r ManagedRuleSetsListOperationResponse) HasMore() bool {
return r.nextLink != nil
}

func (r ManagedRuleSetsListOperationResponse) LoadMore(ctx context.Context) (resp ManagedRuleSetsListOperationResponse, err error) {
if !r.HasMore() {
err = fmt.Errorf("no more pages returned")
return
}
return r.nextPageFunc(ctx, *r.nextLink)
}

// ManagedRuleSetsList ...
func (c WebApplicationFirewallManagedRuleSetsClient) ManagedRuleSetsList(ctx context.Context, id commonids.SubscriptionId) (resp ManagedRuleSetsListOperationResponse, err error) {
req, err := c.preparerForManagedRuleSetsList(ctx, id)
if err != nil {
err = autorest.NewErrorWithError(err, "webapplicationfirewallmanagedrulesets.WebApplicationFirewallManagedRuleSetsClient", "ManagedRuleSetsList", nil, "Failure preparing request")
return
}

resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client))
if err != nil {
err = autorest.NewErrorWithError(err, "webapplicationfirewallmanagedrulesets.WebApplicationFirewallManagedRuleSetsClient", "ManagedRuleSetsList", resp.HttpResponse, "Failure sending request")
return
}

resp, err = c.responderForManagedRuleSetsList(resp.HttpResponse)
if err != nil {
err = autorest.NewErrorWithError(err, "webapplicationfirewallmanagedrulesets.WebApplicationFirewallManagedRuleSetsClient", "ManagedRuleSetsList", resp.HttpResponse, "Failure responding to request")
return
}
return
}

// preparerForManagedRuleSetsList prepares the ManagedRuleSetsList request.
func (c WebApplicationFirewallManagedRuleSetsClient) preparerForManagedRuleSetsList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) {
queryParameters := map[string]interface{}{
"api-version": defaultApiVersion,
}

preparer := autorest.CreatePreparer(
autorest.AsContentType("application/json; charset=utf-8"),
autorest.AsGet(),
autorest.WithBaseURL(c.baseUri),
autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Network/frontDoorWebApplicationFirewallManagedRuleSets", id.ID())),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}

// preparerForManagedRuleSetsListWithNextLink prepares the ManagedRuleSetsList request with the given nextLink token.
func (c WebApplicationFirewallManagedRuleSetsClient) preparerForManagedRuleSetsListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) {
uri, err := url.Parse(nextLink)
if err != nil {
return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err)
}
queryParameters := map[string]interface{}{}
for k, v := range uri.Query() {
if len(v) == 0 {
continue
}
val := v[0]
val = autorest.Encode("query", val)
queryParameters[k] = val
}

preparer := autorest.CreatePreparer(
autorest.AsContentType("application/json; charset=utf-8"),
autorest.AsGet(),
autorest.WithBaseURL(c.baseUri),
autorest.WithPath(uri.Path),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}

// responderForManagedRuleSetsList handles the response to the ManagedRuleSetsList request. The method always
// closes the http.Response Body.
func (c WebApplicationFirewallManagedRuleSetsClient) responderForManagedRuleSetsList(resp *http.Response) (result ManagedRuleSetsListOperationResponse, err error) {
type page struct {
Values []ManagedRuleSetDefinition `json:"value"`
NextLink *string `json:"nextLink"`
}
var respObj page
err = autorest.Respond(
resp,
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&respObj),
autorest.ByClosing())
result.HttpResponse = resp
result.Model = &respObj.Values
result.nextLink = respObj.NextLink
if respObj.NextLink != nil {
result.nextPageFunc = func(ctx context.Context, nextLink string) (result ManagedRuleSetsListOperationResponse, err error) {
req, err := c.preparerForManagedRuleSetsListWithNextLink(ctx, nextLink)
if err != nil {
err = autorest.NewErrorWithError(err, "webapplicationfirewallmanagedrulesets.WebApplicationFirewallManagedRuleSetsClient", "ManagedRuleSetsList", nil, "Failure preparing request")
return
}

result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client))
if err != nil {
err = autorest.NewErrorWithError(err, "webapplicationfirewallmanagedrulesets.WebApplicationFirewallManagedRuleSetsClient", "ManagedRuleSetsList", result.HttpResponse, "Failure sending request")
return
}

result, err = c.responderForManagedRuleSetsList(result.HttpResponse)
if err != nil {
err = autorest.NewErrorWithError(err, "webapplicationfirewallmanagedrulesets.WebApplicationFirewallManagedRuleSetsClient", "ManagedRuleSetsList", result.HttpResponse, "Failure responding to request")
return
}

return
}
}
return
}

// ManagedRuleSetsListComplete retrieves all of the results into a single object
func (c WebApplicationFirewallManagedRuleSetsClient) ManagedRuleSetsListComplete(ctx context.Context, id commonids.SubscriptionId) (ManagedRuleSetsListCompleteResult, error) {
return c.ManagedRuleSetsListCompleteMatchingPredicate(ctx, id, ManagedRuleSetDefinitionOperationPredicate{})
}

// ManagedRuleSetsListCompleteMatchingPredicate retrieves all of the results and then applied the predicate
func (c WebApplicationFirewallManagedRuleSetsClient) ManagedRuleSetsListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ManagedRuleSetDefinitionOperationPredicate) (resp ManagedRuleSetsListCompleteResult, err error) {
items := make([]ManagedRuleSetDefinition, 0)

page, err := c.ManagedRuleSetsList(ctx, id)
if err != nil {
err = fmt.Errorf("loading the initial page: %+v", err)
return
}
if page.Model != nil {
for _, v := range *page.Model {
if predicate.Matches(v) {
items = append(items, v)
}
}
}

for page.HasMore() {
page, err = page.LoadMore(ctx)
if err != nil {
err = fmt.Errorf("loading the next page: %+v", err)
return
}

if page.Model != nil {
for _, v := range *page.Model {
if predicate.Matches(v) {
items = append(items, v)
}
}
}
}

out := ManagedRuleSetsListCompleteResult{
Items: items,
}
return out, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package webapplicationfirewallmanagedrulesets

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.

type ManagedRuleDefinition struct {
DefaultAction *ActionType `json:"defaultAction,omitempty"`
DefaultState *ManagedRuleEnabledState `json:"defaultState,omitempty"`
Description *string `json:"description,omitempty"`
RuleId *string `json:"ruleId,omitempty"`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package webapplicationfirewallmanagedrulesets

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.

type ManagedRuleGroupDefinition struct {
Description *string `json:"description,omitempty"`
RuleGroupName *string `json:"ruleGroupName,omitempty"`
Rules *[]ManagedRuleDefinition `json:"rules,omitempty"`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package webapplicationfirewallmanagedrulesets

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.

type ManagedRuleSetDefinition struct {
Id *string `json:"id,omitempty"`
Location *string `json:"location,omitempty"`
Name *string `json:"name,omitempty"`
Properties *ManagedRuleSetDefinitionProperties `json:"properties,omitempty"`
Tags *map[string]string `json:"tags,omitempty"`
Type *string `json:"type,omitempty"`
}
Loading
Loading