// Code generated by azure-service-operator-codegen. DO NOT EDIT.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
package v1api20210701

import (
	"fmt"
	arm "github.com/Azure/azure-service-operator/v2/api/machinelearningservices/v1api20210701/arm"
	storage "github.com/Azure/azure-service-operator/v2/api/machinelearningservices/v1api20210701/storage"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime/conditions"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime/configmaps"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime/core"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime/secrets"
	"github.com/rotisserie/eris"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/runtime/schema"
	"sigs.k8s.io/controller-runtime/pkg/conversion"
)

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={azure,machinelearningservices}
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
// +kubebuilder:printcolumn:name="Severity",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].severity"
// +kubebuilder:printcolumn:name="Reason",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].reason"
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].message"
// Generator information:
// - Generated from: /machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2021-07-01/machineLearningServices.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/connections/{connectionName}
type WorkspacesConnection struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              WorkspacesConnection_Spec   `json:"spec,omitempty"`
	Status            WorkspacesConnection_STATUS `json:"status,omitempty"`
}

var _ conditions.Conditioner = &WorkspacesConnection{}

// GetConditions returns the conditions of the resource
func (connection *WorkspacesConnection) GetConditions() conditions.Conditions {
	return connection.Status.Conditions
}

// SetConditions sets the conditions on the resource status
func (connection *WorkspacesConnection) SetConditions(conditions conditions.Conditions) {
	connection.Status.Conditions = conditions
}

var _ conversion.Convertible = &WorkspacesConnection{}

// ConvertFrom populates our WorkspacesConnection from the provided hub WorkspacesConnection
func (connection *WorkspacesConnection) ConvertFrom(hub conversion.Hub) error {
	// intermediate variable for conversion
	var source storage.WorkspacesConnection

	err := source.ConvertFrom(hub)
	if err != nil {
		return eris.Wrap(err, "converting from hub to source")
	}

	err = connection.AssignProperties_From_WorkspacesConnection(&source)
	if err != nil {
		return eris.Wrap(err, "converting from source to connection")
	}

	return nil
}

// ConvertTo populates the provided hub WorkspacesConnection from our WorkspacesConnection
func (connection *WorkspacesConnection) ConvertTo(hub conversion.Hub) error {
	// intermediate variable for conversion
	var destination storage.WorkspacesConnection
	err := connection.AssignProperties_To_WorkspacesConnection(&destination)
	if err != nil {
		return eris.Wrap(err, "converting to destination from connection")
	}
	err = destination.ConvertTo(hub)
	if err != nil {
		return eris.Wrap(err, "converting from destination to hub")
	}

	return nil
}

var _ configmaps.Exporter = &WorkspacesConnection{}

// ConfigMapDestinationExpressions returns the Spec.OperatorSpec.ConfigMapExpressions property
func (connection *WorkspacesConnection) ConfigMapDestinationExpressions() []*core.DestinationExpression {
	if connection.Spec.OperatorSpec == nil {
		return nil
	}
	return connection.Spec.OperatorSpec.ConfigMapExpressions
}

var _ secrets.Exporter = &WorkspacesConnection{}

// SecretDestinationExpressions returns the Spec.OperatorSpec.SecretExpressions property
func (connection *WorkspacesConnection) SecretDestinationExpressions() []*core.DestinationExpression {
	if connection.Spec.OperatorSpec == nil {
		return nil
	}
	return connection.Spec.OperatorSpec.SecretExpressions
}

var _ genruntime.KubernetesResource = &WorkspacesConnection{}

// AzureName returns the Azure name of the resource
func (connection *WorkspacesConnection) AzureName() string {
	return connection.Spec.AzureName
}

// GetAPIVersion returns the ARM API version of the resource. This is always "2021-07-01"
func (connection WorkspacesConnection) GetAPIVersion() string {
	return "2021-07-01"
}

// GetResourceScope returns the scope of the resource
func (connection *WorkspacesConnection) GetResourceScope() genruntime.ResourceScope {
	return genruntime.ResourceScopeResourceGroup
}

