agree-partner-api 3.0.0b1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. agree_partner_api-3.0.0b1/LICENSE +21 -0
  2. agree_partner_api-3.0.0b1/PKG-INFO +56 -0
  3. agree_partner_api-3.0.0b1/README.md +42 -0
  4. agree_partner_api-3.0.0b1/agree_partner_api/__init__.py +28 -0
  5. agree_partner_api-3.0.0b1/agree_partner_api/generated/__init__.py +56 -0
  6. agree_partner_api-3.0.0b1/agree_partner_api/generated/api/__init__.py +5 -0
  7. agree_partner_api-3.0.0b1/agree_partner_api/generated/api/perfis_api.py +719 -0
  8. agree_partner_api-3.0.0b1/agree_partner_api/generated/api_client.py +865 -0
  9. agree_partner_api-3.0.0b1/agree_partner_api/generated/api_response.py +21 -0
  10. agree_partner_api-3.0.0b1/agree_partner_api/generated/configuration.py +654 -0
  11. agree_partner_api-3.0.0b1/agree_partner_api/generated/exceptions.py +218 -0
  12. agree_partner_api-3.0.0b1/agree_partner_api/generated/models/__init__.py +20 -0
  13. agree_partner_api-3.0.0b1/agree_partner_api/generated/models/problem.py +120 -0
  14. agree_partner_api-3.0.0b1/agree_partner_api/generated/models/problem_error.py +90 -0
  15. agree_partner_api-3.0.0b1/agree_partner_api/generated/models/profile.py +111 -0
  16. agree_partner_api-3.0.0b1/agree_partner_api/generated/models/profile_list.py +99 -0
  17. agree_partner_api-3.0.0b1/agree_partner_api/generated/rest.py +334 -0
  18. agree_partner_api-3.0.0b1/agree_partner_api/pagination.py +52 -0
  19. agree_partner_api-3.0.0b1/agree_partner_api/retry.py +108 -0
  20. agree_partner_api-3.0.0b1/agree_partner_api.egg-info/PKG-INFO +56 -0
  21. agree_partner_api-3.0.0b1/agree_partner_api.egg-info/SOURCES.txt +26 -0
  22. agree_partner_api-3.0.0b1/agree_partner_api.egg-info/dependency_links.txt +1 -0
  23. agree_partner_api-3.0.0b1/agree_partner_api.egg-info/requires.txt +4 -0
  24. agree_partner_api-3.0.0b1/agree_partner_api.egg-info/top_level.txt +1 -0
  25. agree_partner_api-3.0.0b1/pyproject.toml +20 -0
  26. agree_partner_api-3.0.0b1/setup.cfg +4 -0
  27. agree_partner_api-3.0.0b1/tests/test_pagination.py +74 -0
  28. agree_partner_api-3.0.0b1/tests/test_retry.py +88 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Agree
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,56 @@
1
+ Metadata-Version: 2.4
2
+ Name: agree-partner-api
3
+ Version: 3.0.0b1
4
+ Summary: SDK gerado da Agree Partner API (feed de perfis), com iterador de paginação e retry. Suporte melhor esforço.
5
+ License-Expression: MIT
6
+ Requires-Python: >=3.11
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: urllib3<3.0.0,>=2.7.0
10
+ Requires-Dist: python-dateutil>=2.8.2
11
+ Requires-Dist: pydantic>=2.11
12
+ Requires-Dist: typing-extensions>=4.7.1
13
+ Dynamic: license-file
14
+
15
+ # agree-partner-api (Python)
16
+
17
+ > **Gerado** do contrato OpenAPI da Agree Partner API pelo [openapi-generator](https://openapi-generator.tech) 7.27.0. **Suporte melhor esforço.** Quem usa Go, Java ou outra linguagem: gere o cliente direto do contrato, em https://developers.agree.agr.br/openapi/partner-v1.yaml.
18
+
19
+ O que não é gerado é só uma camada fina:
20
+
21
+ - **iterador de paginação:** repete os mesmos filtros em toda página, segue o `next_cursor` e para quando ele vem vazio;
22
+ - **retry com backoff:** no `429 rate_limited`, espera o `Retry-After` até um teto (30 s); o `429 quota_exceeded` nunca é repetido; `503` e erro de rede têm até 3 tentativas com espera crescente; `500` tem no máximo uma nova tentativa.
23
+
24
+ O token é o da empresa parceira: `POST /oauth/token` com `grant_type=client_credentials`, `scope=farm:read` e `resource=https://api-sandbox.agree.agr.br/partner/v1`, com `client_id` e `client_secret` no Basic. O guia de início rápido do portal mostra o passo a passo.
25
+
26
+ ## Instalar
27
+
28
+ ```bash
29
+ pip install agree-partner-api
30
+ ```
31
+
32
+ Python 3.11 ou mais novo.
33
+
34
+ ## Exemplo
35
+
36
+ ```python
37
+ import os
38
+
39
+ from agree_partner_api import ApiClient, Configuration, PerfisApi, all_profiles, call_with_retry
40
+
41
+ config = Configuration(host="https://api-sandbox.agree.agr.br", access_token=os.environ["AGREE_ACCESS_TOKEN"])
42
+ api = PerfisApi(ApiClient(config))
43
+
44
+ for profile in all_profiles(api, os.environ["AGREE_CLIENT_ID"], call=call_with_retry, page_size=100):
45
+ print(profile.subject_ref, profile.uf, profile.cultures)
46
+ ```
47
+
48
+ Para ver o `suppressed` de cada página, use `profile_pages` no lugar de `all_profiles`. Para uma chamada solta com retry: `call_with_retry(lambda: api.get_profile(subject_ref, x_agree_client_id=client_id))`.
49
+
50
+ ## Como o código é gerado
51
+
52
+ O código gerado dos três SDKs sai de `openapi/partner-v1.yaml`, na raiz do repositório: a vista pública do contrato, a mesma que o portal publica. `scripts/generate.sh` refaz os três com a imagem do gerador fixada pelo digest. Antes de gerar, `scripts/prepare_spec.py` deixa abertos, só na entrada do gerador, os enums e os objetos das respostas: a API pode ganhar um valor ou um campo novo sem mudar de versão, e o código gerado não pode quebrar por isso. Não edite as pastas `generated/` à mão.
53
+
54
+ ## Versão
55
+
56
+ A major acompanha a da API (3.x). A primeira publicação é uma pré-release.
@@ -0,0 +1,42 @@
1
+ # agree-partner-api (Python)
2
+
3
+ > **Gerado** do contrato OpenAPI da Agree Partner API pelo [openapi-generator](https://openapi-generator.tech) 7.27.0. **Suporte melhor esforço.** Quem usa Go, Java ou outra linguagem: gere o cliente direto do contrato, em https://developers.agree.agr.br/openapi/partner-v1.yaml.
4
+
5
+ O que não é gerado é só uma camada fina:
6
+
7
+ - **iterador de paginação:** repete os mesmos filtros em toda página, segue o `next_cursor` e para quando ele vem vazio;
8
+ - **retry com backoff:** no `429 rate_limited`, espera o `Retry-After` até um teto (30 s); o `429 quota_exceeded` nunca é repetido; `503` e erro de rede têm até 3 tentativas com espera crescente; `500` tem no máximo uma nova tentativa.
9
+
10
+ O token é o da empresa parceira: `POST /oauth/token` com `grant_type=client_credentials`, `scope=farm:read` e `resource=https://api-sandbox.agree.agr.br/partner/v1`, com `client_id` e `client_secret` no Basic. O guia de início rápido do portal mostra o passo a passo.
11
+
12
+ ## Instalar
13
+
14
+ ```bash
15
+ pip install agree-partner-api
16
+ ```
17
+
18
+ Python 3.11 ou mais novo.
19
+
20
+ ## Exemplo
21
+
22
+ ```python
23
+ import os
24
+
25
+ from agree_partner_api import ApiClient, Configuration, PerfisApi, all_profiles, call_with_retry
26
+
27
+ config = Configuration(host="https://api-sandbox.agree.agr.br", access_token=os.environ["AGREE_ACCESS_TOKEN"])
28
+ api = PerfisApi(ApiClient(config))
29
+
30
+ for profile in all_profiles(api, os.environ["AGREE_CLIENT_ID"], call=call_with_retry, page_size=100):
31
+ print(profile.subject_ref, profile.uf, profile.cultures)
32
+ ```
33
+
34
+ Para ver o `suppressed` de cada página, use `profile_pages` no lugar de `all_profiles`. Para uma chamada solta com retry: `call_with_retry(lambda: api.get_profile(subject_ref, x_agree_client_id=client_id))`.
35
+
36
+ ## Como o código é gerado
37
+
38
+ O código gerado dos três SDKs sai de `openapi/partner-v1.yaml`, na raiz do repositório: a vista pública do contrato, a mesma que o portal publica. `scripts/generate.sh` refaz os três com a imagem do gerador fixada pelo digest. Antes de gerar, `scripts/prepare_spec.py` deixa abertos, só na entrada do gerador, os enums e os objetos das respostas: a API pode ganhar um valor ou um campo novo sem mudar de versão, e o código gerado não pode quebrar por isso. Não edite as pastas `generated/` à mão.
39
+
40
+ ## Versão
41
+
42
+ A major acompanha a da API (3.x). A primeira publicação é uma pré-release.
@@ -0,0 +1,28 @@
1
+ """SDK gerado da Agree Partner API (feed de perfis), com iterador de paginação e retry.
2
+
3
+ O código em ``agree_partner_api.generated`` é gerado do contrato OpenAPI e não deve ser editado à
4
+ mão. Só ``pagination`` e ``retry`` são escritos à mão. Suporte melhor esforço.
5
+ """
6
+
7
+ from agree_partner_api.generated import ApiClient, Configuration
8
+ from agree_partner_api.generated.api.perfis_api import PerfisApi
9
+ from agree_partner_api.generated.exceptions import ApiException
10
+ from agree_partner_api.generated.models.profile import Profile
11
+ from agree_partner_api.generated.models.profile_list import ProfileList
12
+ from agree_partner_api.pagination import all_profiles, profile_pages
13
+ from agree_partner_api.retry import RetryPolicy, call_with_retry
14
+
15
+ __version__ = "3.0.0b1"
16
+
17
+ __all__ = [
18
+ "ApiClient",
19
+ "ApiException",
20
+ "Configuration",
21
+ "PerfisApi",
22
+ "Profile",
23
+ "ProfileList",
24
+ "RetryPolicy",
25
+ "all_profiles",
26
+ "call_with_retry",
27
+ "profile_pages",
28
+ ]
@@ -0,0 +1,56 @@
1
+ # coding: utf-8
2
+
3
+ # flake8: noqa
4
+
5
+ """
6
+ Agree Partner API
7
+
8
+ Vista pública da Agree Partner API para a sandbox de parceiros. Traz só as rotas disponíveis hoje: o feed e o detalhe de perfis desidentificados dos produtores que autorizaram compartilhar dados com o parceiro. Somente leitura. ## Autenticação O token é o da própria empresa parceira, pelo grant `client_credentials`, com o `client_id` e o `client_secret` no cabeçalho Basic, `scope=farm:read` e `resource=https://api-sandbox.agree.agr.br/partner/v1`. Toda chamada leva `Authorization: Bearer <token>` e o cabeçalho `X-Agree-Client-Id` com o `client_id` do token. ## Paginação O feed é paginado por `next_cursor`, que é opaco: repita a chamada com `cursor=<next_cursor>` e os mesmos filtros até ele vir vazio. Não há total. ## Limites Cada parceiro tem um limite de requisições por segundo, anunciado em `Agree-RateLimit-Limit`. O feed e o detalhe de perfis têm também um orçamento de consultas e de produtores distintos por hora e por dia (UTC). Acima deles, a resposta é `429 rate_limited`, com `Retry-After`. Com a quota mensal ligada, a quota esgotada responde `429 quota_exceeded`. ## Erros Os erros do serviço são Problem Details (RFC 9457) em `application/problem+json`. Trate o campo `code`; o `trace_id` serve para abrir chamado. Recusas da borda da rede e falhas do balanceador podem vir sem esse formato: trate como temporárias e repita com espera crescente. Guia, catálogo de erros e dicionário de dados: Portal do desenvolvedor Agree.
9
+
10
+ The version of the OpenAPI document: 3.0.0
11
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
12
+
13
+ Do not edit the class manually.
14
+ """ # noqa: E501
15
+
16
+
17
+ __version__ = "3.0.0b1"
18
+
19
+ # Define package exports
20
+ __all__ = [
21
+ "PerfisApi",
22
+ "ApiResponse",
23
+ "ApiClient",
24
+ "Configuration",
25
+ "OpenApiException",
26
+ "ApiTypeError",
27
+ "ApiValueError",
28
+ "ApiKeyError",
29
+ "ApiAttributeError",
30
+ "ApiException",
31
+ "Problem",
32
+ "ProblemError",
33
+ "Profile",
34
+ "ProfileList",
35
+ ]
36
+
37
+ # import apis into sdk package
38
+ from agree_partner_api.generated.api.perfis_api import PerfisApi as PerfisApi
39
+
40
+ # import ApiClient
41
+ from agree_partner_api.generated.api_response import ApiResponse as ApiResponse
42
+ from agree_partner_api.generated.api_client import ApiClient as ApiClient
43
+ from agree_partner_api.generated.configuration import Configuration as Configuration
44
+ from agree_partner_api.generated.exceptions import OpenApiException as OpenApiException
45
+ from agree_partner_api.generated.exceptions import ApiTypeError as ApiTypeError
46
+ from agree_partner_api.generated.exceptions import ApiValueError as ApiValueError
47
+ from agree_partner_api.generated.exceptions import ApiKeyError as ApiKeyError
48
+ from agree_partner_api.generated.exceptions import ApiAttributeError as ApiAttributeError
49
+ from agree_partner_api.generated.exceptions import ApiException as ApiException
50
+
51
+ # import models into sdk package
52
+ from agree_partner_api.generated.models.problem import Problem as Problem
53
+ from agree_partner_api.generated.models.problem_error import ProblemError as ProblemError
54
+ from agree_partner_api.generated.models.profile import Profile as Profile
55
+ from agree_partner_api.generated.models.profile_list import ProfileList as ProfileList
56
+
@@ -0,0 +1,5 @@
1
+ # flake8: noqa
2
+
3
+ # import apis into api package
4
+ from agree_partner_api.generated.api.perfis_api import PerfisApi
5
+