# EscalationPolicies

## Overview

### Available Operations

* [GetByTeam](#getbyteam) - Get Escalation Policy By team
* [Create](#create) - Create Escalation Policies
* [Remove](#remove) - Remove Escalation Policy
* [GetByID](#getbyid) - Get Escalation Policy By ID
* [Update](#update) - Update Escalation Policy

## GetByTeam

Returns all escalation policy details of the given `ownerID` (teamId) in the request param. Requires `access_token` as a `Bearer {{token}}` in the `Authorization` header with `read` scope.

### Example Usage

```go
package main

import(
	"context"
	"os"
	squadcastsdk "github.com/solarwinds/squadcast-sdk-go"
	"log"
)

func main() {
    ctx := context.Background()

    s := squadcastsdk.New(
        squadcastsdk.WithSecurity(os.Getenv("SQUADCASTSDK_REFRESH_TOKEN_AUTH")),
    )

    res, err := s.EscalationPolicies.GetByTeam(ctx, "<id>", nil, nil)
    if err != nil {
        log.Fatal(err)
    }
    if res.Object != nil {
        for {
            // handle items

            res, err = res.Next()

            if err != nil {
                // handle error
            }

            if res == nil {
                break
            }
        }
    }
}
```

### Parameters

| Parameter    | Type                                                             | Required             | Description                                                                                                       |
| ------------ | ---------------------------------------------------------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------- |
| `ctx`        | [context.Context](https://pkg.go.dev/context#Context)            | :heavy\_check\_mark: | The context to use for the request.                                                                               |
| `ownerID`    | `string`                                                         | :heavy\_check\_mark: | here owner\_id represents team\_id, if team\_id is not provided, it will return escalation policies of all teams. |
| `pageNumber` | `*int64`                                                         | :heavy\_minus\_sign: | N/A                                                                                                               |
| `pageSize`   | `*int64`                                                         | :heavy\_minus\_sign: | N/A                                                                                                               |
| `opts`       | \[][operations.Option](/go-sdk/docs/models/operations/option.md) | :heavy\_minus\_sign: | The options for this request.                                                                                     |

### Response

[**\*operations.EscalationPoliciesGetEscalationPolicyByTeamResponse**](/go-sdk/docs/models/operations/escalationpoliciesgetescalationpolicybyteamresponse.md)**, error**

### Errors

| Error Type                         | Status Code | Content Type     |
| ---------------------------------- | ----------- | ---------------- |
| apierrors.BadRequestError          | 400         | application/json |
| apierrors.UnauthorizedError        | 401         | application/json |
| apierrors.PaymentRequiredError     | 402         | application/json |
| apierrors.ForbiddenError           | 403         | application/json |
| apierrors.NotFoundError            | 404         | application/json |
| apierrors.ConflictError            | 409         | application/json |
| apierrors.UnprocessableEntityError | 422         | application/json |
| apierrors.InternalServerError      | 500         | application/json |
| apierrors.BadGatewayError          | 502         | application/json |
| apierrors.ServiceUnavailableError  | 503         | application/json |
| apierrors.GatewayTimeoutError      | 504         | application/json |
| apierrors.APIError                 | 4XX, 5XX    | \*/\*            |

## Create

Add escalation policy to the organization. Returns the escalation policy object in response. Requires `access_token` as a `Bearer {{token}}` in the `Authorization` header with `user-write` scope.

### Example Usage

```go
package main

import(
	"context"
	"os"
	squadcastsdk "github.com/solarwinds/squadcast-sdk-go"
	"github.com/solarwinds/squadcast-sdk-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := squadcastsdk.New(
        squadcastsdk.WithSecurity(os.Getenv("SQUADCASTSDK_REFRESH_TOKEN_AUTH")),
    )

    res, err := s.EscalationPolicies.Create(ctx, components.V3EscalationPoliciesCreateEscalationPolicyRequest{
        OwnerID: "<id>",
        Name: "<value>",
        Description: "properly aw gerbil address co-producer guzzle delight difficult",
        Repetition: 549305,
        RepeatAfter: 226311,
        Rules: []components.V3EscalationPoliciesEscalationPolicyRule{
            components.V3EscalationPoliciesEscalationPolicyRule{
                EscalationTime: 646220,
                Via: []string{
                    "<value 1>",
                    "<value 2>",
                },
                RoundrobinEnabled: true,
                RoundrobinNextIndex: 685302,
                Entities: []components.V3EscalationPoliciesEscalationEntity{},
                EscalateWithinRoundrobin: true,
                Repetition: 149319,
                RepeatAfter: 619552,
            },
        },
        EnableIncidentReminders: false,
        IncidentReminderRules: []components.V3EscalationPoliciesIncidentReminderRule{},
        EnableIncidentRetrigger: false,
        RetriggerAfter: 660610,
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Object != nil {
        // handle response
    }
}
```

### Parameters

| Parameter | Type                                                                                                                                                | Required             | Description                                |
| --------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | ------------------------------------------ |
| `ctx`     | [context.Context](https://pkg.go.dev/context#Context)                                                                                               | :heavy\_check\_mark: | The context to use for the request.        |
| `request` | [components.V3EscalationPoliciesCreateEscalationPolicyRequest](/go-sdk/docs/models/components/v3escalationpoliciescreateescalationpolicyrequest.md) | :heavy\_check\_mark: | The request object to use for the request. |
| `opts`    | \[][operations.Option](/go-sdk/docs/models/operations/option.md)                                                                                    | :heavy\_minus\_sign: | The options for this request.              |

### Response

[**\*operations.EscalationPoliciesCreateEscalationPoliciesResponse**](/go-sdk/docs/models/operations/escalationpoliciescreateescalationpoliciesresponse.md)**, error**

### Errors

| Error Type                         | Status Code | Content Type     |
| ---------------------------------- | ----------- | ---------------- |
| apierrors.BadRequestError          | 400         | application/json |
| apierrors.UnauthorizedError        | 401         | application/json |
| apierrors.PaymentRequiredError     | 402         | application/json |
| apierrors.ForbiddenError           | 403         | application/json |
| apierrors.NotFoundError            | 404         | application/json |
| apierrors.ConflictError            | 409         | application/json |
| apierrors.UnprocessableEntityError | 422         | application/json |
| apierrors.InternalServerError      | 500         | application/json |
| apierrors.BadGatewayError          | 502         | application/json |
| apierrors.ServiceUnavailableError  | 503         | application/json |
| apierrors.GatewayTimeoutError      | 504         | application/json |
| apierrors.APIError                 | 4XX, 5XX    | \*/\*            |

## Remove

Remove escalation policy from the organization. Upon success, the escalation policy will be removed from the organization. Requires `access_token` as a `Bearer {{token}}` in the `Authorization` header with `user-write` scope.

### Example Usage

```go
package main

import(
	"context"
	"os"
	squadcastsdk "github.com/solarwinds/squadcast-sdk-go"
	"log"
)

func main() {
    ctx := context.Background()

    s := squadcastsdk.New(
        squadcastsdk.WithSecurity(os.Getenv("SQUADCASTSDK_REFRESH_TOKEN_AUTH")),
    )

    res, err := s.EscalationPolicies.Remove(ctx, "<id>")
    if err != nil {
        log.Fatal(err)
    }
    if res.Body != nil {
        // handle response
    }
}
```

### Parameters

| Parameter            | Type                                                             | Required             | Description                         |
| -------------------- | ---------------------------------------------------------------- | -------------------- | ----------------------------------- |
| `ctx`                | [context.Context](https://pkg.go.dev/context#Context)            | :heavy\_check\_mark: | The context to use for the request. |
| `escalationPolicyID` | `string`                                                         | :heavy\_check\_mark: | (Required) escalation policy ID     |
| `opts`               | \[][operations.Option](/go-sdk/docs/models/operations/option.md) | :heavy\_minus\_sign: | The options for this request.       |

### Response

[**\*operations.EscalationPoliciesRemoveEscalationPolicyResponse**](/go-sdk/docs/models/operations/escalationpoliciesremoveescalationpolicyresponse.md)**, error**

### Errors

| Error Type                         | Status Code | Content Type     |
| ---------------------------------- | ----------- | ---------------- |
| apierrors.BadRequestError          | 400         | application/json |
| apierrors.UnauthorizedError        | 401         | application/json |
| apierrors.PaymentRequiredError     | 402         | application/json |
| apierrors.ForbiddenError           | 403         | application/json |
| apierrors.NotFoundError            | 404         | application/json |
| apierrors.ConflictError            | 409         | application/json |
| apierrors.UnprocessableEntityError | 422         | application/json |
| apierrors.InternalServerError      | 500         | application/json |
| apierrors.BadGatewayError          | 502         | application/json |
| apierrors.ServiceUnavailableError  | 503         | application/json |
| apierrors.GatewayTimeoutError      | 504         | application/json |
| apierrors.APIError                 | 4XX, 5XX    | \*/\*            |

## GetByID

Returns an escalation policy details of the given `escalationPolicyID` in the request param. Requires `access_token` as a `Bearer {{token}}` in the `Authorization` header with `read` scope.

### Example Usage

```go
package main

import(
	"context"
	"os"
	squadcastsdk "github.com/solarwinds/squadcast-sdk-go"
	"log"
)

func main() {
    ctx := context.Background()

    s := squadcastsdk.New(
        squadcastsdk.WithSecurity(os.Getenv("SQUADCASTSDK_REFRESH_TOKEN_AUTH")),
    )

    res, err := s.EscalationPolicies.GetByID(ctx, "<id>")
    if err != nil {
        log.Fatal(err)
    }
    if res.Object != nil {
        // handle response
    }
}
```

### Parameters

| Parameter            | Type                                                             | Required             | Description                         |
| -------------------- | ---------------------------------------------------------------- | -------------------- | ----------------------------------- |
| `ctx`                | [context.Context](https://pkg.go.dev/context#Context)            | :heavy\_check\_mark: | The context to use for the request. |
| `escalationPolicyID` | `string`                                                         | :heavy\_check\_mark: | (Required) escalation policy ID     |
| `opts`               | \[][operations.Option](/go-sdk/docs/models/operations/option.md) | :heavy\_minus\_sign: | The options for this request.       |

### Response

[**\*operations.EscalationPoliciesGetEscalationPolicyByIDResponse**](/go-sdk/docs/models/operations/escalationpoliciesgetescalationpolicybyidresponse.md)**, error**

### Errors

| Error Type                         | Status Code | Content Type     |
| ---------------------------------- | ----------- | ---------------- |
| apierrors.BadRequestError          | 400         | application/json |
| apierrors.UnauthorizedError        | 401         | application/json |
| apierrors.PaymentRequiredError     | 402         | application/json |
| apierrors.ForbiddenError           | 403         | application/json |
| apierrors.NotFoundError            | 404         | application/json |
| apierrors.ConflictError            | 409         | application/json |
| apierrors.UnprocessableEntityError | 422         | application/json |
| apierrors.InternalServerError      | 500         | application/json |
| apierrors.BadGatewayError          | 502         | application/json |
| apierrors.ServiceUnavailableError  | 503         | application/json |
| apierrors.GatewayTimeoutError      | 504         | application/json |
| apierrors.APIError                 | 4XX, 5XX    | \*/\*            |

## Update

Update organization escalation policy details. Requires `access_token` as a `Bearer {{token}}` in the `Authorization` header with `user-write` scope.

### Example Usage

```go
package main

import(
	"context"
	"os"
	squadcastsdk "github.com/solarwinds/squadcast-sdk-go"
	"log"
)

func main() {
    ctx := context.Background()

    s := squadcastsdk.New(
        squadcastsdk.WithSecurity(os.Getenv("SQUADCASTSDK_REFRESH_TOKEN_AUTH")),
    )

    example, fileErr := os.Open("example.file")
    if fileErr != nil {
        panic(fileErr)
    }

    res, err := s.EscalationPolicies.Update(ctx, "<id>", example)
    if err != nil {
        log.Fatal(err)
    }
    if res.Object != nil {
        // handle response
    }
}
```

### Parameters

| Parameter                                           | Type                                                             | Required             | Description                         |
| --------------------------------------------------- | ---------------------------------------------------------------- | -------------------- | ----------------------------------- |
| `ctx`                                               | [context.Context](https://pkg.go.dev/context#Context)            | :heavy\_check\_mark: | The context to use for the request. |
| `escalationPolicyID`                                | `string`                                                         | :heavy\_check\_mark: | (Required) escalation policy ID     |
| `v3EscalationPoliciesUpdateEscalationPolicyRequest` | `any`                                                            | :heavy\_check\_mark: | N/A                                 |
| `opts`                                              | \[][operations.Option](/go-sdk/docs/models/operations/option.md) | :heavy\_minus\_sign: | The options for this request.       |

### Response

[**\*operations.EscalationPoliciesUpdateEscalationPolicyResponse**](/go-sdk/docs/models/operations/escalationpoliciesupdateescalationpolicyresponse.md)**, error**

### Errors

| Error Type                         | Status Code | Content Type     |
| ---------------------------------- | ----------- | ---------------- |
| apierrors.BadRequestError          | 400         | application/json |
| apierrors.UnauthorizedError        | 401         | application/json |
| apierrors.PaymentRequiredError     | 402         | application/json |
| apierrors.ForbiddenError           | 403         | application/json |
| apierrors.NotFoundError            | 404         | application/json |
| apierrors.ConflictError            | 409         | application/json |
| apierrors.UnprocessableEntityError | 422         | application/json |
| apierrors.InternalServerError      | 500         | application/json |
| apierrors.BadGatewayError          | 502         | application/json |
| apierrors.ServiceUnavailableError  | 503         | application/json |
| apierrors.GatewayTimeoutError      | 504         | application/json |
| apierrors.APIError                 | 4XX, 5XX    | \*/\*            |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.incidents.cloud.solarwinds.com/go-sdk/docs/sdks/escalationpolicies.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