// GetSpec returns the specification of this resource
func (connection *WorkspacesConnection) GetSpec() genruntime.ConvertibleSpec {
	return &connection.Spec
}

// GetStatus returns the status of this resource
func (connection *WorkspacesConnection) GetStatus() genruntime.ConvertibleStatus {
	return &connection.Status
}

// GetSupportedOperations returns the operations supported by the resource
func (connection *WorkspacesConnection) GetSupportedOperations() []genruntime.ResourceOperation {
	return []genruntime.ResourceOperation{
		genruntime.ResourceOperationDelete,
		genruntime.ResourceOperationGet,
		genruntime.ResourceOperationPut,
	}
}

// GetType returns the ARM Type of the resource. This is always "Microsoft.MachineLearningServices/workspaces/connections"
func (connection *WorkspacesConnection) GetType() string {
	return "Microsoft.MachineLearningServices/workspaces/connections"
}

// NewEmptyStatus returns a new empty (blank) status
func (connection *WorkspacesConnection) NewEmptyStatus() genruntime.ConvertibleStatus {
	return &WorkspacesConnection_STATUS{}
}

// Owner returns the ResourceReference of the owner
func (connection *WorkspacesConnection) Owner() *genruntime.ResourceReference {
	if connection.Spec.Owner == nil {
		return nil
	}

	group, kind := genruntime.LookupOwnerGroupKind(connection.Spec)
	return connection.Spec.Owner.AsResourceReference(group, kind)
}

// SetStatus sets the status of this resource
func (connection *WorkspacesConnection) SetStatus(status genruntime.ConvertibleStatus) error {
	// If we have exactly the right type of status, assign it
	if st, ok := status.(*WorkspacesConnection_STATUS); ok {
		connection.Status = *st
		return nil
	}

	// Convert status to required version
	var st WorkspacesConnection_STATUS
	err := status.ConvertStatusTo(&st)
	if err != nil {
		return eris.Wrap(err, "failed to convert status")
	}

	connection.Status = st
	return nil
}

// AssignProperties_From_WorkspacesConnection populates our WorkspacesConnection from the provided source WorkspacesConnection
func (connection *WorkspacesConnection) AssignProperties_From_WorkspacesConnection(source *storage.WorkspacesConnection) error {

	// ObjectMeta
	connection.ObjectMeta = *source.ObjectMeta.DeepCopy()

	// Spec
	var spec WorkspacesConnection_Spec
	err := spec.AssignProperties_From_WorkspacesConnection_Spec(&source.Spec)
	if err != nil {
		return eris.Wrap(err, "calling AssignProperties_From_WorkspacesConnection_Spec() to populate field Spec")
	}
	connection.Spec = spec

	// Status
	var status WorkspacesConnection_STATUS
	err = status.AssignProperties_From_WorkspacesConnection_STATUS(&source.Status)
	if err != nil {
		return eris.Wrap(err, "calling AssignProperties_From_WorkspacesConnection_STATUS() to populate field Status")
	}
	connection.Status = status

	// No error
	return nil
}

// AssignProperties_To_WorkspacesConnection populates the provided destination WorkspacesConnection from our WorkspacesConnection
func (connection *WorkspacesConnection) AssignProperties_To_WorkspacesConnection(destination *storage.WorkspacesConnection) error {

	// ObjectMeta
	destination.ObjectMeta = *connection.ObjectMeta.DeepCopy()

	// Spec
	var spec storage.WorkspacesConnection_Spec
	err := connection.Spec.AssignProperties_To_WorkspacesConnection_Spec(&spec)
	if err != nil {
		return eris.Wrap(err, "calling AssignProperties_To_WorkspacesConnection_Spec() to populate field Spec")
	}
	destination.Spec = spec

	// Status
	var status storage.WorkspacesConnection_STATUS
	err = connection.Status.AssignProperties_To_WorkspacesConnection_STATUS(&status)
	if err != nil {
		return eris.Wrap(err, "calling AssignProperties_To_WorkspacesConnection_STATUS() to populate field Status")
	}
	destination.Status = status

	// No error
	return nil
}

