1// Copyright (c) 2016, 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2// Code generated. DO NOT EDIT.
3
4// Core Services API
5//
6// API covering the Networking (https://docs.cloud.oracle.com/iaas/Content/Network/Concepts/overview.htm),
7// Compute (https://docs.cloud.oracle.com/iaas/Content/Compute/Concepts/computeoverview.htm), and
8// Block Volume (https://docs.cloud.oracle.com/iaas/Content/Block/Concepts/overview.htm) services. Use this API
9// to manage resources such as virtual cloud networks (VCNs), compute instances, and
10// block storage volumes.
11//
12
13package core
14
15import (
16	"encoding/json"
17	"github.com/oracle/oci-go-sdk/common"
18)
19
20// ExportImageDetails The destination details for the image export.
21// Set `destinationType` to `objectStorageTuple`
22// and use ExportImageViaObjectStorageTupleDetails
23// when specifying the namespace, bucket name, and object name.
24// Set `destinationType` to `objectStorageUri` and
25// use ExportImageViaObjectStorageUriDetails
26// when specifying the Object Storage URL.
27type ExportImageDetails interface {
28}
29
30type exportimagedetails struct {
31	JsonData        []byte
32	DestinationType string `json:"destinationType"`
33}
34
35// UnmarshalJSON unmarshals json
36func (m *exportimagedetails) UnmarshalJSON(data []byte) error {
37	m.JsonData = data
38	type Unmarshalerexportimagedetails exportimagedetails
39	s := struct {
40		Model Unmarshalerexportimagedetails
41	}{}
42	err := json.Unmarshal(data, &s.Model)
43	if err != nil {
44		return err
45	}
46	m.DestinationType = s.Model.DestinationType
47
48	return err
49}
50
51// UnmarshalPolymorphicJSON unmarshals polymorphic json
52func (m *exportimagedetails) UnmarshalPolymorphicJSON(data []byte) (interface{}, error) {
53
54	if data == nil || string(data) == "null" {
55		return nil, nil
56	}
57
58	var err error
59	switch m.DestinationType {
60	case "objectStorageUri":
61		mm := ExportImageViaObjectStorageUriDetails{}
62		err = json.Unmarshal(data, &mm)
63		return mm, err
64	case "objectStorageTuple":
65		mm := ExportImageViaObjectStorageTupleDetails{}
66		err = json.Unmarshal(data, &mm)
67		return mm, err
68	default:
69		return *m, nil
70	}
71}
72
73func (m exportimagedetails) String() string {
74	return common.PointerString(m)
75}
76