// 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"
	"github.com/go-openapi/validate"
)

// DomainPermission DomainPermission represents a permission applied to one domain (explicit block/allow).
//
// swagger:model DomainPermission
type DomainPermission struct {

	// Time at which the permission entry was created (ISO 8601 Datetime).
	// Example: 2021-07-30T09:20:25+00:00
	CreatedAt string `json:"created_at,omitempty"`

	// ID of the account that created this domain permission entry.
	// Example: 01FBW2758ZB6PBR200YPDDJK4C
	CreatedBy string `json:"created_by,omitempty"`

	// The hostname of the domain.
	// Example: example.org
	Domain string `json:"domain,omitempty"`

	// The ID of the domain permission entry.
	// Example: 01FBW21XJA09XYX51KV5JVBW0F
	// Read Only: true
	ID string `json:"id,omitempty"`

	// Obfuscate the domain name when serving this domain permission entry publicly.
	// Example: false
	Obfuscate bool `json:"obfuscate,omitempty"`

	// Private comment for this permission entry, visible to this instance's admins only.
	// Example: they are poopoo
	PrivateComment string `json:"private_comment,omitempty"`

	// If the domain is blocked, what's the publicly-stated reason for the block.
	// Example: they smell
	PublicComment string `json:"public_comment,omitempty"`

	// Time at which this domain was silenced. Key will not be present on open domains.
	// Example: 2021-07-30T09:20:25+00:00
	SilencedAt string `json:"silenced_at,omitempty"`

	// If applicable, the ID of the subscription that caused this domain permission entry to be created.
	// Example: 01FBW25TF5J67JW3HFHZCSD23K
	SubscriptionID string `json:"subscription_id,omitempty"`

	// Time at which this domain was suspended. Key will not be present on open domains.
	// Example: 2021-07-30T09:20:25+00:00
	SuspendedAt string `json:"suspended_at,omitempty"`
}

// Validate validates this domain permission
func (m *DomainPermission) Validate(formats strfmt.Registry) error {
	return nil
}

// ContextValidate validate this domain permission based on the context it is used
func (m *DomainPermission) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *DomainPermission) contextValidateID(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "id", "body", string(m.ID)); err != nil {
		return err
	}

	return nil
}

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

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