// OriginalGVK returns a GroupValueKind for the original API version used to create the resource
func (connection *WorkspacesConnection) OriginalGVK() *schema.GroupVersionKind {
	return &schema.GroupVersionKind{
		Group:   GroupVersion.Group,
		Version: connection.Spec.OriginalVersion(),
		Kind:    "WorkspacesConnection",
	}
}

// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2021-07-01/machineLearningServices.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/connections/{connectionName}
type WorkspacesConnectionList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []WorkspacesConnection `json:"items"`
}

type WorkspacesConnection_Spec struct {
	// AuthType: Authorization type of the workspace connection.
	AuthType *string `json:"authType,omitempty"`

	// AzureName: The name of the resource in Azure. This is often the same as the name of the resource in Kubernetes but it
	// doesn't have to be.
	AzureName string `json:"azureName,omitempty"`

	// Category: Category of the workspace connection.
	Category *string `json:"category,omitempty"`

	// OperatorSpec: The specification for configuring operator behavior. This field is interpreted by the operator and not
	// passed directly to Azure
	OperatorSpec *WorkspacesConnectionOperatorSpec `json:"operatorSpec,omitempty"`

	// +kubebuilder:validation:Required
	// Owner: The owner of the resource. The owner controls where the resource goes when it is deployed. The owner also
	// controls the resources lifecycle. When the owner is deleted the resource will also be deleted. Owner is expected to be a
	// reference to a machinelearningservices.azure.com/Workspace resource
	Owner *genruntime.KnownResourceReference `group:"machinelearningservices.azure.com" json:"owner,omitempty" kind:"Workspace"`

	// Target: Target of the workspace connection.
	Target *string `json:"target,omitempty"`

	// Value: Value details of the workspace connection.
	Value *string `json:"value,omitempty"`

	// ValueFormat: format for the workspace connection value
	ValueFormat *WorkspaceConnectionProps_ValueFormat `json:"valueFormat,omitempty"`
}

var _ genruntime.ARMTransformer = &WorkspacesConnection_Spec{}

// ConvertToARM converts from a Kubernetes CRD object to an ARM object
func (connection *WorkspacesConnection_Spec) ConvertToARM(resolved genruntime.ConvertToARMResolvedDetails) (interface{}, error) {
	if connection == nil {
		return nil, nil
	}
	result := &arm.WorkspacesConnection_Spec{}

	// Set property "Name":
	result.Name = resolved.Name

	// Set property "Properties":
	if connection.AuthType != nil ||
		connection.Category != nil ||
		connection.Target != nil ||
		connection.Value != nil ||
		connection.ValueFormat != nil {
		result.Properties = &arm.WorkspaceConnectionProps{}
	}
	if connection.AuthType != nil {
		authType := *connection.AuthType
		result.Properties.AuthType = &authType
	}
	if connection.Category != nil {
		category := *connection.Category
		result.Properties.Category = &category
	}
	if connection.Target != nil {
		target := *connection.Target
		result.Properties.Target = &target
	}
	if connection.Value != nil {
		value := *connection.Value
		result.Properties.Value = &value
	}
	if connection.ValueFormat != nil {
		var temp string
		temp = string(*connection.ValueFormat)
		valueFormat := arm.WorkspaceConnectionProps_ValueFormat(temp)
		result.Properties.ValueFormat = &valueFormat
	}
	return result, nil
}

// NewEmptyARMValue returns an empty ARM value suitable for deserializing into
func (connection *WorkspacesConnection_Spec) NewEmptyARMValue() genruntime.ARMResourceStatus {
	return &arm.WorkspacesConnection_Spec{}
}

