forked from opensearch-project/opensearch-migrations
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Specify User Agent for Console CLI requests (opensearch-project#952)
Allows setting a global user agent on CDK deployments that will be configured in a client_options section in the services.yaml. This user agent will currently be provided to the Traffic Replayer for its replayed requests (existing logic) and to the Console CLI for all of its boto3 requests and python requests library requests. This can also be extended to other migrations as support is added. --------- Signed-off-by: Tanner Lewis <[email protected]>
- Loading branch information
Showing
25 changed files
with
646 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...n/src/main/docker/migrationConsole/lib/console_link/console_link/models/client_options.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from typing import Dict, Optional | ||
import logging | ||
from cerberus import Validator | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
SCHEMA = { | ||
"client_options": { | ||
"type": "dict", | ||
"schema": { | ||
"user_agent_extra": {"type": "string", "required": False}, | ||
}, | ||
} | ||
} | ||
|
||
|
||
class ClientOptions: | ||
""" | ||
Options that can be configured for boto3 and request library clients. | ||
""" | ||
|
||
user_agent_extra: Optional[str] = None | ||
|
||
def __init__(self, config: Dict) -> None: | ||
logger.info(f"Initializing client options with config: {config}") | ||
v = Validator(SCHEMA) | ||
if not v.validate({'client_options': config}): | ||
raise ValueError("Invalid config file for client options", v.errors) | ||
|
||
self.user_agent_extra = config.get("user_agent_extra", None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.