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// LogAnalytics API
6//
7// The LogAnalytics API for the LogAnalytics service.
8//
9
10package loganalytics
11
12import (
13	"encoding/json"
14	"github.com/oracle/oci-go-sdk/common"
15)
16
17// CreateStandardTaskDetails Details for creating a scheduled task.
18// The client must fully specify the details.
19// Not supported for TaskType ACCELERATION.
20type CreateStandardTaskDetails struct {
21
22	// Compartment Identifier OCID  (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm).
23	CompartmentId *string `mandatory:"true" json:"compartmentId"`
24
25	// Schedules, typically a single schedule.
26	Schedules []Schedule `mandatory:"true" json:"schedules"`
27
28	Action Action `mandatory:"true" json:"action"`
29
30	// A user-friendly name that is changeable and that does not have to be unique.
31	// Format: a leading alphanumeric, followed by zero or more
32	// alphanumerics, underscores, spaces, backslashes, or hyphens in any order).
33	// No trailing spaces allowed.
34	DisplayName *string `mandatory:"false" json:"displayName"`
35
36	// Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only.
37	// Example: `{"bar-key": "value"}`
38	FreeformTags map[string]string `mandatory:"false" json:"freeformTags"`
39
40	// Defined tags for this resource. Each key is predefined and scoped to a namespace.
41	// Example: `{"foo-namespace": {"bar-key": "value"}}`
42	DefinedTags map[string]map[string]interface{} `mandatory:"false" json:"definedTags"`
43
44	// Task type.
45	TaskType TaskTypeEnum `mandatory:"true" json:"taskType"`
46}
47
48//GetCompartmentId returns CompartmentId
49func (m CreateStandardTaskDetails) GetCompartmentId() *string {
50	return m.CompartmentId
51}
52
53//GetDisplayName returns DisplayName
54func (m CreateStandardTaskDetails) GetDisplayName() *string {
55	return m.DisplayName
56}
57
58//GetFreeformTags returns FreeformTags
59func (m CreateStandardTaskDetails) GetFreeformTags() map[string]string {
60	return m.FreeformTags
61}
62
63//GetDefinedTags returns DefinedTags
64func (m CreateStandardTaskDetails) GetDefinedTags() map[string]map[string]interface{} {
65	return m.DefinedTags
66}
67
68func (m CreateStandardTaskDetails) String() string {
69	return common.PointerString(m)
70}
71
72// MarshalJSON marshals to json representation
73func (m CreateStandardTaskDetails) MarshalJSON() (buff []byte, e error) {
74	type MarshalTypeCreateStandardTaskDetails CreateStandardTaskDetails
75	s := struct {
76		DiscriminatorParam string `json:"kind"`
77		MarshalTypeCreateStandardTaskDetails
78	}{
79		"STANDARD",
80		(MarshalTypeCreateStandardTaskDetails)(m),
81	}
82
83	return json.Marshal(&s)
84}
85
86// UnmarshalJSON unmarshals from json
87func (m *CreateStandardTaskDetails) UnmarshalJSON(data []byte) (e error) {
88	model := struct {
89		DisplayName   *string                           `json:"displayName"`
90		FreeformTags  map[string]string                 `json:"freeformTags"`
91		DefinedTags   map[string]map[string]interface{} `json:"definedTags"`
92		CompartmentId *string                           `json:"compartmentId"`
93		TaskType      TaskTypeEnum                      `json:"taskType"`
94		Schedules     []schedule                        `json:"schedules"`
95		Action        action                            `json:"action"`
96	}{}
97
98	e = json.Unmarshal(data, &model)
99	if e != nil {
100		return
101	}
102	var nn interface{}
103	m.DisplayName = model.DisplayName
104
105	m.FreeformTags = model.FreeformTags
106
107	m.DefinedTags = model.DefinedTags
108
109	m.CompartmentId = model.CompartmentId
110
111	m.TaskType = model.TaskType
112
113	m.Schedules = make([]Schedule, len(model.Schedules))
114	for i, n := range model.Schedules {
115		nn, e = n.UnmarshalPolymorphicJSON(n.JsonData)
116		if e != nil {
117			return e
118		}
119		if nn != nil {
120			m.Schedules[i] = nn.(Schedule)
121		} else {
122			m.Schedules[i] = nil
123		}
124	}
125
126	nn, e = model.Action.UnmarshalPolymorphicJSON(model.Action.JsonData)
127	if e != nil {
128		return
129	}
130	if nn != nil {
131		m.Action = nn.(Action)
132	} else {
133		m.Action = nil
134	}
135
136	return
137}
138