
    BA                         S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJ	r	  SSKJ
r
  SS	KJr  SS
KJr  SSKJr   " S S\	R                  5      rg)z(Command to modify an Apigee API product.    )absolute_import)division)unicode_literalsN)apigee)base)
exceptions)argument_groups)defaults)resource_argsc                   8    \ rS rSrSrSSS.r\S 5       rS rSr	g	)
Update   z&Update an existing Apigee API product.z
          {description}

          `{command}` applies a set of modifications to an existing API product.

          To create a new API product, run:

              $ {parent_command} create
          a  
          To update the display name of the API product with the internal name ``my-prod'', run:

              $ {command} my-prod --display-name="Example Project"

          To update the description of the API product, run:

              $ {command} my-prod --description="This API is famous for appearing in a YouTube video."

          To remove the API product's description, run:

              $ {command} my-prod --clear-description

          To remove manual approval requirements from the API and change its access level to public, run:

              $ {command} my-prod --public-access --automatic-approval

          To impose a quota of 45 calls per minute per application on the API product, run:

              $ {command} my-prod --quota=45 --quota-interval=1 --quota-unit=minute

          To remove a quota on the API product and switch it to unlisted access with manual approval, run:

              $ {command} my-prod --manual-approval --private-access --clear-quota

          To set the API product's custom attribute ``foo'' to the value ``bar'', updating that attribute if it exists and creating it if it doesn't, and remove the attribute ``baz'' if it exists, run:

              $ {command} my-prod --add-attribute="foo=bar"  --remove-attribute=baz

          To update the list of API proxies included in the API product, run:

              $ {command} my-prod --add-api=NEW_ONE,NEW_TWO --remove-api=OLD_ONE,OLD_TWO

          To switch the API product to including all ``test'' environment APIs no matter what API proxy or resource they expose, run:

              $ {command} my-prod --add-environment=test --all-apis --all-resources

          To update the list of API resources included in the API product, and
          output the updated API product as a JSON object, run:

              $ {command} my-prod --add-resource="NEW_ONE#NEW_TWO" --remove-resource="OLD_ONE#OLD_TWO" --format=json
          )DESCRIPTIONEXAMPLESc                    [         R                  " U SS[        R                  " 5       /S9  [        R
                  " U SSSSSSS	9  U R                  S
SSS9  U R                  5       nUR                  SSSSSS9  UR                  SSSSSS9  UR                  SSSSSS9  [        R
                  " U SSSSSSS 9  [        R
                  " U S!S"S#S$[        R                  " 5       S%S&S'9  U R                  5       nUR                  S(5      nUR                  S)[        S*S+9  UR                  S,[        S-S+9  UR                  S./ S/QS0S19  UR                  S2S3S4S59  [        R                  " U S6S7S85        U R                  5       nUR                  S9SS:S;S<S=9  UR                  S>SS?S;S@S=9  [        R
                  " U SASBSCSDSE9  [        R
                  " U SFSGSHSISJSKSL9  g )MNzorganization.productzhAPI product to be updated. To get a list of available API products, run:


    $ {parent_command} list

)fallthroughsenvironmentenvironmentsa  Environments to which the API product is bound. Requests to environments that are not listed are rejected, preventing developers from accessing those resources even if they can access the same API proxies in another environment.

For example, this can be used to prevent applications with access to production APIs from accessing the alpha or beta versions of those APIs.

To get a list of available environments, run:

    $ {grandparent_command} environments listz--all-environmentsz:Make all environments accessible through this API product.)	clear_arg
clear_helpdest--display-nameset_displayNamez\Name to be displayed in the UI or developer portal to developers registering for API access.)r   helpz--public-accessaccessstore_constpubliczKMake this API product visible to developers in the Apigee developer portal.)r   actionconstr   z--private-accessprivatez\Hide this API product in the developer portal but make it accessible by external developers.z--internal-accessinternalz,Prevent external access to this API product.APIAPIsa  API proxies to which this API product is bound. Only those API
proxies will be accessible through the API product.

The API proxy names must already be deployed to the bound environments, or
creation of the API product will fail. To get a list of deployed API proxies,
run:

    $ {grandparent_command} deployments list