// PopulateFromARM populates a Kubernetes CRD object from an Azure ARM object
func (connection *WorkspacesConnection_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReference, armInput interface{}) error {
	typedInput, ok := armInput.(arm.WorkspacesConnection_Spec)
	if !ok {
		return fmt.Errorf("unexpected type supplied for PopulateFromARM() function. Expected arm.WorkspacesConnection_Spec, got %T", armInput)
	}

	// Set property "AuthType":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.AuthType != nil {
			authType := *typedInput.Properties.AuthType
			connection.AuthType = &authType
		}
	}

	// Set property "AzureName":
	connection.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name))

	// Set property "Category":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Category != nil {
			category := *typedInput.Properties.Category
			connection.Category = &category
		}
	}

	// no assignment for property "OperatorSpec"

	// Set property "Owner":
	connection.Owner = &genruntime.KnownResourceReference{
		Name:  owner.Name,
		ARMID: owner.ARMID,
	}

	// Set property "Target":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Target != nil {
			target := *typedInput.Properties.Target
			connection.Target = &target
		}
	}

	// Set property "Value":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Value != nil {
			value := *typedInput.Properties.Value
			connection.Value = &value
		}
	}

	// Set property "ValueFormat":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ValueFormat != nil {
			var temp string
			temp = string(*typedInput.Properties.ValueFormat)
			valueFormat := WorkspaceConnectionProps_ValueFormat(temp)
			connection.ValueFormat = &valueFormat
		}
	}

	// No error
	return nil
}

var _ genruntime.ConvertibleSpec = &WorkspacesConnection_Spec{}

// ConvertSpecFrom populates our WorkspacesConnection_Spec from the provided source
func (connection *WorkspacesConnection_Spec) ConvertSpecFrom(source genruntime.ConvertibleSpec) error {
	src, ok := source.(*storage.WorkspacesConnection_Spec)
	if ok {
		// Populate our instance from source
		return connection.AssignProperties_From_WorkspacesConnection_Spec(src)
	}

	// Convert to an intermediate form
	src = &storage.WorkspacesConnection_Spec{}
	err := src.ConvertSpecFrom(source)
	if err != nil {
		return eris.Wrap(err, "initial step of conversion in ConvertSpecFrom()")
	}

	// Update our instance from src
	err = connection.AssignProperties_From_WorkspacesConnection_Spec(src)
	if err != nil {
		return eris.Wrap(err, "final step of conversion in ConvertSpecFrom()")
	}

	return nil
}

// ConvertSpecTo populates the provided destination from our WorkspacesConnection_Spec
func (connection *WorkspacesConnection_Spec) ConvertSpecTo(destination genruntime.ConvertibleSpec) error {
	dst, ok := destination.(*storage.WorkspacesConnection_Spec)
	if ok {
		// Populate destination from our instance
		return connection.AssignProperties_To_WorkspacesConnection_Spec(dst)
	}

	// Convert to an intermediate form
	dst = &storage.WorkspacesConnection_Spec{}
	err := connection.AssignProperties_To_WorkspacesConnection_Spec(dst)
	if err != nil {
		return eris.Wrap(err, "initial step of conversion in ConvertSpecTo()")
	}

	// Update dst from our instance
	err = dst.ConvertSpecTo(destination)
	if err != nil {
		return eris.Wrap(err, "final step of conversion in ConvertSpecTo()")
	}

	return nil
}

// AssignProperties_From_WorkspacesConnection_Spec populates our WorkspacesConnection_Spec from the provided source WorkspacesConnection_Spec
func (connection *WorkspacesConnection_Spec) AssignProperties_From_WorkspacesConnection_Spec(source *storage.WorkspacesConnection_Spec) error {

	// AuthType
	connection.AuthType = genruntime.ClonePointerToString(source.AuthType)

	// AzureName
	connection.AzureName = source.AzureName

	// Category
	connection.Category = genruntime.ClonePointerToString(source.Category)

	// OperatorSpec
	if source.OperatorSpec != nil {
		var operatorSpec WorkspacesConnectionOperatorSpec
		err := operatorSpec.AssignProperties_From_WorkspacesConnectionOperatorSpec(source.OperatorSpec)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_From_WorkspacesConnectionOperatorSpec() to populate field OperatorSpec")
		}
		connection.OperatorSpec = &operatorSpec
	} else {
		connection.OperatorSpec = nil
	}

	// Owner
	if source.Owner != nil {
		owner := source.Owner.Copy()
		connection.Owner = &owner
	} else {
		connection.Owner = nil
	}

	// Target
	connection.Target = genruntime.ClonePointerToString(source.Target)

	// Value
	connection.Value = genruntime.ClonePointerToString(source.Value)

	// ValueFormat
	if source.ValueFormat != nil {
		valueFormat := *source.ValueFormat
		valueFormatTemp := genruntime.ToEnum(valueFormat, workspaceConnectionProps_ValueFormat_Values)
		connection.ValueFormat = &valueFormatTemp
	} else {
		connection.ValueFormat = nil
	}

	// No error
	return nil
}

