|
| 1 | +// Copyright 2025 MongoDB Inc |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package v1 |
| 16 | + |
| 17 | +import ( |
| 18 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 19 | + |
| 20 | + "github.com/mongodb/mongodb-atlas-kubernetes/v2/api" |
| 21 | + "github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1/status" |
| 22 | +) |
| 23 | + |
| 24 | +func init() { |
| 25 | + SchemeBuilder.Register(&AtlasOrgSettings{}) |
| 26 | + SchemeBuilder.Register(&AtlasOrgSettingsList{}) |
| 27 | +} |
| 28 | + |
| 29 | +type AtlasOrgSettingsSpec struct { |
| 30 | + // OrgId Unique 24-hexadecimal digit string that identifies the organization that |
| 31 | + // contains your projects |
| 32 | + // +required |
| 33 | + OrgID string `json:"orgID"` |
| 34 | + |
| 35 | + // ConnectionSecretRef is the name of the Kubernetes Secret which contains the information about the way to connect to |
| 36 | + // Atlas (Public & Private API keys). |
| 37 | + ConnectionSecretRef *api.LocalObjectReference `json:"connectionSecretRef,omitempty"` |
| 38 | + |
| 39 | + // ApiAccessListRequired Flag that indicates whether to require API operations to |
| 40 | + // originate from an IP Address added to the API access list for the specified |
| 41 | + // organization. |
| 42 | + // +optional |
| 43 | + ApiAccessListRequired *bool `json:"apiAccessListRequired,omitempty"` |
| 44 | + |
| 45 | + // GenAIFeaturesEnabled Flag that indicates whether this organization has access to |
| 46 | + // generative AI features. This setting only applies to Atlas Commercial and is |
| 47 | + // enabled by default. Once this setting is turned on, Project Owners may be able |
| 48 | + // to enable or disable individual AI features at the project level. |
| 49 | + // +optional |
| 50 | + GenAIFeaturesEnabled *bool `json:"genAIFeaturesEnabled,omitempty"` |
| 51 | + |
| 52 | + // MaxServiceAccountSecretValidityInHours Number that represents the maximum period |
| 53 | + // before expiry in hours for new Atlas Admin API Service Account secrets within |
| 54 | + // the specified organization. |
| 55 | + // +optional |
| 56 | + MaxServiceAccountSecretValidityInHours *int `json:"maxServiceAccountSecretValidityInHours,omitempty"` |
| 57 | + |
| 58 | + // MultiFactorAuthRequired Flag that indicates whether to require users to set up |
| 59 | + // Multi-Factor Authentication (MFA) before accessing the specified organization. |
| 60 | + // To learn more, see: |
| 61 | + // https://www.mongodb.com/docs/atlas/security-multi-factor-authentication/. |
| 62 | + // +optional |
| 63 | + MultiFactorAuthRequired *bool `json:"multiFactorAuthRequired,omitempty"` |
| 64 | + |
| 65 | + // RestrictEmployeeAccess Flag that indicates whether to block MongoDB Support from |
| 66 | + // accessing Atlas infrastructure and cluster logs for any deployment in the |
| 67 | + // specified organization without explicit permission. Once this setting is turned |
| 68 | + // on, you can grant MongoDB Support a 24-hour bypass access to the Atlas |
| 69 | + // deployment to resolve support issues. To learn more, see: |
| 70 | + // https://www.mongodb.com/docs/atlas/security-restrict-support-access/. |
| 71 | + // +optional |
| 72 | + RestrictEmployeeAccess *bool `json:"restrictEmployeeAccess,omitempty"` |
| 73 | + |
| 74 | + // SecurityContact String that specifies a single email address for the specified |
| 75 | + // organization to receive security-related notifications. Specifying a security |
| 76 | + // contact does not grant them authorization or access to Atlas for security |
| 77 | + // decisions or approvals. An empty string is valid and clears the existing |
| 78 | + // security contact (if any). |
| 79 | + // +optional |
| 80 | + SecurityContact *string `json:"securityContact,omitempty"` |
| 81 | + |
| 82 | + // StreamsCrossGroupEnabled Flag that indicates whether a group's Atlas Stream |
| 83 | + // Processing instances in this organization can create connections to other |
| 84 | + // group's clusters in the same organization. |
| 85 | + // +optional |
| 86 | + StreamsCrossGroupEnabled *bool `json:"streamsCrossGroupEnabled,omitempty"` |
| 87 | +} |
| 88 | + |
| 89 | +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 90 | +// +kubebuilder:object:root=true |
| 91 | +// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status` |
| 92 | +// +kubebuilder:name:plural=AtlasOrgSettings, singular=AtlasOrgSettings |
| 93 | +// +kubebuilder:resource:categories=atlas,shortName=aos |
| 94 | +// +kubebuilder:subresource:status |
| 95 | +type AtlasOrgSettings struct { |
| 96 | + metav1.TypeMeta `json:",inline"` |
| 97 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 98 | + |
| 99 | + Spec AtlasOrgSettingsSpec `json:"spec,omitempty"` |
| 100 | + Status status.AtlasOrgSettingsStatus `json:"status,omitempty"` |
| 101 | +} |
| 102 | + |
| 103 | +func (aos *AtlasOrgSettings) Credentials() *api.LocalObjectReference { |
| 104 | + return aos.Spec.ConnectionSecretRef |
| 105 | +} |
| 106 | + |
| 107 | +func (aos *AtlasOrgSettings) GetConditions() []metav1.Condition { |
| 108 | + if aos.Status.Conditions == nil { |
| 109 | + return []metav1.Condition{} |
| 110 | + } |
| 111 | + return aos.Status.Conditions |
| 112 | +} |
| 113 | + |
| 114 | +// +kubebuilder:object:root=true |
| 115 | +type AtlasOrgSettingsList struct { |
| 116 | + metav1.TypeMeta `json:",inline"` |
| 117 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 118 | + Items []AtlasOrgSettings `json:"items"` |
| 119 | +} |
0 commit comments