// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.

package provider

import (
	"context"
	"fmt"
	speakeasy_int64planmodifier "github.com/airbytehq/terraform-provider-airbyte/internal/planmodifiers/int64planmodifier"
	speakeasy_listplanmodifier "github.com/airbytehq/terraform-provider-airbyte/internal/planmodifiers/listplanmodifier"
	speakeasy_objectplanmodifier "github.com/airbytehq/terraform-provider-airbyte/internal/planmodifiers/objectplanmodifier"
	speakeasy_stringplanmodifier "github.com/airbytehq/terraform-provider-airbyte/internal/planmodifiers/stringplanmodifier"
	tfTypes "github.com/airbytehq/terraform-provider-airbyte/internal/provider/types"
	"github.com/airbytehq/terraform-provider-airbyte/internal/sdk"
	"github.com/airbytehq/terraform-provider-airbyte/internal/sdk/models/operations"
	"github.com/airbytehq/terraform-provider-airbyte/internal/validators"
	"github.com/hashicorp/terraform-plugin-framework-validators/int64validator"
	"github.com/hashicorp/terraform-plugin-framework-validators/listvalidator"
	"github.com/hashicorp/terraform-plugin-framework-validators/objectvalidator"
	"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
	"github.com/hashicorp/terraform-plugin-framework/path"
	"github.com/hashicorp/terraform-plugin-framework/resource"
	"github.com/hashicorp/terraform-plugin-framework/resource/schema"
	"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
	"github.com/hashicorp/terraform-plugin-framework/resource/schema/int64default"
	"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
	"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
	"github.com/hashicorp/terraform-plugin-framework/schema/validator"
	"github.com/hashicorp/terraform-plugin-framework/types"
	"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
)

// Ensure provider defined types fully satisfy framework interfaces.
var _ resource.Resource = &SourceGoogleAnalyticsDataAPIResource{}
var _ resource.ResourceWithImportState = &SourceGoogleAnalyticsDataAPIResource{}

func NewSourceGoogleAnalyticsDataAPIResource() resource.Resource {
	return &SourceGoogleAnalyticsDataAPIResource{}
}

// SourceGoogleAnalyticsDataAPIResource defines the resource implementation.
type SourceGoogleAnalyticsDataAPIResource struct {
	client *sdk.SDK
}

// SourceGoogleAnalyticsDataAPIResourceModel describes the resource data model.
type SourceGoogleAnalyticsDataAPIResourceModel struct {
	Configuration      tfTypes.SourceGoogleAnalyticsDataAPI `tfsdk:"configuration"`
	CreatedAt          types.Int64                          `tfsdk:"created_at"`
	DefinitionID       types.String                         `tfsdk:"definition_id"`
	Name               types.String                         `tfsdk:"name"`
	ResourceAllocation *tfTypes.ScopedResourceRequirements  `tfsdk:"resource_allocation"`
	SecretID           types.String                         `tfsdk:"secret_id"`
	SourceID           types.String                         `tfsdk:"source_id"`
	SourceType         types.String                         `tfsdk:"source_type"`
	WorkspaceID        types.String                         `tfsdk:"workspace_id"`
}

func (r *SourceGoogleAnalyticsDataAPIResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
	resp.TypeName = req.ProviderTypeName + "_source_google_analytics_data_api"
}

