Resources¶
Este módulo que contem as queries de acordo com cada entidade do projeto.
Fornecedor¶
- class
salic_api.resources.FornecedorDetail(query_data=None)¶Class related with information about an specific Fornecedor
build_query_args()¶Return a dictionary with arguments to be passed to the query method of the query class.
hal_links(result)¶Responsable for generate Fornecedores” urls
query_class¶pseudónimo de
salic_api.resources.fornecedor.query.FornecedorQuery
- class
salic_api.resources.FornecedorList¶Class related with informations about Fornecedores” list of one project
detail_resource_class¶pseudónimo de
salic_api.resources.fornecedor.fornecedor_detail.FornecedorDetail
prepared_detail_object(item)¶Modify list of arguments to pass to a detail resource.
query_class¶pseudónimo de
salic_api.resources.fornecedor.query.FornecedorQuery
- class
salic_api.resources.ProdutoDetail(query_data=None)¶
hal_links(result)¶Responsable for generate Projetos and Fornecedores” urls
- class
salic_api.resources.Produto¶
build_query_args()¶Return a dictionary with arguments to be passed to the query method of the query class.
detail_resource_class¶pseudónimo de
ProdutoDetail
query_class¶pseudónimo de
salic_api.resources.fornecedor.query.ProductQuery
Incentivador¶
- class
salic_api.resources.DoacaoList¶
build_query_args()¶Return a dictionary with arguments to be passed to the query method of the query class.
detail_resource_class¶pseudónimo de
DoacaoDetail
query_class¶pseudónimo de
salic_api.resources.incentivador.query.DoacaoQuery
- class
salic_api.resources.DoacaoDetail(query_data=None)¶
hal_links(result)¶Return the link dictionary that is stored on “_links” field of a JSON+HAL response.
prepare_result(result)¶Clean result after insertion of related objects.
The default implementation does nothing, but can be overridden in subclasses.
- class
salic_api.resources.IncentivadorDetail(query_data=None)¶
build_query_args()¶Return a dictionary with arguments to be passed to the query method of the query class.
hal_links(result)¶Return the link dictionary that is stored on “_links” field of a JSON+HAL response.
prepare_result(result)¶Clean result after insertion of related objects.
The default implementation does nothing, but can be overridden in subclasses.
query_class¶pseudónimo de
salic_api.resources.incentivador.query.IncentivadorQuery
- class
salic_api.resources.IncentivadorList¶
detail_resource_class¶pseudónimo de
salic_api.resources.incentivador.incentivador_detail.IncentivadorDetail
prepared_detail_object(item)¶Modify list of arguments to pass to a detail resource.
query_class¶pseudónimo de
salic_api.resources.incentivador.query.IncentivadorQuery
- class
salic_api.resources.IncentivadorQuery¶
- class
salic_api.resources.DoacaoQuery¶
Pre Projeto¶
- class
salic_api.resources.PreProjetoDetail(query_data=None)¶
hal_links(result)¶Return the link dictionary that is stored on “_links” field of a JSON+HAL response.
query_class¶pseudónimo de
salic_api.resources.preprojeto.query.PreProjetoQuery
- class
salic_api.resources.PreProjetoList¶
detail_resource_class¶pseudónimo de
salic_api.resources.preprojeto.pre_projeto_detail.PreProjetoDetail
query_class¶pseudónimo de
salic_api.resources.preprojeto.query.PreProjetoQuery
- class
salic_api.resources.PreProjetoQuery¶
Projeto¶
- class
salic_api.resources.Area¶
detail_resource_class¶pseudónimo de
AreaDetail
query_class¶pseudónimo de
salic_api.resources.projeto.query.AreaQuery
- class
salic_api.resources.Captacao¶
query_class¶pseudónimo de
salic_api.resources.projeto.query.CaptacaoQuery
- class
salic_api.resources.ProjetoDetail(query_data=None)¶
hal_embedded(data)¶Return a dictionary of embedded resources stored at the “_embedded” field of a JSON+HAL response.
hal_links(result)¶Return the link dictionary that is stored on “_links” field of a JSON+HAL response.
Fetch all related and embedded data from other models and add it to the current result.
The default implementation does nothing, but can be overridden in subclasses.
prepare_result(result)¶Clean result after insertion of related objects.
The default implementation does nothing, but can be overridden in subclasses.
query_class¶pseudónimo de
salic_api.resources.projeto.query.ProjetoQuery
Query¶
- class
salic_api.resources.ProjetoQuery¶
- class
salic_api.resources.CaptacaoQuery¶Returns Captacao value of a project
- class
salic_api.resources.AreaQuery¶Returns description and id of Area
- class
salic_api.resources.SegmentoQuery¶Returns description and id of Segmento
- class
salic_api.resources.CertidoesNegativasQuery¶Returns certificate’s name and situation according to it’s id
- class
salic_api.resources.DivulgacaoQuery¶Returns instrument of propagation and its type. Ex: Peça - CARTAZ/POSTER, Veiculo - IMPRESSOS
- class
salic_api.resources.DeslocamentoQuery¶Returns descriptions of places which the project may pass.
- class
salic_api.resources.DistribuicaoQuery¶Returns information of how the project will be distributed. Ex: ticket prices…
- class
salic_api.resources.ReadequacaoQuery¶
resources.build_brand_link()¶
resources.build_file_link()¶
Proponente¶
- class
salic_api.resources.ProponenteDetail(query_data=None)¶
build_query_args()¶Return a dictionary with arguments to be passed to the query method of the query class.
hal_links(result)¶Return the link dictionary that is stored on “_links” field of a JSON+HAL response.
prepare_result(result)¶Clean result after insertion of related objects.
The default implementation does nothing, but can be overridden in subclasses.
query_class¶pseudónimo de
salic_api.resources.proponente.query.ProponenteQuery
- class
salic_api.resources.ProponenteList¶
detail_resource_class¶pseudónimo de
salic_api.resources.proponente.proponente_detail.ProponenteDetail
prepared_detail_object(item)¶Modify list of arguments to pass to a detail resource.
query_class¶pseudónimo de
salic_api.resources.proponente.query.ProponenteQuery
- class
salic_api.resources.ProponenteQuery¶
format_utils¶
query¶
- class
salic_api.resources.Query¶Base class for all query objects for the SALIC api.
count(qs)¶Return the number of elements on queryset.
execute_query(query, *args, **kwargs)¶Execute an SQL query.
fetch(query, binds=None)¶Execute the given query and fetches all results.
- Args:
- query:
- An SQL query
- binds:
- An optional dictionary with binds from variable names to their corresponding values to be inserted into the query.
raw_query(*args, **kwargs)¶Create a raw SQLAlchemy query object in the current session.
select_as(*args, **kwargs)¶Apply all filters in the given dictionary.
>>> q.select_as( ... ModelA, {'field_a': value_a, 'field_b': value_b}, ... ModelB, {'field_c': value_c})If a single model is present, the query can be simpler:
>>> q.select_as(ModelA, ... field_a=value_a, ... field_b=value_b)
resource¶
- class
salic_api.resources.SalicResource(query_data=None)¶Base class for List and Detail resources.
apply_hal_data(result)¶Insert HAL information on output data.
HAL info usually comprises of a _links and a _embedded fields
build_query_args()¶Return a dictionary with arguments to be passed to the query method of the query class.
fetch_result()¶Happy path for obtaining a raw representation of the resulting object from the database.
filter_cgccpf(cgccpf, elements)¶Given a cgc/cpf/cnpj, makes sure it return only elements with exact match. Used to correct the use of SQL LIKE statement
get(**kwargs)¶Default response to a GET request.
hal_links(result)¶Return the link dictionary that is stored on “_links” field of a JSON+HAL response.
query_db()¶Return a query with all requested objects
render(data, headers={}, status_code=200, raw=False)¶Render response for given data.
- Args:
- data:
- Raw data structure
- headers (dict):
- A mapping with extra headers for inclusion in the response.
- status_code (int):
- HTTP Response status code
- raw (bool):
- If True, do not serialize data to the desired format. Useful for testing.
resolve_content()¶Content Type resolution.
url(*args, **kwargs)¶Return a normalized URL for a path relative to the current resource.
If path begins with a backslash, treat it as a absolute path relative to the API_ROOT_URL.
- class
salic_api.resources.ListResource¶Base class for all Salic-API end points that return lists.
apply_hal_data(result)¶Insert HAL information on output data.
HAL info usually comprises of a _links and a _embedded fields
fetch_result()¶Happy path for obtaining a raw representation of the resulting object from the database.
hal_pagination_links(results, limit=None, offset=None)¶Create pagination links: self, first, last, next.
prepare_item(item)¶Clean item inserted in the result list.
prepared_detail_object(item)¶Modify list of arguments to pass to a detail resource.
query_db()¶Return a pair of (queryset, size) with a possibly truncated queryset of results and the number of elements in the complete queryset.
render(data, headers=None, **kwargs)¶Render response for given data.
- Args:
- data:
- Raw data structure
- headers (dict):
- A mapping with extra headers for inclusion in the response.
- status_code (int):
- HTTP Response status code
- raw (bool):
- If True, do not serialize data to the desired format. Useful for testing.
- class
salic_api.resources.DetailResource(query_data=None)¶Base class for all end points that return dictionaries.
apply_hal_data(result)¶Insert HAL information on output data.
HAL info usually comprises of a _links and a _embedded fields
fetch_result()¶Happy path for obtaining a raw representation of the resulting object from the database.
hal_embedded(data)¶Return a dictionary of embedded resources stored at the “_embedded” field of a JSON+HAL response.
hal_embedded_links(embedded)¶Return a dictionary mapping each embedded list with its corresponding dictionary of links.
This method does nothing and should be overridden on subclasses.
Fetch all related and embedded data from other models and add it to the current result.
The default implementation does nothing, but can be overridden in subclasses.
prepare_result(result)¶Clean result after insertion of related objects.
The default implementation does nothing, but can be overridden in subclasses.
query_db()¶Return a query with all requested objects
serialization¶
serialization.listify_queryset()¶Returns a fully serializable list of dictionaries
serialization.serialize(format, **kwargs)¶Return a string of serialized data for the given output format.
serialization.convert_atom()¶Convert atomic Python data type to JSON compatible value.
serialization.convert_object()¶Convert an instance of a queryset to a JSON compatible value.
serialization.to_xml()¶
serialization.to_json()¶
serialization.to_csv(columns)¶