1// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates.  All rights reserved.
2// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
3// Code generated. DO NOT EDIT.
4
5// Data Integration API
6//
7// Use the Data Integration Service APIs to perform common extract, load, and transform (ETL) tasks.
8//
9
10package dataintegration
11
12import (
13	"encoding/json"
14	"github.com/oracle/oci-go-sdk/common"
15)
16
17// ReadOperationConfig The information about the read operation.
18type ReadOperationConfig struct {
19
20	// The key of the object.
21	Key *string `mandatory:"false" json:"key"`
22
23	// The model version of an object.
24	ModelVersion *string `mandatory:"false" json:"modelVersion"`
25
26	ParentRef *ParentReference `mandatory:"false" json:"parentRef"`
27
28	// An array of operations.
29	Operations []PushDownOperation `mandatory:"false" json:"operations"`
30
31	DataFormat *DataFormat `mandatory:"false" json:"dataFormat"`
32
33	PartitionConfig PartitionConfig `mandatory:"false" json:"partitionConfig"`
34
35	ReadAttribute AbstractReadAttribute `mandatory:"false" json:"readAttribute"`
36
37	// The status of an object that can be set to value 1 for shallow references across objects, other values reserved.
38	ObjectStatus *int `mandatory:"false" json:"objectStatus"`
39}
40
41func (m ReadOperationConfig) String() string {
42	return common.PointerString(m)
43}
44
45// MarshalJSON marshals to json representation
46func (m ReadOperationConfig) MarshalJSON() (buff []byte, e error) {
47	type MarshalTypeReadOperationConfig ReadOperationConfig
48	s := struct {
49		DiscriminatorParam string `json:"modelType"`
50		MarshalTypeReadOperationConfig
51	}{
52		"READ_OPERATION_CONFIG",
53		(MarshalTypeReadOperationConfig)(m),
54	}
55
56	return json.Marshal(&s)
57}
58
59// UnmarshalJSON unmarshals from json
60func (m *ReadOperationConfig) UnmarshalJSON(data []byte) (e error) {
61	model := struct {
62		Key             *string               `json:"key"`
63		ModelVersion    *string               `json:"modelVersion"`
64		ParentRef       *ParentReference      `json:"parentRef"`
65		Operations      []pushdownoperation   `json:"operations"`
66		DataFormat      *DataFormat           `json:"dataFormat"`
67		PartitionConfig partitionconfig       `json:"partitionConfig"`
68		ReadAttribute   abstractreadattribute `json:"readAttribute"`
69		ObjectStatus    *int                  `json:"objectStatus"`
70	}{}
71
72	e = json.Unmarshal(data, &model)
73	if e != nil {
74		return
75	}
76	var nn interface{}
77	m.Key = model.Key
78
79	m.ModelVersion = model.ModelVersion
80
81	m.ParentRef = model.ParentRef
82
83	m.Operations = make([]PushDownOperation, len(model.Operations))
84	for i, n := range model.Operations {
85		nn, e = n.UnmarshalPolymorphicJSON(n.JsonData)
86		if e != nil {
87			return e
88		}
89		if nn != nil {
90			m.Operations[i] = nn.(PushDownOperation)
91		} else {
92			m.Operations[i] = nil
93		}
94	}
95
96	m.DataFormat = model.DataFormat
97
98	nn, e = model.PartitionConfig.UnmarshalPolymorphicJSON(model.PartitionConfig.JsonData)
99	if e != nil {
100		return
101	}
102	if nn != nil {
103		m.PartitionConfig = nn.(PartitionConfig)
104	} else {
105		m.PartitionConfig = nil
106	}
107
108	nn, e = model.ReadAttribute.UnmarshalPolymorphicJSON(model.ReadAttribute.JsonData)
109	if e != nil {
110		return
111	}
112	if nn != nil {
113		m.ReadAttribute = nn.(AbstractReadAttribute)
114	} else {
115		m.ReadAttribute = nil
116	}
117
118	m.ObjectStatus = model.ObjectStatus
119
120	return
121}
122