// AssignProperties_To_WorkspacesConnection_Spec populates the provided destination WorkspacesConnection_Spec from our WorkspacesConnection_Spec
func (connection *WorkspacesConnection_Spec) AssignProperties_To_WorkspacesConnection_Spec(destination *storage.WorkspacesConnection_Spec) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// AuthType
	destination.AuthType = genruntime.ClonePointerToString(connection.AuthType)

	// AzureName
	destination.AzureName = connection.AzureName

	// Category
	destination.Category = genruntime.ClonePointerToString(connection.Category)

	// OperatorSpec
	if connection.OperatorSpec != nil {
		var operatorSpec storage.WorkspacesConnectionOperatorSpec
		err := connection.OperatorSpec.AssignProperties_To_WorkspacesConnectionOperatorSpec(&operatorSpec)
		if err != nil {
			return eris.Wrap(err, "calling AssignProperties_To_WorkspacesConnectionOperatorSpec() to populate field OperatorSpec")
		}
		destination.OperatorSpec = &operatorSpec
	} else {
		destination.OperatorSpec = nil
	}

	// OriginalVersion
	destination.OriginalVersion = connection.OriginalVersion()

	// Owner
	if connection.Owner != nil {
		owner := connection.Owner.Copy()
		destination.Owner = &owner
	} else {
		destination.Owner = nil
	}

	// Target
	destination.Target = genruntime.ClonePointerToString(connection.Target)

	// Value
	destination.Value = genruntime.ClonePointerToString(connection.Value)

	// ValueFormat
	if connection.ValueFormat != nil {
		valueFormat := string(*connection.ValueFormat)
		destination.ValueFormat = &valueFormat
	} else {
		destination.ValueFormat = nil
	}

	// Update the property bag
	if len(propertyBag) > 0 {
		destination.PropertyBag = propertyBag
	} else {
		destination.PropertyBag = nil
	}

	// No error
	return nil
}

// OriginalVersion returns the original API version used to create the resource.
func (connection *WorkspacesConnection_Spec) OriginalVersion() string {
	return GroupVersion.Version
}

// SetAzureName sets the Azure name of the resource
func (connection *WorkspacesConnection_Spec) SetAzureName(azureName string) {
	connection.AzureName = azureName
}

type WorkspacesConnection_STATUS struct {
	// AuthType: Authorization type of the workspace connection.
	AuthType *string `json:"authType,omitempty"`

	// Category: Category of the workspace connection.
	Category *string `json:"category,omitempty"`

	// Conditions: The observed state of the resource
	Conditions []conditions.Condition `json:"conditions,omitempty"`

	// Id: ResourceId of the workspace connection.
	Id *string `json:"id,omitempty"`

	// Name: Friendly name of the workspace connection.
	Name *string `json:"name,omitempty"`

	// Target: Target of the workspace connection.
	Target *string `json:"target,omitempty"`

	// Type: Resource type of workspace connection.
	Type *string `json:"type,omitempty"`

	// Value: Value details of the workspace connection.
	Value *string `json:"value,omitempty"`

	// ValueFormat: format for the workspace connection value
	ValueFormat *WorkspaceConnectionProps_ValueFormat_STATUS `json:"valueFormat,omitempty"`
}

var _ genruntime.ConvertibleStatus = &WorkspacesConnection_STATUS{}