func (r *SourceGoogleAnalyticsDataAPIResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
	resp.Schema = schema.Schema{
		MarkdownDescription: "SourceGoogleAnalyticsDataAPI Resource",
		Attributes: map[string]schema.Attribute{
			"configuration": schema.SingleNestedAttribute{
				Required: true,
				PlanModifiers: []planmodifier.Object{
					speakeasy_objectplanmodifier.SuppressDiff(speakeasy_objectplanmodifier.ExplicitSuppress),
				},
				Attributes: map[string]schema.Attribute{
					"convert_conversions_event": schema.BoolAttribute{
						Computed:    true,
						Optional:    true,
						Default:     booldefault.StaticBool(false),
						Description: `Enables conversion of ` + "`" + `conversions:*` + "`" + ` event metrics from integers to floats. This is beneficial for preventing data rounding when the API returns float values for any ` + "`" + `conversions:*` + "`" + ` fields. Default: false`,
					},
					"credentials": schema.SingleNestedAttribute{
						Optional: true,
						Attributes: map[string]schema.Attribute{
							"authenticate_via_google_oauth": schema.SingleNestedAttribute{
								Optional: true,
								Attributes: map[string]schema.Attribute{
									"access_token": schema.StringAttribute{
										Optional:    true,
										Sensitive:   true,
										Description: `Access Token for making authenticated requests.`,
									},
									"client_id": schema.StringAttribute{
										Required:    true,
										Description: `The Client ID of your Google Analytics developer application.`,
									},
									"client_secret": schema.StringAttribute{
										Required:    true,
										Sensitive:   true,
										Description: `The Client Secret of your Google Analytics developer application.`,
									},
									"refresh_token": schema.StringAttribute{
										Required:    true,
										Sensitive:   true,
										Description: `The token for obtaining a new access token.`,
									},
								},
								Validators: []validator.Object{
									objectvalidator.ConflictsWith(path.Expressions{
										path.MatchRelative().AtParent().AtName("service_account_key_authentication"),
									}...),
								},
							},
							"service_account_key_authentication": schema.SingleNestedAttribute{
								Optional: true,
								Attributes: map[string]schema.Attribute{
									"credentials_json": schema.StringAttribute{
										Required:    true,
										Sensitive:   true,
										Description: `The JSON key linked to the service account used for authorization. For steps on obtaining this key, refer to <a href="https://docs.airbyte.com/integrations/sources/google-analytics-data-api/#setup-guide">the setup guide</a>.`,
									},
								},
								Validators: []validator.Object{
									objectvalidator.ConflictsWith(path.Expressions{
										path.MatchRelative().AtParent().AtName("authenticate_via_google_oauth"),
									}...),
								},
							},
						},
						Description: `Credentials for the service`,
					},
					"custom_reports_array": schema.ListNestedAttribute{
						Optional: true,
						NestedObject: schema.NestedAttributeObject{
							Attributes: map[string]schema.Attribute{
								"cohort_spec": schema.SingleNestedAttribute{
									Optional: true,
									Attributes: map[string]schema.Attribute{
										"disabled": schema.SingleNestedAttribute{
											Optional: true,
											Validators: []validator.Object{
												objectvalidator.ConflictsWith(path.Expressions{
													path.MatchRelative().AtParent().AtName("enabled"),
												}...),
											},
										},
										"enabled": schema.SingleNestedAttribute{
											Optional: true,
											Attributes: map[string]schema.Attribute{
												"cohort_report_settings": schema.SingleNestedAttribute{
													Optional: true,
													Attributes: map[string]schema.Attribute{
														"accumulate": schema.BoolAttribute{
															Optional:    true,
															Description: `If true, accumulates the result from first touch day to the end day`,
														},
													},
													Description: `Optional settings for a cohort report.`,
												},
												"cohorts": schema.ListNestedAttribute{
													Optional: true,
													NestedObject: schema.NestedAttributeObject{
														Attributes: map[string]schema.Attribute{
															"date_range": schema.SingleNestedAttribute{
																Required: true,
																Attributes: map[string]schema.Attribute{
																	"end_date": schema.StringAttribute{
																		Required: true,
																		Validators: []validator.String{
																			validators.IsValidDate(),
																		},
																	},
																	"start_date": schema.StringAttribute{
																		Required: true,
																		Validators: []validator.String{
																			validators.IsValidDate(),
																		},
																	},
																},
															},
															"dimension": schema.StringAttribute{
																Required:    true,
																Description: `Dimension used by the cohort. Required and only supports ` + "`" + `firstSessionDate` + "`" + `. must be "firstSessionDate"`,
																Validators: []validator.String{
																	stringvalidator.OneOf(
																		"firstSessionDate",
																	),
																},
															},
															"name": schema.StringAttribute{
																Optional:    true,
																Description: `Assigns a name to this cohort. If not set, cohorts are named by their zero based index cohort_0, cohort_1, etc.`,
															},
														},
													},
												},
												"cohorts_range": schema.SingleNestedAttribute{
													Optional: true,
													Attributes: map[string]schema.Attribute{
														"end_offset": schema.Int64Attribute{
															Required:    true,
															Description: `Specifies the end date of the extended reporting date range for a cohort report.`,
														},
														"granularity": schema.StringAttribute{
															Required:    true,
															Description: `The granularity used to interpret the startOffset and endOffset for the extended reporting date range for a cohort report. must be one of ["GRANULARITY_UNSPECIFIED", "DAILY", "WEEKLY", "MONTHLY"]`,
															Validators: []validator.String{
																stringvalidator.OneOf(
																	"GRANULARITY_UNSPECIFIED",
																	"DAILY",
																	"WEEKLY",
																	"MONTHLY",
																),
															},
														},
														"start_offset": schema.Int64Attribute{
															Optional:    true,
															Description: `Specifies the start date of the extended reporting date range for a cohort report.`,
														},
													},
												},
											},
											Validators: []validator.Object{
												objectvalidator.ConflictsWith(path.Expressions{
													path.MatchRelative().AtParent().AtName("disabled"),
												}...),
											},
										},
									},
									Description: `Cohort reports creates a time series of user retention for the cohort.`,
								},
								"dimension_filter": schema.SingleNestedAttribute{
									Optional: true,
									Attributes: map[string]schema.Attribute{
										"and_group": schema.SingleNestedAttribute{
											Optional: true,
											Attributes: map[string]schema.Attribute{
												"expressions": schema.ListNestedAttribute{
													Required: true,
													NestedObject: schema.NestedAttributeObject{
														Attributes: map[string]schema.Attribute{
															"field_name": schema.StringAttribute{
																Required: true,
															},
															"filter": schema.SingleNestedAttribute{
																Required: true,
																Attributes: map[string]schema.Attribute{
																	"between_filter": schema.SingleNestedAttribute{
																		Optional: true,
																		Attributes: map[string]schema.Attribute{
																			"from_value": schema.SingleNestedAttribute{
																				Required: true,
																				Attributes: map[string]schema.Attribute{
																					"double_value": schema.SingleNestedAttribute{
																						Optional: true,
																						Attributes: map[string]schema.Attribute{
																							"value": schema.NumberAttribute{
																								Required: true,
																							},
																						},
																						Validators: []validator.Object{
																							objectvalidator.ConflictsWith(path.Expressions{
																								path.MatchRelative().AtParent().AtName("int64_value"),
																							}...),
																						},
																					},
																					"int64_value": schema.SingleNestedAttribute{
																						Optional: true,
																						Attributes: map[string]schema.Attribute{
																							"value": schema.StringAttribute{
																								Required: true,
																							},
																						},
																						Validators: []validator.Object{
																							objectvalidator.ConflictsWith(path.Expressions{
																								path.MatchRelative().AtParent().AtName("double_value"),
																							}...),
																						},
																					},
																				},
																			},
																			"to_value": schema.SingleNestedAttribute{
																				Required: true,
																				Attributes: map[string]schema.Attribute{
																					"double_value": schema.SingleNestedAttribute{
																						Optional: true,
																						Attributes: map[string]schema.Attribute{
																							"value": schema.NumberAttribute{
																								Required: true,
																							},
																						},
																						Validators: []validator.Object{
																							objectvalidator.ConflictsWith(path.Expressions{
																								path.MatchRelative().AtParent().AtName("int64_value"),
																							}...),
																						},
																					},
																					"int64_value": schema.SingleNestedAttribute{
																						Optional: true,
																						Attributes: map[string]schema.Attribute{
																							"value": schema.StringAttribute{
																								Required: true,
																							},
																						},
																						Validators: []validator.Object{
																							objectvalidator.ConflictsWith(path.Expressions{
																								path.MatchRelative().AtParent().AtName("double_value"),
																							}...),
																						},
																					},
																				},
																			},
																		},
																		Validators: []validator.Object{
																			objectvalidator.ConflictsWith(path.Expressions{
																				path.MatchRelative().AtParent().AtName("in_list_filter"),
																				path.MatchRelative().AtParent().AtName("numeric_filter"),
																				path.MatchRelative().AtParent().AtName("string_filter"),
																			}...),
																		},
																	},
																	"in_list_filter": schema.SingleNestedAttribute{
																		Optional: true,
																		Attributes: map[string]schema.Attribute{
																			"case_sensitive": schema.BoolAttribute{
																				Optional: true,
																			},
																			"values": schema.ListAttribute{
																				Required:    true,
																				ElementType: types.StringType,
																				Validators: []validator.List{
																					listvalidator.SizeAtLeast(1),
																				},
																			},
																		},
																		Validators: []validator.Object{
																			objectvalidator.ConflictsWith(path.Expressions{
																				path.MatchRelative().AtParent().AtName("between_filter"),
																				path.MatchRelative().AtParent().AtName("numeric_filter"),
																				path.MatchRelative().AtParent().AtName("string_filter"),
																			}...),
																		},
																	},
																	"numeric_filter": schema.SingleNestedAttribute{
																		Optional: true,
																		Attributes: map[string]schema.Attribute{
																			"operation": schema.ListAttribute{
																				Required:    true,
																				ElementType: types.StringType,
																			},
																			"value": schema.SingleNestedAttribute{
																				Required: true,
																				Attributes: map[string]schema.Attribute{
																					"double_value": schema.SingleNestedAttribute{
																						Optional: true,
																						Attributes: map[string]schema.Attribute{
																							"value": schema.NumberAttribute{
																								Required: true,
																							},
																						},
																						Validators: []validator.Object{
																							objectvalidator.ConflictsWith(path.Expressions{
																								path.MatchRelative().AtParent().AtName("int64_value"),
																							}...),
																						},
																					},
																					"int64_value": schema.SingleNestedAttribute{
																						Optional: true,
																						Attributes: map[string]schema.Attribute{
																							"value": schema.StringAttribute{
																								Required: true,
																							},
																						},
																						Validators: []validator.Object{
																							objectvalidator.ConflictsWith(path.Expressions{
																								path.MatchRelative().AtParent().AtName("double_value"),
																							}...),
																						},
																					},
																				},
																			},
																		},
																		Validators: []validator.Object{
																			objectvalidator.ConflictsWith(path.Expressions{
																				path.MatchRelative().AtParent().AtName("between_filter"),
																				path.MatchRelative().AtParent().AtName("in_list_filter"),
																				path.MatchRelative().AtParent().AtName("string_filter"),
																			}...),
																		},
																	},
																	"string_filter": schema.SingleNestedAttribute{
																		Optional: true,
																		Attributes: map[string]schema.Attribute{
																			"case_sensitive": schema.BoolAttribute{
																				Optional: true,
																			},
																			"match_type": schema.ListAttribute{
																				Optional:    true,
																				ElementType: types.StringType,
																			},
																			"value": schema.StringAttribute{
																				Required: true,
																			},
																		},
																		Validators: []validator.Object{
																			objectvalidator.ConflictsWith(path.Expressions{
																				path.MatchRelative().AtParent().AtName("between_filter"),
																				path.MatchRelative().AtParent().AtName("in_list_filter"),
																				path.MatchRelative().AtParent().AtName("numeric_filter"),
																			}...),
																		},
																	},
																},
															},
														},
													},
												},
											},
											Description: `The FilterExpressions in andGroup have an AND relationship.`,
											Validators: []validator.Object{
												objectvalidator.ConflictsWith(path.Expressions{
													path.MatchRelative().AtParent().AtName("filter"),
													path.MatchRelative().AtParent().AtName("not_expression"),
													path.MatchRelative().AtParent().AtName("or_group"),
												}...),
											},
										},
										"filter": schema.SingleNestedAttribute{
											Optional: true,
											Attributes: map[string]schema.Attribute{
												"field_name": schema.StringAttribute{
													Required: true,
												},
												"filter": schema.SingleNestedAttribute{
													Required: true,
													Attributes: map[string]schema.Attribute{
														"between_filter": schema.SingleNestedAttribute{
															Optional: true,
															Attributes: map[string]schema.Attribute{
																"from_value": schema.SingleNestedAttribute{
																	Required: true,
																	Attributes: map[string]schema.Attribute{
																		"double_value": schema.SingleNestedAttribute{
																			Optional: true,
																			Attributes: map[string]schema.Attribute{
																				"value": schema.NumberAttribute{
																					Required: true,
																				},
																			},
																			Validators: []validator.Object{
																				objectvalidator.ConflictsWith(path.Expressions{
																					path.MatchRelative().AtParent().AtName("int64_value"),
																				}...),
																			},
																		},
																		"int64_value": schema.SingleNestedAttribute{
																			Optional: true,
																			Attributes: map[string]schema.Attribute{
																				"value": schema.StringAttribute{
																					Required: true,
																				},
																			},
																			Validators: []validator.Object{
																				objectvalidator.ConflictsWith(path.Expressions{
																					path.MatchRelative().AtParent().AtName("double_value"),
																				}...),
																			},
																		},
																	},
																},
																"to_value": schema.SingleNestedAttribute{
																	Required: true,
																	Attributes: map[string]schema.Attribute{
																		"double_value": schema.SingleNestedAttribute{
																			Optional: true,
																			Attributes: map[string]schema.Attribute{
																				"value": schema.NumberAttribute{
																					Required: true,
																				},
																			},
																			Validators: []validator.Object{
																				objectvalidator.ConflictsWith(path.Expressions{
																					path.MatchRelative().AtParent().AtName("int64_value"),
																				}...),
																			},
																		},
																		"int64_value": schema.SingleNestedAttribute{
																			Optional: true,
																			Attributes: map[string]schema.Attribute{
																				"value": schema.StringAttribute{
																					Required: true,
																				},
																			},
																			Validators: []validator.Object{
																				objectvalidator.ConflictsWith(path.Expressions{
																					path.MatchRelative().AtParent().AtName("double_value"),
																				}...),
																			},
																		},
																	},
																},
															},
															Validators: []validator.Object{
																objectvalidator.ConflictsWith(path.Expressions{
																	path.MatchRelative().AtParent().AtName("in_list_filter"),
																	path.MatchRelative().AtParent().AtName("numeric_filter"),
																	path.MatchRelative().AtParent().AtName("string_filter"),
																}...),
															},
														},
														"in_list_filter": schema.SingleNestedAttribute{
															Optional: true,
															Attributes: map[string]schema.Attribute{
																"case_sensitive": schema.BoolAttribute{
																	Optional: true,
																},
																"values": schema.ListAttribute{
																	Required:    true,
																	ElementType: types.StringType,
																	Validators: []validator.List{
																		listvalidator.SizeAtLeast(1),
																	},
																},
															},
															Validators: []validator.Object{
																objectvalidator.ConflictsWith(path.Expressions{
																	path.MatchRelative().AtParent().AtName("between_filter"),
																	path.MatchRelative().AtParent().AtName("numeric_filter"),
																	path.MatchRelative().AtParent().AtName("string_filter"),
																}...),
															},
														},
														"numeric_filter": schema.SingleNestedAttribute{
															Optional: true,
															Attributes: map[string]schema.Attribute{
																"operation": schema.ListAttribute{
																	Required:    true,
																	ElementType: types.StringType,
																},
																"value": schema.SingleNestedAttribute{
																	Required: true,
																	Attributes: map[string]schema.Attribute{
																		"double_value": schema.SingleNestedAttribute{
																			Optional: true,
																			Attributes: map[string]schema.Attribute{
																				"value": schema.NumberAttribute{
																					Required: true,
																				},
																			},
																			Validators: []validator.Object{
																				objectvalidator.ConflictsWith(path.Expressions{
																					path.MatchRelative().AtParent().AtName("int64_value"),
																				}...),
																			},
																		},
																		"int64_value": schema.SingleNestedAttribute{
																			Optional: true,
																			Attributes: map[string]schema.Attribute{
																				"value": schema.StringAttribute{
																					Required: true,
																				},
																			},
																			Validators: []validator.Object{
																				objectvalidator.ConflictsWith(path.Expressions{
																					path.MatchRelative().AtParent().AtName("double_value"),
																				}...),
																			},
																		},
																	},
																},
															},
															Validators: []validator.Object{
																objectvalidator.ConflictsWith(path.Expressions{
																	path.MatchRelative().AtParent().AtName("between_filter"),
																	path.MatchRelative().AtParent().AtName("in_list_filter"),
																	path.MatchRelative().AtParent().AtName("string_filter"),
																}...),
															},
														},
														"string_filter": schema.SingleNestedAttribute{
															Optional: true,
															Attributes: map[string]schema.Attribute{
																"case_sensitive": schema.BoolAttribute{
																	Optional: true,
																},
																"match_type": schema.ListAttribute{
																	Optional:    true,
																	ElementType: types.StringType,
																},
																"value": schema.StringAttribute{
																	Required: true,
																},
															},
															Validators: []validator.Object{
																objectvalidator.ConflictsWith(path.Expressions{
																	path.MatchRelative().AtParent().AtName("between_filter"),
																	path.MatchRelative().AtParent().AtName("in_list_filter"),
																	path.MatchRelative().AtParent().AtName("numeric_filter"),
																}...),
															},
														},
													},
												},
											},
											Description: `A primitive filter. In the same FilterExpression, all of the filter's field names need to be either all dimensions.`,
											Validators: []validator.Object{
												objectvalidator.ConflictsWith(path.Expressions{
													path.MatchRelative().AtParent().AtName("and_group"),
													path.MatchRelative().AtParent().AtName("not_expression"),
													path.MatchRelative().AtParent().AtName("or_group"),
												}...),
											},
										},
										"not_expression": schema.SingleNestedAttribute{
											Optional: true,
											Attributes: map[string]schema.Attribute{
												"expression": schema.SingleNestedAttribute{
													Optional: true,
													Attributes: map[string]schema.Attribute{
														"field_name": schema.StringAttribute{
															Required: true,
														},
														"filter": schema.SingleNestedAttribute{
															Required: true,
															Attributes: map[string]schema.Attribute{
																"between_filter": schema.SingleNestedAttribute{
																	Optional: true,
																	Attributes: map[string]schema.Attribute{
																		"from_value": schema.SingleNestedAttribute{
																			Required: true,
																			Attributes: map[string]schema.Attribute{
																				"double_value": schema.SingleNestedAttribute{
																					Optional: true,
																					Attributes: map[string]schema.Attribute{
																						"value": schema.NumberAttribute{
																							Required: true,
																						},
																					},
																					Validators: []validator.Object{
																						objectvalidator.ConflictsWith(path.Expressions{
																							path.MatchRelative().AtParent().AtName("int64_value"),
																						}...),
																					},
																				},
																				"int64_value": schema.SingleNestedAttribute{
																					Optional: true,
																					Attributes: map[string]schema.Attribute{
																						"value": schema.StringAttribute{
																							Required: true,
																						},
																					},
																					Validators: []validator.Object{
																						objectvalidator.ConflictsWith(path.Expressions{
																							path.MatchRelative().AtParent().AtName("double_value"),
																						}...),
																					},
																				},
																			},
																		},
																		"to_value": schema.SingleNestedAttribute{
																			Required: true,
																			Attributes: map[string]schema.Attribute{
																				"double_value": schema.SingleNestedAttribute{
																					Optional: true,
																					Attributes: map[string]schema.Attribute{
																						"value": schema.NumberAttribute{
																							Required: true,
																						},
																					},
																					Validators: []validator.Object{
																						objectvalidator.ConflictsWith(path.Expressions{
																							path.MatchRelative().AtParent().AtName("int64_value"),
																						}...),
																					},
																				},
																				"int64_value": schema.SingleNestedAttribute{
																					Optional: true,
																					Attributes: map[string]schema.Attribute{
																						"value": schema.StringAttribute{
																							Required: true,
																						},
																					},
																					Validators: []validator.Object{
																						objectvalidator.ConflictsWith(path.Expressions{
																							path.MatchRelative().AtParent().AtName("double_value"),
																						}...),
																					},
																				},
																			},
																		},
																	},
																	Validators: []validator.Object{
																		objectvalidator.ConflictsWith(path.Expressions{
																			path.MatchRelative().AtParent().AtName("in_list_filter"),
																			path.MatchRelative().AtParent().AtName("numeric_filter"),
																			path.MatchRelative().AtParent().AtName("string_filter"),
																		}...),
																	},
																},
																"in_list_filter": schema.SingleNestedAttribute{
																	Optional: true,
																	Attributes: map[string]schema.Attribute{
																		"case_sensitive": schema.BoolAttribute{
																			Optional: true,
																		},
																		"values": schema.ListAttribute{
																			Required:    true,
																			ElementType: types.StringType,
																			Validators: []validator.List{
																				listvalidator.SizeAtLeast(1),
																			},
																		},
																	},
																	Validators: []validator.Object{
																		objectvalidator.ConflictsWith(path.Expressions{
																			path.MatchRelative().AtParent().AtName("between_filter"),
																			path.MatchRelative().AtParent().AtName("numeric_filter"),
																			path.MatchRelative().AtParent().AtName("string_filter"),
																		}...),
																	},
																},
																"numeric_filter": schema.SingleNestedAttribute{
																	Optional: true,
																	Attributes: map[string]schema.Attribute{
																		"operation": schema.ListAttribute{
																			Required:    true,
																			ElementType: types.StringType,
																		},
																		"value": schema.SingleNestedAttribute{
																			Required: true,
																			Attributes: map[string]schema.Attribute{
																				"double_value": schema.SingleNestedAttribute{
																					Optional: true,
																					Attributes: map[string]schema.Attribute{
																						"value": schema.NumberAttribute{
																							Required: true,
																						},
																					},
																					Validators: []validator.Object{
																						objectvalidator.ConflictsWith(path.Expressions{
																							path.MatchRelative().AtParent().AtName("int64_value"),
																						}...),
																					},
																				},
																				"int64_value": schema.SingleNestedAttribute{
																					Optional: true,
																					Attributes: map[string]schema.Attribute{
																						"value": schema.StringAttribute{
																							Required: true,
																						},
																					},
																					Validators: []validator.Object{
																						objectvalidator.ConflictsWith(path.Expressions{
																							path.MatchRelative().AtParent().AtName("double_value"),
																						}...),
																					},
																				},
																			},
																		},
																	},
																	Validators: []validator.Object{
																		objectvalidator.ConflictsWith(path.Expressions{
																			path.MatchRelative().AtParent().AtName("between_filter"),
																			path.MatchRelative().AtParent().AtName("in_list_filter"),
																			path.MatchRelative().AtParent().AtName("string_filter"),
																		}...),
																	},
																},
																"string_filter": schema.SingleNestedAttribute{
																	Optional: true,
																	Attributes: map[string]schema.Attribute{
																		"case_sensitive": schema.BoolAttribute{
																			Optional: true,
																		},
																		"match_type": schema.ListAttribute{
																			Optional:    true,
																			ElementType: types.StringType,
																		},
																		"value": schema.StringAttribute{
																			Required: true,
																		},
																	},
																	Validators: []validator.Object{
																		objectvalidator.ConflictsWith(path.Expressions{
																			path.MatchRelative().AtParent().AtName("between_filter"),
																			path.MatchRelative().AtParent().AtName("in_list_filter"),
																			path.MatchRelative().AtParent().AtName("numeric_filter"),
																		}...),
																	},
																},
															},
														},
													},
												},
											},
											Description: `The FilterExpression is NOT of notExpression.`,
											Validators: []validator.Object{
												objectvalidator.ConflictsWith(path.Expressions{
													path.MatchRelative().AtParent().AtName("and_group"),
													path.MatchRelative().AtParent().AtName("filter"),
													path.MatchRelative().AtParent().AtName("or_group"),
												}...),
											},
										},
										"or_group": schema.SingleNestedAttribute{
											Optional: true,
											Attributes: map[string]schema.Attribute{
												"expressions": schema.ListNestedAttribute{
													Required: true,
													NestedObject: schema.NestedAttributeObject{
														Attributes: map[string]schema.Attribute{
															"field_name": schema.StringAttribute{
																Required: true,
															},
															"filter": schema.SingleNestedAttribute{
																Required: true,
																Attributes: map[string]schema.Attribute{
																	"between_filter": schema.SingleNestedAttribute{
																		Optional: true,
																		Attributes: map[string]schema.Attribute{
																			"from_value": schema.SingleNestedAttribute{
																				Required: true,
																				Attributes: map[string]schema.Attribute{
																					"double_value": schema.SingleNestedAttribute{
																						Optional: true,
																						Attributes: map[string]schema.Attribute{
																							"value": schema.NumberAttribute{
																								Required: true,
																							},
																						},
																						Validators: []validator.Object{
																							objectvalidator.ConflictsWith(path.Expressions{
																								path.MatchRelative().AtParent().AtName("int64_value"),
																							}...),
																						},
																					},
																					"int64_value": schema.SingleNestedAttribute{
																						Optional: true,
																						Attributes: map[string]schema.Attribute{
																							"value": schema.StringAttribute{
																								Required: true,
																							},
																						},
																						Validators: []validator.Object{
																							objectvalidator.ConflictsWith(path.Expressions{
																								path.MatchRelative().AtParent().AtName("double_value"),
																							}...),
																						},
																					},
																				},
																			},
																			"to_value": schema.SingleNestedAttribute{
																				Required: true,
																				Attributes: map[string]schema.Attribute{
																					"double_value": schema.SingleNestedAttribute{
																						Optional: true,
																						Attributes: map[string]schema.Attribute{
																							"value": schema.NumberAttribute{
																								Required: true,
																							},
																						},
																						Validators: []validator.Object{
																							objectvalidator.ConflictsWith(path.Expressions{
																								path.MatchRelative().AtParent().AtName("int64_value"),
																							}...),
																						},
																					},
																					"int64_value": schema.SingleNestedAttribute{
																						Optional: true,
																						Attributes: map[string]schema.Attribute{
																							"value": schema.StringAttribute{
																								Required: true,
																							},
																						},
																						Validators: []validator.Object{
																							objectvalidator.ConflictsWith(path.Expressions{
																								path.MatchRelative().AtParent().AtName("double_value"),
																							}...),
																						},
																					},
																				},
																			},
																		},
																		Validators: []validator.Object{
																			objectvalidator.ConflictsWith(path.Expressions{
																				path.MatchRelative().AtParent().AtName("in_list_filter"),
																				path.MatchRelative().AtParent().AtName("numeric_filter"),
																				path.MatchRelative().AtParent().AtName("string_filter"),
																			}...),
																		},
																	},
																	"in_list_filter": schema.SingleNestedAttribute{
																		Optional: true,
																		Attributes: map[string]schema.Attribute{
																			"case_sensitive": schema.BoolAttribute{
																				Optional: true,
																			},
																			"values": schema.ListAttribute{
																				Required:    true,
																				ElementType: types.StringType,
																				Validators: []validator.List{
																					listvalidator.SizeAtLeast(1),
																				},
																			},
																		},
																		Validators: []validator.Object{
																			objectvalidator.ConflictsWith(path.Expressions{
																				path.MatchRelative().AtParent().AtName("between_filter"),
																				path.MatchRelative().AtParent().AtName("numeric_filter"),
																				path.MatchRelative().AtParent().AtName("string_filter"),
																			}...),
																		},
																	},
																	"numeric_filter": schema.SingleNestedAttribute{
																		Optional: true,
																		Attributes: map[string]schema.Attribute{
																			"operation": schema.ListAttribute{
																				Required:    true,
																				ElementType: types.StringType,
																			},
																			"value": schema.SingleNestedAttribute{
																				Required: true,
																				Attributes: map[string]schema.Attribute{
																					"double_value": schema.SingleNestedAttribute{
																						Optional: true,
																						Attributes: map[string]schema.Attribute{
																							"value": schema.NumberAttribute{
																								Required: true,
																							},
																						},
																						Validators: []validator.Object{
																							objectvalidator.ConflictsWith(path.Expressions{
																								path.MatchRelative().AtParent().AtName("int64_value"),
																							}...),
																						},
																					},
																					"int64_value": schema.SingleNestedAttribute{
																						Optional: true,
																						Attributes: map[string]schema.Attribute{
																							"value": schema.StringAttribute{
																								Required: true,
																							},
																						},
																						Validators: []validator.Object{
																							objectvalidator.ConflictsWith(path.Expressions{
																								path.MatchRelative().AtParent().AtName("double_value"),
																							}...),
																						},
																					},
																				},
																			},
																		},
																		Validators: []validator.Object{
																			objectvalidator.ConflictsWith(path.Expressions{
																				path.MatchRelative().AtParent().AtName("between_filter"),
																				path.MatchRelative().AtParent().AtName("in_list_filter"),
																				path.MatchRelative().AtParent().AtName("string_filter"),
																			}...),
																		},
																	},
																	"string_filter": schema.SingleNestedAttribute{
																		Optional: true,
																		Attributes: map[string]schema.Attribute{
																			"case_sensitive": schema.BoolAttribute{
																				Optional: true,
																			},
																			"match_type": schema.ListAttribute{
																				Optional:    true,
																				ElementType: types.StringType,
																			},
																			"value": schema.StringAttribute{
																				Required: true,
																			},
																		},
																		Validators: []validator.Object{
																			objectvalidator.ConflictsWith(path.Expressions{
																				path.MatchRelative().AtParent().AtName("between_filter"),
																				path.MatchRelative().AtParent().AtName("in_list_filter"),
																				path.MatchRelative().AtParent().AtName("numeric_filter"),
																			}...),
																		},
																	},
																},
															},
														},
													},
												},
											},
											Description: `The FilterExpressions in orGroup have an OR relationship.`,
											Validators: []validator.Object{
												objectvalidator.ConflictsWith(path.Expressions{
													path.MatchRelative().AtParent().AtName("and_group"),
													path.MatchRelative().AtParent().AtName("filter"),
													path.MatchRelative().AtParent().AtName("not_expression"),
												}...),
											},
										},
									},
									Description: `Dimensions filter`,
								},
								"dimensions": schema.ListAttribute{
									Required:    true,
									ElementType: types.StringType,
									Description: `A list of dimensions.`,
									Validators: []validator.List{
										listvalidator.SizeAtLeast(1),
									},
								},
								"metric_filter": schema.SingleNestedAttribute{
									Optional: true,
									Attributes: map[string]schema.Attribute{
										"and_group": schema.SingleNestedAttribute{
											Optional: true,
											Attributes: map[string]schema.Attribute{
												"expressions": schema.ListNestedAttribute{
													Required: true,
													NestedObject: schema.NestedAttributeObject{
														Attributes: map[string]schema.Attribute{
															"field_name": schema.StringAttribute{
																Required: true,
															},
															"filter": schema.SingleNestedAttribute{
																Required: true,
																Attributes: map[string]schema.Attribute{
																	"between_filter": schema.SingleNestedAttribute{
																		Optional: true,
																		Attributes: map[string]schema.Attribute{
																			"from_value": schema.SingleNestedAttribute{
																				Required: true,
																				Attributes: map[string]schema.Attribute{
																					"double_value": schema.SingleNestedAttribute{
																						Optional: true,
																						Attributes: map[string]schema.Attribute{
																							"value": schema.NumberAttribute{
																								Required: true,
																							},
																						},
																						Validators: []validator.Object{
																							objectvalidator.ConflictsWith(path.Expressions{
																								path.MatchRelative().AtParent().AtName("int64_value"),
																							}...),
																						},
																					},
																					"int64_value": schema.SingleNestedAttribute{
																						Optional: true,
																						Attributes: map[string]schema.Attribute{
																							"value": schema.StringAttribute{
																								Required: true,
																							},
																						},
																						Validators: []validator.Object{
																							objectvalidator.ConflictsWith(path.Expressions{
																								path.MatchRelative().AtParent().AtName("double_value"),
																							}...),
																						},
																					},
																				},
																			},
																			"to_value": schema.SingleNestedAttribute{
																				Required: true,
																				Attributes: map[string]schema.Attribute{
																					"double_value": schema.SingleNestedAttribute{
																						Optional: true,
																						Attributes: map[string]schema.Attribute{
																							"value": schema.NumberAttribute{
																								Required: true,
																							},
																						},
																						Validators: []validator.Object{
																							objectvalidator.ConflictsWith(path.Expressions{
																								path.MatchRelative().AtParent().AtName("int64_value"),
																							}...),
																						},
																					},
																					"int64_value": schema.SingleNestedAttribute{
																						Optional: true,
																						Attributes: map[string]schema.Attribute{
																							"value": schema.StringAttribute{
																								Required: true,
																							},
																						},
																						Validators: []validator.Object{
																							objectvalidator.ConflictsWith(path.Expressions{
																								path.MatchRelative().AtParent().AtName("double_value"),
																							}...),
																						},
																					},
																				},
																			},
																		},
																		Validators: []validator.Object{
																			objectvalidator.ConflictsWith(path.Expressions{
																				path.MatchRelative().AtParent().AtName("in_list_filter"),
																				path.MatchRelative().AtParent().AtName("numeric_filter"),
																				path.MatchRelative().AtParent().AtName("string_filter"),
																			}...),
																		},
																	},
																	"in_list_filter": schema.SingleNestedAttribute{
																		Optional: true,
																		Attributes: map[string]schema.Attribute{
																			"case_sensitive": schema.BoolAttribute{
																				Optional: true,
																			},
																			"values": schema.ListAttribute{
																				Required:    true,
																				ElementType: types.StringType,
																				Validators: []validator.List{
																					listvalidator.SizeAtLeast(1),
																				},
																			},
																		},
																		Validators: []validator.Object{
																			objectvalidator.ConflictsWith(path.Expressions{
																				path.MatchRelative().AtParent().AtName("between_filter"),
																				path.MatchRelative().AtParent().AtName("numeric_filter"),
																				path.MatchRelative().AtParent().AtName("string_filter"),
																			}...),
																		},
																	},
																	"numeric_filter": schema.SingleNestedAttribute{
																		Optional: true,
																		Attributes: map[string]schema.Attribute{
																			"operation": schema.ListAttribute{
																				Required:    true,
																				ElementType: types.StringType,
																			},
																			"value": schema.SingleNestedAttribute{
																				Required: true,
																				Attributes: map[string]schema.Attribute{
																					"double_value": schema.SingleNestedAttribute{
																						Optional: true,
																						Attributes: map[string]schema.Attribute{
																							"value": schema.NumberAttribute{
																								Required: true,
																							},
																						},
																						Validators: []validator.Object{
																							objectvalidator.ConflictsWith(path.Expressions{
																								path.MatchRelative().AtParent().AtName("int64_value"),
																							}...),
																						},
																					},
																					"int64_value": schema.SingleNestedAttribute{
																						Optional: true,
																						Attributes: map[string]schema.Attribute{
																							"value": schema.StringAttribute{
																								Required: true,
																							},
																						},
																						Validators: []validator.Object{
																							objectvalidator.ConflictsWith(path.Expressions{
																								path.MatchRelative().AtParent().AtName("double_value"),
																							}...),
																						},
																					},
																				},
																			},
																		},
																		Validators: []validator.Object{
																			objectvalidator.ConflictsWith(path.Expressions{
																				path.MatchRelative().AtParent().AtName("between_filter"),
																				path.MatchRelative().AtParent().AtName("in_list_filter"),
																				path.MatchRelative().AtParent().AtName("string_filter"),
																			}...),
																		},
																	},
																	"string_filter": schema.SingleNestedAttribute{
																		Optional: true,
																		Attributes: map[string]schema.Attribute{
																			"case_sensitive": schema.BoolAttribute{
																				Optional: true,
																			},
																			"match_type": schema.ListAttribute{
																				Optional:    true,
																				ElementType: types.StringType,
																			},
																			"value": schema.StringAttribute{
																				Required: true,
																			},
																		},
																		Validators: []validator.Object{
																			objectvalidator.ConflictsWith(path.Expressions{
																				path.MatchRelative().AtParent().AtName("between_filter"),
																				path.MatchRelative().AtParent().AtName("in_list_filter"),
																				path.MatchRelative().AtParent().AtName("numeric_filter"),
																			}...),
																		},
																	},
																},
															},
														},
													},
												},
											},
											Description: `The FilterExpressions in andGroup have an AND relationship.`,
											Validators: []validator.Object{
												objectvalidator.ConflictsWith(path.Expressions{
													path.MatchRelative().AtParent().AtName("filter"),
													path.MatchRelative().AtParent().AtName("not_expression"),
													path.MatchRelative().AtParent().AtName("or_group"),
												}...),
											},
										},
										"filter": schema.SingleNestedAttribute{
											Optional: true,
											Attributes: map[string]schema.Attribute{
												"field_name": schema.StringAttribute{
													Required: true,
												},
												"filter": schema.SingleNestedAttribute{
													Required: true,
													Attributes: map[string]schema.Attribute{
														"between_filter": schema.SingleNestedAttribute{
															Optional: true,
															Attributes: map[string]schema.Attribute{
																"from_value": schema.SingleNestedAttribute{
																	Required: true,
																	Attributes: map[string]schema.Attribute{
																		"double_value": schema.SingleNestedAttribute{
																			Optional: true,
																			Attributes: map[string]schema.Attribute{
																				"value": schema.NumberAttribute{
																					Required: true,
																				},
																			},
																			Validators: []validator.Object{
																				objectvalidator.ConflictsWith(path.Expressions{
																					path.MatchRelative().AtParent().AtName("int64_value"),
																				}...),
																			},
																		},
																		"int64_value": schema.SingleNestedAttribute{
																			Optional: true,
																			Attributes: map[string]schema.Attribute{
																				"value": schema.StringAttribute{
																					Required: true,
																				},
																			},
																			Validators: []validator.Object{
																				objectvalidator.ConflictsWith(path.Expressions{
																					path.MatchRelative().AtParent().AtName("double_value"),
																				}...),
																			},
																		},
																	},
																},
																"to_value": schema.SingleNestedAttribute{
																	Required: true,
																	Attributes: map[string]schema.Attribute{
																		"double_value": schema.SingleNestedAttribute{
																			Optional: true,
																			Attributes: map[string]schema.Attribute{
																				"value": schema.NumberAttribute{
																					Required: true,
																				},
																			},
																			Validators: []validator.Object{
																				objectvalidator.ConflictsWith(path.Expressions{
																					path.MatchRelative().AtParent().AtName("int64_value"),
																				}...),
																			},
																		},
																		"int64_value": schema.SingleNestedAttribute{
																			Optional: true,
																			Attributes: map[string]schema.Attribute{
																				"value": schema.StringAttribute{
																					Required: true,
																				},
																			},
																			Validators: []validator.Object{
																				objectvalidator.ConflictsWith(path.Expressions{
																					path.MatchRelative().AtParent().AtName("double_value"),
																				}...),
																			},
																		},
																	},
																},
															},
															Validators: []validator.Object{
																objectvalidator.ConflictsWith(path.Expressions{
																	path.MatchRelative().AtParent().AtName("in_list_filter"),
																	path.MatchRelative().AtParent().AtName("numeric_filter"),
																	path.MatchRelative().AtParent().AtName("string_filter"),
																}...),
															},
														},
														"in_list_filter": schema.SingleNestedAttribute{
															Optional: true,
															Attributes: map[string]schema.Attribute{
																"case_sensitive": schema.BoolAttribute{
																	Optional: true,
																},
																"values": schema.ListAttribute{
																	Required:    true,
																	ElementType: types.StringType,
																	Validators: []validator.List{
																		listvalidator.SizeAtLeast(1),
																	},
																},
															},
															Validators: []validator.Object{
																objectvalidator.ConflictsWith(path.Expressions{
																	path.MatchRelative().AtParent().AtName("between_filter"),
																	path.MatchRelative().AtParent().AtName("numeric_filter"),
																	path.MatchRelative().AtParent().AtName("string_filter"),
																}...),
															},
														},
														"numeric_filter": schema.SingleNestedAttribute{
															Optional: true,
															Attributes: map[string]schema.Attribute{
																"operation": schema.ListAttribute{
																	Required:    true,
																	ElementType: types.StringType,
																},
																"value": schema.SingleNestedAttribute{
																	Required: true,
																	Attributes: map[string]schema.Attribute{
																		"double_value": schema.SingleNestedAttribute{
																			Optional: true,
																			Attributes: map[string]schema.Attribute{
																				"value": schema.NumberAttribute{
																					Required: true,
																				},
																			},
																			Validators: []validator.Object{
																				objectvalidator.ConflictsWith(path.Expressions{
																					path.MatchRelative().AtParent().AtName("int64_value"),
																				}...),
																			},
																		},
																		"int64_value": schema.SingleNestedAttribute{
																			Optional: true,
																			Attributes: map[string]schema.Attribute{
																				"value": schema.StringAttribute{
																					Required: true,
																				},
																			},
																			Validators: []validator.Object{
																				objectvalidator.ConflictsWith(path.Expressions{
																					path.MatchRelative().AtParent().AtName("double_value"),
																				}...),
																			},
																		},
																	},
																},
															},
															Validators: []validator.Object{
																objectvalidator.ConflictsWith(path.Expressions{
																	path.MatchRelative().AtParent().AtName("between_filter"),
																	path.MatchRelative().AtParent().AtName("in_list_filter"),
																	path.MatchRelative().AtParent().AtName("string_filter"),
																}...),
															},
														},
														"string_filter": schema.SingleNestedAttribute{
															Optional: true,
															Attributes: map[string]schema.Attribute{
																"case_sensitive": schema.BoolAttribute{
																	Optional: true,
																},
																"match_type": schema.ListAttribute{
																	Optional:    true,
																	ElementType: types.StringType,
																},
																"value": schema.StringAttribute{
																	Required: true,
																},
															},
															Validators: []validator.Object{
																objectvalidator.ConflictsWith(path.Expressions{
																	path.MatchRelative().AtParent().AtName("between_filter"),
																	path.MatchRelative().AtParent().AtName("in_list_filter"),
																	path.MatchRelative().AtParent().AtName("numeric_filter"),
																}...),
															},
														},
													},
												},
											},
											Description: `A primitive filter. In the same FilterExpression, all of the filter's field names need to be either all metrics.`,
											Validators: []validator.Object{
												objectvalidator.ConflictsWith(path.Expressions{
													path.MatchRelative().AtParent().AtName("and_group"),
													path.MatchRelative().AtParent().AtName("not_expression"),
													path.MatchRelative().AtParent().AtName("or_group"),
												}...),
											},
										},
										"not_expression": schema.SingleNestedAttribute{
											Optional: true,
											Attributes: map[string]schema.Attribute{
												"expression": schema.SingleNestedAttribute{
													Optional: true,
													Attributes: map[string]schema.Attribute{
														"field_name": schema.StringAttribute{
															Required: true,
														},
														"filter": schema.SingleNestedAttribute{
															Required: true,
															Attributes: map[string]schema.Attribute{
																"between_filter": schema.SingleNestedAttribute{
																	Optional: true,
																	Attributes: map[string]schema.Attribute{
																		"from_value": schema.SingleNestedAttribute{
																			Required: true,
																			Attributes: map[string]schema.Attribute{
																				"double_value": schema.SingleNestedAttribute{
																					Optional: true,
																					Attributes: map[string]schema.Attribute{
																						"value": schema.NumberAttribute{
																							Required: true,
																						},
																					},
																					Validators: []validator.Object{
																						objectvalidator.ConflictsWith(path.Expressions{
																							path.MatchRelative().AtParent().AtName("int64_value"),
																						}...),
																					},
																				},
																				"int64_value": schema.SingleNestedAttribute{
																					Optional: true,
																					Attributes: map[string]schema.Attribute{
																						"value": schema.StringAttribute{
																							Required: true,
																						},
																					},
																					Validators: []validator.Object{
																						objectvalidator.ConflictsWith(path.Expressions{
																							path.MatchRelative().AtParent().AtName("double_value"),
																						}...),
																					},
																				},
																			},
																		},
																		"to_value": schema.SingleNestedAttribute{
																			Required: true,
																			Attributes: map[string]schema.Attribute{
																				"double_value": schema.SingleNestedAttribute{
																					Optional: true,
																					Attributes: map[string]schema.Attribute{
																						"value": schema.NumberAttribute{
																							Required: true,
																						},
																					},
																					Validators: []validator.Object{
																						objectvalidator.ConflictsWith(path.Expressions{
																							path.MatchRelative().AtParent().AtName("int64_value"),
																						}...),
																					},
																				},
																				"int64_value": schema.SingleNestedAttribute{
																					Optional: true,
																					Attributes: map[string]schema.Attribute{
																						"value": schema.StringAttribute{
																							Required: true,
																						},
																					},
																					Validators: []validator.Object{
																						objectvalidator.ConflictsWith(path.Expressions{
																							path.MatchRelative().AtParent().AtName("double_value"),
																						}...),
																					},
																				},
																			},
																		},
																	},
																	Validators: []validator.Object{
																		objectvalidator.ConflictsWith(path.Expressions{
																			path.MatchRelative().AtParent().AtName("in_list_filter"),
																			path.MatchRelative().AtParent().AtName("numeric_filter"),
																			path.MatchRelative().AtParent().AtName("string_filter"),
																		}...),
																	},
																},
																"in_list_filter": schema.SingleNestedAttribute{
																	Optional: true,
																	Attributes: map[string]schema.Attribute{
																		"case_sensitive": schema.BoolAttribute{
																			Optional: true,
																		},
																		"values": schema.ListAttribute{
																			Required:    true,
																			ElementType: types.StringType,
																			Validators: []validator.List{
																				listvalidator.SizeAtLeast(1),
																			},
																		},
																	},
																	Validators: []validator.Object{
																		objectvalidator.ConflictsWith(path.Expressions{
																			path.MatchRelative().AtParent().AtName("between_filter"),
																			path.MatchRelative().AtParent().AtName("numeric_filter"),
																			path.MatchRelative().AtParent().AtName("string_filter"),
																		}...),
																	},
																},
																"numeric_filter": schema.SingleNestedAttribute{
																	Optional: true,
																	Attributes: map[string]schema.Attribute{
																		"operation": schema.ListAttribute{
																			Required:    true,
																			ElementType: types.StringType,
																		},
																		"value": schema.SingleNestedAttribute{
																			Required: true,
																			Attributes: map[string]schema.Attribute{
																				"double_value": schema.SingleNestedAttribute{
																					Optional: true,
																					Attributes: map[string]schema.Attribute{
																						"value": schema.NumberAttribute{
																							Required: true,
																						},
																					},
																					Validators: []validator.Object{
																						objectvalidator.ConflictsWith(path.Expressions{
																							path.MatchRelative().AtParent().AtName("int64_value"),
																						}...),
																					},
																				},
																				"int64_value": schema.SingleNestedAttribute{
																					Optional: true,
																					Attributes: map[string]schema.Attribute{
																						"value": schema.StringAttribute{
																							Required: true,
																						},
																					},
																					Validators: []validator.Object{
																						objectvalidator.ConflictsWith(path.Expressions{
																							path.MatchRelative().AtParent().AtName("double_value"),
																						}...),
																					},
																				},
																			},
																		},
																	},
																	Validators: []validator.Object{
																		objectvalidator.ConflictsWith(path.Expressions{
																			path.MatchRelative().AtParent().AtName("between_filter"),
																			path.MatchRelative().AtParent().AtName("in_list_filter"),
																			path.MatchRelative().AtParent().AtName("string_filter"),
																		}...),
																	},
																},
																"string_filter": schema.SingleNestedAttribute{
																	Optional: true,
																	Attributes: map[string]schema.Attribute{
																		"case_sensitive": schema.BoolAttribute{
																			Optional: true,
																		},
																		"match_type": schema.ListAttribute{
																			Optional:    true,
																			ElementType: types.StringType,
																		},
																		"value": schema.StringAttribute{
																			Required: true,
																		},
																	},
																	Validators: []validator.Object{
																		objectvalidator.ConflictsWith(path.Expressions{
																			path.MatchRelative().AtParent().AtName("between_filter"),
																			path.MatchRelative().AtParent().AtName("in_list_filter"),
																			path.MatchRelative().AtParent().AtName("numeric_filter"),
																		}...),
																	},
																},
															},
														},
													},
												},
											},
											Description: `The FilterExpression is NOT of notExpression.`,
											Validators: []validator.Object{
												objectvalidator.ConflictsWith(path.Expressions{
													path.MatchRelative().AtParent().AtName("and_group"),
													path.MatchRelative().AtParent().AtName("filter"),
													path.MatchRelative().AtParent().AtName("or_group"),
												}...),
											},
										},
										"or_group": schema.SingleNestedAttribute{
											Optional: true,
											Attributes: map[string]schema.Attribute{
												"expressions": schema.ListNestedAttribute{
													Required: true,
													NestedObject: schema.NestedAttributeObject{
														Attributes: map[string]schema.Attribute{
															"field_name": schema.StringAttribute{
																Required: true,
															},
															"filter": schema.SingleNestedAttribute{
																Required: true,
																Attributes: map[string]schema.Attribute{
																	"between_filter": schema.SingleNestedAttribute{
																		Optional: true,
																		Attributes: map[string]schema.Attribute{
																			"from_value": schema.SingleNestedAttribute{
																				Required: true,
																				Attributes: map[string]schema.Attribute{
																					"double_value": schema.SingleNestedAttribute{
																						Optional: true,
																						Attributes: map[string]schema.Attribute{
																							"value": schema.NumberAttribute{
																								Required: true,
																							},
																						},
																						Validators: []validator.Object{
																							objectvalidator.ConflictsWith(path.Expressions{
																								path.MatchRelative().AtParent().AtName("int64_value"),
																							}...),
																						},
																					},
																					"int64_value": schema.SingleNestedAttribute{
																						Optional: true,
																						Attributes: map[string]schema.Attribute{
																							"value": schema.StringAttribute{
																								Required: true,
																							},
																						},
																						Validators: []validator.Object{
																							objectvalidator.ConflictsWith(path.Expressions{
																								path.MatchRelative().AtParent().AtName("double_value"),
																							}...),
																						},
																					},
																				},
																			},
																			"to_value": schema.SingleNestedAttribute{
																				Required: true,
																				Attributes: map[string]schema.Attribute{
																					"double_value": schema.SingleNestedAttribute{
																						Optional: true,
																						Attributes: map[string]schema.Attribute{
																							"value": schema.NumberAttribute{
																								Required: true,
																							},
																						},
																						Validators: []validator.Object{
																							objectvalidator.ConflictsWith(path.Expressions{
																								path.MatchRelative().AtParent().AtName("int64_value"),
																							}...),
																						},
																					},
																					"int64_value": schema.SingleNestedAttribute{
																						Optional: true,
																						Attributes: map[string]schema.Attribute{
																							"value": schema.StringAttribute{
																								Required: true,
																							},
																						},
																						Validators: []validator.Object{
																							objectvalidator.ConflictsWith(path.Expressions{
																								path.MatchRelative().AtParent().AtName("double_value"),
																							}...),
																						},
																					},
																				},
																			},
																		},
																		Validators: []validator.Object{
																			objectvalidator.ConflictsWith(path.Expressions{
																				path.MatchRelative().AtParent().AtName("in_list_filter"),
																				path.MatchRelative().AtParent().AtName("numeric_filter"),
																				path.MatchRelative().AtParent().AtName("string_filter"),
																			}...),
																		},
																	},
																	"in_list_filter": schema.SingleNestedAttribute{
																		Optional: true,
																		Attributes: map[string]schema.Attribute{
																			"case_sensitive": schema.BoolAttribute{
																				Optional: true,
																			},
																			"values": schema.ListAttribute{
																				Required:    true,
																				ElementType: types.StringType,
																				Validators: []validator.List{
																					listvalidator.SizeAtLeast(1),
																				},
																			},
																		},
																		Validators: []validator.Object{
																			objectvalidator.ConflictsWith(path.Expressions{
																				path.MatchRelative().AtParent().AtName("between_filter"),
																				path.MatchRelative().AtParent().AtName("numeric_filter"),
																				path.MatchRelative().AtParent().AtName("string_filter"),
																			}...),
																		},
																	},
																	"numeric_filter": schema.SingleNestedAttribute{
																		Optional: true,
																		Attributes: map[string]schema.Attribute{
																			"operation": schema.ListAttribute{
																				Required:    true,
																				ElementType: types.StringType,
																			},
																			"value": schema.SingleNestedAttribute{
																				Required: true,
																				Attributes: map[string]schema.Attribute{
																					"double_value": schema.SingleNestedAttribute{
																						Optional: true,
																						Attributes: map[string]schema.Attribute{
																							"value": schema.NumberAttribute{
																								Required: true,
																							},
																						},
																						Validators: []validator.Object{
																							objectvalidator.ConflictsWith(path.Expressions{
																								path.MatchRelative().AtParent().AtName("int64_value"),
																							}...),
																						},
																					},
																					"int64_value": schema.SingleNestedAttribute{
																						Optional: true,
																						Attributes: map[string]schema.Attribute{
																							"value": schema.StringAttribute{
																								Required: true,
																							},
																						},
																						Validators: []validator.Object{
																							objectvalidator.ConflictsWith(path.Expressions{
																								path.MatchRelative().AtParent().AtName("double_value"),
																							}...),
																						},
																					},
																				},
																			},
																		},
																		Validators: []validator.Object{
																			objectvalidator.ConflictsWith(path.Expressions{
																				path.MatchRelative().AtParent().AtName("between_filter"),
																				path.MatchRelative().AtParent().AtName("in_list_filter"),
																				path.MatchRelative().AtParent().AtName("string_filter"),
																			}...),
																		},
																	},
																	"string_filter": schema.SingleNestedAttribute{
																		Optional: true,
																		Attributes: map[string]schema.Attribute{
																			"case_sensitive": schema.BoolAttribute{
																				Optional: true,
																			},
																			"match_type": schema.ListAttribute{
																				Optional:    true,
																				ElementType: types.StringType,
																			},
																			"value": schema.StringAttribute{
																				Required: true,
																			},
																		},
																		Validators: []validator.Object{
																			objectvalidator.ConflictsWith(path.Expressions{
																				path.MatchRelative().AtParent().AtName("between_filter"),
																				path.MatchRelative().AtParent().AtName("in_list_filter"),
																				path.MatchRelative().AtParent().AtName("numeric_filter"),
																			}...),
																		},
																	},
																},
															},
														},
													},
												},
											},
											Description: `The FilterExpressions in orGroup have an OR relationship.`,
											Validators: []validator.Object{
												objectvalidator.ConflictsWith(path.Expressions{
													path.MatchRelative().AtParent().AtName("and_group"),
													path.MatchRelative().AtParent().AtName("filter"),
													path.MatchRelative().AtParent().AtName("not_expression"),
												}...),
											},
										},
									},
									Description: `Metrics filter`,
								},
								"metrics": schema.ListAttribute{
									Required:    true,
									ElementType: types.StringType,
									Description: `A list of metrics.`,
									Validators: []validator.List{
										listvalidator.SizeAtLeast(1),
									},
								},
								"name": schema.StringAttribute{
									Required:    true,
									Description: `The name of the custom report, this name would be used as stream name.`,
								},
							},
						},
						Description: `You can add your Custom Analytics report by creating one.`,
					},
					"date_ranges_end_date": schema.StringAttribute{
						Optional:    true,
						Description: `The end date from which to replicate report data in the format YYYY-MM-DD. Data generated after this date will not be included in the report. Not applied to custom Cohort reports. When no date is provided or the date is in the future, the date from today is used.`,
						Validators: []validator.String{
							validators.IsValidDate(),
						},
					},
					"date_ranges_start_date": schema.StringAttribute{
						Optional:    true,
						Description: `The start date from which to replicate report data in the format YYYY-MM-DD. Data generated before this date will not be included in the report. Not applied to custom Cohort reports.`,
						Validators: []validator.String{
							validators.IsValidDate(),
						},
					},
					"keep_empty_rows": schema.BoolAttribute{
						Computed:    true,
						Optional:    true,
						Default:     booldefault.StaticBool(false),
						Description: `If false, each row with all metrics equal to 0 will not be returned. If true, these rows will be returned if they are not separately removed by a filter. More information is available in <a href="https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runReport#request-body">the documentation</a>. Default: false`,
					},
					"lookback_window": schema.Int64Attribute{
						Computed:    true,
						Optional:    true,
						Default:     int64default.StaticInt64(2),
						Description: `Since attribution changes after the event date, and Google Analytics has a data processing latency, we should specify how many days in the past we should refresh the data in every run. So if you set it at 5 days, in every sync it will fetch the last bookmark date minus 5 days. Default: 2`,
						Validators: []validator.Int64{
							int64validator.Between(2, 60),
						},
					},
					"property_ids": schema.ListAttribute{
						Required:    true,
						ElementType: types.StringType,
						Description: `A list of your Property IDs. The Property ID is a unique number assigned to each property in Google Analytics, found in your GA4 property URL. This ID allows the connector to track the specific events associated with your property. Refer to the <a href='https://developers.google.com/analytics/devguides/reporting/data/v1/property-id#what_is_my_property_id'>Google Analytics documentation</a> to locate your property ID.`,
						Validators: []validator.List{
							listvalidator.UniqueValues(),
						},
					},
					"window_in_days": schema.Int64Attribute{
						Computed:    true,
						Optional:    true,
						Default:     int64default.StaticInt64(1),
						Description: `The interval in days for each data request made to the Google Analytics API. A larger value speeds up data sync, but increases the chance of data sampling, which may result in inaccuracies. We recommend a value of 1 to minimize sampling, unless speed is an absolute priority over accuracy. Acceptable values range from 1 to 364. Does not apply to custom Cohort reports. More information is available in <a href="https://docs.airbyte.com/integrations/sources/google-analytics-data-api">the documentation</a>. Default: 1`,
						Validators: []validator.Int64{
							int64validator.Between(1, 364),
						},
					},
				},
			},
			"created_at": schema.Int64Attribute{
				Computed: true,
				PlanModifiers: []planmodifier.Int64{
					speakeasy_int64planmodifier.SuppressDiff(speakeasy_int64planmodifier.ExplicitSuppress),
				},
			},
			"definition_id": schema.StringAttribute{
				Computed: true,
				Optional: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.RequiresReplaceIfConfigured(),
					speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
				},
				Description: `The UUID of the connector definition. One of configuration.sourceType or definitionId must be provided. Requires replacement if changed.`,
			},
			"name": schema.StringAttribute{
				Required: true,
				PlanModifiers: []planmodifier.String{
					speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
				},
				Description: `Name of the source e.g. dev-mysql-instance.`,
			},
			"resource_allocation": schema.SingleNestedAttribute{
				Computed: true,
				PlanModifiers: []planmodifier.Object{
					speakeasy_objectplanmodifier.SuppressDiff(speakeasy_objectplanmodifier.ExplicitSuppress),
				},
				Attributes: map[string]schema.Attribute{
					"default": schema.SingleNestedAttribute{
						Computed: true,
						PlanModifiers: []planmodifier.Object{
							speakeasy_objectplanmodifier.SuppressDiff(speakeasy_objectplanmodifier.ExplicitSuppress),
						},
						Attributes: map[string]schema.Attribute{
							"cpu_limit": schema.StringAttribute{
								Computed: true,
								PlanModifiers: []planmodifier.String{
									speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
								},
							},
							"cpu_request": schema.StringAttribute{
								Computed: true,
								PlanModifiers: []planmodifier.String{
									speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
								},
							},
							"ephemeral_storage_limit": schema.StringAttribute{
								Computed: true,
								PlanModifiers: []planmodifier.String{
									speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
								},
							},
							"ephemeral_storage_request": schema.StringAttribute{
								Computed: true,
								PlanModifiers: []planmodifier.String{
									speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
								},
							},
							"memory_limit": schema.StringAttribute{
								Computed: true,
								PlanModifiers: []planmodifier.String{
									speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
								},
							},
							"memory_request": schema.StringAttribute{
								Computed: true,
								PlanModifiers: []planmodifier.String{
									speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
								},
							},
						},
						Description: `optional resource requirements to run workers (blank for unbounded allocations)`,
					},
					"job_specific": schema.ListNestedAttribute{
						Computed: true,
						PlanModifiers: []planmodifier.List{
							speakeasy_listplanmodifier.SuppressDiff(speakeasy_listplanmodifier.ExplicitSuppress),
						},
						NestedObject: schema.NestedAttributeObject{
							PlanModifiers: []planmodifier.Object{
								speakeasy_objectplanmodifier.SuppressDiff(speakeasy_objectplanmodifier.ExplicitSuppress),
							},
							Attributes: map[string]schema.Attribute{
								"job_type": schema.StringAttribute{
									Computed: true,
									PlanModifiers: []planmodifier.String{
										speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
									},
									Description: `enum that describes the different types of jobs that the platform runs. must be one of ["get_spec", "check_connection", "discover_schema", "sync", "reset_connection", "connection_updater", "replicate"]`,
									Validators: []validator.String{
										stringvalidator.OneOf(
											"get_spec",
											"check_connection",
											"discover_schema",
											"sync",
											"reset_connection",
											"connection_updater",
											"replicate",
										),
									},
								},
								"resource_requirements": schema.SingleNestedAttribute{
									Computed: true,
									PlanModifiers: []planmodifier.Object{
										speakeasy_objectplanmodifier.SuppressDiff(speakeasy_objectplanmodifier.ExplicitSuppress),
									},
									Attributes: map[string]schema.Attribute{
										"cpu_limit": schema.StringAttribute{
											Computed: true,
											PlanModifiers: []planmodifier.String{
												speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
											},
										},
										"cpu_request": schema.StringAttribute{
											Computed: true,
											PlanModifiers: []planmodifier.String{
												speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
											},
										},
										"ephemeral_storage_limit": schema.StringAttribute{
											Computed: true,
											PlanModifiers: []planmodifier.String{
												speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
											},
										},
										"ephemeral_storage_request": schema.StringAttribute{
											Computed: true,
											PlanModifiers: []planmodifier.String{
												speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
											},
										},
										"memory_limit": schema.StringAttribute{
											Computed: true,
											PlanModifiers: []planmodifier.String{
												speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
											},
										},
										"memory_request": schema.StringAttribute{
											Computed: true,
											PlanModifiers: []planmodifier.String{
												speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
											},
										},
									},
									Description: `optional resource requirements to run workers (blank for unbounded allocations)`,
								},
							},
						},
					},
				},
				Description: `actor or actor definition specific resource requirements. if default is set, these are the requirements that should be set for ALL jobs run for this actor definition. it is overriden by the job type specific configurations. if not set, the platform will use defaults. these values will be overriden by configuration at the connection level.`,
			},
			"secret_id": schema.StringAttribute{
				Optional: true,
				PlanModifiers: []planmodifier.String{
					stringplanmodifier.RequiresReplaceIfConfigured(),
				},
				Description: `Optional secretID obtained through the public API OAuth redirect flow. Requires replacement if changed.`,
			},
			"source_id": schema.StringAttribute{
				Computed: true,
				PlanModifiers: []planmodifier.String{
					speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
				},
			},
			"source_type": schema.StringAttribute{
				Computed: true,
				PlanModifiers: []planmodifier.String{
					speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
				},
			},
			"workspace_id": schema.StringAttribute{
				Required: true,
				PlanModifiers: []planmodifier.String{
					speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
				},
			},
		},
	}
}

