|
| 1 | +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +package cloudforce_one |
| 4 | + |
| 5 | +import ( |
| 6 | + "context" |
| 7 | + "errors" |
| 8 | + "fmt" |
| 9 | + "net/http" |
| 10 | + |
| 11 | + "github.com/cloudflare/cloudflare-go/v4/internal/apijson" |
| 12 | + "github.com/cloudflare/cloudflare-go/v4/internal/param" |
| 13 | + "github.com/cloudflare/cloudflare-go/v4/internal/requestconfig" |
| 14 | + "github.com/cloudflare/cloudflare-go/v4/option" |
| 15 | +) |
| 16 | + |
| 17 | +// ThreatEventInsightService contains methods and other services that help with |
| 18 | +// interacting with the cloudflare API. |
| 19 | +// |
| 20 | +// Note, unlike clients, this service does not read variables from the environment |
| 21 | +// automatically. You should not instantiate this service directly, and instead use |
| 22 | +// the [NewThreatEventInsightService] method instead. |
| 23 | +type ThreatEventInsightService struct { |
| 24 | + Options []option.RequestOption |
| 25 | +} |
| 26 | + |
| 27 | +// NewThreatEventInsightService generates a new service that applies the given |
| 28 | +// options to each request. These options are applied after the parent client's |
| 29 | +// options (if there is one), and before any request-specific options. |
| 30 | +func NewThreatEventInsightService(opts ...option.RequestOption) (r *ThreatEventInsightService) { |
| 31 | + r = &ThreatEventInsightService{} |
| 32 | + r.Options = opts |
| 33 | + return |
| 34 | +} |
| 35 | + |
| 36 | +// Updates an event insight |
| 37 | +func (r *ThreatEventInsightService) Update(ctx context.Context, accountID float64, eventID string, insightID string, body ThreatEventInsightUpdateParams, opts ...option.RequestOption) (res *ThreatEventInsightUpdateResponse, err error) { |
| 38 | + var env ThreatEventInsightUpdateResponseEnvelope |
| 39 | + opts = append(r.Options[:], opts...) |
| 40 | + if eventID == "" { |
| 41 | + err = errors.New("missing required eventId parameter") |
| 42 | + return |
| 43 | + } |
| 44 | + if insightID == "" { |
| 45 | + err = errors.New("missing required insightId parameter") |
| 46 | + return |
| 47 | + } |
| 48 | + path := fmt.Sprintf("accounts/%v/cloudforce-one/events/%s/insight/%s", accountID, eventID, insightID) |
| 49 | + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) |
| 50 | + if err != nil { |
| 51 | + return |
| 52 | + } |
| 53 | + res = &env.Result |
| 54 | + return |
| 55 | +} |
| 56 | + |
| 57 | +// Deletes an event insight |
| 58 | +func (r *ThreatEventInsightService) Delete(ctx context.Context, accountID float64, eventID string, insightID string, opts ...option.RequestOption) (res *ThreatEventInsightDeleteResponse, err error) { |
| 59 | + var env ThreatEventInsightDeleteResponseEnvelope |
| 60 | + opts = append(r.Options[:], opts...) |
| 61 | + if eventID == "" { |
| 62 | + err = errors.New("missing required eventId parameter") |
| 63 | + return |
| 64 | + } |
| 65 | + if insightID == "" { |
| 66 | + err = errors.New("missing required insightId parameter") |
| 67 | + return |
| 68 | + } |
| 69 | + path := fmt.Sprintf("accounts/%v/cloudforce-one/events/%s/insight/%s", accountID, eventID, insightID) |
| 70 | + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) |
| 71 | + if err != nil { |
| 72 | + return |
| 73 | + } |
| 74 | + res = &env.Result |
| 75 | + return |
| 76 | +} |
| 77 | + |
| 78 | +// Adds an insight to an event |
| 79 | +func (r *ThreatEventInsightService) Creat(ctx context.Context, accountID float64, eventID string, body ThreatEventInsightCreatParams, opts ...option.RequestOption) (res *ThreatEventInsightCreatResponse, err error) { |
| 80 | + var env ThreatEventInsightCreatResponseEnvelope |
| 81 | + opts = append(r.Options[:], opts...) |
| 82 | + if eventID == "" { |
| 83 | + err = errors.New("missing required eventId parameter") |
| 84 | + return |
| 85 | + } |
| 86 | + path := fmt.Sprintf("accounts/%v/cloudforce-one/events/%s/insight/create", accountID, eventID) |
| 87 | + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) |
| 88 | + if err != nil { |
| 89 | + return |
| 90 | + } |
| 91 | + res = &env.Result |
| 92 | + return |
| 93 | +} |
| 94 | + |
| 95 | +// Reads an event insight |
| 96 | +func (r *ThreatEventInsightService) Get(ctx context.Context, accountID float64, eventID string, insightID string, opts ...option.RequestOption) (res *ThreatEventInsightGetResponse, err error) { |
| 97 | + var env ThreatEventInsightGetResponseEnvelope |
| 98 | + opts = append(r.Options[:], opts...) |
| 99 | + if eventID == "" { |
| 100 | + err = errors.New("missing required eventId parameter") |
| 101 | + return |
| 102 | + } |
| 103 | + if insightID == "" { |
| 104 | + err = errors.New("missing required insightId parameter") |
| 105 | + return |
| 106 | + } |
| 107 | + path := fmt.Sprintf("accounts/%v/cloudforce-one/events/%s/insight/%s", accountID, eventID, insightID) |
| 108 | + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) |
| 109 | + if err != nil { |
| 110 | + return |
| 111 | + } |
| 112 | + res = &env.Result |
| 113 | + return |
| 114 | +} |
| 115 | + |
| 116 | +type ThreatEventInsightUpdateResponse struct { |
| 117 | + Content string `json:"content,required"` |
| 118 | + UUID string `json:"uuid,required"` |
| 119 | + JSON threatEventInsightUpdateResponseJSON `json:"-"` |
| 120 | +} |
| 121 | + |
| 122 | +// threatEventInsightUpdateResponseJSON contains the JSON metadata for the struct |
| 123 | +// [ThreatEventInsightUpdateResponse] |
| 124 | +type threatEventInsightUpdateResponseJSON struct { |
| 125 | + Content apijson.Field |
| 126 | + UUID apijson.Field |
| 127 | + raw string |
| 128 | + ExtraFields map[string]apijson.Field |
| 129 | +} |
| 130 | + |
| 131 | +func (r *ThreatEventInsightUpdateResponse) UnmarshalJSON(data []byte) (err error) { |
| 132 | + return apijson.UnmarshalRoot(data, r) |
| 133 | +} |
| 134 | + |
| 135 | +func (r threatEventInsightUpdateResponseJSON) RawJSON() string { |
| 136 | + return r.raw |
| 137 | +} |
| 138 | + |
| 139 | +type ThreatEventInsightDeleteResponse struct { |
| 140 | + Success bool `json:"success,required"` |
| 141 | + JSON threatEventInsightDeleteResponseJSON `json:"-"` |
| 142 | +} |
| 143 | + |
| 144 | +// threatEventInsightDeleteResponseJSON contains the JSON metadata for the struct |
| 145 | +// [ThreatEventInsightDeleteResponse] |
| 146 | +type threatEventInsightDeleteResponseJSON struct { |
| 147 | + Success apijson.Field |
| 148 | + raw string |
| 149 | + ExtraFields map[string]apijson.Field |
| 150 | +} |
| 151 | + |
| 152 | +func (r *ThreatEventInsightDeleteResponse) UnmarshalJSON(data []byte) (err error) { |
| 153 | + return apijson.UnmarshalRoot(data, r) |
| 154 | +} |
| 155 | + |
| 156 | +func (r threatEventInsightDeleteResponseJSON) RawJSON() string { |
| 157 | + return r.raw |
| 158 | +} |
| 159 | + |
| 160 | +type ThreatEventInsightCreatResponse struct { |
| 161 | + Content string `json:"content,required"` |
| 162 | + UUID string `json:"uuid,required"` |
| 163 | + JSON threatEventInsightCreatResponseJSON `json:"-"` |
| 164 | +} |
| 165 | + |
| 166 | +// threatEventInsightCreatResponseJSON contains the JSON metadata for the struct |
| 167 | +// [ThreatEventInsightCreatResponse] |
| 168 | +type threatEventInsightCreatResponseJSON struct { |
| 169 | + Content apijson.Field |
| 170 | + UUID apijson.Field |
| 171 | + raw string |
| 172 | + ExtraFields map[string]apijson.Field |
| 173 | +} |
| 174 | + |
| 175 | +func (r *ThreatEventInsightCreatResponse) UnmarshalJSON(data []byte) (err error) { |
| 176 | + return apijson.UnmarshalRoot(data, r) |
| 177 | +} |
| 178 | + |
| 179 | +func (r threatEventInsightCreatResponseJSON) RawJSON() string { |
| 180 | + return r.raw |
| 181 | +} |
| 182 | + |
| 183 | +type ThreatEventInsightGetResponse struct { |
| 184 | + Content string `json:"content,required"` |
| 185 | + UUID string `json:"uuid,required"` |
| 186 | + JSON threatEventInsightGetResponseJSON `json:"-"` |
| 187 | +} |
| 188 | + |
| 189 | +// threatEventInsightGetResponseJSON contains the JSON metadata for the struct |
| 190 | +// [ThreatEventInsightGetResponse] |
| 191 | +type threatEventInsightGetResponseJSON struct { |
| 192 | + Content apijson.Field |
| 193 | + UUID apijson.Field |
| 194 | + raw string |
| 195 | + ExtraFields map[string]apijson.Field |
| 196 | +} |
| 197 | + |
| 198 | +func (r *ThreatEventInsightGetResponse) UnmarshalJSON(data []byte) (err error) { |
| 199 | + return apijson.UnmarshalRoot(data, r) |
| 200 | +} |
| 201 | + |
| 202 | +func (r threatEventInsightGetResponseJSON) RawJSON() string { |
| 203 | + return r.raw |
| 204 | +} |
| 205 | + |
| 206 | +type ThreatEventInsightUpdateParams struct { |
| 207 | + Content param.Field[string] `json:"content,required"` |
| 208 | +} |
| 209 | + |
| 210 | +func (r ThreatEventInsightUpdateParams) MarshalJSON() (data []byte, err error) { |
| 211 | + return apijson.MarshalRoot(r) |
| 212 | +} |
| 213 | + |
| 214 | +type ThreatEventInsightUpdateResponseEnvelope struct { |
| 215 | + Result ThreatEventInsightUpdateResponse `json:"result,required"` |
| 216 | + Success bool `json:"success,required"` |
| 217 | + JSON threatEventInsightUpdateResponseEnvelopeJSON `json:"-"` |
| 218 | +} |
| 219 | + |
| 220 | +// threatEventInsightUpdateResponseEnvelopeJSON contains the JSON metadata for the |
| 221 | +// struct [ThreatEventInsightUpdateResponseEnvelope] |
| 222 | +type threatEventInsightUpdateResponseEnvelopeJSON struct { |
| 223 | + Result apijson.Field |
| 224 | + Success apijson.Field |
| 225 | + raw string |
| 226 | + ExtraFields map[string]apijson.Field |
| 227 | +} |
| 228 | + |
| 229 | +func (r *ThreatEventInsightUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { |
| 230 | + return apijson.UnmarshalRoot(data, r) |
| 231 | +} |
| 232 | + |
| 233 | +func (r threatEventInsightUpdateResponseEnvelopeJSON) RawJSON() string { |
| 234 | + return r.raw |
| 235 | +} |
| 236 | + |
| 237 | +type ThreatEventInsightDeleteResponseEnvelope struct { |
| 238 | + Result ThreatEventInsightDeleteResponse `json:"result,required"` |
| 239 | + Success bool `json:"success,required"` |
| 240 | + JSON threatEventInsightDeleteResponseEnvelopeJSON `json:"-"` |
| 241 | +} |
| 242 | + |
| 243 | +// threatEventInsightDeleteResponseEnvelopeJSON contains the JSON metadata for the |
| 244 | +// struct [ThreatEventInsightDeleteResponseEnvelope] |
| 245 | +type threatEventInsightDeleteResponseEnvelopeJSON struct { |
| 246 | + Result apijson.Field |
| 247 | + Success apijson.Field |
| 248 | + raw string |
| 249 | + ExtraFields map[string]apijson.Field |
| 250 | +} |
| 251 | + |
| 252 | +func (r *ThreatEventInsightDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { |
| 253 | + return apijson.UnmarshalRoot(data, r) |
| 254 | +} |
| 255 | + |
| 256 | +func (r threatEventInsightDeleteResponseEnvelopeJSON) RawJSON() string { |
| 257 | + return r.raw |
| 258 | +} |
| 259 | + |
| 260 | +type ThreatEventInsightCreatParams struct { |
| 261 | + Content param.Field[string] `json:"content,required"` |
| 262 | +} |
| 263 | + |
| 264 | +func (r ThreatEventInsightCreatParams) MarshalJSON() (data []byte, err error) { |
| 265 | + return apijson.MarshalRoot(r) |
| 266 | +} |
| 267 | + |
| 268 | +type ThreatEventInsightCreatResponseEnvelope struct { |
| 269 | + Result ThreatEventInsightCreatResponse `json:"result,required"` |
| 270 | + Success bool `json:"success,required"` |
| 271 | + JSON threatEventInsightCreatResponseEnvelopeJSON `json:"-"` |
| 272 | +} |
| 273 | + |
| 274 | +// threatEventInsightCreatResponseEnvelopeJSON contains the JSON metadata for the |
| 275 | +// struct [ThreatEventInsightCreatResponseEnvelope] |
| 276 | +type threatEventInsightCreatResponseEnvelopeJSON struct { |
| 277 | + Result apijson.Field |
| 278 | + Success apijson.Field |
| 279 | + raw string |
| 280 | + ExtraFields map[string]apijson.Field |
| 281 | +} |
| 282 | + |
| 283 | +func (r *ThreatEventInsightCreatResponseEnvelope) UnmarshalJSON(data []byte) (err error) { |
| 284 | + return apijson.UnmarshalRoot(data, r) |
| 285 | +} |
| 286 | + |
| 287 | +func (r threatEventInsightCreatResponseEnvelopeJSON) RawJSON() string { |
| 288 | + return r.raw |
| 289 | +} |
| 290 | + |
| 291 | +type ThreatEventInsightGetResponseEnvelope struct { |
| 292 | + Result ThreatEventInsightGetResponse `json:"result,required"` |
| 293 | + Success bool `json:"success,required"` |
| 294 | + JSON threatEventInsightGetResponseEnvelopeJSON `json:"-"` |
| 295 | +} |
| 296 | + |
| 297 | +// threatEventInsightGetResponseEnvelopeJSON contains the JSON metadata for the |
| 298 | +// struct [ThreatEventInsightGetResponseEnvelope] |
| 299 | +type threatEventInsightGetResponseEnvelopeJSON struct { |
| 300 | + Result apijson.Field |
| 301 | + Success apijson.Field |
| 302 | + raw string |
| 303 | + ExtraFields map[string]apijson.Field |
| 304 | +} |
| 305 | + |
| 306 | +func (r *ThreatEventInsightGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { |
| 307 | + return apijson.UnmarshalRoot(data, r) |
| 308 | +} |
| 309 | + |
| 310 | +func (r threatEventInsightGetResponseEnvelopeJSON) RawJSON() string { |
| 311 | + return r.raw |
| 312 | +} |
0 commit comments