Skip to content

Commit

Permalink
Merge pull request #219 from aldbr/main_FEAT_audience
Browse files Browse the repository at this point in the history
Restructure the `auth` endpoint
  • Loading branch information
chrisburr authored Mar 7, 2024
2 parents ae79122 + aeb9cac commit f126d9f
Show file tree
Hide file tree
Showing 37 changed files with 2,525 additions and 1,957 deletions.
1 change: 0 additions & 1 deletion diracx-cli/src/diracx/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ async def login(
async with DiracClient() as api:
data = await api.auth.initiate_device_flow(
client_id=api.client_id,
audience="Dirac server",
scope=" ".join(scopes),
)
print("Now go to:", data.verification_uri_complete)
Expand Down
2 changes: 1 addition & 1 deletion diracx-client/src/diracx/client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.1, generator: @autorest/python@6.4.11)
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.2)
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand Down
34 changes: 29 additions & 5 deletions diracx-client/src/diracx/client/_client.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.1, generator: @autorest/python@6.4.11)
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.2)
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from copy import deepcopy
from typing import Any

from azure.core import PipelineClient
from azure.core.pipeline import policies
from azure.core.rest import HttpRequest, HttpResponse

from . import models as _models
Expand Down Expand Up @@ -40,8 +41,29 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
self, *, endpoint: str = "", **kwargs: Any
) -> None:
self._config = DiracConfiguration(**kwargs)
_policies = kwargs.pop("policies", None)
if _policies is None:
_policies = [
policies.RequestIdPolicy(**kwargs),
self._config.headers_policy,
self._config.user_agent_policy,
self._config.proxy_policy,
policies.ContentDecodePolicy(**kwargs),
self._config.redirect_policy,
self._config.retry_policy,
self._config.authentication_policy,
self._config.custom_hook_policy,
self._config.logging_policy,
policies.DistributedTracingPolicy(**kwargs),
(
policies.SensitiveHeaderCleanupPolicy(**kwargs)
if self._config.redirect_policy
else None
),
self._config.http_logging_policy,
]
self._client: PipelineClient = PipelineClient(
base_url=endpoint, config=self._config, **kwargs
base_url=endpoint, policies=_policies, **kwargs
)

client_models = {
Expand All @@ -53,7 +75,7 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
self.well_known = WellKnownOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.auth = AuthOperations( # pylint: disable=abstract-class-instantiated
self.auth = AuthOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.config = ConfigOperations(
Expand All @@ -63,7 +85,9 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
self._client, self._config, self._serialize, self._deserialize
)

def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
def send_request(
self, request: HttpRequest, *, stream: bool = False, **kwargs: Any
) -> HttpResponse:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
Expand All @@ -83,7 +107,7 @@ def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:

request_copy = deepcopy(request)
request_copy.url = self._client.format_url(request_copy.url)
return self._client.send_request(request_copy, **kwargs)
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore

def close(self) -> None:
self._client.close()
Expand Down
9 changes: 4 additions & 5 deletions diracx-client/src/diracx/client/_configuration.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.1, generator: @autorest/python@6.4.11)
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.2)
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import Any

from azure.core.configuration import Configuration
from azure.core.pipeline import policies

VERSION = "unknown"


class DiracConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
class DiracConfiguration: # pylint: disable=too-many-instance-attributes
"""Configuration for Dirac.
Note that all parameters used to create this instance are saved as instance
attributes.
"""

def __init__(self, **kwargs: Any) -> None:
super(DiracConfiguration, self).__init__(**kwargs)

kwargs.setdefault("sdk_moniker", "dirac/{}".format(VERSION))
self.polling_interval = kwargs.get("polling_interval", 30)
self._configure(**kwargs)

def _configure(self, **kwargs: Any) -> None:
Expand All @@ -39,11 +38,11 @@ def _configure(self, **kwargs: Any) -> None:
self.http_logging_policy = kwargs.get(
"http_logging_policy"
) or policies.HttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get(
"custom_hook_policy"
) or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(
**kwargs
)
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
Loading

0 comments on commit f126d9f

Please sign in to comment.