func (r *SourceGoogleAnalyticsDataAPIResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
	// Prevent panic if the provider has not been configured.
	if req.ProviderData == nil {
		return
	}

	client, ok := req.ProviderData.(*sdk.SDK)

	if !ok {
		resp.Diagnostics.AddError(
			"Unexpected Resource Configure Type",
			fmt.Sprintf("Expected *sdk.SDK, got: %T. Please report this issue to the provider developers.", req.ProviderData),
		)

		return
	}

	r.client = client
}

func (r *SourceGoogleAnalyticsDataAPIResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
	var data *SourceGoogleAnalyticsDataAPIResourceModel
	var plan types.Object

	resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...)
	if resp.Diagnostics.HasError() {
		return
	}

	resp.Diagnostics.Append(plan.As(ctx, &data, basetypes.ObjectAsOptions{
		UnhandledNullAsEmpty:    true,
		UnhandledUnknownAsEmpty: true,
	})...)

	if resp.Diagnostics.HasError() {
		return
	}

	request := data.ToSharedSourceGoogleAnalyticsDataAPICreateRequest()
	res, err := r.client.Sources.CreateSourceGoogleAnalyticsDataAPI(ctx, request)
	if err != nil {
		resp.Diagnostics.AddError("failure to invoke API", err.Error())
		if res != nil && res.RawResponse != nil {
			resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse))
		}
		return
	}
	if res == nil {
		resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res))
		return
	}
	if res.StatusCode != 200 {
		resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse))
		return
	}
	if !(res.SourceResponse != nil) {
		resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse))
		return
	}
	data.RefreshFromSharedSourceResponse(res.SourceResponse)
	refreshPlan(ctx, plan, &data, resp.Diagnostics)
	var sourceID string
	sourceID = data.SourceID.ValueString()

	request1 := operations.GetSourceGoogleAnalyticsDataAPIRequest{
		SourceID: sourceID,
	}
	res1, err := r.client.Sources.GetSourceGoogleAnalyticsDataAPI(ctx, request1)
	if err != nil {
		resp.Diagnostics.AddError("failure to invoke API", err.Error())
		if res1 != nil && res1.RawResponse != nil {
			resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res1.RawResponse))
		}
		return
	}
	if res1 == nil {
		resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res1))
		return
	}
	if res1.StatusCode != 200 {
		resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res1.StatusCode), debugResponse(res1.RawResponse))
		return
	}
	if !(res1.SourceResponse != nil) {
		resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res1.RawResponse))
		return
	}
	data.RefreshFromSharedSourceResponse(res1.SourceResponse)
	refreshPlan(ctx, plan, &data, resp.Diagnostics)

	// Save updated data into Terraform state
	resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
}

