# Silences ## List Silences `client.Alerting.Silences.List(ctx, query) (*SinglePage[SilenceListResponse], error)` **get** `/accounts/{account_id}/alerting/v3/silences` Gets a list of silences for an account. ### Parameters - `query SilenceListParams` - `AccountID param.Field[string]` The account id ### Returns - `type SilenceListResponse struct{…}` - `ID string` Silence ID - `CreatedAt string` When the silence was created. - `EndTime string` When the silence ends. - `PolicyID string` The unique identifier of a notification policy - `StartTime string` When the silence starts. - `UpdatedAt string` When the silence was modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/alerting" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.Alerting.Silences.List(context.TODO(), alerting.SilenceListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result": [ { "id": "f878e90c23f44126ae3cfc399f646977", "created_at": "2022-01-01T00:00:00Z", "end_time": "2022-01-01T00:00:00Z", "policy_id": "0da2b59ef118439d8097bdfb215203c9", "start_time": "2022-01-01T00:00:00Z", "updated_at": "2022-01-01T00:00:00Z" } ] } ``` ## Get Silence `client.Alerting.Silences.Get(ctx, silenceID, query) (*SilenceGetResponse, error)` **get** `/accounts/{account_id}/alerting/v3/silences/{silence_id}` Gets a specific silence for an account. ### Parameters - `silenceID string` Silence ID - `query SilenceGetParams` - `AccountID param.Field[string]` The account id ### Returns - `type SilenceGetResponse struct{…}` - `ID string` Silence ID - `CreatedAt string` When the silence was created. - `EndTime string` When the silence ends. - `PolicyID string` The unique identifier of a notification policy - `StartTime string` When the silence starts. - `UpdatedAt string` When the silence was modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/alerting" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) silence, err := client.Alerting.Silences.Get( context.TODO(), "f878e90c23f44126ae3cfc399f646977", alerting.SilenceGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", silence.ID) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result": { "id": "f878e90c23f44126ae3cfc399f646977", "created_at": "2022-01-01T00:00:00Z", "end_time": "2022-01-01T00:00:00Z", "policy_id": "0da2b59ef118439d8097bdfb215203c9", "start_time": "2022-01-01T00:00:00Z", "updated_at": "2022-01-01T00:00:00Z" } } ``` ## Create Silences `client.Alerting.Silences.New(ctx, params) (*SilenceNewResponse, error)` **post** `/accounts/{account_id}/alerting/v3/silences` Creates a new silence for an account. ### Parameters - `params SilenceNewParams` - `AccountID param.Field[string]` Path param: The account id - `Body param.Field[[]SilenceNewParamsBody]` Body param - `EndTime string` When the silence ends. - `PolicyID string` The unique identifier of a notification policy - `StartTime string` When the silence starts. ### Returns - `type SilenceNewResponse struct{…}` - `Errors []SilenceNewResponseError` - `Message string` - `Code int64` - `Messages []SilenceNewResponseMessage` - `Message string` - `Code int64` - `Success SilenceNewResponseSuccess` Whether the API call was successful - `const SilenceNewResponseSuccessTrue SilenceNewResponseSuccess = true` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/alerting" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) silence, err := client.Alerting.Silences.New(context.TODO(), alerting.SilenceNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Body: []alerting.SilenceNewParamsBody{alerting.SilenceNewParamsBody{ }}, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", silence.Errors) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true } ``` ## Update Silences `client.Alerting.Silences.Update(ctx, params) (*SinglePage[SilenceUpdateResponse], error)` **put** `/accounts/{account_id}/alerting/v3/silences` Updates existing silences for an account. ### Parameters - `params SilenceUpdateParams` - `AccountID param.Field[string]` Path param: The account id - `Body param.Field[[]SilenceUpdateParamsBody]` Body param - `ID string` Silence ID - `EndTime string` When the silence ends. - `StartTime string` When the silence starts. ### Returns - `type SilenceUpdateResponse struct{…}` - `ID string` Silence ID - `CreatedAt string` When the silence was created. - `EndTime string` When the silence ends. - `PolicyID string` The unique identifier of a notification policy - `StartTime string` When the silence starts. - `UpdatedAt string` When the silence was modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/alerting" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.Alerting.Silences.Update(context.TODO(), alerting.SilenceUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Body: []alerting.SilenceUpdateParamsBody{alerting.SilenceUpdateParamsBody{ }}, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true, "result": [ { "id": "f878e90c23f44126ae3cfc399f646977", "created_at": "2022-01-01T00:00:00Z", "end_time": "2022-01-01T00:00:00Z", "policy_id": "0da2b59ef118439d8097bdfb215203c9", "start_time": "2022-01-01T00:00:00Z", "updated_at": "2022-01-01T00:00:00Z" } ] } ``` ## Delete Silence `client.Alerting.Silences.Delete(ctx, silenceID, body) (*SilenceDeleteResponse, error)` **delete** `/accounts/{account_id}/alerting/v3/silences/{silence_id}` Deletes an existing silence for an account. ### Parameters - `silenceID string` Silence ID - `body SilenceDeleteParams` - `AccountID param.Field[string]` The account id ### Returns - `type SilenceDeleteResponse struct{…}` - `Errors []SilenceDeleteResponseError` - `Message string` - `Code int64` - `Messages []SilenceDeleteResponseMessage` - `Message string` - `Code int64` - `Success SilenceDeleteResponseSuccess` Whether the API call was successful - `const SilenceDeleteResponseSuccessTrue SilenceDeleteResponseSuccess = true` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/alerting" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) silence, err := client.Alerting.Silences.Delete( context.TODO(), "f878e90c23f44126ae3cfc399f646977", alerting.SilenceDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", silence.Errors) } ``` #### Response ```json { "errors": [ { "message": "message", "code": 1000 } ], "messages": [ { "message": "message", "code": 1000 } ], "success": true } ```