def testListMultipleMixedConfigurations(self): """Tests list for a variety of operations.""" o1 = self.MakeOperation(self.Project(), 'o1', True) list_entry = encoding.PyValueToMessage( self.messages.Status.DetailsValueListEntry, {'additionalProperties': { 'type@': 'type', 'info': 'info' }}) error = self.messages.Status(code=500, details=[list_entry], message='Internal Server Error') o2 = self.MakeOperation(self.Project(), 'o2', True, error=error) method_value = extra_types.JsonValue( string_value='google.appengine.v1.Versions.UpdateVersion') target_value = extra_types.JsonValue( string_value='apps/{}/services/flex/versions/2023394'.format( self.Project())) insert_time = extra_types.JsonValue( string_value='2016-11-21T14:21:14.643Z') props = { 'method': method_value, 'target': target_value, 'insertTime': insert_time } o3 = self.MakeOperation(self.Project(), 'o3', True, props=props) o4 = self.MakeOperation(self.Project(), 'o4', False) o1_template = operations_util.Operation(o1) o2_template = operations_util.Operation(o2) o3_template = operations_util.Operation(o3) o4_template = operations_util.Operation(o4) self.ExpectListOperationsRequest( self.Project(), self.MakeListOperationsResponse([o1, o2, o3, o4])) operations = list(self.Run('app operations list --format=disable')) self.assertEqual(len(operations), 4) self.assertEqual(operations[0], o1_template) self.assertEqual(operations[1], o2_template) self.assertEqual(operations[2], o3_template) self.assertEqual(operations[3], o4_template)
def ListOperations(self, op_filter=None): """Lists all operations for the given application. Args: op_filter: String to filter which operations to grab. Returns: A list of opeartion_util.Operation objects. """ request = self.messages.AppengineAppsOperationsListRequest( name=self._FormatApp(), filter=op_filter) response = requests.MakeRequest(self.client.apps_operations.List, request) return [operations_util.Operation(op) for op in response.operations]
def ListOperations(self, op_filter=None): """Lists all operations for the given application. Args: op_filter: String to filter which operations to grab. Returns: A list of opeartion_util.Operation objects. """ request = self.messages.AppengineAppsOperationsListRequest( name=self._FormatApp(), filter=op_filter) operations = list_pager.YieldFromList( self.client.apps_operations, request, field='operations', batch_size=100, batch_size_attribute='pageSize') return [operations_util.Operation(op) for op in operations]
def testListOnlyPending(self): """Tests list for a variety of operations.""" self.MakeOperation(self.Project(), 'o1', True) list_entry = encoding.PyValueToMessage( self.messages.Status.DetailsValueListEntry, {'additionalProperties': { 'type@': 'type', 'info': 'info' }}) error = self.messages.Status(code=500, details=[list_entry], message='Internal Server Error') self.MakeOperation(self.Project(), 'o2', True, error=error) o3 = self.MakeOperation(self.Project(), 'o3', False) o3_template = operations_util.Operation(o3) self.ExpectListOperationsRequest(self.Project(), self.MakeListOperationsResponse([o3]), filter_='done:false') operations = list( self.Run('app operations list --pending --format=disable')) self.assertEqual(len(operations), 1) self.assertEqual(operations[0], o3_template)