func (d *ResourceData) Id() string {
	var result string
	if d.state != nil {
		result = d.state.ID
	}
	if d.newState != nil {
		result = d.newState.ID
	}
	return result
}
Id returns the ID of the resource.
package schema
import (
	"log"
	"reflect"
	"strings"
	"sync"
	"time"
	"github.com/hashicorp/terraform/terraform"
)
type ResourceData struct {
	schema   map[string]*Schema
	config   *terraform.ResourceConfig
	state    *terraform.InstanceState
	diff     *terraform.InstanceDiff
	meta     map[string]interface{}
	timeouts *ResourceTimeout
	multiReader *MultiLevelFieldReader
	setWriter   *MapFieldWriter
	newState    *terraform.InstanceState
	partial     bool
	partialMap  map[string]struct{}
	once        sync.Once
	isNew       bool
}
type getResult struct {
	Value          interface{}
	ValueProcessed interface{}
	Computed       bool
	Exists         bool
	Schema         *Schema
}
func (d *ResourceData) UnsafeSetFieldRaw(key string, value string) {
	d.once.Do(d.init)
	d.setWriter.unsafeWriteField(key, value)
}
func (d *ResourceData) Get(key string) interface{} {
	v, _ := d.GetOk(key)
	return v
}
func (d *ResourceData) GetChange(key string) (interface{}, interface{}) {
	o, n := d.getChange(key, getSourceState, getSourceDiff)
	return o.Value, n.Value
}
func (d *ResourceData) GetOk(key string) (interface{}, bool) {
	r := d.getRaw(key, getSourceSet)
	exists := r.Exists && !r.Computed
	if exists {
		value := r.Value
		zero := r.Schema.Type.Zero()
		if eq, ok := value.(Equal); ok {
			exists = !eq.Equal(zero)
		} else {
			exists = !reflect.DeepEqual(value, zero)
		}
	}
	return r.Value, exists
}
func (d *ResourceData) getRaw(key string, level getSource) getResult {
	var parts []string
	if key != "" {
		parts = strings.Split(key, ".")
	}
	return d.get(parts, level)
}
func (d *ResourceData) HasChange(key string) bool {
	o, n := d.GetChange(key)
	if eq, ok := o.(Equal); ok {
		return !eq.Equal(n)
	}
	return !reflect.DeepEqual(o, n)
}
func (d *ResourceData) Partial(on bool) {
	d.partial = on
	if on {
		if d.partialMap == nil {
			d.partialMap = make(map[string]struct{})
		}
	} else {
		d.partialMap = nil
	}
}
func (d *ResourceData) Set(key string, value interface{}) error {
	d.once.Do(d.init)
	reflectVal := reflect.ValueOf(value)
	if reflectVal.Kind() == reflect.Ptr {
		if reflectVal.IsNil() {
			value = nil
		} else {
			reflectVal = reflect.Indirect(reflectVal)
			if reflectVal.Kind() != reflect.Struct {
				value = reflectVal.Interface()
			}
		}
	}
	return d.setWriter.WriteField(strings.Split(key, "."), value)
}
func (d *ResourceData) SetPartial(k string) {
	if d.partial {
		d.partialMap[k] = struct{}{}
	}
}
func (d *ResourceData) MarkNewResource() {
	d.isNew = true
}
func (d *ResourceData) IsNewResource() bool {
	return d.isNew
}