func (r *SourceGoogleAnalyticsDataAPIResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
	var data *SourceGoogleAnalyticsDataAPIResourceModel
	var item types.Object

	resp.Diagnostics.Append(req.State.Get(ctx, &item)...)
	if resp.Diagnostics.HasError() {
		return
	}

	resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{
		UnhandledNullAsEmpty:    true,
		UnhandledUnknownAsEmpty: true,
	})...)

	if resp.Diagnostics.HasError() {
		return
	}

	var sourceID string
	sourceID = data.SourceID.ValueString()

	request := operations.GetSourceGoogleAnalyticsDataAPIRequest{
		SourceID: sourceID,
	}
	res, err := r.client.Sources.GetSourceGoogleAnalyticsDataAPI(ctx, request)
	if err != nil {
		resp.Diagnostics.AddError("failure to invoke API", err.Error())
		if res != nil && res.RawResponse != nil {
			resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse))
		}
		return
	}
	if res == nil {
		resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res))
		return
	}
	if res.StatusCode == 404 {
		resp.State.RemoveResource(ctx)
		return
	}
	if res.StatusCode != 200 {
		resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse))
		return
	}
	if !(res.SourceResponse != nil) {
		resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse))
		return
	}
	data.RefreshFromSharedSourceResponse(res.SourceResponse)

	// Save updated data into Terraform state
	resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
}