// ConvertStatusFrom populates our WorkspacesConnection_STATUS from the provided source
func (connection *WorkspacesConnection_STATUS) ConvertStatusFrom(source genruntime.ConvertibleStatus) error {
	src, ok := source.(*storage.WorkspacesConnection_STATUS)
	if ok {
		// Populate our instance from source
		return connection.AssignProperties_From_WorkspacesConnection_STATUS(src)
	}

	// Convert to an intermediate form
	src = &storage.WorkspacesConnection_STATUS{}
	err := src.ConvertStatusFrom(source)
	if err != nil {
		return eris.Wrap(err, "initial step of conversion in ConvertStatusFrom()")
	}

	// Update our instance from src
	err = connection.AssignProperties_From_WorkspacesConnection_STATUS(src)
	if err != nil {
		return eris.Wrap(err, "final step of conversion in ConvertStatusFrom()")
	}

	return nil
}

// ConvertStatusTo populates the provided destination from our WorkspacesConnection_STATUS
func (connection *WorkspacesConnection_STATUS) ConvertStatusTo(destination genruntime.ConvertibleStatus) error {
	dst, ok := destination.(*storage.WorkspacesConnection_STATUS)
	if ok {
		// Populate destination from our instance
		return connection.AssignProperties_To_WorkspacesConnection_STATUS(dst)
	}

	// Convert to an intermediate form
	dst = &storage.WorkspacesConnection_STATUS{}
	err := connection.AssignProperties_To_WorkspacesConnection_STATUS(dst)
	if err != nil {
		return eris.Wrap(err, "initial step of conversion in ConvertStatusTo()")
	}

	// Update dst from our instance
	err = dst.ConvertStatusTo(destination)
	if err != nil {
		return eris.Wrap(err, "final step of conversion in ConvertStatusTo()")
	}

	return nil
}

var _ genruntime.FromARMConverter = &WorkspacesConnection_STATUS{}

// NewEmptyARMValue returns an empty ARM value suitable for deserializing into
func (connection *WorkspacesConnection_STATUS) NewEmptyARMValue() genruntime.ARMResourceStatus {
	return &arm.WorkspacesConnection_STATUS{}
}

// PopulateFromARM populates a Kubernetes CRD object from an Azure ARM object
func (connection *WorkspacesConnection_STATUS) PopulateFromARM(owner genruntime.ArbitraryOwnerReference, armInput interface{}) error {
	typedInput, ok := armInput.(arm.WorkspacesConnection_STATUS)
	if !ok {
		return fmt.Errorf("unexpected type supplied for PopulateFromARM() function. Expected arm.WorkspacesConnection_STATUS, got %T", armInput)
	}

	// Set property "AuthType":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.AuthType != nil {
			authType := *typedInput.Properties.AuthType
			connection.AuthType = &authType
		}
	}

	// Set property "Category":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Category != nil {
			category := *typedInput.Properties.Category
			connection.Category = &category
		}
	}

	// no assignment for property "Conditions"

	// Set property "Id":
	if typedInput.Id != nil {
		id := *typedInput.Id
		connection.Id = &id
	}

	// Set property "Name":
	if typedInput.Name != nil {
		name := *typedInput.Name
		connection.Name = &name
	}

	// Set property "Target":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Target != nil {
			target := *typedInput.Properties.Target
			connection.Target = &target
		}
	}

	// Set property "Type":
	if typedInput.Type != nil {
		typeVar := *typedInput.Type
		connection.Type = &typeVar
	}

	// Set property "Value":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.Value != nil {
			value := *typedInput.Properties.Value
			connection.Value = &value
		}
	}

	// Set property "ValueFormat":
	// copying flattened property:
	if typedInput.Properties != nil {
		if typedInput.Properties.ValueFormat != nil {
			var temp string
			temp = string(*typedInput.Properties.ValueFormat)
			valueFormat := WorkspaceConnectionProps_ValueFormat_STATUS(temp)
			connection.ValueFormat = &valueFormat
		}
	}

	// No error
	return nil
}

