diff --git a/nylas/main.py b/nylas/main.py new file mode 100644 index 00000000..1d52817f --- /dev/null +++ b/nylas/main.py @@ -0,0 +1,33 @@ +from nylas import Client +from nylas.models.credentials import CredentialRequest, UpdateCredentialRequest + +client_id = "547b1b75-6623-4dcd-8ea9-baf50cf00952" +client_secret = "JzL6OyQVaXvowk8czuGW45mHhVCoHfnZW" +api_key = "nyk_v0_JlN7OgZUgsmEoCx6tguhTMGcRqE0XpoLZz6Lp3824ivER13baJbXENK9EPYw5eKU" + + +nylas = Client( + api_key=api_key, +) + +creds_data = {"client_id":"bce5ddf5-038e-4653-9843-ec1d4274549e","client_secret":"ZM48Q~Yng3WqXjM2D3f..zZ4g.LBJWFCmE_b7b3Y"} +# +# +creds_created,_ = nylas.connectors.credentials.create("microsoft",CredentialRequest(name="Test creds",credential_type="adminconsent",credential_data=creds_data)) +# # +print(creds_created) +# # # +list_response = nylas.connectors.credentials.list("microsoft"); +# +print(list_response) +# +creds,_ = nylas.connectors.credentials.find("microsoft",creds_created.id) +# # +print(creds) + +updated_creds,_=nylas.connectors.credentials.update("microsoft",creds_created.id,UpdateCredentialRequest(name="New creds",credential_data=creds_data)) +# # +print(updated_creds) + +deleted_response = nylas.connectors.credentials.destroy("microsoft",updated_creds.id) +print(deleted_response) \ No newline at end of file diff --git a/nylas/resources/auth.py b/nylas/resources/auth.py index e1c4ecc2..42e2734a 100644 --- a/nylas/resources/auth.py +++ b/nylas/resources/auth.py @@ -15,7 +15,6 @@ URLForAdminConsentConfig, ) from nylas.models.response import Response -from nylas.resources.credentials import Credentials from nylas.resources.grants import Grants from nylas.resources.resource import Resource @@ -59,16 +58,6 @@ def _build_query_with_admin_consent(config: dict) -> dict: class Auth(Resource): - @property - def credentials(self) -> Credentials: - """ - Access the Credentials API. - - Returns: - The Credentials API. - """ - return Credentials(self._http_client) - @property def grants(self) -> Grants: """ diff --git a/nylas/resources/connectors.py b/nylas/resources/connectors.py index ec171379..a2d78c2c 100644 --- a/nylas/resources/connectors.py +++ b/nylas/resources/connectors.py @@ -1,3 +1,5 @@ +from nylas.resources.credentials import Credentials + from nylas.handler.api_resources import ( ListableApiResource, FindableApiResource, @@ -22,6 +24,15 @@ class Connectors( UpdatableApiResource, DestroyableApiResource, ): + @property + def credentials(self) -> Credentials: + """ + Access the Credentials API. + + Returns: + The Credentials API. + """ + return Credentials(self._http_client) def list(self, query_params: ListConnectorQueryParams) -> ListResponse[Connector]: """ Return all Connectors.