func (r *SourceGoogleAnalyticsDataAPIResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
	var data *SourceGoogleAnalyticsDataAPIResourceModel
	var plan types.Object

	resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...)
	if resp.Diagnostics.HasError() {
		return
	}

	merge(ctx, req, resp, &data)
	if resp.Diagnostics.HasError() {
		return
	}

	var sourceID string
	sourceID = data.SourceID.ValueString()

	sourceGoogleAnalyticsDataAPIPutRequest := data.ToSharedSourceGoogleAnalyticsDataAPIPutRequest()
	request := operations.PutSourceGoogleAnalyticsDataAPIRequest{
		SourceID:                               sourceID,
		SourceGoogleAnalyticsDataAPIPutRequest: sourceGoogleAnalyticsDataAPIPutRequest,
	}
	res, err := r.client.Sources.PutSourceGoogleAnalyticsDataAPI(ctx, request)
	if err != nil {
		resp.Diagnostics.AddError("failure to invoke API", err.Error())
		if res != nil && res.RawResponse != nil {
			resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse))
		}
		return
	}
	if res == nil {
		resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res))
		return
	}
	if fmt.Sprintf("%v", res.StatusCode)[0] != '2' {
		resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse))
		return
	}
	refreshPlan(ctx, plan, &data, resp.Diagnostics)
	var sourceId1 string
	sourceId1 = data.SourceID.ValueString()

	request1 := operations.GetSourceGoogleAnalyticsDataAPIRequest{
		SourceID: sourceId1,
	}
	res1, err := r.client.Sources.GetSourceGoogleAnalyticsDataAPI(ctx, request1)
	if err != nil {
		resp.Diagnostics.AddError("failure to invoke API", err.Error())
		if res1 != nil && res1.RawResponse != nil {
			resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res1.RawResponse))
		}
		return
	}
	if res1 == nil {
		resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res1))
		return
	}
	if res1.StatusCode != 200 {
		resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res1.StatusCode), debugResponse(res1.RawResponse))
		return
	}
	if !(res1.SourceResponse != nil) {
		resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res1.RawResponse))
		return
	}
	data.RefreshFromSharedSourceResponse(res1.SourceResponse)
	refreshPlan(ctx, plan, &data, resp.Diagnostics)

	// Save updated data into Terraform state
	resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
}

func (r *SourceGoogleAnalyticsDataAPIResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
	var data *SourceGoogleAnalyticsDataAPIResourceModel
	var item types.Object

	resp.Diagnostics.Append(req.State.Get(ctx, &item)...)
	if resp.Diagnostics.HasError() {
		return
	}

	resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{
		UnhandledNullAsEmpty:    true,
		UnhandledUnknownAsEmpty: true,
	})...)

	if resp.Diagnostics.HasError() {
		return
	}

	var sourceID string
	sourceID = data.SourceID.ValueString()

	request := operations.DeleteSourceGoogleAnalyticsDataAPIRequest{
		SourceID: sourceID,
	}
	res, err := r.client.Sources.DeleteSourceGoogleAnalyticsDataAPI(ctx, request)
	if err != nil {
		resp.Diagnostics.AddError("failure to invoke API", err.Error())
		if res != nil && res.RawResponse != nil {
			resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse))
		}
		return
	}
	if res == nil {
		resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res))
		return
	}
	if fmt.Sprintf("%v", res.StatusCode)[0] != '2' {
		resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse))
		return
	}

}

func (r *SourceGoogleAnalyticsDataAPIResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
	resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("source_id"), req.ID)...)
}