To deploy an API proxy, run:

    $ {grandparent_command} apis deploy.proxiesz
--all-apisz\Include all deployed API proxies in the product, so long as they match the other parameters.)r   r   r   resource	resourcesa(  API resources to be bundled in the API product.

By default, the resource paths are mapped from the `proxy.pathsuffix` variable.

The proxy path suffix is defined as the URI fragment following the
ProxyEndpoint base path. For example, if ``/forecastrss'' is given as an element
of this list, and the base path defined for the API proxy is `/weather`, then
only requests to `/weather/forecastrss` are permitted by the API product.

Proxy paths can use asterisks as wildcards; `/**` indicates that all sub-URIs
are included, whereas a single asterisk indicates that only URIs one level
down are included.

By default, `/` supports the same resources as `/**` as well as the base path
defined by the API proxy.

For example, if the base path of the API proxy is `/v1/weatherapikey`, then
the API product supports requests to `/v1/weatherapikey` and to any sub-URIs,
such as `/v1/weatherapikey/forecastrss`, `/v1/weatherapikey/region/CA`, and so
on.

The API proxy resources must already be deployed to the bound environments, or
creation of the API product will fail.apiResourcesz--all-resourcesz^Include all deployed API resources in the product, so long as they match the other parameters.)r   collector_typer   r   zRTo impose a quota limit on calls to the API product, specify all of the following:--quotazNumber of request messages permitted per app by this API
product for the specified `--quota-interval` and `--quota-unit`.

For example, `--quota=50`, `--quota-interval=12`, and `--quota-unit=hour` means
50 requests are allowed every 12 hours.)typer   --quota-intervalzFTime interval over which the number of request messages is calculated.--quota-unit)minutehourdaymonthz!Time unit for `--quota-interval`.)choicesr   z--clear-quota
store_truez6Remove any quota currently imposed on the API product.)r   r   descriptionzpOverview of the API product. Include key information about the API product that is not captured by other fields.z%Remove the API product's description.z--manual-approvalmanualset_approvalTypezpRequire manual approval of developer requests to access this API product before their consumer keys can be used.)r   r   r   r   z--automatic-approvalautozQAllow developers to generate approved consumer keys without waiting for approval.zOAuth scopezOAuth scopeszComma-separated list of OAuth scopes that are validated at runtime. Apigee validates that the scopes in any access token presented match the scopes defined in the OAuth policy assoicated with the API product.scopes)r   	attribute
attributeszKey-value attribute pairs that may be used to extend the default API product profile with customer-specific metadata. Up to 17 attributes can be specified.Tz
NAME=VALUENAME)	dict_likeadd_metavarremove_metavar)r   AddSingleResourceArgumentr
   !GCPProductOrganizationFallthroughr	   AddEditableListArgumentadd_argumentadd_mutually_exclusive_groupHashDelimitedArgListadd_argument_groupintAddClearableArgument)parseraccess_groupquota_mutexquota_groupapproval_groups        %lib/surface/apigee/products/update.pyArgsUpdate.ArgsZ   s   ++	* @@BCE ++	8 'O" 7  9 668L"  $ 3  5 ;  = ++	, .%/( ++	*. &;;=#.=/B 557K00
