// Code generated by go-swagger; DO NOT EDIT.

package models

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"context"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
)

// SecretServiceCreateSyncBody secret service create sync body
//
// swagger:model SecretServiceCreateSyncBody
type SecretServiceCreateSyncBody struct {

	// integration name
	IntegrationName string `json:"integration_name,omitempty"`

	// name
	Name string `json:"name,omitempty"`

	// sync config gitlab
	SyncConfigGitlab *Secrets20231128SyncConfigGitlab `json:"sync_config_gitlab,omitempty"`

	// sync config hcp terraform
	SyncConfigHcpTerraform *Secrets20231128SyncConfigHcpTerraform `json:"sync_config_hcp_terraform,omitempty"`

	// type
	Type string `json:"type,omitempty"`
}

// Validate validates this secret service create sync body
func (m *SecretServiceCreateSyncBody) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateSyncConfigGitlab(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateSyncConfigHcpTerraform(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *SecretServiceCreateSyncBody) validateSyncConfigGitlab(formats strfmt.Registry) error {
	if swag.IsZero(m.SyncConfigGitlab) { // not required
		return nil
	}

	if m.SyncConfigGitlab != nil {
		if err := m.SyncConfigGitlab.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("sync_config_gitlab")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("sync_config_gitlab")
			}
			return err
		}
	}

	return nil
}

func (m *SecretServiceCreateSyncBody) validateSyncConfigHcpTerraform(formats strfmt.Registry) error {
	if swag.IsZero(m.SyncConfigHcpTerraform) { // not required
		return nil
	}

	if m.SyncConfigHcpTerraform != nil {
		if err := m.SyncConfigHcpTerraform.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("sync_config_hcp_terraform")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("sync_config_hcp_terraform")
			}
			return err
		}
	}

	return nil
}

// ContextValidate validate this secret service create sync body based on the context it is used
func (m *SecretServiceCreateSyncBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

	if err := m.contextValidateSyncConfigGitlab(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateSyncConfigHcpTerraform(ctx, formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *SecretServiceCreateSyncBody) contextValidateSyncConfigGitlab(ctx context.Context, formats strfmt.Registry) error {

	if m.SyncConfigGitlab != nil {

		if swag.IsZero(m.SyncConfigGitlab) { // not required
			return nil
		}

		if err := m.SyncConfigGitlab.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("sync_config_gitlab")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("sync_config_gitlab")
			}
			return err
		}
	}

	return nil
}

func (m *SecretServiceCreateSyncBody) contextValidateSyncConfigHcpTerraform(ctx context.Context, formats strfmt.Registry) error {

	if m.SyncConfigHcpTerraform != nil {

		if swag.IsZero(m.SyncConfigHcpTerraform) { // not required
			return nil
		}

		if err := m.SyncConfigHcpTerraform.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("sync_config_hcp_terraform")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("sync_config_hcp_terraform")
			}
			return err
		}
	}

	return nil
}

// MarshalBinary interface implementation
func (m *SecretServiceCreateSyncBody) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

// UnmarshalBinary interface implementation
func (m *SecretServiceCreateSyncBody) UnmarshalBinary(b []byte) error {
	var res SecretServiceCreateSyncBody
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}
