Skip to main content

google_cloud_gkeconnect_gateway_v1/
model.rs

1// Copyright 2025 Google LLC
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//     https://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// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate async_trait;
21extern crate bytes;
22extern crate gaxi;
23extern crate google_cloud_gax;
24extern crate serde;
25extern crate serde_json;
26extern crate serde_with;
27extern crate std;
28extern crate tracing;
29extern crate wkt;
30
31mod debug;
32mod deserialize;
33mod serialize;
34
35/// A request for connection information for a particular membership.
36#[derive(Clone, Default, PartialEq)]
37#[non_exhaustive]
38pub struct GenerateCredentialsRequest {
39    /// Required. The Fleet membership resource.
40    pub name: std::string::String,
41
42    /// Optional. Whether to force the use of Connect Agent-based transport.
43    ///
44    /// This will return a configuration that uses Connect Agent as the underlying
45    /// transport mechanism for cluster types that would otherwise have used a
46    /// different transport. Requires that Connect Agent be installed on the
47    /// cluster. Setting this field to false is equivalent to not setting it.
48    pub force_use_agent: bool,
49
50    /// Optional. The Connect Gateway version to be used in the resulting
51    /// configuration.
52    ///
53    /// Leave this field blank to let the server choose the version (recommended).
54    pub version: std::string::String,
55
56    /// Optional. The namespace to use in the kubeconfig context.
57    ///
58    /// If this field is specified, the server will set the `namespace` field in
59    /// kubeconfig context. If not specified, the `namespace` field is omitted.
60    pub kubernetes_namespace: std::string::String,
61
62    /// Optional. The operating system where the kubeconfig will be used.
63    pub operating_system: crate::model::generate_credentials_request::OperatingSystem,
64
65    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
66}
67
68impl GenerateCredentialsRequest {
69    /// Creates a new default instance.
70    pub fn new() -> Self {
71        std::default::Default::default()
72    }
73
74    /// Sets the value of [name][crate::model::GenerateCredentialsRequest::name].
75    ///
76    /// # Example
77    /// ```ignore,no_run
78    /// # use google_cloud_gkeconnect_gateway_v1::model::GenerateCredentialsRequest;
79    /// let x = GenerateCredentialsRequest::new().set_name("example");
80    /// ```
81    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
82        self.name = v.into();
83        self
84    }
85
86    /// Sets the value of [force_use_agent][crate::model::GenerateCredentialsRequest::force_use_agent].
87    ///
88    /// # Example
89    /// ```ignore,no_run
90    /// # use google_cloud_gkeconnect_gateway_v1::model::GenerateCredentialsRequest;
91    /// let x = GenerateCredentialsRequest::new().set_force_use_agent(true);
92    /// ```
93    pub fn set_force_use_agent<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
94        self.force_use_agent = v.into();
95        self
96    }
97
98    /// Sets the value of [version][crate::model::GenerateCredentialsRequest::version].
99    ///
100    /// # Example
101    /// ```ignore,no_run
102    /// # use google_cloud_gkeconnect_gateway_v1::model::GenerateCredentialsRequest;
103    /// let x = GenerateCredentialsRequest::new().set_version("example");
104    /// ```
105    pub fn set_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
106        self.version = v.into();
107        self
108    }
109
110    /// Sets the value of [kubernetes_namespace][crate::model::GenerateCredentialsRequest::kubernetes_namespace].
111    ///
112    /// # Example
113    /// ```ignore,no_run
114    /// # use google_cloud_gkeconnect_gateway_v1::model::GenerateCredentialsRequest;
115    /// let x = GenerateCredentialsRequest::new().set_kubernetes_namespace("example");
116    /// ```
117    pub fn set_kubernetes_namespace<T: std::convert::Into<std::string::String>>(
118        mut self,
119        v: T,
120    ) -> Self {
121        self.kubernetes_namespace = v.into();
122        self
123    }
124
125    /// Sets the value of [operating_system][crate::model::GenerateCredentialsRequest::operating_system].
126    ///
127    /// # Example
128    /// ```ignore,no_run
129    /// # use google_cloud_gkeconnect_gateway_v1::model::GenerateCredentialsRequest;
130    /// use google_cloud_gkeconnect_gateway_v1::model::generate_credentials_request::OperatingSystem;
131    /// let x0 = GenerateCredentialsRequest::new().set_operating_system(OperatingSystem::Windows);
132    /// ```
133    pub fn set_operating_system<
134        T: std::convert::Into<crate::model::generate_credentials_request::OperatingSystem>,
135    >(
136        mut self,
137        v: T,
138    ) -> Self {
139        self.operating_system = v.into();
140        self
141    }
142}
143
144impl wkt::message::Message for GenerateCredentialsRequest {
145    fn typename() -> &'static str {
146        "type.googleapis.com/google.cloud.gkeconnect.gateway.v1.GenerateCredentialsRequest"
147    }
148}
149
150/// Defines additional types related to [GenerateCredentialsRequest].
151pub mod generate_credentials_request {
152    #[allow(unused_imports)]
153    use super::*;
154
155    /// Operating systems requiring specialized kubeconfigs.
156    ///
157    /// # Working with unknown values
158    ///
159    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
160    /// additional enum variants at any time. Adding new variants is not considered
161    /// a breaking change. Applications should write their code in anticipation of:
162    ///
163    /// - New values appearing in future releases of the client library, **and**
164    /// - New values received dynamically, without application changes.
165    ///
166    /// Please consult the [Working with enums] section in the user guide for some
167    /// guidelines.
168    ///
169    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
170    #[derive(Clone, Debug, PartialEq)]
171    #[non_exhaustive]
172    pub enum OperatingSystem {
173        /// Generates a kubeconfig that works for all operating systems not defined
174        /// below.
175        Unspecified,
176        /// Generates a kubeconfig that is specifically designed to work with
177        /// Windows.
178        Windows,
179        /// If set, the enum was initialized with an unknown value.
180        ///
181        /// Applications can examine the value using [OperatingSystem::value] or
182        /// [OperatingSystem::name].
183        UnknownValue(operating_system::UnknownValue),
184    }
185
186    #[doc(hidden)]
187    pub mod operating_system {
188        #[allow(unused_imports)]
189        use super::*;
190        #[derive(Clone, Debug, PartialEq)]
191        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
192    }
193
194    impl OperatingSystem {
195        /// Gets the enum value.
196        ///
197        /// Returns `None` if the enum contains an unknown value deserialized from
198        /// the string representation of enums.
199        pub fn value(&self) -> std::option::Option<i32> {
200            match self {
201                Self::Unspecified => std::option::Option::Some(0),
202                Self::Windows => std::option::Option::Some(1),
203                Self::UnknownValue(u) => u.0.value(),
204            }
205        }
206
207        /// Gets the enum value as a string.
208        ///
209        /// Returns `None` if the enum contains an unknown value deserialized from
210        /// the integer representation of enums.
211        pub fn name(&self) -> std::option::Option<&str> {
212            match self {
213                Self::Unspecified => std::option::Option::Some("OPERATING_SYSTEM_UNSPECIFIED"),
214                Self::Windows => std::option::Option::Some("OPERATING_SYSTEM_WINDOWS"),
215                Self::UnknownValue(u) => u.0.name(),
216            }
217        }
218    }
219
220    impl std::default::Default for OperatingSystem {
221        fn default() -> Self {
222            use std::convert::From;
223            Self::from(0)
224        }
225    }
226
227    impl std::fmt::Display for OperatingSystem {
228        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
229            wkt::internal::display_enum(f, self.name(), self.value())
230        }
231    }
232
233    impl std::convert::From<i32> for OperatingSystem {
234        fn from(value: i32) -> Self {
235            match value {
236                0 => Self::Unspecified,
237                1 => Self::Windows,
238                _ => Self::UnknownValue(operating_system::UnknownValue(
239                    wkt::internal::UnknownEnumValue::Integer(value),
240                )),
241            }
242        }
243    }
244
245    impl std::convert::From<&str> for OperatingSystem {
246        fn from(value: &str) -> Self {
247            use std::string::ToString;
248            match value {
249                "OPERATING_SYSTEM_UNSPECIFIED" => Self::Unspecified,
250                "OPERATING_SYSTEM_WINDOWS" => Self::Windows,
251                _ => Self::UnknownValue(operating_system::UnknownValue(
252                    wkt::internal::UnknownEnumValue::String(value.to_string()),
253                )),
254            }
255        }
256    }
257
258    impl serde::ser::Serialize for OperatingSystem {
259        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
260        where
261            S: serde::Serializer,
262        {
263            match self {
264                Self::Unspecified => serializer.serialize_i32(0),
265                Self::Windows => serializer.serialize_i32(1),
266                Self::UnknownValue(u) => u.0.serialize(serializer),
267            }
268        }
269    }
270
271    impl<'de> serde::de::Deserialize<'de> for OperatingSystem {
272        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
273        where
274            D: serde::Deserializer<'de>,
275        {
276            deserializer.deserialize_any(wkt::internal::EnumVisitor::<OperatingSystem>::new(
277                ".google.cloud.gkeconnect.gateway.v1.GenerateCredentialsRequest.OperatingSystem",
278            ))
279        }
280    }
281}
282
283/// Connection information for a particular membership.
284#[derive(Clone, Default, PartialEq)]
285#[non_exhaustive]
286pub struct GenerateCredentialsResponse {
287    /// A full YAML kubeconfig in serialized format.
288    pub kubeconfig: ::bytes::Bytes,
289
290    /// The generated URI of the cluster as accessed through the Connect Gateway
291    /// API.
292    pub endpoint: std::string::String,
293
294    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
295}
296
297impl GenerateCredentialsResponse {
298    /// Creates a new default instance.
299    pub fn new() -> Self {
300        std::default::Default::default()
301    }
302
303    /// Sets the value of [kubeconfig][crate::model::GenerateCredentialsResponse::kubeconfig].
304    ///
305    /// # Example
306    /// ```ignore,no_run
307    /// # use google_cloud_gkeconnect_gateway_v1::model::GenerateCredentialsResponse;
308    /// let x = GenerateCredentialsResponse::new().set_kubeconfig(bytes::Bytes::from_static(b"example"));
309    /// ```
310    pub fn set_kubeconfig<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
311        self.kubeconfig = v.into();
312        self
313    }
314
315    /// Sets the value of [endpoint][crate::model::GenerateCredentialsResponse::endpoint].
316    ///
317    /// # Example
318    /// ```ignore,no_run
319    /// # use google_cloud_gkeconnect_gateway_v1::model::GenerateCredentialsResponse;
320    /// let x = GenerateCredentialsResponse::new().set_endpoint("example");
321    /// ```
322    pub fn set_endpoint<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
323        self.endpoint = v.into();
324        self
325    }
326}
327
328impl wkt::message::Message for GenerateCredentialsResponse {
329    fn typename() -> &'static str {
330        "type.googleapis.com/google.cloud.gkeconnect.gateway.v1.GenerateCredentialsResponse"
331    }
332}