// AssignProperties_From_WorkspacesConnection_STATUS populates our WorkspacesConnection_STATUS from the provided source WorkspacesConnection_STATUS
func (connection *WorkspacesConnection_STATUS) AssignProperties_From_WorkspacesConnection_STATUS(source *storage.WorkspacesConnection_STATUS) error {

	// AuthType
	connection.AuthType = genruntime.ClonePointerToString(source.AuthType)

	// Category
	connection.Category = genruntime.ClonePointerToString(source.Category)

	// Conditions
	connection.Conditions = genruntime.CloneSliceOfCondition(source.Conditions)

	// Id
	connection.Id = genruntime.ClonePointerToString(source.Id)

	// Name
	connection.Name = genruntime.ClonePointerToString(source.Name)

	// Target
	connection.Target = genruntime.ClonePointerToString(source.Target)

	// Type
	connection.Type = genruntime.ClonePointerToString(source.Type)

	// Value
	connection.Value = genruntime.ClonePointerToString(source.Value)

	// ValueFormat
	if source.ValueFormat != nil {
		valueFormat := *source.ValueFormat
		valueFormatTemp := genruntime.ToEnum(valueFormat, workspaceConnectionProps_ValueFormat_STATUS_Values)
		connection.ValueFormat = &valueFormatTemp
	} else {
		connection.ValueFormat = nil
	}

	// No error
	return nil
}

// AssignProperties_To_WorkspacesConnection_STATUS populates the provided destination WorkspacesConnection_STATUS from our WorkspacesConnection_STATUS
func (connection *WorkspacesConnection_STATUS) AssignProperties_To_WorkspacesConnection_STATUS(destination *storage.WorkspacesConnection_STATUS) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// AuthType
	destination.AuthType = genruntime.ClonePointerToString(connection.AuthType)

	// Category
	destination.Category = genruntime.ClonePointerToString(connection.Category)

	// Conditions
	destination.Conditions = genruntime.CloneSliceOfCondition(connection.Conditions)

	// Id
	destination.Id = genruntime.ClonePointerToString(connection.Id)

	// Name
	destination.Name = genruntime.ClonePointerToString(connection.Name)

	// Target
	destination.Target = genruntime.ClonePointerToString(connection.Target)

	// Type
	destination.Type = genruntime.ClonePointerToString(connection.Type)

	// Value
	destination.Value = genruntime.ClonePointerToString(connection.Value)

	// ValueFormat
	if connection.ValueFormat != nil {
		valueFormat := string(*connection.ValueFormat)
		destination.ValueFormat = &valueFormat
	} else {
		destination.ValueFormat = nil
	}

	// Update the property bag
	if len(propertyBag) > 0 {
		destination.PropertyBag = propertyBag
	} else {
		destination.PropertyBag = nil
	}

	// No error
	return nil
}

// +kubebuilder:validation:Enum={"JSON"}
type WorkspaceConnectionProps_ValueFormat string

const WorkspaceConnectionProps_ValueFormat_JSON = WorkspaceConnectionProps_ValueFormat("JSON")

// Mapping from string to WorkspaceConnectionProps_ValueFormat
var workspaceConnectionProps_ValueFormat_Values = map[string]WorkspaceConnectionProps_ValueFormat{
	"json": WorkspaceConnectionProps_ValueFormat_JSON,
}

type WorkspaceConnectionProps_ValueFormat_STATUS string

const WorkspaceConnectionProps_ValueFormat_STATUS_JSON = WorkspaceConnectionProps_ValueFormat_STATUS("JSON")

// Mapping from string to WorkspaceConnectionProps_ValueFormat_STATUS
var workspaceConnectionProps_ValueFormat_STATUS_Values = map[string]WorkspaceConnectionProps_ValueFormat_STATUS{
	"json": WorkspaceConnectionProps_ValueFormat_STATUS_JSON,
}

