original_docstring:  Update the throughput on a table or index 
docstring: Update the throughput on a table or index
docstring_tokens: Update the throughput on a table or index
code: def _update_throughput(self, tablename, read, write, index):
          """ Update the throughput on a table or index """
  
          def get_desc() -> Union[TableMeta, GlobalIndexMeta]:
              """ Get the table or global index description """
              desc = self.describe(tablename, refresh=True, require=True)
              if index is not None:
                  return desc.global_indexes[index]
              return desc
  
          desc = get_desc()
  
          def num_or_star(value):
              """ Convert * to -1, otherwise resolve a number """
              return -1 if value == "*" else resolve(value)
  
          read = num_or_star(read)
          write = num_or_star(write)
          if read < 0:
              read = 0 if desc.throughput is None else desc.throughput.read
          if write < 0:
              write = 0 if desc.throughput is None else desc.throughput.write
  
          throughput = Throughput(read, write)
  
          kwargs = {}
          if index:
              self.connection.update_table(
                  tablename, index_updates=[IndexUpdate.update(index, throughput)]
              )
          elif throughput.read or throughput.write:
              self.connection.update_table(
                  tablename, billing_mode=PROVISIONED, throughput=throughput
              )
          else:
              self.connection.update_table(tablename, billing_mode=PAY_PER_REQUEST)
          desc = get_desc()
          while desc.status == "UPDATING":  # pragma: no cover
              time.sleep(5)
              desc = get_desc()
code_tokens: def _update_throughput ( self , tablename , read , write , index ) : def get_desc ( ) -> Union [ TableMeta , GlobalIndexMeta ] : """ Get the table or global index description """ desc = self . describe ( tablename , refresh = True , require = True ) if index is not None : return desc . global_indexes [ index ] return desc desc = get_desc ( ) def num_or_star ( value ) : """ Convert * to -1, otherwise resolve a number """ return - 1 if value == "*" else resolve ( value ) read = num_or_star ( read ) write = num_or_star ( write ) if read < 0 : read = 0 if desc . throughput is None else desc . throughput . read if write < 0 : write = 0 if desc . throughput is None else desc . throughput . write throughput = Throughput ( read , write ) kwargs = { } if index : self . connection . update_table ( tablename , index_updates = [ IndexUpdate . update ( index , throughput ) ] ) elif throughput . read or throughput . write : self . connection . update_table ( tablename , billing_mode = PROVISIONED , throughput = throughput ) else : self . connection . update_table ( tablename , billing_mode = PAY_PER_REQUEST ) desc = get_desc ( ) while desc . status == "UPDATING" : time . sleep ( 5 ) desc = get_desc ( )
short_docstring: Update the throughput on a table or index
short_docstring_tokens: Update the throughput on a table or index
comment: """ Update the throughput on a table or index """$SEP$""" Get the table or global index description """$SEP$""" Convert * to -1, otherwise resolve a number """$SEP$# pragma: no cover