
                         z    d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ	 ddl
mZ  G d d	ej                        Zy
)z?Client for interaction with Api Config CRUD on API Gateway API.    )absolute_import)division)unicode_literals)base)
exceptions)common_flagsc                   .    e Zd ZdZddZ	 	 	 ddZddZy)ApiConfigClientz7Client for Api Config objects on Cloud API Gateway API.Nc                 b   t         j                  j                  | |dd       | j                          | j	                  d       | j                  d       | j                  j                  j                  j                  | j                  j                  j                  j                  d| _        y )N&ApigatewayProjectsLocationsApisConfigsprojects_locations_apis_configs)clientmessage_baseservice_name
apiConfigsapigatewayApiConfig)FULLBASIC)r   
BaseClient__init__DefineDelete
DefineListDefineUpdatemessages0ApigatewayProjectsLocationsApisConfigsGetRequestViewValueValuesEnumr   r   supported_views)selfr   s     5lib/googlecloudsdk/api_lib/api_gateway/api_configs.pyr   zApiConfigClient.__init__   s    OO=6	  8
 	OOL!+, MMJJ  MMJJ  D    c           	      |   t        j                  || j                  j                  j                        }| j                  j                  |j                         ||||||      }| j                  |j                         ||j                         j                               }	| j                  j                  |	      S )a  Creates an Api Config object.

    Args:
      api_config_ref: A parsed resource reference for the api
      display_name: Optional string display name
      labels: Optional cloud labels (as provided in the labels argument)
      backend_auth: Optional string to set the service account for backend auth
      managed_service_configs: Optional field to send in a list of managed
       service configurations. Should be in the form of the
       ApigatewayApiConfigFileMessage's generated from the discovery document
      grpc_service_defs: Optional field to send in a list of GRPC service
       definitions. Should be in the form of
       ApigatewayApiConfigGrpcServiceDefinition's generated from the discovery
       document
      open_api_docs: Optional field to send in a list of Open API documents.
       Should be in the form of ApigatewayApiConfigOpenApiDocument's generated
       from the discovery document


    Returns:
      Long running operation
    )namedisplayNamelabelsgatewayServiceAccountmanagedServiceConfigsgrpcServicesopenapiDocuments)apiConfigIdr   parent)r   ProcessLabelsFlagr   ApigatewayApiConfigLabelsValueRelativeNamecreate_requestNameParentserviceCreate)
r   api_config_refdisplay_namer$   backend_authmanaged_service_configsgrpc_service_defsopen_api_docs
api_configreqs
             r   r3   zApiConfigClient.Create0   s    2 ++))557F 22((* *5&& 3 (J 

"'')&$$&335  7C
 <<s##r    c                    d}|	 | j                   |j                            }| j                  |j                         |      }| j                  j                  |      S # t        $ r t        j                  dd      w xY w)a~  Returns an API Config object.

    Args:
      api_config_ref: A parsed resource reference for the API.
      view: Optional string. If specified as FULL, the source config files will
        be returned.

    Returns:
      An API Config object.

    Raises:
      calliope.InvalidArgumentException: If an invalid view (i.e. not FULL,
      BASIC, or none) was
      provided.
    Nz--viewz'View must be one of: "FULL" or "BASIC".)r"   view)	r   upperKeyErrorcalliope_exceptionsInvalidArgumentExceptionget_requestr.   r2   Get)r   r4   r=   	view_enumr;   s        r   rC   zApiConfigClient.Get\   s    " IA((6	 

 ; ; =I

NC<<C    A!::?A 	AAs   A  A?)N)NNNNNN)__name__
__module____qualname____doc__r   r3   rC    r    r   r
   r
      s!    ?$ >B8<37*$X!r    r
   N)rH   
__future__r   r   r   "googlecloudsdk.api_lib.api_gatewayr   googlecloudsdk.callioper   r@   &googlecloudsdk.command_lib.api_gatewayr   r   r
   rI   r    r   <module>rN      s/     F &  ' 3 E ?[!doo [!r    