def gcloud_clusters_set_master_authorized_network_command( client: ClusterManagerClient, project: str, cluster: str, zone: str, enable: Optional[str] = None, cidrs: Optional[str] = None) -> COMMAND_OUTPUT: """ Enable or Disable authorized CIDRs to master node and add cidrs. https://cloud.google.com/sdk/gcloud/reference/container/clusters/update#--master-authorized-networks Args: client: Google container client. project: GCP project from console. zone: Project query zone, e.g. "europe-west2-a". cluster: Cluster ID, e.g. "dmst-gcloud-cluster-1". enable: "true" or "false" cidrs: Comma seprated list of CIDRs 192.160.0.0/24,10.0.0.0/24, Returns: str: Human readable. dict: Operation entry context. dict: Operation raw response. """ # Perform cluster update update = { 'desired_master_authorized_networks_config': { 'enabled': enable == 'true', 'cidr_blocks': [{ 'cidr_block': cidr_block } for cidr_block in argToList(cidrs)] } } raw_response_msg: Message = client.update_cluster(project_id=project, zone=zone, cluster_id=cluster, update=update, timeout=API_TIMEOUT) raw_response_dict: dict = MessageToDict(raw_response_msg) # Entry context operation: dict = parse_operation(raw_response_dict) entry_context = { OPERATION_CONTEXT: operation, } # Human readable human_readable: str = tableToMarkdown( t=operation, headers=OPERATION_TABLE, name= f'Set master authorized networks - Operation: {operation.get("Name")}') return human_readable, entry_context, raw_response_dict
def gcloud_clusters_set_binary_auth( client: ClusterManagerClient, project: str, cluster: str, zone: str, enable: Optional[str] = None) -> COMMAND_OUTPUT: """ Enable or Disable binary authorize. https://cloud.google.com/sdk/gcloud/reference/container/clusters/update#--enable-binauthz Args: client: Google container client. project: GCP project from console. zone: Project query zone, e.g. "europe-west2-a". cluster: Cluster ID, e.g. "dmst-gcloud-cluster-1". enable: "true" or "false" Returns: str: Human readable. dict: Operation entry context. dict: Operation raw response. """ # Perform cluster update update = { 'desired_binary_authorization': { 'enabled': enable == 'enable', } } raw_response_msg: Message = client.update_cluster(project_id=project, zone=zone, cluster_id=cluster, update=update, timeout=API_TIMEOUT) raw_response_dict: dict = MessageToDict(raw_response_msg) # Entry context operation: dict = parse_operation(raw_response_dict) entry_context = { OPERATION_CONTEXT: operation, } # Human readable human_readable: str = tableToMarkdown( t=operation, headers=OPERATION_TABLE, name= f'Set kubernetes binary authorization - Operation: {operation.get("Name")}' ) return human_readable, entry_context, raw_response_dict