
    J
                        d Z ddlmZ ddlmZ ddlmZ ddlZddlmZ ddlZ G d de	      Z
 ej                  ej                         G d	 d
e	             Z G d de      Z G d de      Z G d de      Z G d dej"                        Zy)zIAdd, replace or delete the cached resource URIs from a single collection.    )absolute_import)division)unicode_literalsN)resource_cachec                       e Zd ZdZd Zy)
_TableRowsz0An _UpdateCacheOp._GetTablesFromUris dict entry.c                      || _         g | _        y N)tablerows)selfr   s     1lib/googlecloudsdk/core/cache/cache_update_ops.py__init__z_TableRows.__init__    s    DJDI    N)__name__
__module____qualname____doc__r    r   r   r   r      s
    8r   r   c                   @    e Zd ZdZd Zd Zej                  d        Zy)_UpdateCacheOpz&The cache update operation base class.c                     || _         y r
   )_completer_class)r   	completers     r   r   z_UpdateCacheOp.__init__)   s
    %Dr   c                    	 t        j                         5 }| j                  |      }i }|D ]v  }|j                  |      }|j	                  |      }|j                  |j                        }|st        |      }|||j                  <   |j                  j                  |       x t        j                  |      D ]  \  }}	| j                  ||	        	 ddd       y# 1 sw Y   yxY w# t        $ r Y yw xY w)z?Applies UpdateRows() to tables that contain the resources uris.)cacheN)r   ResourceCacher   StringToRowGetTableForRowgetnamer   r   appendsix	iteritems
UpdateRows	Exception)
r   urisr   r   tablesurirowr   entryr   s
             r   Updatez_UpdateCacheOp.Update,   s    '')U)))6	C%%c*#**3/%**UZZ(%u%E!&F5::
**

C
   ==0KE4
//%
& 1 *))  
s/   C+ B?CC+ C($C+ (C+ +	C76C7c                      y)zUpdates table with rows.Nr   r   r   r   s      r   r%   z_UpdateCacheOp.UpdateRows?   s     	r   N)	r   r   r   r   r   r,   abcabstractmethodr%   r   r   r   r   r   %   s)    .&& 	 	r   r   c                       e Zd ZdZd Zy)AddToCacheOpzAn AddToCache operation.c                 &    |j                  |       y)zAdds rows to table.N)AddRowsr.   s      r   r%   zAddToCacheOp.UpdateRowsH   s    	MM$r   Nr   r   r   r   r%   r   r   r   r2   r2   E   s
     r   r2   c                       e Zd ZdZd Zy)DeleteFromCacheOpzA DeleteFromCache operation.c                 &    |j                  |       y)zDeletes rows from table.N)
DeleteRowsr.   s      r   r%   zDeleteFromCacheOp.UpdateRowsP   s    	Tr   Nr5   r   r   r   r7   r7   M   s
    $r   r7   c                       e Zd ZdZd Zy)ReplaceCacheOpzA ReplaceCache operation.c                 F    |j                          |j                  |       y)zReplaces table with rows.N)r9   r4   r.   s      r   r%   zReplaceCacheOp.UpdateRowsX   s    		MM$r   Nr5   r   r   r   r;   r;   U   s
    !r   r;   c                       e Zd ZdZy)NoCacheUpdaterzNo cache updater.N)r   r   r   r   r   r   r   r>   r>   ^   s    r   r>   )r   
__future__r   r   r   r/   googlecloudsdk.core.cacher   r#   objectr   add_metaclassABCMetar   r2   r7   r;   BaseUpdaterr>   r   r   r   <module>rE      s     P &  ' 
 4 
  3;;	V 	  	>>  ^ ^// r   