K +  , 0  2
 21  4
 E  G
 ((	8/	1 88:ND   F &   ( ++	  ++	  	    c                 	   UR                   R                  R                  5       R                  5       n[        R
                  R                  U5      nUR                  b  SUR                  -  US'   UR                  b  SUR                  -  US'   UR                  (       a  UR                  US'   / SQnU Vs/ s H  oUU;   PM	     nn[        U5      (       aQ  [        U5      (       dA  UR                  (       d  SnOUR                  (       d  SnOS	n[        R                  " US
5      eUR                  (       a  US	 US	 US	 SUl        SU;   a  US   O/ nU V	s/ s H  oS   U	S   4PM     nn	[        R                   " U5      n
UR"                  bJ  UR"                  nSU;   a   US   S;  a  [        R$                  " SS5      eU
R'                  U5        SUl        UR(                  bZ  UR(                   HC  nSU;   a(  UR*                  (       d  [        R$                  " SS5      eU H  n	X;   d  M
  X	 M     ME     SUl        UR,                  (       a!  SU
;   a  U
S   OSnU(       a  SU0O0 n
SUl        UR*                  (       a  UR*                  U
S'   S nU
R/                  5        V	s/ s H
  o" U	5      PM     nn	XS'   UR0                  (       d$  UR0                  b  [        R$                  " SS5      e[3        5       n[5        U5      nUR/                  5        H  u  nnUb  SU;  a  M  UR7                  SS5      u  nnUS:X  a   XS;  a  / X5'   U H  nX5==   U-  ss'   M     ML  US:X  aV  XS;   aQ  U HI  nU H@  n	XU   ;   d  M  X5   R9                  U	5        X5   (       a  M+  SX5'   UR;                  U5        MB     MK     M  US:X  a  UX5'   M  US:X  d  M  U(       d  M  XS;   d  M  X5	 M     SU;   a  [        R$                  " SS5      eS U;   a  [        R$                  " S!S"5      eS#U;   a  [        R$                  " S$S%5      e[        R<                  R>                   Vs0 s H  nUUU;   a  UU   OS_M     nnUS&   US'   [        R<                  " S'0 UD6n[        R
                  RA                  UU5      $ s  snf s  sn	f s  sn	f s  snf )(zRun the update command.Nz%dquotaquotaIntervalquotaTimeUnit)rQ   rR   rS   r+   r,   r)   z;Products with quotas must specify all three quota settings.r9   namevaluer   )r   r    r!   z--add-attributezPThe `access` attribute must be set to one of "public", "private", or "internal".z--remove-attributez#The `access` attribute is required.c                     U S   U S   S.$ )Nr      )rT   rU    )items    rL   <lambda>Update.Run.<locals>.<lambda>R  s    47T!W"ErO   r   z.An API product's display name cannot be blank._rW   addremovesetclearr$   z--remove-apizAn API product must include at least one API proxy, or else all API proxies will implicitly be included. If this was intended, use [--all-apis] instead of removing APIs individually.r'   z--remove-resourcezAn API product must include at least one API resource, or else all resources will implicitly be included. If this was intended, use [--all-resources] instead of removing resources individually.r   z--remove-environmentzAn API product must include at least one environment, or else all environments will implicitly be included. If this was intended, use [--all-environments] instead of removing environments individually.apiproductsIdrX   )!CONCEPTSproductParseAsDictr   ProductsClientDescriberQ   quota_interval
quota_unitanyallr   RequiredArgumentExceptionclear_quotacollectionsOrderedDictadd_attributeBadArgumentExceptionupdateremove_attributer   clear_attributesitemsr   r_   varssplitr^   r]   ProductsInfo_fieldsr   )selfargsidentifiersrc   quota_field_namesfieldquota_fields_existmissing_argattribute_listrY   r9   add_attributessublistr   attribute_dictattributes_dictsemptied_listsarg_dictkeyrU   labelupdated_products                         rL   Run
Update.Run  s   --''--/668K##,,[9G zz

*gg&!%(;(;!;go!%goC8IJ8Iu7*8IJ
s+='>'>  ($00

GI I 
'

/
"
/
"d /;g.EW\*2N@NOF|T']3NO((8J%))n
n
$

"*K
K--,- 	- 'd(**'wt{{//"$IK KD  	 + #d (0:'=z(#4f)/Hf%Rj"d{{![[jEN9C9I9I9KL9Kt,9KL,L D$8$8$D++
LN N EMDzHnn&
U	#S.YYsA&leU	%'.G
.G
#. H!1Gdu~%n##D)^^ "&!!%(   E>G%*:N- '8 M! ++
@A A &++
JK K &++
 PQ Q &&...C 	cWngcl$6.  
 "/2GFO))4G4O  ''_EEC K& PH MDs   8R9R>+S!SrX   N)
__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodrM   r   __static_attributes__rX   rO   rL   r   r      s5    .)6-p p pdPFrO   r   )r   
__future__r   r   r   rn   googlecloudsdk.api_libr   googlecloudsdk.callioper   r   !googlecloudsdk.command_lib.apigeer	   r
   r   DescribeCommandr   rX   rO   rL   <module>r      s>    / &  '  ) ( . = 6 ;~FT!! ~FrO   