From aa4e3c54466c596aa9fbe1f7a49c6609ec4b346e Mon Sep 17 00:00:00 2001 From: Ramon Snir Date: Tue, 21 May 2024 10:07:25 -0400 Subject: [PATCH] site build settings --- UPDATING_OPENAPI_JSON.md | 5 +- examples/site_settings/main.tf | 22 + internal/netlifyapi/.openapi-generator/FILES | 1 + internal/netlifyapi/api/openapi.yaml | 194 ++- internal/netlifyapi/api_sites.go | 12 +- internal/netlifyapi/model_partial_site.go | 1451 +++++++++++++++++ internal/netlifyapi/model_repo.go | 37 + internal/provider/common_tf_models.go | 10 +- internal/provider/dns_zone_data_source.go | 4 +- internal/provider/dns_zone_resource.go | 6 +- internal/provider/provider.go | 1 + .../provider/site_build_settings_resource.go | 268 +++ internal/provider/site_data_source.go | 32 +- internal/provider/sites_data_source.go | 16 +- openapi.json | 140 +- 15 files changed, 2157 insertions(+), 42 deletions(-) create mode 100644 examples/site_settings/main.tf create mode 100644 internal/netlifyapi/model_partial_site.go create mode 100644 internal/provider/site_build_settings_resource.go diff --git a/UPDATING_OPENAPI_JSON.md b/UPDATING_OPENAPI_JSON.md index fae113b..aacfe13 100644 --- a/UPDATING_OPENAPI_JSON.md +++ b/UPDATING_OPENAPI_JSON.md @@ -10,4 +10,7 @@ This project uses a modified `openapi.json`. Please maintain these instructions 1. Remove all required properties from the `Repo` object (manual builds). 1. Remove the `domain` property from the `required` array of the `DnsZone` object. 1. Remove the `values`, `scopes` and `is_secret` parameters from the `updateEnvVar` operation. -1. Add a request body schema to the `updateEnvVar` operation, by copying it from an earlier version of the `openapi.json`. \ No newline at end of file +1. Add a request body schema to the `updateEnvVar` operation, by copying it from an earlier version of the `openapi.json`. +1. Add a `package_path` property of type string to the `Repo` object. +1. Duplicate the `Site` object into `PartialSite` and remove the `required` properties. +1. Change `updateSite` operation to use the `PartialSite` object as the request body schema (NOTE: not the response body schema). \ No newline at end of file diff --git a/examples/site_settings/main.tf b/examples/site_settings/main.tf new file mode 100644 index 0000000..01cab0f --- /dev/null +++ b/examples/site_settings/main.tf @@ -0,0 +1,22 @@ +terraform { + required_providers { + netlify = { + source = "registry.terraform.io/netlify/netlify" + } + } + required_version = ">= 1.6.0" +} + +# `token` comes from NETLIFY_API_TOKEN, but can be specified with a Terraform variable +provider "netlify" {} + +data "netlify_site" "platform_test" { + account_slug = "ramon-test-1" + name = "platform-test-1" +} + +resource "netlify_site_build_settings" "platform_test" { + site_id = data.netlify_site.platform_test.id + build_command = "npm run build" + publish_directory = "dist" +} diff --git a/internal/netlifyapi/.openapi-generator/FILES b/internal/netlifyapi/.openapi-generator/FILES index 07d7f25..f0612ae 100644 --- a/internal/netlifyapi/.openapi-generator/FILES +++ b/internal/netlifyapi/.openapi-generator/FILES @@ -164,6 +164,7 @@ model_organization_account.go model_outgoing_hook.go model_outgoing_hook_type.go model_outgoing_hook_type_fields_inner.go +model_partial_site.go model_payment_method.go model_payment_method_data.go model_plugin.go diff --git a/internal/netlifyapi/api/openapi.yaml b/internal/netlifyapi/api/openapi.yaml index 5090467..2a2f3a7 100644 --- a/internal/netlifyapi/api/openapi.yaml +++ b/internal/netlifyapi/api/openapi.yaml @@ -4088,7 +4088,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Site' + $ref: '#/components/schemas/PartialSite' description: "" required: true responses: @@ -9667,15 +9667,10 @@ components: Repo: description: Repo model definition example: - repo_url: repo_url repo_type: repo_type - stop_builds: true - skip_automatic_builds: true - deploy_key_id: deploy_key_id created_at: 2000-01-23T04:56:07.000+00:00 installation_id: 0 dir: dir - env: "{}" repo_branch: repo_branch base_rel_dir: true private_logs: true @@ -9683,13 +9678,19 @@ components: - allowed_branches - allowed_branches functions_dir: functions_dir - repo_path: repo_path - untrusted_flow: untrusted_flow skip_prs: true updated_at: 2000-01-23T04:56:07.000+00:00 provider: provider public_repo: true repo_owner_type: repo_owner_type + repo_url: repo_url + stop_builds: true + package_path: package_path + skip_automatic_builds: true + deploy_key_id: deploy_key_id + env: "{}" + repo_path: repo_path + untrusted_flow: untrusted_flow cmd: cmd base: base configuration_file_path: configuration_file_path @@ -9719,6 +9720,8 @@ components: type: string installation_id: type: integer + package_path: + type: string private_logs: type: boolean provider: @@ -10063,15 +10066,10 @@ components: capabilities: "{}" admin_url: admin_url build_settings: - repo_url: repo_url repo_type: repo_type - stop_builds: true - skip_automatic_builds: true - deploy_key_id: deploy_key_id created_at: 2000-01-23T04:56:07.000+00:00 installation_id: 0 dir: dir - env: "{}" repo_branch: repo_branch base_rel_dir: true private_logs: true @@ -10079,13 +10077,19 @@ components: - allowed_branches - allowed_branches functions_dir: functions_dir - repo_path: repo_path - untrusted_flow: untrusted_flow skip_prs: true updated_at: 2000-01-23T04:56:07.000+00:00 provider: provider public_repo: true repo_owner_type: repo_owner_type + repo_url: repo_url + stop_builds: true + package_path: package_path + skip_automatic_builds: true + deploy_key_id: deploy_key_id + env: "{}" + repo_path: repo_path + untrusted_flow: untrusted_flow cmd: cmd base: base configuration_file_path: configuration_file_path @@ -10230,6 +10234,166 @@ components: - state - updated_at - url + PartialSite: + description: Site model definition + example: + sso_login: true + id_domain: id_domain + deploy_url: deploy_url + deploy_hook: deploy_hook + created_at: 2000-01-23T04:56:07.000+00:00 + sso_login_context: sso_login_context + domain_aliases: + - domain_aliases + - domain_aliases + password: password + updated_at: 2000-01-23T04:56:07.000+00:00 + password_hash: password_hash + account_name: account_name + deploy_retention_in_days: 6.027456183070403 + id: id + state: state + plan: plan + default_domain: default_domain + custom_domain: custom_domain + deploy_preview_custom_domain: deploy_preview_custom_domain + managed_dns: true + force_ssl: true + notification_email: notification_email + capabilities: "{}" + admin_url: admin_url + build_settings: + repo_type: repo_type + created_at: 2000-01-23T04:56:07.000+00:00 + installation_id: 0 + dir: dir + repo_branch: repo_branch + base_rel_dir: true + private_logs: true + allowed_branches: + - allowed_branches + - allowed_branches + functions_dir: functions_dir + skip_prs: true + updated_at: 2000-01-23T04:56:07.000+00:00 + provider: provider + public_repo: true + repo_owner_type: repo_owner_type + repo_url: repo_url + stop_builds: true + package_path: package_path + skip_automatic_builds: true + deploy_key_id: deploy_key_id + env: "{}" + repo_path: repo_path + untrusted_flow: untrusted_flow + cmd: cmd + base: base + configuration_file_path: configuration_file_path + password_context: password_context + url: url + labels: + - account_id: account_id + color: color + name: name + description: description + id: id + - account_id: account_id + color: color + name: name + description: description + id: id + account_slug: account_slug + account_id: account_id + ssl_url: ssl_url + name: name + processing_settings: + html: + pretty_urls: true + ignore_html_forms: true + build_image: build_image + branch_deploy_custom_domain: branch_deploy_custom_domain + screenshot_url: screenshot_url + build_timelimit: 0.8008281904610115 + properties: + id: + type: string + plan: + type: string + name: + type: string + default_domain: + type: string + custom_domain: + type: string + branch_deploy_custom_domain: + type: string + deploy_preview_custom_domain: + type: string + domain_aliases: + items: + type: string + type: array + password: + type: string + password_context: + type: string + password_hash: + type: string + sso_login: + type: boolean + sso_login_context: + type: string + notification_email: + type: string + url: + type: string + admin_url: + type: string + deploy_url: + type: string + state: + type: string + screenshot_url: + type: string + created_at: + format: date-time + type: string + updated_at: + format: date-time + type: string + ssl_url: + type: string + force_ssl: + type: boolean + build_settings: + $ref: '#/components/schemas/Repo' + processing_settings: + $ref: '#/components/schemas/Site_processing_settings' + deploy_hook: + type: string + managed_dns: + type: boolean + account_id: + type: string + account_slug: + type: string + account_name: + type: string + capabilities: + type: object + id_domain: + type: string + build_image: + type: string + build_timelimit: + type: number + deploy_retention_in_days: + type: number + labels: + items: + $ref: '#/components/schemas/SiteLabel' + type: array SitesSummary: description: SitesSummary model definition properties: diff --git a/internal/netlifyapi/api_sites.go b/internal/netlifyapi/api_sites.go index 3c185f2..646095c 100644 --- a/internal/netlifyapi/api_sites.go +++ b/internal/netlifyapi/api_sites.go @@ -1227,12 +1227,12 @@ type ApiUpdateSiteRequest struct { ctx context.Context ApiService *SitesAPIService siteId string - site *Site + partialSite *PartialSite } // -func (r ApiUpdateSiteRequest) Site(site Site) ApiUpdateSiteRequest { - r.site = &site +func (r ApiUpdateSiteRequest) PartialSite(partialSite PartialSite) ApiUpdateSiteRequest { + r.partialSite = &partialSite return r } @@ -1278,8 +1278,8 @@ func (a *SitesAPIService) UpdateSiteExecute(r ApiUpdateSiteRequest) (*Site, *htt localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - if r.site == nil { - return localVarReturnValue, nil, reportError("site is required and must be specified") + if r.partialSite == nil { + return localVarReturnValue, nil, reportError("partialSite is required and must be specified") } // to determine the Content-Type header @@ -1300,7 +1300,7 @@ func (a *SitesAPIService) UpdateSiteExecute(r ApiUpdateSiteRequest) (*Site, *htt localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept } // body params - localVarPostBody = r.site + localVarPostBody = r.partialSite req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) if err != nil { return localVarReturnValue, nil, err diff --git a/internal/netlifyapi/model_partial_site.go b/internal/netlifyapi/model_partial_site.go new file mode 100644 index 0000000..d5994ee --- /dev/null +++ b/internal/netlifyapi/model_partial_site.go @@ -0,0 +1,1451 @@ +/* +Netlify's API documentation + +Netlify is a hosting service for the programmable web. It understands your documents and provides an API to handle atomic deploys of websites, manage form submissions, inject JavaScript snippets, and much more. This is a REST-style API that uses JSON for serialization and OAuth 2 for authentication. This document is an OpenAPI reference for the Netlify API that you can explore. For more detailed instructions for common uses, please visit the [online documentation](https://docs.netlify.com/api/get-started/). Visit our Community forum to join the conversation about [understanding and using Netlify’s API](https://community.netlify.com/t/common-issue-understanding-and-using-netlifys-api/160). Additionally, we have two API clients for your convenience: - [Go Client](https://github.com/netlify/open-api#go-client) - [JS Client](https://github.com/netlify/js-client) + +API version: 1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package netlifyapi + +import ( + "encoding/json" + "time" +) + +// checks if the PartialSite type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &PartialSite{} + +// PartialSite Site model definition +type PartialSite struct { + Id *string `json:"id,omitempty"` + Plan *string `json:"plan,omitempty"` + Name *string `json:"name,omitempty"` + DefaultDomain *string `json:"default_domain,omitempty"` + CustomDomain *string `json:"custom_domain,omitempty"` + BranchDeployCustomDomain *string `json:"branch_deploy_custom_domain,omitempty"` + DeployPreviewCustomDomain *string `json:"deploy_preview_custom_domain,omitempty"` + DomainAliases []string `json:"domain_aliases,omitempty"` + Password *string `json:"password,omitempty"` + PasswordContext *string `json:"password_context,omitempty"` + PasswordHash *string `json:"password_hash,omitempty"` + SsoLogin *bool `json:"sso_login,omitempty"` + SsoLoginContext *string `json:"sso_login_context,omitempty"` + NotificationEmail *string `json:"notification_email,omitempty"` + Url *string `json:"url,omitempty"` + AdminUrl *string `json:"admin_url,omitempty"` + DeployUrl *string `json:"deploy_url,omitempty"` + State *string `json:"state,omitempty"` + ScreenshotUrl *string `json:"screenshot_url,omitempty"` + CreatedAt *time.Time `json:"created_at,omitempty"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` + SslUrl *string `json:"ssl_url,omitempty"` + ForceSsl *bool `json:"force_ssl,omitempty"` + BuildSettings *Repo `json:"build_settings,omitempty"` + ProcessingSettings *SiteProcessingSettings `json:"processing_settings,omitempty"` + DeployHook *string `json:"deploy_hook,omitempty"` + ManagedDns *bool `json:"managed_dns,omitempty"` + AccountId *string `json:"account_id,omitempty"` + AccountSlug *string `json:"account_slug,omitempty"` + AccountName *string `json:"account_name,omitempty"` + Capabilities map[string]interface{} `json:"capabilities,omitempty"` + IdDomain *string `json:"id_domain,omitempty"` + BuildImage *string `json:"build_image,omitempty"` + BuildTimelimit *float32 `json:"build_timelimit,omitempty"` + DeployRetentionInDays *float32 `json:"deploy_retention_in_days,omitempty"` + Labels []SiteLabel `json:"labels,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _PartialSite PartialSite + +// NewPartialSite instantiates a new PartialSite object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewPartialSite() *PartialSite { + this := PartialSite{} + return &this +} + +// NewPartialSiteWithDefaults instantiates a new PartialSite object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewPartialSiteWithDefaults() *PartialSite { + this := PartialSite{} + return &this +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *PartialSite) GetId() string { + if o == nil || IsNil(o.Id) { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetIdOk() (*string, bool) { + if o == nil || IsNil(o.Id) { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *PartialSite) HasId() bool { + if o != nil && !IsNil(o.Id) { + return true + } + + return false +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *PartialSite) SetId(v string) { + o.Id = &v +} + +// GetPlan returns the Plan field value if set, zero value otherwise. +func (o *PartialSite) GetPlan() string { + if o == nil || IsNil(o.Plan) { + var ret string + return ret + } + return *o.Plan +} + +// GetPlanOk returns a tuple with the Plan field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetPlanOk() (*string, bool) { + if o == nil || IsNil(o.Plan) { + return nil, false + } + return o.Plan, true +} + +// HasPlan returns a boolean if a field has been set. +func (o *PartialSite) HasPlan() bool { + if o != nil && !IsNil(o.Plan) { + return true + } + + return false +} + +// SetPlan gets a reference to the given string and assigns it to the Plan field. +func (o *PartialSite) SetPlan(v string) { + o.Plan = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *PartialSite) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *PartialSite) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *PartialSite) SetName(v string) { + o.Name = &v +} + +// GetDefaultDomain returns the DefaultDomain field value if set, zero value otherwise. +func (o *PartialSite) GetDefaultDomain() string { + if o == nil || IsNil(o.DefaultDomain) { + var ret string + return ret + } + return *o.DefaultDomain +} + +// GetDefaultDomainOk returns a tuple with the DefaultDomain field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetDefaultDomainOk() (*string, bool) { + if o == nil || IsNil(o.DefaultDomain) { + return nil, false + } + return o.DefaultDomain, true +} + +// HasDefaultDomain returns a boolean if a field has been set. +func (o *PartialSite) HasDefaultDomain() bool { + if o != nil && !IsNil(o.DefaultDomain) { + return true + } + + return false +} + +// SetDefaultDomain gets a reference to the given string and assigns it to the DefaultDomain field. +func (o *PartialSite) SetDefaultDomain(v string) { + o.DefaultDomain = &v +} + +// GetCustomDomain returns the CustomDomain field value if set, zero value otherwise. +func (o *PartialSite) GetCustomDomain() string { + if o == nil || IsNil(o.CustomDomain) { + var ret string + return ret + } + return *o.CustomDomain +} + +// GetCustomDomainOk returns a tuple with the CustomDomain field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetCustomDomainOk() (*string, bool) { + if o == nil || IsNil(o.CustomDomain) { + return nil, false + } + return o.CustomDomain, true +} + +// HasCustomDomain returns a boolean if a field has been set. +func (o *PartialSite) HasCustomDomain() bool { + if o != nil && !IsNil(o.CustomDomain) { + return true + } + + return false +} + +// SetCustomDomain gets a reference to the given string and assigns it to the CustomDomain field. +func (o *PartialSite) SetCustomDomain(v string) { + o.CustomDomain = &v +} + +// GetBranchDeployCustomDomain returns the BranchDeployCustomDomain field value if set, zero value otherwise. +func (o *PartialSite) GetBranchDeployCustomDomain() string { + if o == nil || IsNil(o.BranchDeployCustomDomain) { + var ret string + return ret + } + return *o.BranchDeployCustomDomain +} + +// GetBranchDeployCustomDomainOk returns a tuple with the BranchDeployCustomDomain field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetBranchDeployCustomDomainOk() (*string, bool) { + if o == nil || IsNil(o.BranchDeployCustomDomain) { + return nil, false + } + return o.BranchDeployCustomDomain, true +} + +// HasBranchDeployCustomDomain returns a boolean if a field has been set. +func (o *PartialSite) HasBranchDeployCustomDomain() bool { + if o != nil && !IsNil(o.BranchDeployCustomDomain) { + return true + } + + return false +} + +// SetBranchDeployCustomDomain gets a reference to the given string and assigns it to the BranchDeployCustomDomain field. +func (o *PartialSite) SetBranchDeployCustomDomain(v string) { + o.BranchDeployCustomDomain = &v +} + +// GetDeployPreviewCustomDomain returns the DeployPreviewCustomDomain field value if set, zero value otherwise. +func (o *PartialSite) GetDeployPreviewCustomDomain() string { + if o == nil || IsNil(o.DeployPreviewCustomDomain) { + var ret string + return ret + } + return *o.DeployPreviewCustomDomain +} + +// GetDeployPreviewCustomDomainOk returns a tuple with the DeployPreviewCustomDomain field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetDeployPreviewCustomDomainOk() (*string, bool) { + if o == nil || IsNil(o.DeployPreviewCustomDomain) { + return nil, false + } + return o.DeployPreviewCustomDomain, true +} + +// HasDeployPreviewCustomDomain returns a boolean if a field has been set. +func (o *PartialSite) HasDeployPreviewCustomDomain() bool { + if o != nil && !IsNil(o.DeployPreviewCustomDomain) { + return true + } + + return false +} + +// SetDeployPreviewCustomDomain gets a reference to the given string and assigns it to the DeployPreviewCustomDomain field. +func (o *PartialSite) SetDeployPreviewCustomDomain(v string) { + o.DeployPreviewCustomDomain = &v +} + +// GetDomainAliases returns the DomainAliases field value if set, zero value otherwise. +func (o *PartialSite) GetDomainAliases() []string { + if o == nil || IsNil(o.DomainAliases) { + var ret []string + return ret + } + return o.DomainAliases +} + +// GetDomainAliasesOk returns a tuple with the DomainAliases field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetDomainAliasesOk() ([]string, bool) { + if o == nil || IsNil(o.DomainAliases) { + return nil, false + } + return o.DomainAliases, true +} + +// HasDomainAliases returns a boolean if a field has been set. +func (o *PartialSite) HasDomainAliases() bool { + if o != nil && !IsNil(o.DomainAliases) { + return true + } + + return false +} + +// SetDomainAliases gets a reference to the given []string and assigns it to the DomainAliases field. +func (o *PartialSite) SetDomainAliases(v []string) { + o.DomainAliases = v +} + +// GetPassword returns the Password field value if set, zero value otherwise. +func (o *PartialSite) GetPassword() string { + if o == nil || IsNil(o.Password) { + var ret string + return ret + } + return *o.Password +} + +// GetPasswordOk returns a tuple with the Password field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetPasswordOk() (*string, bool) { + if o == nil || IsNil(o.Password) { + return nil, false + } + return o.Password, true +} + +// HasPassword returns a boolean if a field has been set. +func (o *PartialSite) HasPassword() bool { + if o != nil && !IsNil(o.Password) { + return true + } + + return false +} + +// SetPassword gets a reference to the given string and assigns it to the Password field. +func (o *PartialSite) SetPassword(v string) { + o.Password = &v +} + +// GetPasswordContext returns the PasswordContext field value if set, zero value otherwise. +func (o *PartialSite) GetPasswordContext() string { + if o == nil || IsNil(o.PasswordContext) { + var ret string + return ret + } + return *o.PasswordContext +} + +// GetPasswordContextOk returns a tuple with the PasswordContext field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetPasswordContextOk() (*string, bool) { + if o == nil || IsNil(o.PasswordContext) { + return nil, false + } + return o.PasswordContext, true +} + +// HasPasswordContext returns a boolean if a field has been set. +func (o *PartialSite) HasPasswordContext() bool { + if o != nil && !IsNil(o.PasswordContext) { + return true + } + + return false +} + +// SetPasswordContext gets a reference to the given string and assigns it to the PasswordContext field. +func (o *PartialSite) SetPasswordContext(v string) { + o.PasswordContext = &v +} + +// GetPasswordHash returns the PasswordHash field value if set, zero value otherwise. +func (o *PartialSite) GetPasswordHash() string { + if o == nil || IsNil(o.PasswordHash) { + var ret string + return ret + } + return *o.PasswordHash +} + +// GetPasswordHashOk returns a tuple with the PasswordHash field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetPasswordHashOk() (*string, bool) { + if o == nil || IsNil(o.PasswordHash) { + return nil, false + } + return o.PasswordHash, true +} + +// HasPasswordHash returns a boolean if a field has been set. +func (o *PartialSite) HasPasswordHash() bool { + if o != nil && !IsNil(o.PasswordHash) { + return true + } + + return false +} + +// SetPasswordHash gets a reference to the given string and assigns it to the PasswordHash field. +func (o *PartialSite) SetPasswordHash(v string) { + o.PasswordHash = &v +} + +// GetSsoLogin returns the SsoLogin field value if set, zero value otherwise. +func (o *PartialSite) GetSsoLogin() bool { + if o == nil || IsNil(o.SsoLogin) { + var ret bool + return ret + } + return *o.SsoLogin +} + +// GetSsoLoginOk returns a tuple with the SsoLogin field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetSsoLoginOk() (*bool, bool) { + if o == nil || IsNil(o.SsoLogin) { + return nil, false + } + return o.SsoLogin, true +} + +// HasSsoLogin returns a boolean if a field has been set. +func (o *PartialSite) HasSsoLogin() bool { + if o != nil && !IsNil(o.SsoLogin) { + return true + } + + return false +} + +// SetSsoLogin gets a reference to the given bool and assigns it to the SsoLogin field. +func (o *PartialSite) SetSsoLogin(v bool) { + o.SsoLogin = &v +} + +// GetSsoLoginContext returns the SsoLoginContext field value if set, zero value otherwise. +func (o *PartialSite) GetSsoLoginContext() string { + if o == nil || IsNil(o.SsoLoginContext) { + var ret string + return ret + } + return *o.SsoLoginContext +} + +// GetSsoLoginContextOk returns a tuple with the SsoLoginContext field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetSsoLoginContextOk() (*string, bool) { + if o == nil || IsNil(o.SsoLoginContext) { + return nil, false + } + return o.SsoLoginContext, true +} + +// HasSsoLoginContext returns a boolean if a field has been set. +func (o *PartialSite) HasSsoLoginContext() bool { + if o != nil && !IsNil(o.SsoLoginContext) { + return true + } + + return false +} + +// SetSsoLoginContext gets a reference to the given string and assigns it to the SsoLoginContext field. +func (o *PartialSite) SetSsoLoginContext(v string) { + o.SsoLoginContext = &v +} + +// GetNotificationEmail returns the NotificationEmail field value if set, zero value otherwise. +func (o *PartialSite) GetNotificationEmail() string { + if o == nil || IsNil(o.NotificationEmail) { + var ret string + return ret + } + return *o.NotificationEmail +} + +// GetNotificationEmailOk returns a tuple with the NotificationEmail field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetNotificationEmailOk() (*string, bool) { + if o == nil || IsNil(o.NotificationEmail) { + return nil, false + } + return o.NotificationEmail, true +} + +// HasNotificationEmail returns a boolean if a field has been set. +func (o *PartialSite) HasNotificationEmail() bool { + if o != nil && !IsNil(o.NotificationEmail) { + return true + } + + return false +} + +// SetNotificationEmail gets a reference to the given string and assigns it to the NotificationEmail field. +func (o *PartialSite) SetNotificationEmail(v string) { + o.NotificationEmail = &v +} + +// GetUrl returns the Url field value if set, zero value otherwise. +func (o *PartialSite) GetUrl() string { + if o == nil || IsNil(o.Url) { + var ret string + return ret + } + return *o.Url +} + +// GetUrlOk returns a tuple with the Url field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetUrlOk() (*string, bool) { + if o == nil || IsNil(o.Url) { + return nil, false + } + return o.Url, true +} + +// HasUrl returns a boolean if a field has been set. +func (o *PartialSite) HasUrl() bool { + if o != nil && !IsNil(o.Url) { + return true + } + + return false +} + +// SetUrl gets a reference to the given string and assigns it to the Url field. +func (o *PartialSite) SetUrl(v string) { + o.Url = &v +} + +// GetAdminUrl returns the AdminUrl field value if set, zero value otherwise. +func (o *PartialSite) GetAdminUrl() string { + if o == nil || IsNil(o.AdminUrl) { + var ret string + return ret + } + return *o.AdminUrl +} + +// GetAdminUrlOk returns a tuple with the AdminUrl field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetAdminUrlOk() (*string, bool) { + if o == nil || IsNil(o.AdminUrl) { + return nil, false + } + return o.AdminUrl, true +} + +// HasAdminUrl returns a boolean if a field has been set. +func (o *PartialSite) HasAdminUrl() bool { + if o != nil && !IsNil(o.AdminUrl) { + return true + } + + return false +} + +// SetAdminUrl gets a reference to the given string and assigns it to the AdminUrl field. +func (o *PartialSite) SetAdminUrl(v string) { + o.AdminUrl = &v +} + +// GetDeployUrl returns the DeployUrl field value if set, zero value otherwise. +func (o *PartialSite) GetDeployUrl() string { + if o == nil || IsNil(o.DeployUrl) { + var ret string + return ret + } + return *o.DeployUrl +} + +// GetDeployUrlOk returns a tuple with the DeployUrl field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetDeployUrlOk() (*string, bool) { + if o == nil || IsNil(o.DeployUrl) { + return nil, false + } + return o.DeployUrl, true +} + +// HasDeployUrl returns a boolean if a field has been set. +func (o *PartialSite) HasDeployUrl() bool { + if o != nil && !IsNil(o.DeployUrl) { + return true + } + + return false +} + +// SetDeployUrl gets a reference to the given string and assigns it to the DeployUrl field. +func (o *PartialSite) SetDeployUrl(v string) { + o.DeployUrl = &v +} + +// GetState returns the State field value if set, zero value otherwise. +func (o *PartialSite) GetState() string { + if o == nil || IsNil(o.State) { + var ret string + return ret + } + return *o.State +} + +// GetStateOk returns a tuple with the State field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetStateOk() (*string, bool) { + if o == nil || IsNil(o.State) { + return nil, false + } + return o.State, true +} + +// HasState returns a boolean if a field has been set. +func (o *PartialSite) HasState() bool { + if o != nil && !IsNil(o.State) { + return true + } + + return false +} + +// SetState gets a reference to the given string and assigns it to the State field. +func (o *PartialSite) SetState(v string) { + o.State = &v +} + +// GetScreenshotUrl returns the ScreenshotUrl field value if set, zero value otherwise. +func (o *PartialSite) GetScreenshotUrl() string { + if o == nil || IsNil(o.ScreenshotUrl) { + var ret string + return ret + } + return *o.ScreenshotUrl +} + +// GetScreenshotUrlOk returns a tuple with the ScreenshotUrl field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetScreenshotUrlOk() (*string, bool) { + if o == nil || IsNil(o.ScreenshotUrl) { + return nil, false + } + return o.ScreenshotUrl, true +} + +// HasScreenshotUrl returns a boolean if a field has been set. +func (o *PartialSite) HasScreenshotUrl() bool { + if o != nil && !IsNil(o.ScreenshotUrl) { + return true + } + + return false +} + +// SetScreenshotUrl gets a reference to the given string and assigns it to the ScreenshotUrl field. +func (o *PartialSite) SetScreenshotUrl(v string) { + o.ScreenshotUrl = &v +} + +// GetCreatedAt returns the CreatedAt field value if set, zero value otherwise. +func (o *PartialSite) GetCreatedAt() time.Time { + if o == nil || IsNil(o.CreatedAt) { + var ret time.Time + return ret + } + return *o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetCreatedAtOk() (*time.Time, bool) { + if o == nil || IsNil(o.CreatedAt) { + return nil, false + } + return o.CreatedAt, true +} + +// HasCreatedAt returns a boolean if a field has been set. +func (o *PartialSite) HasCreatedAt() bool { + if o != nil && !IsNil(o.CreatedAt) { + return true + } + + return false +} + +// SetCreatedAt gets a reference to the given time.Time and assigns it to the CreatedAt field. +func (o *PartialSite) SetCreatedAt(v time.Time) { + o.CreatedAt = &v +} + +// GetUpdatedAt returns the UpdatedAt field value if set, zero value otherwise. +func (o *PartialSite) GetUpdatedAt() time.Time { + if o == nil || IsNil(o.UpdatedAt) { + var ret time.Time + return ret + } + return *o.UpdatedAt +} + +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetUpdatedAtOk() (*time.Time, bool) { + if o == nil || IsNil(o.UpdatedAt) { + return nil, false + } + return o.UpdatedAt, true +} + +// HasUpdatedAt returns a boolean if a field has been set. +func (o *PartialSite) HasUpdatedAt() bool { + if o != nil && !IsNil(o.UpdatedAt) { + return true + } + + return false +} + +// SetUpdatedAt gets a reference to the given time.Time and assigns it to the UpdatedAt field. +func (o *PartialSite) SetUpdatedAt(v time.Time) { + o.UpdatedAt = &v +} + +// GetSslUrl returns the SslUrl field value if set, zero value otherwise. +func (o *PartialSite) GetSslUrl() string { + if o == nil || IsNil(o.SslUrl) { + var ret string + return ret + } + return *o.SslUrl +} + +// GetSslUrlOk returns a tuple with the SslUrl field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetSslUrlOk() (*string, bool) { + if o == nil || IsNil(o.SslUrl) { + return nil, false + } + return o.SslUrl, true +} + +// HasSslUrl returns a boolean if a field has been set. +func (o *PartialSite) HasSslUrl() bool { + if o != nil && !IsNil(o.SslUrl) { + return true + } + + return false +} + +// SetSslUrl gets a reference to the given string and assigns it to the SslUrl field. +func (o *PartialSite) SetSslUrl(v string) { + o.SslUrl = &v +} + +// GetForceSsl returns the ForceSsl field value if set, zero value otherwise. +func (o *PartialSite) GetForceSsl() bool { + if o == nil || IsNil(o.ForceSsl) { + var ret bool + return ret + } + return *o.ForceSsl +} + +// GetForceSslOk returns a tuple with the ForceSsl field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetForceSslOk() (*bool, bool) { + if o == nil || IsNil(o.ForceSsl) { + return nil, false + } + return o.ForceSsl, true +} + +// HasForceSsl returns a boolean if a field has been set. +func (o *PartialSite) HasForceSsl() bool { + if o != nil && !IsNil(o.ForceSsl) { + return true + } + + return false +} + +// SetForceSsl gets a reference to the given bool and assigns it to the ForceSsl field. +func (o *PartialSite) SetForceSsl(v bool) { + o.ForceSsl = &v +} + +// GetBuildSettings returns the BuildSettings field value if set, zero value otherwise. +func (o *PartialSite) GetBuildSettings() Repo { + if o == nil || IsNil(o.BuildSettings) { + var ret Repo + return ret + } + return *o.BuildSettings +} + +// GetBuildSettingsOk returns a tuple with the BuildSettings field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetBuildSettingsOk() (*Repo, bool) { + if o == nil || IsNil(o.BuildSettings) { + return nil, false + } + return o.BuildSettings, true +} + +// HasBuildSettings returns a boolean if a field has been set. +func (o *PartialSite) HasBuildSettings() bool { + if o != nil && !IsNil(o.BuildSettings) { + return true + } + + return false +} + +// SetBuildSettings gets a reference to the given Repo and assigns it to the BuildSettings field. +func (o *PartialSite) SetBuildSettings(v Repo) { + o.BuildSettings = &v +} + +// GetProcessingSettings returns the ProcessingSettings field value if set, zero value otherwise. +func (o *PartialSite) GetProcessingSettings() SiteProcessingSettings { + if o == nil || IsNil(o.ProcessingSettings) { + var ret SiteProcessingSettings + return ret + } + return *o.ProcessingSettings +} + +// GetProcessingSettingsOk returns a tuple with the ProcessingSettings field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetProcessingSettingsOk() (*SiteProcessingSettings, bool) { + if o == nil || IsNil(o.ProcessingSettings) { + return nil, false + } + return o.ProcessingSettings, true +} + +// HasProcessingSettings returns a boolean if a field has been set. +func (o *PartialSite) HasProcessingSettings() bool { + if o != nil && !IsNil(o.ProcessingSettings) { + return true + } + + return false +} + +// SetProcessingSettings gets a reference to the given SiteProcessingSettings and assigns it to the ProcessingSettings field. +func (o *PartialSite) SetProcessingSettings(v SiteProcessingSettings) { + o.ProcessingSettings = &v +} + +// GetDeployHook returns the DeployHook field value if set, zero value otherwise. +func (o *PartialSite) GetDeployHook() string { + if o == nil || IsNil(o.DeployHook) { + var ret string + return ret + } + return *o.DeployHook +} + +// GetDeployHookOk returns a tuple with the DeployHook field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetDeployHookOk() (*string, bool) { + if o == nil || IsNil(o.DeployHook) { + return nil, false + } + return o.DeployHook, true +} + +// HasDeployHook returns a boolean if a field has been set. +func (o *PartialSite) HasDeployHook() bool { + if o != nil && !IsNil(o.DeployHook) { + return true + } + + return false +} + +// SetDeployHook gets a reference to the given string and assigns it to the DeployHook field. +func (o *PartialSite) SetDeployHook(v string) { + o.DeployHook = &v +} + +// GetManagedDns returns the ManagedDns field value if set, zero value otherwise. +func (o *PartialSite) GetManagedDns() bool { + if o == nil || IsNil(o.ManagedDns) { + var ret bool + return ret + } + return *o.ManagedDns +} + +// GetManagedDnsOk returns a tuple with the ManagedDns field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetManagedDnsOk() (*bool, bool) { + if o == nil || IsNil(o.ManagedDns) { + return nil, false + } + return o.ManagedDns, true +} + +// HasManagedDns returns a boolean if a field has been set. +func (o *PartialSite) HasManagedDns() bool { + if o != nil && !IsNil(o.ManagedDns) { + return true + } + + return false +} + +// SetManagedDns gets a reference to the given bool and assigns it to the ManagedDns field. +func (o *PartialSite) SetManagedDns(v bool) { + o.ManagedDns = &v +} + +// GetAccountId returns the AccountId field value if set, zero value otherwise. +func (o *PartialSite) GetAccountId() string { + if o == nil || IsNil(o.AccountId) { + var ret string + return ret + } + return *o.AccountId +} + +// GetAccountIdOk returns a tuple with the AccountId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetAccountIdOk() (*string, bool) { + if o == nil || IsNil(o.AccountId) { + return nil, false + } + return o.AccountId, true +} + +// HasAccountId returns a boolean if a field has been set. +func (o *PartialSite) HasAccountId() bool { + if o != nil && !IsNil(o.AccountId) { + return true + } + + return false +} + +// SetAccountId gets a reference to the given string and assigns it to the AccountId field. +func (o *PartialSite) SetAccountId(v string) { + o.AccountId = &v +} + +// GetAccountSlug returns the AccountSlug field value if set, zero value otherwise. +func (o *PartialSite) GetAccountSlug() string { + if o == nil || IsNil(o.AccountSlug) { + var ret string + return ret + } + return *o.AccountSlug +} + +// GetAccountSlugOk returns a tuple with the AccountSlug field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetAccountSlugOk() (*string, bool) { + if o == nil || IsNil(o.AccountSlug) { + return nil, false + } + return o.AccountSlug, true +} + +// HasAccountSlug returns a boolean if a field has been set. +func (o *PartialSite) HasAccountSlug() bool { + if o != nil && !IsNil(o.AccountSlug) { + return true + } + + return false +} + +// SetAccountSlug gets a reference to the given string and assigns it to the AccountSlug field. +func (o *PartialSite) SetAccountSlug(v string) { + o.AccountSlug = &v +} + +// GetAccountName returns the AccountName field value if set, zero value otherwise. +func (o *PartialSite) GetAccountName() string { + if o == nil || IsNil(o.AccountName) { + var ret string + return ret + } + return *o.AccountName +} + +// GetAccountNameOk returns a tuple with the AccountName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetAccountNameOk() (*string, bool) { + if o == nil || IsNil(o.AccountName) { + return nil, false + } + return o.AccountName, true +} + +// HasAccountName returns a boolean if a field has been set. +func (o *PartialSite) HasAccountName() bool { + if o != nil && !IsNil(o.AccountName) { + return true + } + + return false +} + +// SetAccountName gets a reference to the given string and assigns it to the AccountName field. +func (o *PartialSite) SetAccountName(v string) { + o.AccountName = &v +} + +// GetCapabilities returns the Capabilities field value if set, zero value otherwise. +func (o *PartialSite) GetCapabilities() map[string]interface{} { + if o == nil || IsNil(o.Capabilities) { + var ret map[string]interface{} + return ret + } + return o.Capabilities +} + +// GetCapabilitiesOk returns a tuple with the Capabilities field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetCapabilitiesOk() (map[string]interface{}, bool) { + if o == nil || IsNil(o.Capabilities) { + return map[string]interface{}{}, false + } + return o.Capabilities, true +} + +// HasCapabilities returns a boolean if a field has been set. +func (o *PartialSite) HasCapabilities() bool { + if o != nil && !IsNil(o.Capabilities) { + return true + } + + return false +} + +// SetCapabilities gets a reference to the given map[string]interface{} and assigns it to the Capabilities field. +func (o *PartialSite) SetCapabilities(v map[string]interface{}) { + o.Capabilities = v +} + +// GetIdDomain returns the IdDomain field value if set, zero value otherwise. +func (o *PartialSite) GetIdDomain() string { + if o == nil || IsNil(o.IdDomain) { + var ret string + return ret + } + return *o.IdDomain +} + +// GetIdDomainOk returns a tuple with the IdDomain field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetIdDomainOk() (*string, bool) { + if o == nil || IsNil(o.IdDomain) { + return nil, false + } + return o.IdDomain, true +} + +// HasIdDomain returns a boolean if a field has been set. +func (o *PartialSite) HasIdDomain() bool { + if o != nil && !IsNil(o.IdDomain) { + return true + } + + return false +} + +// SetIdDomain gets a reference to the given string and assigns it to the IdDomain field. +func (o *PartialSite) SetIdDomain(v string) { + o.IdDomain = &v +} + +// GetBuildImage returns the BuildImage field value if set, zero value otherwise. +func (o *PartialSite) GetBuildImage() string { + if o == nil || IsNil(o.BuildImage) { + var ret string + return ret + } + return *o.BuildImage +} + +// GetBuildImageOk returns a tuple with the BuildImage field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetBuildImageOk() (*string, bool) { + if o == nil || IsNil(o.BuildImage) { + return nil, false + } + return o.BuildImage, true +} + +// HasBuildImage returns a boolean if a field has been set. +func (o *PartialSite) HasBuildImage() bool { + if o != nil && !IsNil(o.BuildImage) { + return true + } + + return false +} + +// SetBuildImage gets a reference to the given string and assigns it to the BuildImage field. +func (o *PartialSite) SetBuildImage(v string) { + o.BuildImage = &v +} + +// GetBuildTimelimit returns the BuildTimelimit field value if set, zero value otherwise. +func (o *PartialSite) GetBuildTimelimit() float32 { + if o == nil || IsNil(o.BuildTimelimit) { + var ret float32 + return ret + } + return *o.BuildTimelimit +} + +// GetBuildTimelimitOk returns a tuple with the BuildTimelimit field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetBuildTimelimitOk() (*float32, bool) { + if o == nil || IsNil(o.BuildTimelimit) { + return nil, false + } + return o.BuildTimelimit, true +} + +// HasBuildTimelimit returns a boolean if a field has been set. +func (o *PartialSite) HasBuildTimelimit() bool { + if o != nil && !IsNil(o.BuildTimelimit) { + return true + } + + return false +} + +// SetBuildTimelimit gets a reference to the given float32 and assigns it to the BuildTimelimit field. +func (o *PartialSite) SetBuildTimelimit(v float32) { + o.BuildTimelimit = &v +} + +// GetDeployRetentionInDays returns the DeployRetentionInDays field value if set, zero value otherwise. +func (o *PartialSite) GetDeployRetentionInDays() float32 { + if o == nil || IsNil(o.DeployRetentionInDays) { + var ret float32 + return ret + } + return *o.DeployRetentionInDays +} + +// GetDeployRetentionInDaysOk returns a tuple with the DeployRetentionInDays field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetDeployRetentionInDaysOk() (*float32, bool) { + if o == nil || IsNil(o.DeployRetentionInDays) { + return nil, false + } + return o.DeployRetentionInDays, true +} + +// HasDeployRetentionInDays returns a boolean if a field has been set. +func (o *PartialSite) HasDeployRetentionInDays() bool { + if o != nil && !IsNil(o.DeployRetentionInDays) { + return true + } + + return false +} + +// SetDeployRetentionInDays gets a reference to the given float32 and assigns it to the DeployRetentionInDays field. +func (o *PartialSite) SetDeployRetentionInDays(v float32) { + o.DeployRetentionInDays = &v +} + +// GetLabels returns the Labels field value if set, zero value otherwise. +func (o *PartialSite) GetLabels() []SiteLabel { + if o == nil || IsNil(o.Labels) { + var ret []SiteLabel + return ret + } + return o.Labels +} + +// GetLabelsOk returns a tuple with the Labels field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PartialSite) GetLabelsOk() ([]SiteLabel, bool) { + if o == nil || IsNil(o.Labels) { + return nil, false + } + return o.Labels, true +} + +// HasLabels returns a boolean if a field has been set. +func (o *PartialSite) HasLabels() bool { + if o != nil && !IsNil(o.Labels) { + return true + } + + return false +} + +// SetLabels gets a reference to the given []SiteLabel and assigns it to the Labels field. +func (o *PartialSite) SetLabels(v []SiteLabel) { + o.Labels = v +} + +func (o PartialSite) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o PartialSite) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Id) { + toSerialize["id"] = o.Id + } + if !IsNil(o.Plan) { + toSerialize["plan"] = o.Plan + } + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.DefaultDomain) { + toSerialize["default_domain"] = o.DefaultDomain + } + if !IsNil(o.CustomDomain) { + toSerialize["custom_domain"] = o.CustomDomain + } + if !IsNil(o.BranchDeployCustomDomain) { + toSerialize["branch_deploy_custom_domain"] = o.BranchDeployCustomDomain + } + if !IsNil(o.DeployPreviewCustomDomain) { + toSerialize["deploy_preview_custom_domain"] = o.DeployPreviewCustomDomain + } + if !IsNil(o.DomainAliases) { + toSerialize["domain_aliases"] = o.DomainAliases + } + if !IsNil(o.Password) { + toSerialize["password"] = o.Password + } + if !IsNil(o.PasswordContext) { + toSerialize["password_context"] = o.PasswordContext + } + if !IsNil(o.PasswordHash) { + toSerialize["password_hash"] = o.PasswordHash + } + if !IsNil(o.SsoLogin) { + toSerialize["sso_login"] = o.SsoLogin + } + if !IsNil(o.SsoLoginContext) { + toSerialize["sso_login_context"] = o.SsoLoginContext + } + if !IsNil(o.NotificationEmail) { + toSerialize["notification_email"] = o.NotificationEmail + } + if !IsNil(o.Url) { + toSerialize["url"] = o.Url + } + if !IsNil(o.AdminUrl) { + toSerialize["admin_url"] = o.AdminUrl + } + if !IsNil(o.DeployUrl) { + toSerialize["deploy_url"] = o.DeployUrl + } + if !IsNil(o.State) { + toSerialize["state"] = o.State + } + if !IsNil(o.ScreenshotUrl) { + toSerialize["screenshot_url"] = o.ScreenshotUrl + } + if !IsNil(o.CreatedAt) { + toSerialize["created_at"] = o.CreatedAt + } + if !IsNil(o.UpdatedAt) { + toSerialize["updated_at"] = o.UpdatedAt + } + if !IsNil(o.SslUrl) { + toSerialize["ssl_url"] = o.SslUrl + } + if !IsNil(o.ForceSsl) { + toSerialize["force_ssl"] = o.ForceSsl + } + if !IsNil(o.BuildSettings) { + toSerialize["build_settings"] = o.BuildSettings + } + if !IsNil(o.ProcessingSettings) { + toSerialize["processing_settings"] = o.ProcessingSettings + } + if !IsNil(o.DeployHook) { + toSerialize["deploy_hook"] = o.DeployHook + } + if !IsNil(o.ManagedDns) { + toSerialize["managed_dns"] = o.ManagedDns + } + if !IsNil(o.AccountId) { + toSerialize["account_id"] = o.AccountId + } + if !IsNil(o.AccountSlug) { + toSerialize["account_slug"] = o.AccountSlug + } + if !IsNil(o.AccountName) { + toSerialize["account_name"] = o.AccountName + } + if !IsNil(o.Capabilities) { + toSerialize["capabilities"] = o.Capabilities + } + if !IsNil(o.IdDomain) { + toSerialize["id_domain"] = o.IdDomain + } + if !IsNil(o.BuildImage) { + toSerialize["build_image"] = o.BuildImage + } + if !IsNil(o.BuildTimelimit) { + toSerialize["build_timelimit"] = o.BuildTimelimit + } + if !IsNil(o.DeployRetentionInDays) { + toSerialize["deploy_retention_in_days"] = o.DeployRetentionInDays + } + if !IsNil(o.Labels) { + toSerialize["labels"] = o.Labels + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *PartialSite) UnmarshalJSON(data []byte) (err error) { + varPartialSite := _PartialSite{} + + err = json.Unmarshal(data, &varPartialSite) + + if err != nil { + return err + } + + *o = PartialSite(varPartialSite) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "id") + delete(additionalProperties, "plan") + delete(additionalProperties, "name") + delete(additionalProperties, "default_domain") + delete(additionalProperties, "custom_domain") + delete(additionalProperties, "branch_deploy_custom_domain") + delete(additionalProperties, "deploy_preview_custom_domain") + delete(additionalProperties, "domain_aliases") + delete(additionalProperties, "password") + delete(additionalProperties, "password_context") + delete(additionalProperties, "password_hash") + delete(additionalProperties, "sso_login") + delete(additionalProperties, "sso_login_context") + delete(additionalProperties, "notification_email") + delete(additionalProperties, "url") + delete(additionalProperties, "admin_url") + delete(additionalProperties, "deploy_url") + delete(additionalProperties, "state") + delete(additionalProperties, "screenshot_url") + delete(additionalProperties, "created_at") + delete(additionalProperties, "updated_at") + delete(additionalProperties, "ssl_url") + delete(additionalProperties, "force_ssl") + delete(additionalProperties, "build_settings") + delete(additionalProperties, "processing_settings") + delete(additionalProperties, "deploy_hook") + delete(additionalProperties, "managed_dns") + delete(additionalProperties, "account_id") + delete(additionalProperties, "account_slug") + delete(additionalProperties, "account_name") + delete(additionalProperties, "capabilities") + delete(additionalProperties, "id_domain") + delete(additionalProperties, "build_image") + delete(additionalProperties, "build_timelimit") + delete(additionalProperties, "deploy_retention_in_days") + delete(additionalProperties, "labels") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullablePartialSite struct { + value *PartialSite + isSet bool +} + +func (v NullablePartialSite) Get() *PartialSite { + return v.value +} + +func (v *NullablePartialSite) Set(val *PartialSite) { + v.value = val + v.isSet = true +} + +func (v NullablePartialSite) IsSet() bool { + return v.isSet +} + +func (v *NullablePartialSite) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePartialSite(val *PartialSite) *NullablePartialSite { + return &NullablePartialSite{value: val, isSet: true} +} + +func (v NullablePartialSite) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePartialSite) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/internal/netlifyapi/model_repo.go b/internal/netlifyapi/model_repo.go index 150caf6..8758709 100644 --- a/internal/netlifyapi/model_repo.go +++ b/internal/netlifyapi/model_repo.go @@ -31,6 +31,7 @@ type Repo struct { Env map[string]interface{} `json:"env,omitempty"` FunctionsDir *string `json:"functions_dir,omitempty"` InstallationId *int64 `json:"installation_id,omitempty"` + PackagePath *string `json:"package_path,omitempty"` PrivateLogs *bool `json:"private_logs,omitempty"` Provider *string `json:"provider,omitempty"` PublicRepo *bool `json:"public_repo,omitempty"` @@ -419,6 +420,38 @@ func (o *Repo) SetInstallationId(v int64) { o.InstallationId = &v } +// GetPackagePath returns the PackagePath field value if set, zero value otherwise. +func (o *Repo) GetPackagePath() string { + if o == nil || IsNil(o.PackagePath) { + var ret string + return ret + } + return *o.PackagePath +} + +// GetPackagePathOk returns a tuple with the PackagePath field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Repo) GetPackagePathOk() (*string, bool) { + if o == nil || IsNil(o.PackagePath) { + return nil, false + } + return o.PackagePath, true +} + +// HasPackagePath returns a boolean if a field has been set. +func (o *Repo) HasPackagePath() bool { + if o != nil && !IsNil(o.PackagePath) { + return true + } + + return false +} + +// SetPackagePath gets a reference to the given string and assigns it to the PackagePath field. +func (o *Repo) SetPackagePath(v string) { + o.PackagePath = &v +} + // GetPrivateLogs returns the PrivateLogs field value if set, zero value otherwise. func (o *Repo) GetPrivateLogs() bool { if o == nil || IsNil(o.PrivateLogs) { @@ -878,6 +911,9 @@ func (o Repo) ToMap() (map[string]interface{}, error) { if !IsNil(o.InstallationId) { toSerialize["installation_id"] = o.InstallationId } + if !IsNil(o.PackagePath) { + toSerialize["package_path"] = o.PackagePath + } if !IsNil(o.PrivateLogs) { toSerialize["private_logs"] = o.PrivateLogs } @@ -950,6 +986,7 @@ func (o *Repo) UnmarshalJSON(data []byte) (err error) { delete(additionalProperties, "env") delete(additionalProperties, "functions_dir") delete(additionalProperties, "installation_id") + delete(additionalProperties, "package_path") delete(additionalProperties, "private_logs") delete(additionalProperties, "provider") delete(additionalProperties, "public_repo") diff --git a/internal/provider/common_tf_models.go b/internal/provider/common_tf_models.go index bcbdfea..9a2b606 100644 --- a/internal/provider/common_tf_models.go +++ b/internal/provider/common_tf_models.go @@ -2,7 +2,7 @@ package provider import "github.com/hashicorp/terraform-plugin-framework/types" -type NetlifyDomainModel struct { +type netlifyDomainModel struct { ID types.String `tfsdk:"id"` Name types.String `tfsdk:"name"` RegisteredAt types.String `tfsdk:"registered_at"` @@ -11,11 +11,3 @@ type NetlifyDomainModel struct { AutoRenew types.Bool `tfsdk:"auto_renew"` AutoRenewAt types.String `tfsdk:"auto_renew_at"` } - -type NetlifySiteModel struct { - ID types.String `tfsdk:"id"` - AccountSlug types.String `tfsdk:"account_slug"` - Name types.String `tfsdk:"name"` - CustomDomain types.String `tfsdk:"custom_domain"` - DomainAliases []types.String `tfsdk:"domain_aliases"` -} diff --git a/internal/provider/dns_zone_data_source.go b/internal/provider/dns_zone_data_source.go index 4ce1b16..3e19e77 100644 --- a/internal/provider/dns_zone_data_source.go +++ b/internal/provider/dns_zone_data_source.go @@ -34,7 +34,7 @@ type dnsZoneDataSourceModel struct { AccountID types.String `tfsdk:"account_id"` AccountSlug types.String `tfsdk:"account_slug"` DnsServers types.List `tfsdk:"dns_servers"` - Domain *NetlifyDomainModel `tfsdk:"domain"` + Domain *netlifyDomainModel `tfsdk:"domain"` Records []dnsRecordModel `tfsdk:"records"` } @@ -214,7 +214,7 @@ func (d *dnsZoneDataSource) Read(ctx context.Context, req datasource.ReadRequest if zone.Domain == nil { config.Domain = nil } else { - config.Domain = &NetlifyDomainModel{ + config.Domain = &netlifyDomainModel{ ID: types.StringValue(zone.Domain.Id), Name: types.StringValue(zone.Domain.Name), RegisteredAt: types.StringValue(zone.Domain.RegisteredAt.Format(time.RFC3339)), diff --git a/internal/provider/dns_zone_resource.go b/internal/provider/dns_zone_resource.go index 60e6aa2..1f006f4 100644 --- a/internal/provider/dns_zone_resource.go +++ b/internal/provider/dns_zone_resource.go @@ -37,7 +37,7 @@ type dnsZoneResourceModel struct { AccountID types.String `tfsdk:"account_id"` AccountSlug types.String `tfsdk:"account_slug"` DnsServers types.List `tfsdk:"dns_servers"` - Domain *NetlifyDomainModel `tfsdk:"domain"` + Domain *netlifyDomainModel `tfsdk:"domain"` } func (r *dnsZoneResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { @@ -169,7 +169,7 @@ func (r *dnsZoneResource) Create(ctx context.Context, req resource.CreateRequest if dnsZone.Domain == nil { plan.Domain = nil } else { - plan.Domain = &NetlifyDomainModel{ + plan.Domain = &netlifyDomainModel{ ID: types.StringValue(dnsZone.Domain.Id), Name: types.StringValue(dnsZone.Domain.Name), RegisteredAt: types.StringValue(dnsZone.Domain.RegisteredAt.Format(time.RFC3339)), @@ -218,7 +218,7 @@ func (r *dnsZoneResource) Read(ctx context.Context, req resource.ReadRequest, re if dnsZone.Domain == nil { state.Domain = nil } else { - state.Domain = &NetlifyDomainModel{ + state.Domain = &netlifyDomainModel{ ID: types.StringValue(dnsZone.Domain.Id), Name: types.StringValue(dnsZone.Domain.Name), RegisteredAt: types.StringValue(dnsZone.Domain.RegisteredAt.Format(time.RFC3339)), diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 116370c..049cf63 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -138,6 +138,7 @@ func (p *NetlifyProvider) Resources(ctx context.Context) []func() resource.Resou NewDnsRecordResource, NewDnsZoneResource, NewEnvironmentVariableResource, + NewSiteBuildSettingsResource, } } diff --git a/internal/provider/site_build_settings_resource.go b/internal/provider/site_build_settings_resource.go new file mode 100644 index 0000000..dd86c3d --- /dev/null +++ b/internal/provider/site_build_settings_resource.go @@ -0,0 +1,268 @@ +package provider + +import ( + "context" + "fmt" + "time" + + "github.com/hashicorp/terraform-plugin-framework/diag" + "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/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/netlify/terraform-provider-netlify/internal/netlifyapi" +) + +var ( + _ resource.Resource = &siteBuildSettingsResource{} + _ resource.ResourceWithConfigure = &siteBuildSettingsResource{} + _ resource.ResourceWithImportState = &siteBuildSettingsResource{} +) + +func NewSiteBuildSettingsResource() resource.Resource { + return &siteBuildSettingsResource{} +} + +type siteBuildSettingsResource struct { + data NetlifyProviderData +} + +type siteBuildSettingsResourceModel struct { + SiteID types.String `tfsdk:"site_id"` + LastUpdated types.String `tfsdk:"last_updated"` + BaseDirectory types.String `tfsdk:"base_directory"` + PackageDirectory types.String `tfsdk:"package_directory"` + BuildCommand types.String `tfsdk:"build_command"` + PublishDirectory types.String `tfsdk:"publish_directory"` + FunctionsDirectory types.String `tfsdk:"functions_directory"` + StopBuilds types.Bool `tfsdk:"stop_builds"` + // Runtime types.String `tfsdk:"runtime"` // ?!?! is this plugins.package? + + BuildImage types.String `tfsdk:"build_image"` + // NodeJSVersion types.String `tfsdk:"node_js_version"` // versions.node.active / default: versions.node.active or versions.node.default + + PrettyURLs types.Bool `tfsdk:"pretty_urls"` +} + +func (r *siteBuildSettingsResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_site_build_settings" +} + +func (r *siteBuildSettingsResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + data, ok := req.ProviderData.(NetlifyProviderData) + + if !ok { + resp.Diagnostics.AddError( + "Unexpected Resource Configure Type", + fmt.Sprintf("Expected NetlifyProviderData, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + return + } + + r.data = data +} + +func (r *siteBuildSettingsResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { + resp.Schema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "site_id": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + }, + "last_updated": schema.StringAttribute{ + Computed: true, + }, + // "runtime": schema.StringAttribute{ + // Optional: true, + // }, + "base_directory": schema.StringAttribute{ + Optional: true, + Computed: true, + Default: stringdefault.StaticString(""), + }, + "package_directory": schema.StringAttribute{ + Optional: true, + Computed: true, + Default: stringdefault.StaticString(""), + }, + "build_command": schema.StringAttribute{ + Required: true, + }, + "publish_directory": schema.StringAttribute{ + Required: true, + }, + "functions_directory": schema.StringAttribute{ + Optional: true, + Computed: true, + Default: stringdefault.StaticString(""), + }, + "stop_builds": schema.BoolAttribute{ + Optional: true, + Computed: true, + Default: booldefault.StaticBool(false), + }, + "build_image": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + // "node_js_version": schema.StringAttribute{ + // Optional: true, + // Computed: true, + // PlanModifiers: []planmodifier.String{ + // stringplanmodifier.UseStateForUnknown(), + // }, + // }, + "pretty_urls": schema.BoolAttribute{ + Optional: true, + Computed: true, + Default: booldefault.StaticBool(true), + }, + }, + } +} + +func (r *siteBuildSettingsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + var plan siteBuildSettingsResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + r.write(ctx, &plan, &resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) + if resp.Diagnostics.HasError() { + return + } +} + +func (r *siteBuildSettingsResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state siteBuildSettingsResourceModel + resp.Diagnostics.Append(req.State.Get(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } + + r.read(ctx, &state, &resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } +} + +func (r *siteBuildSettingsResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + var plan siteBuildSettingsResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + r.write(ctx, &plan, &resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, plan)...) + if resp.Diagnostics.HasError() { + return + } +} + +func (r *siteBuildSettingsResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + var state siteBuildSettingsResourceModel + resp.Diagnostics.Append(req.State.Get(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.AddWarning("Site build settings are now unmanaged.", "Site build settings are now unmanaged. The site will continue to build with the last settings.") +} + +func (r *siteBuildSettingsResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + resource.ImportStatePassthroughID(ctx, path.Root("site_id"), req, resp) +} + +func (r *siteBuildSettingsResource) read(ctx context.Context, state *siteBuildSettingsResourceModel, diagnostics *diag.Diagnostics) { + site, _, err := r.data.client.SitesAPI.GetSite(ctx, state.SiteID.ValueString()).Execute() + if err != nil { + diagnostics.AddError( + "Error reading site build settings", + fmt.Sprintf("Could not read site build settings for site %q: %q", state.SiteID.ValueString(), err.Error()), + ) + return + } + + state.BaseDirectory = types.StringPointerValue(site.BuildSettings.Base) + state.PackageDirectory = types.StringPointerValue(site.BuildSettings.PackagePath) + state.BuildCommand = types.StringPointerValue(site.BuildSettings.Cmd) + state.PublishDirectory = types.StringPointerValue(site.BuildSettings.Dir) + state.FunctionsDirectory = types.StringPointerValue(site.BuildSettings.FunctionsDir) + state.StopBuilds = types.BoolPointerValue(site.BuildSettings.StopBuilds) + state.BuildImage = types.StringValue(site.BuildImage) + state.PrettyURLs = types.BoolPointerValue(site.ProcessingSettings.Html.PrettyUrls) +} + +func (r *siteBuildSettingsResource) write(ctx context.Context, plan *siteBuildSettingsResourceModel, diagnostics *diag.Diagnostics) { + var curState siteBuildSettingsResourceModel + curState.SiteID = plan.SiteID + r.read(ctx, &curState, diagnostics) + if diagnostics.HasError() { + return + } + + site := netlifyapi.PartialSite{ + BuildSettings: &netlifyapi.Repo{ + Base: plan.BaseDirectory.ValueStringPointer(), + PackagePath: plan.PackageDirectory.ValueStringPointer(), + Cmd: plan.BuildCommand.ValueStringPointer(), + Dir: plan.PublishDirectory.ValueStringPointer(), + FunctionsDir: plan.FunctionsDirectory.ValueStringPointer(), + StopBuilds: plan.StopBuilds.ValueBoolPointer(), + }, + ProcessingSettings: &netlifyapi.SiteProcessingSettings{ + Html: &netlifyapi.SiteProcessingSettingsHtml{ + PrettyUrls: plan.PrettyURLs.ValueBoolPointer(), + }, + }, + } + + if plan.BuildImage.IsUnknown() || plan.BuildImage.IsNull() { + site.BuildImage = curState.BuildImage.ValueStringPointer() + } else { + site.BuildImage = plan.BuildImage.ValueStringPointer() + } + + _, _, err := r.data.client.SitesAPI. + UpdateSite(ctx, plan.SiteID.ValueString()). + PartialSite(site). + Execute() + if err != nil { + diagnostics.AddError( + "Error updating site build settings", + fmt.Sprintf("Could not update site build settings for site %q: %q", plan.SiteID.ValueString(), err.Error()), + ) + return + } + + plan.LastUpdated = types.StringValue(time.Now().Format(time.RFC850)) +} diff --git a/internal/provider/site_data_source.go b/internal/provider/site_data_source.go index e77c9b5..b08d62b 100644 --- a/internal/provider/site_data_source.go +++ b/internal/provider/site_data_source.go @@ -26,6 +26,15 @@ type siteDataSource struct { data NetlifyProviderData } +type siteModel struct { + ID types.String `tfsdk:"id"` + AccountSlug types.String `tfsdk:"account_slug"` + Name types.String `tfsdk:"name"` + CustomDomain types.String `tfsdk:"custom_domain"` + DomainAliases []types.String `tfsdk:"domain_aliases"` + GitDeployKey types.String `tfsdk:"git_deploy_key"` +} + func (d *siteDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { if req.ProviderData == nil { return @@ -75,12 +84,15 @@ func (d *siteDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, r Computed: true, ElementType: types.StringType, }, + "git_deploy_key": schema.StringAttribute{ + Computed: true, + }, }, } } func (d *siteDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - var config NetlifySiteModel + var config siteModel resp.Diagnostics.Append(req.Config.Get(ctx, &config)...) if resp.Diagnostics.HasError() { return @@ -118,6 +130,19 @@ func (d *siteDataSource) Read(ctx context.Context, req datasource.ReadRequest, r } } + var siteDeployKey *netlifyapi.DeployKey + if site.BuildSettings.DeployKeyId != nil { + var err error + siteDeployKey, _, err = d.data.client.DeployKeysAPI.GetDeployKey(ctx, *site.BuildSettings.DeployKeyId).Execute() + if siteDeployKey == nil || err != nil { + resp.Diagnostics.AddError( + "Error reading site deploy key", + fmt.Sprintf("Could not read site deploy key for site %q: %q", site.Id, err.Error()), + ) + return + } + } + config.ID = types.StringValue(site.Id) config.AccountSlug = types.StringValue(site.AccountSlug) config.Name = types.StringValue(site.Name) @@ -126,6 +151,11 @@ func (d *siteDataSource) Read(ctx context.Context, req datasource.ReadRequest, r for i, alias := range site.DomainAliases { config.DomainAliases[i] = types.StringValue(alias) } + if siteDeployKey != nil { + config.GitDeployKey = types.StringValue(siteDeployKey.PublicKey) + } else { + config.GitDeployKey = types.StringNull() + } resp.Diagnostics.Append(resp.State.Set(ctx, &config)...) if resp.Diagnostics.HasError() { diff --git a/internal/provider/sites_data_source.go b/internal/provider/sites_data_source.go index f0afb52..87e2f92 100644 --- a/internal/provider/sites_data_source.go +++ b/internal/provider/sites_data_source.go @@ -23,8 +23,16 @@ type sitesDataSource struct { } type sitesDataSourceModel struct { - AccountSlug types.String `tfsdk:"account_slug"` - Sites []NetlifySiteModel `tfsdk:"sites"` + AccountSlug types.String `tfsdk:"account_slug"` + Sites []sitesSiteModel `tfsdk:"sites"` +} + +type sitesSiteModel struct { + ID types.String `tfsdk:"id"` + AccountSlug types.String `tfsdk:"account_slug"` + Name types.String `tfsdk:"name"` + CustomDomain types.String `tfsdk:"custom_domain"` + DomainAliases []types.String `tfsdk:"domain_aliases"` } func (d *sitesDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { @@ -93,9 +101,9 @@ func (d *sitesDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp.Diagnostics.AddError("Error reading Netlify account", fmt.Sprintf("Could not list Netlify sites in account %q: %q", config.AccountSlug.ValueString(), err.Error())) return } - config.Sites = make([]NetlifySiteModel, len(sites)) + config.Sites = make([]sitesSiteModel, len(sites)) for i, site := range sites { - config.Sites[i] = NetlifySiteModel{ + config.Sites[i] = sitesSiteModel{ ID: types.StringValue(site.Id), AccountSlug: types.StringValue(site.AccountSlug), Name: types.StringValue(site.Name), diff --git a/openapi.json b/openapi.json index c74347a..0ff5434 100644 --- a/openapi.json +++ b/openapi.json @@ -5557,7 +5557,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Site" + "$ref": "#/components/schemas/PartialSite" } } } @@ -12525,6 +12525,9 @@ "installation_id": { "type": "integer" }, + "package_path": { + "type": "string" + }, "private_logs": { "type": "boolean" }, @@ -13079,6 +13082,141 @@ ], "description": "Site model definition" }, + "PartialSite": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "plan": { + "type": "string" + }, + "name": { + "type": "string" + }, + "default_domain": { + "type": "string" + }, + "custom_domain": { + "type": "string" + }, + "branch_deploy_custom_domain": { + "type": "string" + }, + "deploy_preview_custom_domain": { + "type": "string" + }, + "domain_aliases": { + "type": "array", + "items": { + "type": "string" + } + }, + "password": { + "type": "string" + }, + "password_context": { + "type": "string" + }, + "password_hash": { + "type": "string" + }, + "sso_login": { + "type": "boolean" + }, + "sso_login_context": { + "type": "string" + }, + "notification_email": { + "type": "string" + }, + "url": { + "type": "string" + }, + "admin_url": { + "type": "string" + }, + "deploy_url": { + "type": "string" + }, + "state": { + "type": "string" + }, + "screenshot_url": { + "type": "string" + }, + "created_at": { + "type": "string", + "format": "date-time" + }, + "updated_at": { + "type": "string", + "format": "date-time" + }, + "ssl_url": { + "type": "string" + }, + "force_ssl": { + "type": "boolean" + }, + "build_settings": { + "$ref": "#/components/schemas/Repo" + }, + "processing_settings": { + "type": "object", + "properties": { + "html": { + "type": "object", + "properties": { + "pretty_urls": { + "type": "boolean" + } + } + }, + "ignore_html_forms": { + "type": "boolean" + } + } + }, + "deploy_hook": { + "type": "string" + }, + "managed_dns": { + "type": "boolean" + }, + "account_id": { + "type": "string" + }, + "account_slug": { + "type": "string" + }, + "account_name": { + "type": "string" + }, + "capabilities": { + "type": "object" + }, + "id_domain": { + "type": "string" + }, + "build_image": { + "type": "string" + }, + "build_timelimit": { + "type": "number" + }, + "deploy_retention_in_days": { + "type": "number" + }, + "labels": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SiteLabel" + } + } + }, + "description": "Site model definition" + }, "SitesSummary": { "type": "object", "properties": {