// Details for configuring operator behavior. Fields in this struct are interpreted by the operator directly rather than being passed to Azure
type WorkspacesConnectionOperatorSpec struct {
	// ConfigMapExpressions: configures where to place operator written dynamic ConfigMaps (created with CEL expressions).
	ConfigMapExpressions []*core.DestinationExpression `json:"configMapExpressions,omitempty"`

	// SecretExpressions: configures where to place operator written dynamic secrets (created with CEL expressions).
	SecretExpressions []*core.DestinationExpression `json:"secretExpressions,omitempty"`
}

// AssignProperties_From_WorkspacesConnectionOperatorSpec populates our WorkspacesConnectionOperatorSpec from the provided source WorkspacesConnectionOperatorSpec
func (operator *WorkspacesConnectionOperatorSpec) AssignProperties_From_WorkspacesConnectionOperatorSpec(source *storage.WorkspacesConnectionOperatorSpec) error {

	// ConfigMapExpressions
	if source.ConfigMapExpressions != nil {
		configMapExpressionList := make([]*core.DestinationExpression, len(source.ConfigMapExpressions))
		for configMapExpressionIndex, configMapExpressionItem := range source.ConfigMapExpressions {
			if configMapExpressionItem != nil {
				configMapExpression := *configMapExpressionItem.DeepCopy()
				configMapExpressionList[configMapExpressionIndex] = &configMapExpression
			} else {
				configMapExpressionList[configMapExpressionIndex] = nil
			}
		}
		operator.ConfigMapExpressions = configMapExpressionList
	} else {
		operator.ConfigMapExpressions = nil
	}

	// SecretExpressions
	if source.SecretExpressions != nil {
		secretExpressionList := make([]*core.DestinationExpression, len(source.SecretExpressions))
		for secretExpressionIndex, secretExpressionItem := range source.SecretExpressions {
			if secretExpressionItem != nil {
				secretExpression := *secretExpressionItem.DeepCopy()
				secretExpressionList[secretExpressionIndex] = &secretExpression
			} else {
				secretExpressionList[secretExpressionIndex] = nil
			}
		}
		operator.SecretExpressions = secretExpressionList
	} else {
		operator.SecretExpressions = nil
	}

	// No error
	return nil
}

// AssignProperties_To_WorkspacesConnectionOperatorSpec populates the provided destination WorkspacesConnectionOperatorSpec from our WorkspacesConnectionOperatorSpec
func (operator *WorkspacesConnectionOperatorSpec) AssignProperties_To_WorkspacesConnectionOperatorSpec(destination *storage.WorkspacesConnectionOperatorSpec) error {
	// Create a new property bag
	propertyBag := genruntime.NewPropertyBag()

	// ConfigMapExpressions
	if operator.ConfigMapExpressions != nil {
		configMapExpressionList := make([]*core.DestinationExpression, len(operator.ConfigMapExpressions))
		for configMapExpressionIndex, configMapExpressionItem := range operator.ConfigMapExpressions {
			if configMapExpressionItem != nil {
				configMapExpression := *configMapExpressionItem.DeepCopy()
				configMapExpressionList[configMapExpressionIndex] = &configMapExpression
			} else {
				configMapExpressionList[configMapExpressionIndex] = nil
			}
		}
		destination.ConfigMapExpressions = configMapExpressionList
	} else {
		destination.ConfigMapExpressions = nil
	}

	// SecretExpressions
	if operator.SecretExpressions != nil {
		secretExpressionList := make([]*core.DestinationExpression, len(operator.SecretExpressions))
		for secretExpressionIndex, secretExpressionItem := range operator.SecretExpressions {
			if secretExpressionItem != nil {
				secretExpression := *secretExpressionItem.DeepCopy()
				secretExpressionList[secretExpressionIndex] = &secretExpression
			} else {
				secretExpressionList[secretExpressionIndex] = nil
			}
		}
		destination.SecretExpressions = secretExpressionList
	} else {
		destination.SecretExpressions = nil
	}

	// Update the property bag
	if len(propertyBag) > 0 {
		destination.PropertyBag = propertyBag
	} else {
		destination.PropertyBag = nil
	}

	// No error
	return nil
}

func init() {
	SchemeBuilder.Register(&WorkspacesConnection{}, &WorkspacesConnectionList{})
}
