@@ -2021,6 +2021,64 @@ def get_http_proxy_config(self) -> Union[Dict, ManagedClusterHTTPProxyConfig, No
20212021 # this parameter does not need validation
20222022 return http_proxy_config
20232023
2024+ def get_disable_http_proxy (self ) -> bool :
2025+ """Obtain the value of disable_http_proxy.
2026+
2027+ This function will verify the parameter by default. If both enable_http_proxy and disable_http_proxy are
2028+ specified, raise a MutuallyExclusiveArgumentError.
2029+
2030+ :return: bool
2031+ """
2032+ return self ._get_disable_http_proxy (enable_validation = True )
2033+
2034+ def _get_disable_http_proxy (self , enable_validation : bool = False ) -> bool :
2035+ """Internal function to obtain the value of disable_http_proxy.
2036+
2037+ This function supports the option of enable_validation. When enabled, if both enable_http_proxy and
2038+ disable_http_proxy are specified, raise a MutuallyExclusiveArgumentError.
2039+
2040+ :return: bool
2041+ """
2042+ # read the original value passed by the command
2043+ disable_http_proxy = self .raw_param .get ("disable_http_proxy" )
2044+
2045+ if enable_validation :
2046+ if disable_http_proxy and self ._get_enable_http_proxy (enable_validation = False ):
2047+ raise MutuallyExclusiveArgumentError (
2048+ "Cannot specify --enable-http-proxy and --disable-http-proxy at the same time."
2049+ )
2050+
2051+ return disable_http_proxy
2052+
2053+ def get_enable_http_proxy (self ) -> bool :
2054+ """Obtain the value of enable_http_proxy.
2055+
2056+ This function will verify the parameter by default. If both enable_http_proxy and disable_http_proxy are
2057+ specified, raise a MutuallyExclusiveArgumentError.
2058+
2059+ :return: bool
2060+ """
2061+ return self ._get_enable_http_proxy (enable_validation = True )
2062+
2063+ def _get_enable_http_proxy (self , enable_validation : bool = False ) -> bool :
2064+ """Internal function to obtain the value of enable_http_proxy.
2065+
2066+ This function supports the option of enable_validation. When enabled, if both enable_http_proxy and
2067+ disable_http_proxy are specified, raise a MutuallyExclusiveArgumentError.
2068+
2069+ :return: bool
2070+ """
2071+ # read the original value passed by the command
2072+ enable_http_proxy = self .raw_param .get ("enable_http_proxy" )
2073+
2074+ if enable_validation :
2075+ if enable_http_proxy and self ._get_disable_http_proxy (enable_validation = False ):
2076+ raise MutuallyExclusiveArgumentError (
2077+ "Cannot specify --enable-http-proxy and --disable-http-proxy at the same time."
2078+ )
2079+
2080+ return enable_http_proxy
2081+
20242082 def get_assignee_from_identity_or_sp_profile (self ) -> Tuple [str , bool ]:
20252083 """Helper function to obtain the value of assignee from identity_profile or service_principal_profile.
20262084
@@ -8490,11 +8548,38 @@ def update_monitoring_profile_flow_logs(self, mc: ManagedCluster) -> ManagedClus
84908548 def update_http_proxy_config (self , mc : ManagedCluster ) -> ManagedCluster :
84918549 """Set up http proxy config for the ManagedCluster object.
84928550
8551+ Only updates if --http-proxy-config was explicitly provided, to avoid wiping existing config.
8552+
84938553 :return: the ManagedCluster object
84948554 """
84958555 self ._ensure_mc (mc )
84968556
8497- mc .http_proxy_config = self .context .get_http_proxy_config ()
8557+ http_proxy_config = self .context .get_http_proxy_config ()
8558+ if http_proxy_config is not None :
8559+ mc .http_proxy_config = http_proxy_config
8560+ return mc
8561+
8562+ def update_http_proxy_enabled (self , mc : ManagedCluster ) -> ManagedCluster :
8563+ """Update http proxy enabled/disabled state for the ManagedCluster object.
8564+
8565+ :return: the ManagedCluster object
8566+ """
8567+ self ._ensure_mc (mc )
8568+
8569+ if self .context .get_disable_http_proxy ():
8570+ if mc .http_proxy_config is None :
8571+ mc .http_proxy_config = (
8572+ self .models .ManagedClusterHTTPProxyConfig () # pylint: disable=no-member
8573+ )
8574+ mc .http_proxy_config .enabled = False
8575+
8576+ if self .context .get_enable_http_proxy ():
8577+ if mc .http_proxy_config is None :
8578+ mc .http_proxy_config = (
8579+ self .models .ManagedClusterHTTPProxyConfig () # pylint: disable=no-member
8580+ )
8581+ mc .http_proxy_config .enabled = True
8582+
84988583 return mc
84998584
85008585 def update_identity (self , mc : ManagedCluster ) -> ManagedCluster :
@@ -9800,6 +9885,8 @@ def update_mc_profile_default(self) -> ManagedCluster:
98009885 mc = self .update_identity_profile (mc )
98019886 # set up http proxy config
98029887 mc = self .update_http_proxy_config (mc )
9888+ # update http proxy enabled/disabled state
9889+ mc = self .update_http_proxy_enabled (mc )
98039890 # update workload autoscaler profile
98049891 mc = self .update_workload_auto_scaler_profile (mc )
98059892 # update kubernetes support plan
0 commit comments