// Code generated by Fern. DO NOT EDIT.

package blocks

import (
	context "context"
	management "github.com/auth0/go-auth0/v2/management"
	core "github.com/auth0/go-auth0/v2/management/core"
	internal "github.com/auth0/go-auth0/v2/management/internal"
	option "github.com/auth0/go-auth0/v2/management/option"
)

type Client struct {
	WithRawResponse *RawClient

	options *core.RequestOptions
	baseURL string
	caller  *internal.Caller
}

func NewClient(options *core.RequestOptions) *Client {
	return &Client{
		WithRawResponse: NewRawClient(options),
		options:         options,
		baseURL:         options.BaseURL,
		caller: internal.NewCaller(
			&internal.CallerParams{
				Client:      options.HTTPClient,
				MaxAttempts: options.MaxAttempts,
			},
		),
	}
}

// Check if the given IP address is blocked via the <a href="https://auth0.com/docs/configure/attack-protection/suspicious-ip-throttling">Suspicious IP Throttling</a> due to multiple suspicious attempts.
func (c *Client) CheckIP(
	ctx context.Context,
	// IP address to check.
	id management.AnomalyIPFormat,
	opts ...option.RequestOption,
) error {
	_, err := c.WithRawResponse.CheckIP(
		ctx,
		id,
		opts...,
	)
	if err != nil {
		return err
	}
	return nil
}

// Remove a block imposed by <a href="https://auth0.com/docs/configure/attack-protection/suspicious-ip-throttling">Suspicious IP Throttling</a> for the given IP address.
func (c *Client) UnblockIP(
	ctx context.Context,
	// IP address to unblock.
	id management.AnomalyIPFormat,
	opts ...option.RequestOption,
) error {
	_, err := c.WithRawResponse.UnblockIP(
		ctx,
		id,
		opts...,
	)
	if err != nil {
		return err
	}
	return nil
}
