From 86523bebbe9a5e36c139819492f51cb02e05bd5f Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Fri, 3 Apr 2026 14:09:22 +0800 Subject: [PATCH 1/6] Add agentic workflow mergefest --- .gitattributes | 2 + .github/workflows/mergefest.lock.yml | 1241 ++++++++++++++++++++++++++ .github/workflows/mergefest.md | 351 ++++++++ .github/workflows/shared/mood.md | 1 + 4 files changed, 1595 insertions(+) create mode 100644 .github/workflows/mergefest.lock.yml create mode 100644 .github/workflows/mergefest.md create mode 100644 .github/workflows/shared/mood.md diff --git a/.gitattributes b/.gitattributes index e6fd58130684..f5c8d439f920 100644 --- a/.gitattributes +++ b/.gitattributes @@ -27,3 +27,5 @@ *.jar binary *.so binary *.war binary + +.github/workflows/*.lock.yml linguist-generated=true merge=ours \ No newline at end of file diff --git a/.github/workflows/mergefest.lock.yml b/.github/workflows/mergefest.lock.yml new file mode 100644 index 000000000000..ed54060e368a --- /dev/null +++ b/.github/workflows/mergefest.lock.yml @@ -0,0 +1,1241 @@ +# ___ _ _ +# / _ \ | | (_) +# | |_| | __ _ ___ _ __ | |_ _ ___ +# | _ |/ _` |/ _ \ '_ \| __| |/ __| +# | | | | (_| | __/ | | | |_| | (__ +# \_| |_/\__, |\___|_| |_|\__|_|\___| +# __/ | +# _ _ |___/ +# | | | | / _| | +# | | | | ___ _ __ _ __| |_| | _____ ____ +# | |/\| |/ _ \ '__| |/ /| _| |/ _ \ \ /\ / / ___| +# \ /\ / (_) | | | | ( | | | | (_) \ V V /\__ \ +# \/ \/ \___/|_| |_|\_\|_| |_|\___/ \_/\_/ |___/ +# +# This file was automatically generated by gh-aw (v0.65.6). DO NOT EDIT. +# +# To update this file, edit github/gh-aw/.github/workflows/mergefest.md@852cb06ad52958b402ed982b69957ffc57ca0619 and run: +# gh aw compile +# Not all edits will cause changes to this file. +# +# For more information: https://github.github.com/gh-aw/introduction/overview/ +# +# Automatically merges the main branch into pull request branches when invoked with /mergefest command +# +# Source: github/gh-aw/.github/workflows/mergefest.md@852cb06ad52958b402ed982b69957ffc57ca0619 +# +# Resolved workflow manifest: +# Imports: +# - shared/mood.md +# +# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"bc53fb1f26f2f3676fb5a1b8b644137baf5e7dfba7ba8062717c5804d062f75f","compiler_version":"v0.65.6","strict":true,"agent_id":"copilot"} + +name: "Mergefest" +"on": + issue_comment: + types: + - created + - edited + +permissions: {} + +concurrency: + group: "gh-aw-${{ github.workflow }}-${{ github.event.issue.number || github.event.pull_request.number || github.run_id }}" + +run-name: "Mergefest" + +jobs: + activation: + needs: pre_activation + if: "needs.pre_activation.outputs.activated == 'true' && (github.event_name == 'issue_comment' && (startsWith(github.event.comment.body, '/mergefest ') || startsWith(github.event.comment.body, '/mergefest\n') || github.event.comment.body == '/mergefest') && github.event.issue.pull_request != null)" + runs-on: ubuntu-slim + permissions: + contents: read + discussions: write + issues: write + pull-requests: write + outputs: + body: ${{ steps.sanitized.outputs.body }} + comment_id: ${{ steps.add-comment.outputs.comment-id }} + comment_repo: ${{ steps.add-comment.outputs.comment-repo }} + comment_url: ${{ steps.add-comment.outputs.comment-url }} + lockdown_check_failed: ${{ steps.generate_aw_info.outputs.lockdown_check_failed == 'true' }} + model: ${{ steps.generate_aw_info.outputs.model }} + secret_verification_result: ${{ steps.validate-secret.outputs.verification_result }} + slash_command: ${{ needs.pre_activation.outputs.matched_command }} + text: ${{ steps.sanitized.outputs.text }} + title: ${{ steps.sanitized.outputs.title }} + steps: + - name: Setup Scripts + uses: github/gh-aw-actions/setup@31130b20a8fd3ef263acbe2091267c0aace07e09 # v0.65.6 + with: + destination: ${{ runner.temp }}/gh-aw/actions + - name: Generate agentic run info + id: generate_aw_info + env: + GH_AW_INFO_ENGINE_ID: "copilot" + GH_AW_INFO_ENGINE_NAME: "GitHub Copilot CLI" + GH_AW_INFO_MODEL: ${{ vars.GH_AW_MODEL_AGENT_COPILOT || 'auto' }} + GH_AW_INFO_VERSION: "latest" + GH_AW_INFO_AGENT_VERSION: "latest" + GH_AW_INFO_CLI_VERSION: "v0.65.6" + GH_AW_INFO_WORKFLOW_NAME: "Mergefest" + GH_AW_INFO_EXPERIMENTAL: "false" + GH_AW_INFO_SUPPORTS_TOOLS_ALLOWLIST: "true" + GH_AW_INFO_STAGED: "false" + GH_AW_INFO_ALLOWED_DOMAINS: '["defaults"]' + GH_AW_INFO_FIREWALL_ENABLED: "true" + GH_AW_INFO_AWF_VERSION: "v0.25.11" + GH_AW_INFO_AWMG_VERSION: "" + GH_AW_INFO_FIREWALL_TYPE: "squid" + GH_AW_COMPILED_STRICT: "true" + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('${{ runner.temp }}/gh-aw/actions/generate_aw_info.cjs'); + await main(core, context); + - name: Add eyes reaction for immediate feedback + id: react + if: github.event_name == 'issues' || github.event_name == 'issue_comment' || github.event_name == 'pull_request_review_comment' || github.event_name == 'discussion' || github.event_name == 'discussion_comment' || github.event_name == 'pull_request' && github.event.pull_request.head.repo.id == github.repository_id + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + env: + GH_AW_REACTION: "eyes" + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('${{ runner.temp }}/gh-aw/actions/add_reaction.cjs'); + await main(); + - name: Validate COPILOT_GITHUB_TOKEN secret + id: validate-secret + run: ${RUNNER_TEMP}/gh-aw/actions/validate_multi_secret.sh COPILOT_GITHUB_TOKEN 'GitHub Copilot CLI' https://github.github.com/gh-aw/reference/engines/#github-copilot-default + env: + COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }} + - name: Checkout .github and .agents folders + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + sparse-checkout: | + .github + .agents + sparse-checkout-cone-mode: true + fetch-depth: 1 + - name: Check workflow file timestamps + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + env: + GH_AW_WORKFLOW_FILE: "mergefest.lock.yml" + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('${{ runner.temp }}/gh-aw/actions/check_workflow_timestamp_api.cjs'); + await main(); + - name: Check compile-agentic version + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + env: + GH_AW_COMPILED_VERSION: "v0.65.6" + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('${{ runner.temp }}/gh-aw/actions/check_version_updates.cjs'); + await main(); + - name: Compute current body text + id: sanitized + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('${{ runner.temp }}/gh-aw/actions/compute_text.cjs'); + await main(); + - name: Add comment with workflow run link + id: add-comment + if: github.event_name == 'issues' || github.event_name == 'issue_comment' || github.event_name == 'pull_request_review_comment' || github.event_name == 'discussion' || github.event_name == 'discussion_comment' || github.event_name == 'pull_request' && github.event.pull_request.head.repo.id == github.repository_id + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + env: + GH_AW_WORKFLOW_NAME: "Mergefest" + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('${{ runner.temp }}/gh-aw/actions/add_workflow_run_comment.cjs'); + await main(); + - name: Create prompt with built-in context + env: + GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt + GH_AW_SAFE_OUTPUTS: ${{ runner.temp }}/gh-aw/safeoutputs/outputs.jsonl + GH_AW_GITHUB_ACTOR: ${{ github.actor }} + GH_AW_GITHUB_EVENT_COMMENT_ID: ${{ github.event.comment.id }} + GH_AW_GITHUB_EVENT_DISCUSSION_NUMBER: ${{ github.event.discussion.number }} + GH_AW_GITHUB_EVENT_ISSUE_NUMBER: ${{ github.event.issue.number }} + GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }} + GH_AW_GITHUB_REPOSITORY: ${{ github.repository }} + GH_AW_GITHUB_RUN_ID: ${{ github.run_id }} + GH_AW_GITHUB_WORKSPACE: ${{ github.workspace }} + GH_AW_IS_PR_COMMENT: ${{ github.event.issue.pull_request && 'true' || '' }} + # poutine:ignore untrusted_checkout_exec + run: | + bash ${RUNNER_TEMP}/gh-aw/actions/create_prompt_first.sh + { + cat << 'GH_AW_PROMPT_297e2c4c652c2e56_EOF' + + GH_AW_PROMPT_297e2c4c652c2e56_EOF + cat "${RUNNER_TEMP}/gh-aw/prompts/xpia.md" + cat "${RUNNER_TEMP}/gh-aw/prompts/temp_folder_prompt.md" + cat "${RUNNER_TEMP}/gh-aw/prompts/markdown.md" + cat "${RUNNER_TEMP}/gh-aw/prompts/safe_outputs_prompt.md" + cat << 'GH_AW_PROMPT_297e2c4c652c2e56_EOF' + + Tools: push_to_pull_request_branch, missing_tool, missing_data, noop + GH_AW_PROMPT_297e2c4c652c2e56_EOF + cat "${RUNNER_TEMP}/gh-aw/prompts/safe_outputs_push_to_pr_branch.md" + cat << 'GH_AW_PROMPT_297e2c4c652c2e56_EOF' + + + The following GitHub context information is available for this workflow: + {{#if __GH_AW_GITHUB_ACTOR__ }} + - **actor**: __GH_AW_GITHUB_ACTOR__ + {{/if}} + {{#if __GH_AW_GITHUB_REPOSITORY__ }} + - **repository**: __GH_AW_GITHUB_REPOSITORY__ + {{/if}} + {{#if __GH_AW_GITHUB_WORKSPACE__ }} + - **workspace**: __GH_AW_GITHUB_WORKSPACE__ + {{/if}} + {{#if __GH_AW_GITHUB_EVENT_ISSUE_NUMBER__ }} + - **issue-number**: #__GH_AW_GITHUB_EVENT_ISSUE_NUMBER__ + {{/if}} + {{#if __GH_AW_GITHUB_EVENT_DISCUSSION_NUMBER__ }} + - **discussion-number**: #__GH_AW_GITHUB_EVENT_DISCUSSION_NUMBER__ + {{/if}} + {{#if __GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER__ }} + - **pull-request-number**: #__GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER__ + {{/if}} + {{#if __GH_AW_GITHUB_EVENT_COMMENT_ID__ }} + - **comment-id**: __GH_AW_GITHUB_EVENT_COMMENT_ID__ + {{/if}} + {{#if __GH_AW_GITHUB_RUN_ID__ }} + - **workflow-run-id**: __GH_AW_GITHUB_RUN_ID__ + {{/if}} + + + GH_AW_PROMPT_297e2c4c652c2e56_EOF + cat "${RUNNER_TEMP}/gh-aw/prompts/github_mcp_tools_with_safeoutputs_prompt.md" + if [ "$GITHUB_EVENT_NAME" = "issue_comment" ] && [ -n "$GH_AW_IS_PR_COMMENT" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review_comment" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review" ]; then + cat "${RUNNER_TEMP}/gh-aw/prompts/pr_context_prompt.md" + fi + if [ "$GITHUB_EVENT_NAME" = "issue_comment" ] && [ -n "$GH_AW_IS_PR_COMMENT" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review_comment" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review" ]; then + cat "${RUNNER_TEMP}/gh-aw/prompts/pr_context_push_to_pr_branch_guidance.md" + fi + cat << 'GH_AW_PROMPT_297e2c4c652c2e56_EOF' + + {{#runtime-import .github/workflows/shared/mood.md}} + {{#runtime-import .github/workflows/mergefest.md}} + GH_AW_PROMPT_297e2c4c652c2e56_EOF + } > "$GH_AW_PROMPT" + - name: Interpolate variables and render templates + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + env: + GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt + GH_AW_GITHUB_ACTOR: ${{ github.actor }} + GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }} + GH_AW_GITHUB_REPOSITORY: ${{ github.repository }} + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('${{ runner.temp }}/gh-aw/actions/interpolate_prompt.cjs'); + await main(); + - name: Substitute placeholders + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + env: + GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt + GH_AW_GITHUB_ACTOR: ${{ github.actor }} + GH_AW_GITHUB_EVENT_COMMENT_ID: ${{ github.event.comment.id }} + GH_AW_GITHUB_EVENT_DISCUSSION_NUMBER: ${{ github.event.discussion.number }} + GH_AW_GITHUB_EVENT_ISSUE_NUMBER: ${{ github.event.issue.number }} + GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }} + GH_AW_GITHUB_REPOSITORY: ${{ github.repository }} + GH_AW_GITHUB_RUN_ID: ${{ github.run_id }} + GH_AW_GITHUB_WORKSPACE: ${{ github.workspace }} + GH_AW_IS_PR_COMMENT: ${{ github.event.issue.pull_request && 'true' || '' }} + GH_AW_NEEDS_PRE_ACTIVATION_OUTPUTS_ACTIVATED: ${{ needs.pre_activation.outputs.activated }} + GH_AW_NEEDS_PRE_ACTIVATION_OUTPUTS_MATCHED_COMMAND: ${{ needs.pre_activation.outputs.matched_command }} + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + + const substitutePlaceholders = require('${{ runner.temp }}/gh-aw/actions/substitute_placeholders.cjs'); + + // Call the substitution function + return await substitutePlaceholders({ + file: process.env.GH_AW_PROMPT, + substitutions: { + GH_AW_GITHUB_ACTOR: process.env.GH_AW_GITHUB_ACTOR, + GH_AW_GITHUB_EVENT_COMMENT_ID: process.env.GH_AW_GITHUB_EVENT_COMMENT_ID, + GH_AW_GITHUB_EVENT_DISCUSSION_NUMBER: process.env.GH_AW_GITHUB_EVENT_DISCUSSION_NUMBER, + GH_AW_GITHUB_EVENT_ISSUE_NUMBER: process.env.GH_AW_GITHUB_EVENT_ISSUE_NUMBER, + GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER: process.env.GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER, + GH_AW_GITHUB_REPOSITORY: process.env.GH_AW_GITHUB_REPOSITORY, + GH_AW_GITHUB_RUN_ID: process.env.GH_AW_GITHUB_RUN_ID, + GH_AW_GITHUB_WORKSPACE: process.env.GH_AW_GITHUB_WORKSPACE, + GH_AW_IS_PR_COMMENT: process.env.GH_AW_IS_PR_COMMENT, + GH_AW_NEEDS_PRE_ACTIVATION_OUTPUTS_ACTIVATED: process.env.GH_AW_NEEDS_PRE_ACTIVATION_OUTPUTS_ACTIVATED, + GH_AW_NEEDS_PRE_ACTIVATION_OUTPUTS_MATCHED_COMMAND: process.env.GH_AW_NEEDS_PRE_ACTIVATION_OUTPUTS_MATCHED_COMMAND + } + }); + - name: Validate prompt placeholders + env: + GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt + # poutine:ignore untrusted_checkout_exec + run: bash ${RUNNER_TEMP}/gh-aw/actions/validate_prompt_placeholders.sh + - name: Print prompt + env: + GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt + # poutine:ignore untrusted_checkout_exec + run: bash ${RUNNER_TEMP}/gh-aw/actions/print_prompt_summary.sh + - name: Upload activation artifact + if: success() + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7 + with: + name: activation + path: | + /tmp/gh-aw/aw_info.json + /tmp/gh-aw/aw-prompts/prompt.txt + retention-days: 1 + + agent: + needs: activation + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + pull-requests: read + env: + DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} + GH_AW_ASSETS_ALLOWED_EXTS: "" + GH_AW_ASSETS_BRANCH: "" + GH_AW_ASSETS_MAX_SIZE_KB: 0 + GH_AW_MCP_LOG_DIR: /tmp/gh-aw/mcp-logs/safeoutputs + GH_AW_WORKFLOW_ID_SANITIZED: mergefest + outputs: + checkout_pr_success: ${{ steps.checkout-pr.outputs.checkout_pr_success || 'true' }} + effective_tokens: ${{ steps.parse-mcp-gateway.outputs.effective_tokens }} + has_patch: ${{ steps.collect_output.outputs.has_patch }} + inference_access_error: ${{ steps.detect-inference-error.outputs.inference_access_error || 'false' }} + model: ${{ needs.activation.outputs.model }} + output: ${{ steps.collect_output.outputs.output }} + output_types: ${{ steps.collect_output.outputs.output_types }} + steps: + - name: Setup Scripts + uses: github/gh-aw-actions/setup@31130b20a8fd3ef263acbe2091267c0aace07e09 # v0.65.6 + with: + destination: ${{ runner.temp }}/gh-aw/actions + - name: Set runtime paths + id: set-runtime-paths + run: | + echo "GH_AW_SAFE_OUTPUTS=${RUNNER_TEMP}/gh-aw/safeoutputs/outputs.jsonl" >> "$GITHUB_OUTPUT" + echo "GH_AW_SAFE_OUTPUTS_CONFIG_PATH=${RUNNER_TEMP}/gh-aw/safeoutputs/config.json" >> "$GITHUB_OUTPUT" + echo "GH_AW_SAFE_OUTPUTS_TOOLS_PATH=${RUNNER_TEMP}/gh-aw/safeoutputs/tools.json" >> "$GITHUB_OUTPUT" + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + - name: Create gh-aw temp directory + run: bash ${RUNNER_TEMP}/gh-aw/actions/create_gh_aw_tmp_dir.sh + - name: Configure gh CLI for GitHub Enterprise + run: bash ${RUNNER_TEMP}/gh-aw/actions/configure_gh_for_ghe.sh + env: + GH_TOKEN: ${{ github.token }} + - name: Setup Git configuration + run: "git config user.name \"github-actions[bot]\"\ngit config user.email \"github-actions[bot]@users.noreply.github.com\"\n\n# Create .gitignore to exclude workflow YAML files\ncat > /tmp/merge-gitignore << 'EOF'\n# Exclude all .yml files in .github/workflows/\n.github/workflows/*.yml\nEOF\n" + + - name: Configure Git credentials + env: + REPO_NAME: ${{ github.repository }} + SERVER_URL: ${{ github.server_url }} + run: | + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + git config --global am.keepcr true + # Re-authenticate git with GitHub token + SERVER_URL_STRIPPED="${SERVER_URL#https://}" + git remote set-url origin "https://x-access-token:${{ github.token }}@${SERVER_URL_STRIPPED}/${REPO_NAME}.git" + echo "Git configured with standard GitHub Actions identity" + - name: Checkout PR branch + id: checkout-pr + if: | + github.event.pull_request || github.event.issue.pull_request + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + env: + GH_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('${{ runner.temp }}/gh-aw/actions/checkout_pr_branch.cjs'); + await main(); + - name: Install GitHub Copilot CLI + run: ${RUNNER_TEMP}/gh-aw/actions/install_copilot_cli.sh latest + - name: Install AWF binary + run: bash ${RUNNER_TEMP}/gh-aw/actions/install_awf_binary.sh v0.25.11 + - name: Determine automatic lockdown mode for GitHub MCP Server + id: determine-automatic-lockdown + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + env: + GH_AW_GITHUB_TOKEN: ${{ secrets.GH_AW_GITHUB_TOKEN }} + GH_AW_GITHUB_MCP_SERVER_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN }} + with: + script: | + const determineAutomaticLockdown = require('${{ runner.temp }}/gh-aw/actions/determine_automatic_lockdown.cjs'); + await determineAutomaticLockdown(github, context, core); + - name: Download container images + run: bash ${RUNNER_TEMP}/gh-aw/actions/download_docker_images.sh ghcr.io/github/gh-aw-firewall/agent:0.25.11 ghcr.io/github/gh-aw-firewall/api-proxy:0.25.11 ghcr.io/github/gh-aw-firewall/squid:0.25.11 ghcr.io/github/gh-aw-mcpg:v0.2.11 ghcr.io/github/github-mcp-server:v0.32.0 node:lts-alpine + - name: Write Safe Outputs Config + run: | + mkdir -p ${RUNNER_TEMP}/gh-aw/safeoutputs + mkdir -p /tmp/gh-aw/safeoutputs + mkdir -p /tmp/gh-aw/mcp-logs/safeoutputs + cat > ${RUNNER_TEMP}/gh-aw/safeoutputs/config.json << 'GH_AW_SAFE_OUTPUTS_CONFIG_865f927a5b569f5a_EOF' + {"missing_data":{},"missing_tool":{},"noop":{"max":1,"report-as-issue":"true"},"push_to_pull_request_branch":{"if_no_changes":"warn","max_patch_size":1024,"protected_files":["package.json","bun.lockb","bunfig.toml","deno.json","deno.jsonc","deno.lock","global.json","NuGet.Config","Directory.Packages.props","mix.exs","mix.lock","go.mod","go.sum","stack.yaml","stack.yaml.lock","pom.xml","build.gradle","build.gradle.kts","settings.gradle","settings.gradle.kts","gradle.properties","package-lock.json","yarn.lock","pnpm-lock.yaml","npm-shrinkwrap.json","requirements.txt","Pipfile","Pipfile.lock","pyproject.toml","setup.py","setup.cfg","Gemfile","Gemfile.lock","uv.lock","CODEOWNERS"],"protected_path_prefixes":[".github/",".agents/"]}} + GH_AW_SAFE_OUTPUTS_CONFIG_865f927a5b569f5a_EOF + - name: Write Safe Outputs Tools + run: | + cat > ${RUNNER_TEMP}/gh-aw/safeoutputs/tools_meta.json << 'GH_AW_SAFE_OUTPUTS_TOOLS_META_b9f5be2018cfcb9f_EOF' + { + "description_suffixes": {}, + "repo_params": {}, + "dynamic_tools": [] + } + GH_AW_SAFE_OUTPUTS_TOOLS_META_b9f5be2018cfcb9f_EOF + cat > ${RUNNER_TEMP}/gh-aw/safeoutputs/validation.json << 'GH_AW_SAFE_OUTPUTS_VALIDATION_100106990d6477ae_EOF' + { + "missing_data": { + "defaultMax": 20, + "fields": { + "alternatives": { + "type": "string", + "sanitize": true, + "maxLength": 256 + }, + "context": { + "type": "string", + "sanitize": true, + "maxLength": 256 + }, + "data_type": { + "type": "string", + "sanitize": true, + "maxLength": 128 + }, + "reason": { + "type": "string", + "sanitize": true, + "maxLength": 256 + } + } + }, + "missing_tool": { + "defaultMax": 20, + "fields": { + "alternatives": { + "type": "string", + "sanitize": true, + "maxLength": 512 + }, + "reason": { + "required": true, + "type": "string", + "sanitize": true, + "maxLength": 256 + }, + "tool": { + "type": "string", + "sanitize": true, + "maxLength": 128 + } + } + }, + "noop": { + "defaultMax": 1, + "fields": { + "message": { + "required": true, + "type": "string", + "sanitize": true, + "maxLength": 65000 + } + } + }, + "push_to_pull_request_branch": { + "defaultMax": 1, + "fields": { + "branch": { + "required": true, + "type": "string", + "sanitize": true, + "maxLength": 256 + }, + "message": { + "required": true, + "type": "string", + "sanitize": true, + "maxLength": 65000 + }, + "pull_request_number": { + "issueOrPRNumber": true + } + } + } + } + GH_AW_SAFE_OUTPUTS_VALIDATION_100106990d6477ae_EOF + node ${RUNNER_TEMP}/gh-aw/actions/generate_safe_outputs_tools.cjs + - name: Generate Safe Outputs MCP Server Config + id: safe-outputs-config + run: | + # Generate a secure random API key (360 bits of entropy, 40+ chars) + # Mask immediately to prevent timing vulnerabilities + API_KEY=$(openssl rand -base64 45 | tr -d '/+=') + echo "::add-mask::${API_KEY}" + + PORT=3001 + + # Set outputs for next steps + { + echo "safe_outputs_api_key=${API_KEY}" + echo "safe_outputs_port=${PORT}" + } >> "$GITHUB_OUTPUT" + + echo "Safe Outputs MCP server will run on port ${PORT}" + + - name: Start Safe Outputs MCP HTTP Server + id: safe-outputs-start + env: + DEBUG: '*' + GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }} + GH_AW_SAFE_OUTPUTS_PORT: ${{ steps.safe-outputs-config.outputs.safe_outputs_port }} + GH_AW_SAFE_OUTPUTS_API_KEY: ${{ steps.safe-outputs-config.outputs.safe_outputs_api_key }} + GH_AW_SAFE_OUTPUTS_TOOLS_PATH: ${{ runner.temp }}/gh-aw/safeoutputs/tools.json + GH_AW_SAFE_OUTPUTS_CONFIG_PATH: ${{ runner.temp }}/gh-aw/safeoutputs/config.json + GH_AW_MCP_LOG_DIR: /tmp/gh-aw/mcp-logs/safeoutputs + run: | + # Environment variables are set above to prevent template injection + export DEBUG + export GH_AW_SAFE_OUTPUTS + export GH_AW_SAFE_OUTPUTS_PORT + export GH_AW_SAFE_OUTPUTS_API_KEY + export GH_AW_SAFE_OUTPUTS_TOOLS_PATH + export GH_AW_SAFE_OUTPUTS_CONFIG_PATH + export GH_AW_MCP_LOG_DIR + + bash ${RUNNER_TEMP}/gh-aw/actions/start_safe_outputs_server.sh + + - name: Start MCP Gateway + id: start-mcp-gateway + env: + GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }} + GH_AW_SAFE_OUTPUTS_API_KEY: ${{ steps.safe-outputs-start.outputs.api_key }} + GH_AW_SAFE_OUTPUTS_PORT: ${{ steps.safe-outputs-start.outputs.port }} + GITHUB_MCP_GUARD_MIN_INTEGRITY: ${{ steps.determine-automatic-lockdown.outputs.min_integrity }} + GITHUB_MCP_GUARD_REPOS: ${{ steps.determine-automatic-lockdown.outputs.repos }} + GITHUB_MCP_SERVER_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + run: | + set -eo pipefail + mkdir -p /tmp/gh-aw/mcp-config + + # Export gateway environment variables for MCP config and gateway script + export MCP_GATEWAY_PORT="80" + export MCP_GATEWAY_DOMAIN="host.docker.internal" + MCP_GATEWAY_API_KEY=$(openssl rand -base64 45 | tr -d '/+=') + echo "::add-mask::${MCP_GATEWAY_API_KEY}" + export MCP_GATEWAY_API_KEY + export MCP_GATEWAY_PAYLOAD_DIR="/tmp/gh-aw/mcp-payloads" + mkdir -p "${MCP_GATEWAY_PAYLOAD_DIR}" + export MCP_GATEWAY_PAYLOAD_SIZE_THRESHOLD="524288" + export DEBUG="*" + + export GH_AW_ENGINE="copilot" + export MCP_GATEWAY_DOCKER_COMMAND='docker run -i --rm --network host -v /var/run/docker.sock:/var/run/docker.sock -e MCP_GATEWAY_PORT -e MCP_GATEWAY_DOMAIN -e MCP_GATEWAY_API_KEY -e MCP_GATEWAY_PAYLOAD_DIR -e MCP_GATEWAY_PAYLOAD_SIZE_THRESHOLD -e DEBUG -e MCP_GATEWAY_LOG_DIR -e GH_AW_MCP_LOG_DIR -e GH_AW_SAFE_OUTPUTS -e GH_AW_SAFE_OUTPUTS_CONFIG_PATH -e GH_AW_SAFE_OUTPUTS_TOOLS_PATH -e GH_AW_ASSETS_BRANCH -e GH_AW_ASSETS_MAX_SIZE_KB -e GH_AW_ASSETS_ALLOWED_EXTS -e DEFAULT_BRANCH -e GITHUB_MCP_SERVER_TOKEN -e GITHUB_MCP_GUARD_MIN_INTEGRITY -e GITHUB_MCP_GUARD_REPOS -e GITHUB_REPOSITORY -e GITHUB_SERVER_URL -e GITHUB_SHA -e GITHUB_WORKSPACE -e GITHUB_TOKEN -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RUN_ATTEMPT -e GITHUB_JOB -e GITHUB_ACTION -e GITHUB_EVENT_NAME -e GITHUB_EVENT_PATH -e GITHUB_ACTOR -e GITHUB_ACTOR_ID -e GITHUB_TRIGGERING_ACTOR -e GITHUB_WORKFLOW -e GITHUB_WORKFLOW_REF -e GITHUB_WORKFLOW_SHA -e GITHUB_REF -e GITHUB_REF_NAME -e GITHUB_REF_TYPE -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GH_AW_SAFE_OUTPUTS_PORT -e GH_AW_SAFE_OUTPUTS_API_KEY -v /tmp/gh-aw/mcp-payloads:/tmp/gh-aw/mcp-payloads:rw -v /opt:/opt:ro -v /tmp:/tmp:rw -v '"${GITHUB_WORKSPACE}"':'"${GITHUB_WORKSPACE}"':rw ghcr.io/github/gh-aw-mcpg:v0.2.11' + + mkdir -p /home/runner/.copilot + cat << GH_AW_MCP_CONFIG_ae86df47445bf165_EOF | bash ${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.sh + { + "mcpServers": { + "github": { + "type": "stdio", + "container": "ghcr.io/github/github-mcp-server:v0.32.0", + "env": { + "GITHUB_HOST": "\${GITHUB_SERVER_URL}", + "GITHUB_PERSONAL_ACCESS_TOKEN": "\${GITHUB_MCP_SERVER_TOKEN}", + "GITHUB_READ_ONLY": "1", + "GITHUB_TOOLSETS": "pull_requests,repos" + }, + "guard-policies": { + "allow-only": { + "min-integrity": "$GITHUB_MCP_GUARD_MIN_INTEGRITY", + "repos": "$GITHUB_MCP_GUARD_REPOS" + } + } + }, + "safeoutputs": { + "type": "http", + "url": "http://host.docker.internal:$GH_AW_SAFE_OUTPUTS_PORT", + "headers": { + "Authorization": "\${GH_AW_SAFE_OUTPUTS_API_KEY}" + }, + "guard-policies": { + "write-sink": { + "accept": [ + "*" + ] + } + } + } + }, + "gateway": { + "port": $MCP_GATEWAY_PORT, + "domain": "${MCP_GATEWAY_DOMAIN}", + "apiKey": "${MCP_GATEWAY_API_KEY}", + "payloadDir": "${MCP_GATEWAY_PAYLOAD_DIR}" + } + } + GH_AW_MCP_CONFIG_ae86df47445bf165_EOF + - name: Download activation artifact + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: activation + path: /tmp/gh-aw + - name: Clean git credentials + continue-on-error: true + run: bash ${RUNNER_TEMP}/gh-aw/actions/clean_git_credentials.sh + - name: Execute GitHub Copilot CLI + id: agentic_execution + # Copilot CLI tool arguments (sorted): + # --allow-tool github + # --allow-tool safeoutputs + # --allow-tool shell(cat) + # --allow-tool shell(date) + # --allow-tool shell(echo) + # --allow-tool shell(git add) + # --allow-tool shell(git add:*) + # --allow-tool shell(git branch) + # --allow-tool shell(git branch:*) + # --allow-tool shell(git checkout) + # --allow-tool shell(git checkout:*) + # --allow-tool shell(git commit) + # --allow-tool shell(git commit:*) + # --allow-tool shell(git config) + # --allow-tool shell(git diff) + # --allow-tool shell(git fetch) + # --allow-tool shell(git log) + # --allow-tool shell(git merge) + # --allow-tool shell(git merge:*) + # --allow-tool shell(git pull) + # --allow-tool shell(git reset) + # --allow-tool shell(git rev-parse) + # --allow-tool shell(git rm:*) + # --allow-tool shell(git status) + # --allow-tool shell(git switch:*) + # --allow-tool shell(grep) + # --allow-tool shell(head) + # --allow-tool shell(ls) + # --allow-tool shell(make fmt) + # --allow-tool shell(make lint) + # --allow-tool shell(make recompile) + # --allow-tool shell(make test-unit) + # --allow-tool shell(pwd) + # --allow-tool shell(sort) + # --allow-tool shell(tail) + # --allow-tool shell(uniq) + # --allow-tool shell(wc) + # --allow-tool shell(yq) + # --allow-tool write + timeout-minutes: 10 + run: | + set -o pipefail + touch /tmp/gh-aw/agent-step-summary.md + # shellcheck disable=SC1003 + sudo -E awf --container-workdir "${GITHUB_WORKSPACE}" --mount "${RUNNER_TEMP}/gh-aw:${RUNNER_TEMP}/gh-aw:ro" --mount "${RUNNER_TEMP}/gh-aw:/host${RUNNER_TEMP}/gh-aw:ro" --env-all --exclude-env COPILOT_GITHUB_TOKEN --exclude-env GITHUB_MCP_SERVER_TOKEN --exclude-env MCP_GATEWAY_API_KEY --allow-domains api.business.githubcopilot.com,api.enterprise.githubcopilot.com,api.github.com,api.githubcopilot.com,api.individual.githubcopilot.com,api.snapcraft.io,archive.ubuntu.com,azure.archive.ubuntu.com,crl.geotrust.com,crl.globalsign.com,crl.identrust.com,crl.sectigo.com,crl.thawte.com,crl.usertrust.com,crl.verisign.com,crl3.digicert.com,crl4.digicert.com,crls.ssl.com,github.com,host.docker.internal,json-schema.org,json.schemastore.org,keyserver.ubuntu.com,ocsp.digicert.com,ocsp.geotrust.com,ocsp.globalsign.com,ocsp.identrust.com,ocsp.sectigo.com,ocsp.ssl.com,ocsp.thawte.com,ocsp.usertrust.com,ocsp.verisign.com,packagecloud.io,packages.cloud.google.com,packages.microsoft.com,ppa.launchpad.net,raw.githubusercontent.com,registry.npmjs.org,s.symcb.com,s.symcd.com,security.ubuntu.com,telemetry.enterprise.githubcopilot.com,ts-crl.ws.symantec.com,ts-ocsp.ws.symantec.com,www.googleapis.com --log-level info --proxy-logs-dir /tmp/gh-aw/sandbox/firewall/logs --audit-dir /tmp/gh-aw/sandbox/firewall/audit --enable-host-access --image-tag 0.25.11 --skip-pull --enable-api-proxy \ + -- /bin/bash -c '/usr/local/bin/copilot --add-dir /tmp/gh-aw/ --log-level all --log-dir /tmp/gh-aw/sandbox/agent/logs/ --disable-builtin-mcps --allow-tool github --allow-tool safeoutputs --allow-tool '\''shell(cat)'\'' --allow-tool '\''shell(date)'\'' --allow-tool '\''shell(echo)'\'' --allow-tool '\''shell(git add)'\'' --allow-tool '\''shell(git add:*)'\'' --allow-tool '\''shell(git branch)'\'' --allow-tool '\''shell(git branch:*)'\'' --allow-tool '\''shell(git checkout)'\'' --allow-tool '\''shell(git checkout:*)'\'' --allow-tool '\''shell(git commit)'\'' --allow-tool '\''shell(git commit:*)'\'' --allow-tool '\''shell(git config)'\'' --allow-tool '\''shell(git diff)'\'' --allow-tool '\''shell(git fetch)'\'' --allow-tool '\''shell(git log)'\'' --allow-tool '\''shell(git merge)'\'' --allow-tool '\''shell(git merge:*)'\'' --allow-tool '\''shell(git pull)'\'' --allow-tool '\''shell(git reset)'\'' --allow-tool '\''shell(git rev-parse)'\'' --allow-tool '\''shell(git rm:*)'\'' --allow-tool '\''shell(git status)'\'' --allow-tool '\''shell(git switch:*)'\'' --allow-tool '\''shell(grep)'\'' --allow-tool '\''shell(head)'\'' --allow-tool '\''shell(ls)'\'' --allow-tool '\''shell(make fmt)'\'' --allow-tool '\''shell(make lint)'\'' --allow-tool '\''shell(make recompile)'\'' --allow-tool '\''shell(make test-unit)'\'' --allow-tool '\''shell(pwd)'\'' --allow-tool '\''shell(sort)'\'' --allow-tool '\''shell(tail)'\'' --allow-tool '\''shell(uniq)'\'' --allow-tool '\''shell(wc)'\'' --allow-tool '\''shell(yq)'\'' --allow-tool write --allow-all-paths --add-dir "${GITHUB_WORKSPACE}" --prompt "$(cat /tmp/gh-aw/aw-prompts/prompt.txt)"' 2>&1 | tee -a /tmp/gh-aw/agent-stdio.log + env: + COPILOT_AGENT_RUNNER_TYPE: STANDALONE + COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }} + COPILOT_MODEL: ${{ vars.GH_AW_MODEL_AGENT_COPILOT || '' }} + GH_AW_MCP_CONFIG: /home/runner/.copilot/mcp-config.json + GH_AW_PHASE: agent + GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt + GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }} + GH_AW_VERSION: v0.65.6 + GITHUB_API_URL: ${{ github.api_url }} + GITHUB_AW: true + GITHUB_HEAD_REF: ${{ github.head_ref }} + GITHUB_MCP_SERVER_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + GITHUB_REF_NAME: ${{ github.ref_name }} + GITHUB_SERVER_URL: ${{ github.server_url }} + GITHUB_STEP_SUMMARY: /tmp/gh-aw/agent-step-summary.md + GITHUB_WORKSPACE: ${{ github.workspace }} + GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com + GIT_AUTHOR_NAME: github-actions[bot] + GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com + GIT_COMMITTER_NAME: github-actions[bot] + XDG_CONFIG_HOME: /home/runner + - name: Detect inference access error + id: detect-inference-error + if: always() + continue-on-error: true + run: bash ${RUNNER_TEMP}/gh-aw/actions/detect_inference_access_error.sh + - name: Configure Git credentials + env: + REPO_NAME: ${{ github.repository }} + SERVER_URL: ${{ github.server_url }} + run: | + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + git config --global am.keepcr true + # Re-authenticate git with GitHub token + SERVER_URL_STRIPPED="${SERVER_URL#https://}" + git remote set-url origin "https://x-access-token:${{ github.token }}@${SERVER_URL_STRIPPED}/${REPO_NAME}.git" + echo "Git configured with standard GitHub Actions identity" + - name: Copy Copilot session state files to logs + if: always() + continue-on-error: true + run: bash ${RUNNER_TEMP}/gh-aw/actions/copy_copilot_session_state.sh + - name: Stop MCP Gateway + if: always() + continue-on-error: true + env: + MCP_GATEWAY_PORT: ${{ steps.start-mcp-gateway.outputs.gateway-port }} + MCP_GATEWAY_API_KEY: ${{ steps.start-mcp-gateway.outputs.gateway-api-key }} + GATEWAY_PID: ${{ steps.start-mcp-gateway.outputs.gateway-pid }} + run: | + bash ${RUNNER_TEMP}/gh-aw/actions/stop_mcp_gateway.sh "$GATEWAY_PID" + - name: Redact secrets in logs + if: always() + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('${{ runner.temp }}/gh-aw/actions/redact_secrets.cjs'); + await main(); + env: + GH_AW_SECRET_NAMES: 'COPILOT_GITHUB_TOKEN,GH_AW_GITHUB_MCP_SERVER_TOKEN,GH_AW_GITHUB_TOKEN,GITHUB_TOKEN' + SECRET_COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }} + SECRET_GH_AW_GITHUB_MCP_SERVER_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN }} + SECRET_GH_AW_GITHUB_TOKEN: ${{ secrets.GH_AW_GITHUB_TOKEN }} + SECRET_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Append agent step summary + if: always() + run: bash ${RUNNER_TEMP}/gh-aw/actions/append_agent_step_summary.sh + - name: Copy Safe Outputs + if: always() + env: + GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }} + run: | + mkdir -p /tmp/gh-aw + cp "$GH_AW_SAFE_OUTPUTS" /tmp/gh-aw/safeoutputs.jsonl 2>/dev/null || true + - name: Ingest agent output + id: collect_output + if: always() + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + env: + GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }} + GH_AW_ALLOWED_DOMAINS: "api.business.githubcopilot.com,api.enterprise.githubcopilot.com,api.github.com,api.githubcopilot.com,api.individual.githubcopilot.com,api.snapcraft.io,archive.ubuntu.com,azure.archive.ubuntu.com,crl.geotrust.com,crl.globalsign.com,crl.identrust.com,crl.sectigo.com,crl.thawte.com,crl.usertrust.com,crl.verisign.com,crl3.digicert.com,crl4.digicert.com,crls.ssl.com,github.com,host.docker.internal,json-schema.org,json.schemastore.org,keyserver.ubuntu.com,ocsp.digicert.com,ocsp.geotrust.com,ocsp.globalsign.com,ocsp.identrust.com,ocsp.sectigo.com,ocsp.ssl.com,ocsp.thawte.com,ocsp.usertrust.com,ocsp.verisign.com,packagecloud.io,packages.cloud.google.com,packages.microsoft.com,ppa.launchpad.net,raw.githubusercontent.com,registry.npmjs.org,s.symcb.com,s.symcd.com,security.ubuntu.com,telemetry.enterprise.githubcopilot.com,ts-crl.ws.symantec.com,ts-ocsp.ws.symantec.com,www.googleapis.com" + GITHUB_SERVER_URL: ${{ github.server_url }} + GITHUB_API_URL: ${{ github.api_url }} + GH_AW_COMMAND: mergefest + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('${{ runner.temp }}/gh-aw/actions/collect_ndjson_output.cjs'); + await main(); + - name: Parse agent logs for step summary + if: always() + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + env: + GH_AW_AGENT_OUTPUT: /tmp/gh-aw/sandbox/agent/logs/ + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('${{ runner.temp }}/gh-aw/actions/parse_copilot_log.cjs'); + await main(); + - name: Parse MCP Gateway logs for step summary + if: always() + id: parse-mcp-gateway + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('${{ runner.temp }}/gh-aw/actions/parse_mcp_gateway_log.cjs'); + await main(); + - name: Print firewall logs + if: always() + continue-on-error: true + env: + AWF_LOGS_DIR: /tmp/gh-aw/sandbox/firewall/logs + run: | + # Fix permissions on firewall logs so they can be uploaded as artifacts + # AWF runs with sudo, creating files owned by root + sudo chmod -R a+r /tmp/gh-aw/sandbox/firewall/logs 2>/dev/null || true + # Only run awf logs summary if awf command exists (it may not be installed if workflow failed before install step) + if command -v awf &> /dev/null; then + awf logs summary | tee -a "$GITHUB_STEP_SUMMARY" + else + echo 'AWF binary not installed, skipping firewall log summary' + fi + - name: Parse token usage for step summary + if: always() + continue-on-error: true + run: bash ${RUNNER_TEMP}/gh-aw/actions/parse_token_usage.sh + - name: Write agent output placeholder if missing + if: always() + run: | + if [ ! -f /tmp/gh-aw/agent_output.json ]; then + echo '{"items":[]}' > /tmp/gh-aw/agent_output.json + fi + - name: Upload agent artifacts + if: always() + continue-on-error: true + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7 + with: + name: agent + path: | + /tmp/gh-aw/aw-prompts/prompt.txt + /tmp/gh-aw/sandbox/agent/logs/ + /tmp/gh-aw/redacted-urls.log + /tmp/gh-aw/mcp-logs/ + /tmp/gh-aw/agent-stdio.log + /tmp/gh-aw/agent/ + /tmp/gh-aw/safeoutputs.jsonl + /tmp/gh-aw/agent_output.json + /tmp/gh-aw/aw-*.patch + /tmp/gh-aw/aw-*.bundle + if-no-files-found: ignore + - name: Upload firewall audit logs + if: always() + continue-on-error: true + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7 + with: + name: firewall-audit-logs + path: | + /tmp/gh-aw/sandbox/firewall/logs/ + /tmp/gh-aw/sandbox/firewall/audit/ + if-no-files-found: ignore + + conclusion: + needs: + - activation + - agent + - detection + - safe_outputs + if: always() && (needs.agent.result != 'skipped' || needs.activation.outputs.lockdown_check_failed == 'true') + runs-on: ubuntu-slim + permissions: + contents: write + pull-requests: write + concurrency: + group: "gh-aw-conclusion-mergefest" + cancel-in-progress: false + outputs: + noop_message: ${{ steps.noop.outputs.noop_message }} + tools_reported: ${{ steps.missing_tool.outputs.tools_reported }} + total_count: ${{ steps.missing_tool.outputs.total_count }} + steps: + - name: Setup Scripts + uses: github/gh-aw-actions/setup@31130b20a8fd3ef263acbe2091267c0aace07e09 # v0.65.6 + with: + destination: ${{ runner.temp }}/gh-aw/actions + - name: Download agent output artifact + id: download-agent-output + continue-on-error: true + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: agent + path: /tmp/gh-aw/ + - name: Setup agent output environment variable + id: setup-agent-output-env + if: steps.download-agent-output.outcome == 'success' + run: | + mkdir -p /tmp/gh-aw/ + find "/tmp/gh-aw/" -type f -print + echo "GH_AW_AGENT_OUTPUT=/tmp/gh-aw/agent_output.json" >> "$GITHUB_OUTPUT" + - name: Process No-Op Messages + id: noop + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + env: + GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} + GH_AW_NOOP_MAX: "1" + GH_AW_WORKFLOW_NAME: "Mergefest" + GH_AW_WORKFLOW_SOURCE: "github/gh-aw/.github/workflows/mergefest.md@852cb06ad52958b402ed982b69957ffc57ca0619" + GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/github/gh-aw/blob/852cb06ad52958b402ed982b69957ffc57ca0619/.github/workflows/mergefest.md" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }} + GH_AW_NOOP_REPORT_AS_ISSUE: "true" + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('${{ runner.temp }}/gh-aw/actions/handle_noop_message.cjs'); + await main(); + - name: Record Missing Tool + id: missing_tool + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + env: + GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} + GH_AW_MISSING_TOOL_CREATE_ISSUE: "true" + GH_AW_WORKFLOW_NAME: "Mergefest" + GH_AW_WORKFLOW_SOURCE: "github/gh-aw/.github/workflows/mergefest.md@852cb06ad52958b402ed982b69957ffc57ca0619" + GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/github/gh-aw/blob/852cb06ad52958b402ed982b69957ffc57ca0619/.github/workflows/mergefest.md" + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('${{ runner.temp }}/gh-aw/actions/missing_tool.cjs'); + await main(); + - name: Handle Agent Failure + id: handle_agent_failure + if: always() + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + env: + GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} + GH_AW_WORKFLOW_NAME: "Mergefest" + GH_AW_WORKFLOW_SOURCE: "github/gh-aw/.github/workflows/mergefest.md@852cb06ad52958b402ed982b69957ffc57ca0619" + GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/github/gh-aw/blob/852cb06ad52958b402ed982b69957ffc57ca0619/.github/workflows/mergefest.md" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }} + GH_AW_WORKFLOW_ID: "mergefest" + GH_AW_ENGINE_ID: "copilot" + GH_AW_SECRET_VERIFICATION_RESULT: ${{ needs.activation.outputs.secret_verification_result }} + GH_AW_CHECKOUT_PR_SUCCESS: ${{ needs.agent.outputs.checkout_pr_success }} + GH_AW_INFERENCE_ACCESS_ERROR: ${{ needs.agent.outputs.inference_access_error }} + GH_AW_CODE_PUSH_FAILURE_ERRORS: ${{ needs.safe_outputs.outputs.code_push_failure_errors }} + GH_AW_CODE_PUSH_FAILURE_COUNT: ${{ needs.safe_outputs.outputs.code_push_failure_count }} + GH_AW_LOCKDOWN_CHECK_FAILED: ${{ needs.activation.outputs.lockdown_check_failed }} + GH_AW_GROUP_REPORTS: "false" + GH_AW_FAILURE_REPORT_AS_ISSUE: "true" + GH_AW_TIMEOUT_MINUTES: "10" + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('${{ runner.temp }}/gh-aw/actions/handle_agent_failure.cjs'); + await main(); + - name: Update reaction comment with completion status + id: conclusion + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + env: + GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} + GH_AW_COMMENT_ID: ${{ needs.activation.outputs.comment_id }} + GH_AW_COMMENT_REPO: ${{ needs.activation.outputs.comment_repo }} + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + GH_AW_WORKFLOW_NAME: "Mergefest" + GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }} + GH_AW_DETECTION_CONCLUSION: ${{ needs.detection.outputs.detection_conclusion }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('${{ runner.temp }}/gh-aw/actions/notify_comment_error.cjs'); + await main(); + + detection: + needs: agent + if: > + always() && needs.agent.result != 'skipped' && (needs.agent.outputs.output_types != '' || needs.agent.outputs.has_patch == 'true') + runs-on: ubuntu-latest + permissions: + contents: read + outputs: + detection_conclusion: ${{ steps.detection_conclusion.outputs.conclusion }} + detection_success: ${{ steps.detection_conclusion.outputs.success }} + steps: + - name: Setup Scripts + uses: github/gh-aw-actions/setup@31130b20a8fd3ef263acbe2091267c0aace07e09 # v0.65.6 + with: + destination: ${{ runner.temp }}/gh-aw/actions + - name: Download agent output artifact + id: download-agent-output + continue-on-error: true + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: agent + path: /tmp/gh-aw/ + - name: Setup agent output environment variable + id: setup-agent-output-env + if: steps.download-agent-output.outcome == 'success' + run: | + mkdir -p /tmp/gh-aw/ + find "/tmp/gh-aw/" -type f -print + echo "GH_AW_AGENT_OUTPUT=/tmp/gh-aw/agent_output.json" >> "$GITHUB_OUTPUT" + - name: Checkout repository for patch context + if: needs.agent.outputs.has_patch == 'true' + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + # --- Threat Detection --- + - name: Download container images + run: bash ${RUNNER_TEMP}/gh-aw/actions/download_docker_images.sh ghcr.io/github/gh-aw-firewall/agent:0.25.11 ghcr.io/github/gh-aw-firewall/api-proxy:0.25.11 ghcr.io/github/gh-aw-firewall/squid:0.25.11 + - name: Check if detection needed + id: detection_guard + if: always() + env: + OUTPUT_TYPES: ${{ needs.agent.outputs.output_types }} + HAS_PATCH: ${{ needs.agent.outputs.has_patch }} + run: | + if [[ -n "$OUTPUT_TYPES" || "$HAS_PATCH" == "true" ]]; then + echo "run_detection=true" >> "$GITHUB_OUTPUT" + echo "Detection will run: output_types=$OUTPUT_TYPES, has_patch=$HAS_PATCH" + else + echo "run_detection=false" >> "$GITHUB_OUTPUT" + echo "Detection skipped: no agent outputs or patches to analyze" + fi + - name: Clear MCP configuration for detection + if: always() && steps.detection_guard.outputs.run_detection == 'true' + run: | + rm -f /tmp/gh-aw/mcp-config/mcp-servers.json + rm -f /home/runner/.copilot/mcp-config.json + rm -f "$GITHUB_WORKSPACE/.gemini/settings.json" + - name: Prepare threat detection files + if: always() && steps.detection_guard.outputs.run_detection == 'true' + run: | + mkdir -p /tmp/gh-aw/threat-detection/aw-prompts + cp /tmp/gh-aw/aw-prompts/prompt.txt /tmp/gh-aw/threat-detection/aw-prompts/prompt.txt 2>/dev/null || true + cp /tmp/gh-aw/agent_output.json /tmp/gh-aw/threat-detection/agent_output.json 2>/dev/null || true + for f in /tmp/gh-aw/aw-*.patch; do + [ -f "$f" ] && cp "$f" /tmp/gh-aw/threat-detection/ 2>/dev/null || true + done + for f in /tmp/gh-aw/aw-*.bundle; do + [ -f "$f" ] && cp "$f" /tmp/gh-aw/threat-detection/ 2>/dev/null || true + done + echo "Prepared threat detection files:" + ls -la /tmp/gh-aw/threat-detection/ 2>/dev/null || true + - name: Setup threat detection + if: always() && steps.detection_guard.outputs.run_detection == 'true' + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + env: + WORKFLOW_NAME: "Mergefest" + WORKFLOW_DESCRIPTION: "Automatically merges the main branch into pull request branches when invoked with /mergefest command" + HAS_PATCH: ${{ needs.agent.outputs.has_patch }} + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('${{ runner.temp }}/gh-aw/actions/setup_threat_detection.cjs'); + await main(); + - name: Ensure threat-detection directory and log + if: always() && steps.detection_guard.outputs.run_detection == 'true' + run: | + mkdir -p /tmp/gh-aw/threat-detection + touch /tmp/gh-aw/threat-detection/detection.log + - name: Install GitHub Copilot CLI + run: ${RUNNER_TEMP}/gh-aw/actions/install_copilot_cli.sh latest + - name: Install AWF binary + run: bash ${RUNNER_TEMP}/gh-aw/actions/install_awf_binary.sh v0.25.11 + - name: Execute GitHub Copilot CLI + if: always() && steps.detection_guard.outputs.run_detection == 'true' + id: detection_agentic_execution + # Copilot CLI tool arguments (sorted): + timeout-minutes: 20 + run: | + set -o pipefail + touch /tmp/gh-aw/agent-step-summary.md + # shellcheck disable=SC1003 + sudo -E awf --container-workdir "${GITHUB_WORKSPACE}" --mount "${RUNNER_TEMP}/gh-aw:${RUNNER_TEMP}/gh-aw:ro" --mount "${RUNNER_TEMP}/gh-aw:/host${RUNNER_TEMP}/gh-aw:ro" --env-all --exclude-env COPILOT_GITHUB_TOKEN --allow-domains api.business.githubcopilot.com,api.enterprise.githubcopilot.com,api.github.com,api.githubcopilot.com,api.individual.githubcopilot.com,github.com,host.docker.internal,telemetry.enterprise.githubcopilot.com --log-level info --proxy-logs-dir /tmp/gh-aw/sandbox/firewall/logs --audit-dir /tmp/gh-aw/sandbox/firewall/audit --enable-host-access --image-tag 0.25.11 --skip-pull --enable-api-proxy \ + -- /bin/bash -c '/usr/local/bin/copilot --add-dir /tmp/gh-aw/ --log-level all --log-dir /tmp/gh-aw/sandbox/agent/logs/ --disable-builtin-mcps --allow-all-tools --add-dir "${GITHUB_WORKSPACE}" --prompt "$(cat /tmp/gh-aw/aw-prompts/prompt.txt)"' 2>&1 | tee -a /tmp/gh-aw/threat-detection/detection.log + env: + COPILOT_AGENT_RUNNER_TYPE: STANDALONE + COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }} + COPILOT_MODEL: ${{ vars.GH_AW_MODEL_DETECTION_COPILOT || '' }} + GH_AW_PHASE: detection + GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt + GH_AW_VERSION: v0.65.6 + GITHUB_API_URL: ${{ github.api_url }} + GITHUB_AW: true + GITHUB_HEAD_REF: ${{ github.head_ref }} + GITHUB_REF_NAME: ${{ github.ref_name }} + GITHUB_SERVER_URL: ${{ github.server_url }} + GITHUB_STEP_SUMMARY: /tmp/gh-aw/agent-step-summary.md + GITHUB_WORKSPACE: ${{ github.workspace }} + GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com + GIT_AUTHOR_NAME: github-actions[bot] + GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com + GIT_COMMITTER_NAME: github-actions[bot] + XDG_CONFIG_HOME: /home/runner + - name: Upload threat detection log + if: always() && steps.detection_guard.outputs.run_detection == 'true' + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7 + with: + name: detection + path: /tmp/gh-aw/threat-detection/detection.log + if-no-files-found: ignore + - name: Parse and conclude threat detection + id: detection_conclusion + if: always() + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + env: + RUN_DETECTION: ${{ steps.detection_guard.outputs.run_detection }} + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('${{ runner.temp }}/gh-aw/actions/parse_threat_detection_results.cjs'); + await main(); + + pre_activation: + if: "github.event_name == 'issue_comment' && (startsWith(github.event.comment.body, '/mergefest ') || startsWith(github.event.comment.body, '/mergefest\n') || github.event.comment.body == '/mergefest') && github.event.issue.pull_request != null" + runs-on: ubuntu-slim + outputs: + activated: ${{ steps.check_membership.outputs.is_team_member == 'true' && steps.check_command_position.outputs.command_position_ok == 'true' }} + matched_command: ${{ steps.check_command_position.outputs.matched_command }} + steps: + - name: Setup Scripts + uses: github/gh-aw-actions/setup@31130b20a8fd3ef263acbe2091267c0aace07e09 # v0.65.6 + with: + destination: ${{ runner.temp }}/gh-aw/actions + - name: Check team membership for command workflow + id: check_membership + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + env: + GH_AW_REQUIRED_ROLES: "admin,maintainer,write" + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('${{ runner.temp }}/gh-aw/actions/check_membership.cjs'); + await main(); + - name: Check command position + id: check_command_position + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + env: + GH_AW_COMMANDS: "[\"mergefest\"]" + with: + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('${{ runner.temp }}/gh-aw/actions/check_command_position.cjs'); + await main(); + + safe_outputs: + needs: + - activation + - agent + - detection + if: (!cancelled()) && needs.agent.result != 'skipped' && needs.detection.result == 'success' + runs-on: ubuntu-slim + permissions: + contents: write + pull-requests: write + timeout-minutes: 15 + env: + GH_AW_CALLER_WORKFLOW_ID: "${{ github.repository }}/mergefest" + GH_AW_EFFECTIVE_TOKENS: ${{ needs.agent.outputs.effective_tokens }} + GH_AW_ENGINE_ID: "copilot" + GH_AW_ENGINE_MODEL: ${{ needs.agent.outputs.model }} + GH_AW_WORKFLOW_ID: "mergefest" + GH_AW_WORKFLOW_NAME: "Mergefest" + GH_AW_WORKFLOW_SOURCE: "github/gh-aw/.github/workflows/mergefest.md@852cb06ad52958b402ed982b69957ffc57ca0619" + GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/github/gh-aw/blob/852cb06ad52958b402ed982b69957ffc57ca0619/.github/workflows/mergefest.md" + outputs: + code_push_failure_count: ${{ steps.process_safe_outputs.outputs.code_push_failure_count }} + code_push_failure_errors: ${{ steps.process_safe_outputs.outputs.code_push_failure_errors }} + create_discussion_error_count: ${{ steps.process_safe_outputs.outputs.create_discussion_error_count }} + create_discussion_errors: ${{ steps.process_safe_outputs.outputs.create_discussion_errors }} + process_safe_outputs_processed_count: ${{ steps.process_safe_outputs.outputs.processed_count }} + process_safe_outputs_temporary_id_map: ${{ steps.process_safe_outputs.outputs.temporary_id_map }} + push_commit_sha: ${{ steps.process_safe_outputs.outputs.push_commit_sha }} + push_commit_url: ${{ steps.process_safe_outputs.outputs.push_commit_url }} + steps: + - name: Setup Scripts + uses: github/gh-aw-actions/setup@31130b20a8fd3ef263acbe2091267c0aace07e09 # v0.65.6 + with: + destination: ${{ runner.temp }}/gh-aw/actions + - name: Download agent output artifact + id: download-agent-output + continue-on-error: true + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: agent + path: /tmp/gh-aw/ + - name: Setup agent output environment variable + id: setup-agent-output-env + if: steps.download-agent-output.outcome == 'success' + run: | + mkdir -p /tmp/gh-aw/ + find "/tmp/gh-aw/" -type f -print + echo "GH_AW_AGENT_OUTPUT=/tmp/gh-aw/agent_output.json" >> "$GITHUB_OUTPUT" + - name: Download patch artifact + continue-on-error: true + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: agent + path: /tmp/gh-aw/ + - name: Checkout repository + if: (!cancelled()) && needs.agent.result != 'skipped' && contains(needs.agent.outputs.output_types, 'push_to_pull_request_branch') + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + ref: ${{ github.base_ref || github.event.pull_request.base.ref || github.ref_name || github.event.repository.default_branch }} + token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + persist-credentials: false + fetch-depth: 1 + - name: Configure Git credentials + if: (!cancelled()) && needs.agent.result != 'skipped' && contains(needs.agent.outputs.output_types, 'push_to_pull_request_branch') + env: + REPO_NAME: ${{ github.repository }} + SERVER_URL: ${{ github.server_url }} + GIT_TOKEN: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + run: | + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + git config --global am.keepcr true + # Re-authenticate git with GitHub token + SERVER_URL_STRIPPED="${SERVER_URL#https://}" + git remote set-url origin "https://x-access-token:${GIT_TOKEN}@${SERVER_URL_STRIPPED}/${REPO_NAME}.git" + echo "Git configured with standard GitHub Actions identity" + - name: Configure GH_HOST for enterprise compatibility + id: ghes-host-config + shell: bash + run: | + # Derive GH_HOST from GITHUB_SERVER_URL so the gh CLI targets the correct + # GitHub instance (GHES/GHEC). On github.com this is a harmless no-op. + GH_HOST="${GITHUB_SERVER_URL#https://}" + GH_HOST="${GH_HOST#http://}" + echo "GH_HOST=${GH_HOST}" >> "$GITHUB_ENV" + - name: Process Safe Outputs + id: process_safe_outputs + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + env: + GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} + GH_AW_ALLOWED_DOMAINS: "api.business.githubcopilot.com,api.enterprise.githubcopilot.com,api.github.com,api.githubcopilot.com,api.individual.githubcopilot.com,api.snapcraft.io,archive.ubuntu.com,azure.archive.ubuntu.com,crl.geotrust.com,crl.globalsign.com,crl.identrust.com,crl.sectigo.com,crl.thawte.com,crl.usertrust.com,crl.verisign.com,crl3.digicert.com,crl4.digicert.com,crls.ssl.com,github.com,host.docker.internal,json-schema.org,json.schemastore.org,keyserver.ubuntu.com,ocsp.digicert.com,ocsp.geotrust.com,ocsp.globalsign.com,ocsp.identrust.com,ocsp.sectigo.com,ocsp.ssl.com,ocsp.thawte.com,ocsp.usertrust.com,ocsp.verisign.com,packagecloud.io,packages.cloud.google.com,packages.microsoft.com,ppa.launchpad.net,raw.githubusercontent.com,registry.npmjs.org,s.symcb.com,s.symcd.com,security.ubuntu.com,telemetry.enterprise.githubcopilot.com,ts-crl.ws.symantec.com,ts-ocsp.ws.symantec.com,www.googleapis.com" + GITHUB_SERVER_URL: ${{ github.server_url }} + GITHUB_API_URL: ${{ github.api_url }} + GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG: "{\"missing_data\":{},\"missing_tool\":{},\"noop\":{\"max\":1,\"report-as-issue\":\"true\"},\"push_to_pull_request_branch\":{\"if_no_changes\":\"warn\",\"max_patch_size\":1024,\"protected_files\":[\"package.json\",\"bun.lockb\",\"bunfig.toml\",\"deno.json\",\"deno.jsonc\",\"deno.lock\",\"global.json\",\"NuGet.Config\",\"Directory.Packages.props\",\"mix.exs\",\"mix.lock\",\"go.mod\",\"go.sum\",\"stack.yaml\",\"stack.yaml.lock\",\"pom.xml\",\"build.gradle\",\"build.gradle.kts\",\"settings.gradle\",\"settings.gradle.kts\",\"gradle.properties\",\"package-lock.json\",\"yarn.lock\",\"pnpm-lock.yaml\",\"npm-shrinkwrap.json\",\"requirements.txt\",\"Pipfile\",\"Pipfile.lock\",\"pyproject.toml\",\"setup.py\",\"setup.cfg\",\"Gemfile\",\"Gemfile.lock\",\"uv.lock\",\"CODEOWNERS\",\"AGENTS.md\"],\"protected_path_prefixes\":[\".github/\",\".agents/\"]}}" + GH_AW_CI_TRIGGER_TOKEN: ${{ secrets.GH_AW_CI_TRIGGER_TOKEN }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('${{ runner.temp }}/gh-aw/actions/safe_output_handler_manager.cjs'); + await main(); + - name: Upload Safe Output Items + if: always() + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7 + with: + name: safe-output-items + path: /tmp/gh-aw/safe-output-items.jsonl + if-no-files-found: ignore + diff --git a/.github/workflows/mergefest.md b/.github/workflows/mergefest.md new file mode 100644 index 000000000000..14110d96c3a5 --- /dev/null +++ b/.github/workflows/mergefest.md @@ -0,0 +1,351 @@ +--- +name: Mergefest +description: Automatically merges the main branch into pull request branches when invoked with /mergefest command +on: + slash_command: + name: mergefest + events: [pull_request_comment] +permissions: + contents: read + pull-requests: read + actions: read +engine: copilot +tools: + bash: + - "git fetch" + - "git checkout" + - "git pull" + - "git merge" + - "git status" + - "git diff" + - "git log" + - "git rev-parse" + - "git reset" + - "git add" + - "git commit" + - "git config" + - "git branch" + - "make recompile" + - "make fmt" + - "make lint" + - "make test-unit" + - "cat" + - "echo" + - "ls" + - "grep" + edit: + github: + toolsets: [pull_requests, repos] +safe-outputs: + push-to-pull-request-branch: +timeout-minutes: 10 +strict: true +steps: + - name: Setup Git configuration + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + # Create .gitignore to exclude workflow YAML files + cat > /tmp/merge-gitignore << 'EOF' + # Exclude all .yml files in .github/workflows/ + .github/workflows/*.yml + EOF +imports: + - shared/mood.md +source: github/gh-aw/.github/workflows/mergefest.md@852cb06ad52958b402ed982b69957ffc57ca0619 +--- + +# Mergefest - Merge Main into Pull Request Branch + +You are the Mergefest agent - responsible for merging the main branch into the current pull request branch when invoked with the `/mergefest` command. + +## Mission + +When invoked with `/mergefest` in a pull request comment, merge the main branch into the pull request branch while ensuring that no `.yml` files under `.github/workflows/` are committed during the merge process. + +## Current Context + +- **Repository**: ${{ github.repository }} +- **Pull Request Number**: ${{ github.event.pull_request.number }} +- **Triggered by**: @${{ github.actor }} + +## Task + +Your task is to perform an informed merge of the main branch into the pull request branch: + +### 1. Get Pull Request Information + +First, retrieve the full pull request details to get branch names: + +Use GitHub tools: +``` +Use pull_request_read with method "get" to get PR details including: +- head.ref (the PR branch name) +- base.ref (the base branch, usually main) +- state (to verify PR is open) +``` + +Store the branch names for use in subsequent git commands. + +### 2. Validate the Pull Request + +Before starting the merge: +- Verify the PR is open (state == "open") +- Confirm the PR is not already merged or closed +- Check that the PR branch exists and is accessible + +### 3. Fetch Latest Changes + +Fetch the latest changes from both branches (use branch names from step 1): + +```bash +# Fetch all branches +git fetch origin + +# Get the current branch name +CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)" + +# Ensure we're on the PR branch (use the head.ref from PR details) +# PR_BRANCH will be the value from pull_request_read +git checkout +git pull origin + +# Fetch main branch (or base branch from PR details) +git fetch origin +``` + +Replace and with the actual values from the GitHub API response. + +### 4. Analyze Repository Structure + +Before merging, analyze the repository to make an informed merge decision: + +```bash +# Use the base branch from PR details (e.g., origin/main) +# Check for workflow files that might have conflicts +git diff --name-only origin/...HEAD | grep -E '\.github/workflows/.*\.yml$' || true + +# Check overall diff statistics +git diff --stat origin/...HEAD + +# Check if there are any existing .yml files in workflows that we need to be careful with +find .github/workflows -name "*.yml" -type f 2>/dev/null | head -20 || true +``` + +Replace with the actual base branch name from the GitHub API response. + +### 5. Configure Git to Ignore Workflow YML Files + +Set up git to never stage or commit `.yml` files in `.github/workflows/`: + +```bash +# Add .github/workflows/*.yml to .git/info/exclude (local gitignore) +echo ".github/workflows/*.yml" >> .git/info/exclude + +# Also create a temporary .gitignore for this merge operation +cat > .github/workflows/.gitignore << 'EOF' +*.yml +EOF +``` + +### 6. Perform the Merge + +Execute the merge from the base branch (typically main) into the PR branch: + +```bash +# Use the base branch name from PR details +# Attempt the merge +git merge origin/ --no-edit -m "Merge into " + +# Check merge status +MERGE_STATUS=$? + +if [ $MERGE_STATUS -eq 0 ]; then + echo "โœ… Merge completed successfully" +else + echo "โš ๏ธ Merge conflicts detected - need manual resolution" + git status +fi +``` + +### 7. Handle Merge Conflicts + +If there are merge conflicts: + +1. **Identify conflicted files**: +```bash +git status --short | grep '^UU' || git status --short | grep '^AA' || true +``` + +2. **For `.yml` files in `.github/workflows/`**: + - NEVER attempt to resolve these conflicts automatically + - Use the PR head version (ours): + ```bash + git checkout --ours .github/workflows/*.yml 2>/dev/null || true + git add .github/workflows/*.yml 2>/dev/null || true + ``` + +3. **For `.lock.yml` files in `.github/workflows/`**: + - These are compiled workflow files that can be regenerated + - Accept the merge and then recompile: + ```bash + # Check if there are any .lock.yml conflicts + LOCK_CONFLICTS="$(git status --short | grep '\.lock\.yml$' || true)" + + if [ -n "$LOCK_CONFLICTS" ]; then + echo "๐Ÿ“‹ Detected .lock.yml conflicts, will regenerate after merge" + # Accept the incoming changes (theirs) for lock files + git checkout --theirs .github/workflows/*.lock.yml 2>/dev/null || true + git add .github/workflows/*.lock.yml 2>/dev/null || true + fi + ``` + +4. **For other conflicts**: + - Analyze the conflicts using git tools + - Use your knowledge of the repository structure to make informed decisions + - For documentation files, prefer newer/main branch version + - For code files, attempt to merge intelligently or keep both versions with markers + - When in doubt, keep the PR version and document the conflict + +5. **Complete the merge**: +```bash +git merge --continue || git commit --no-edit -m "Resolve merge conflicts from main" +``` + +6. **If there were .lock.yml conflicts, recompile workflows**: +```bash +# Check if we resolved any .lock.yml conflicts +if git log -1 --stat | grep '\.lock\.yml'; then + echo "๐Ÿ”„ Recompiling workflows after .lock.yml conflicts" + make recompile + + # Stage the recompiled files (but NOT .yml files, only .lock.yml and .md) + git add .github/workflows/*.lock.yml 2>/dev/null || true + git add .github/workflows/*.md 2>/dev/null || true + + # Commit the recompiled files if there are changes + if ! git diff --cached --quiet; then + git commit -m "Recompile workflows after merge conflict resolution" + fi +fi +``` + +### 8. Format, Lint, Test, and Recompile + +After the merge is complete, ensure code quality: + +```bash +# Format the code +echo "๐ŸŽจ Formatting code..." +make fmt + +# Lint the code +echo "๐Ÿ” Linting code..." +make lint + +# Run unit tests +echo "๐Ÿงช Running tests..." +make test-unit + +# Recompile all workflows to ensure they're up to date +echo "๐Ÿ”„ Recompiling workflows..." +make recompile + +# Stage any changes from formatting or recompilation +git add -A + +# Commit if there are changes +if ! git diff --cached --quiet; then + git commit -m "Format, lint, and recompile after merge" +fi +``` + +### 9. Verify No Workflow YML Files Are Staged + +Before pushing, double-check that no `.yml` files from `.github/workflows/` are staged: + +```bash +# List all staged files +STAGED_FILES="$(git diff --cached --name-only)" + +# Check for any .yml files in workflows directory +WORKFLOW_YMLS="$(echo "$STAGED_FILES" | grep -E '^\.github/workflows/.*\.yml$' || true)" + +if [ -n "$WORKFLOW_YMLS" ]; then + echo "โš ๏ธ WARNING: Workflow .yml files are staged, removing them" + echo "$WORKFLOW_YMLS" | while read -r file; do + git reset HEAD "$file" + echo "Unstaged: $file" + done +fi + +# Verify clean staging +git status +``` + +### 10. Push Changes to Pull Request Branch + +Use the safe-outputs system to push changes back to the PR branch: + +```bash +# Final verification +git log --oneline -5 +git diff --stat HEAD~1 HEAD + +# Push will be handled by push-to-pull-request-branch safe output +echo "Ready to push merged changes to " +``` + +The `push-to-pull-request-branch` safe output will automatically: +- Push commits to the PR branch +- Add appropriate commit message prefix +- Handle authentication securely + +## Guidelines + +- **Be Careful**: This operation modifies the PR branch directly +- **Never Commit Workflow YMLs**: Always exclude `.github/workflows/*.yml` files +- **Recompile After Lock File Conflicts**: Run `make recompile` if `.lock.yml` files had conflicts +- **Format, Lint, Test**: Always run `make fmt`, `make lint`, `make test-unit`, and `make recompile` after merge +- **Verify Before Pushing**: Always check what's staged before pushing +- **Handle Conflicts Intelligently**: Use repository knowledge to resolve conflicts +- **Document Actions**: Explain what was merged and any conflicts resolved +- **Report Status**: Always report back on merge success or issues + +## Security + +- **Validate PR exists** and is in valid state before merging +- **Never execute code** from merged files during analysis +- **Respect .gitignore patterns** and exclusions +- **Use safe git operations** - no force pushes + +## Error Handling + +If any of these conditions occur, explain clearly in response: +- PR is closed or already merged +- PR branch is protected and cannot be pushed to +- Merge conflicts cannot be automatically resolved +- Network or git operation failures +- Workflow .yml files were accidentally staged + +## Output Format + +After the merge, provide a summary comment with: + +```markdown +# ๐ŸŽ‰ Mergefest Complete + +Merged `` into `` + +## Merge Summary +- **Commits merged**: [number] +- **Files changed**: [number] +- **Conflicts resolved**: [yes/no, details if any] + +## Changes +[Brief summary of what was merged] + +## Notes +[Any important notes about the merge, conflicts, or excluded files] +``` \ No newline at end of file diff --git a/.github/workflows/shared/mood.md b/.github/workflows/shared/mood.md new file mode 100644 index 000000000000..945c9b46d684 --- /dev/null +++ b/.github/workflows/shared/mood.md @@ -0,0 +1 @@ +. \ No newline at end of file From 6bf6c4e310f7d253dddbdcbc493b1633d8f1d169 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Fri, 3 Apr 2026 15:14:37 +0800 Subject: [PATCH 2/6] comment out make command, allow git format-patch --- .github/workflows/mergefest.lock.yml | 42 +++++++++++++--------------- .github/workflows/mergefest.md | 16 +++++------ 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/.github/workflows/mergefest.lock.yml b/.github/workflows/mergefest.lock.yml index ed54060e368a..a4303cec6f49 100644 --- a/.github/workflows/mergefest.lock.yml +++ b/.github/workflows/mergefest.lock.yml @@ -28,7 +28,7 @@ # Imports: # - shared/mood.md # -# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"bc53fb1f26f2f3676fb5a1b8b644137baf5e7dfba7ba8062717c5804d062f75f","compiler_version":"v0.65.6","strict":true,"agent_id":"copilot"} +# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"0bf2ccb36ef60acd783330c51d2b454f55492abd0bc985efbe4d962c72e73976","compiler_version":"v0.65.6","strict":true,"agent_id":"copilot"} name: "Mergefest" "on": @@ -181,19 +181,19 @@ jobs: run: | bash ${RUNNER_TEMP}/gh-aw/actions/create_prompt_first.sh { - cat << 'GH_AW_PROMPT_297e2c4c652c2e56_EOF' + cat << 'GH_AW_PROMPT_f6952047a99991ed_EOF' - GH_AW_PROMPT_297e2c4c652c2e56_EOF + GH_AW_PROMPT_f6952047a99991ed_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/xpia.md" cat "${RUNNER_TEMP}/gh-aw/prompts/temp_folder_prompt.md" cat "${RUNNER_TEMP}/gh-aw/prompts/markdown.md" cat "${RUNNER_TEMP}/gh-aw/prompts/safe_outputs_prompt.md" - cat << 'GH_AW_PROMPT_297e2c4c652c2e56_EOF' + cat << 'GH_AW_PROMPT_f6952047a99991ed_EOF' Tools: push_to_pull_request_branch, missing_tool, missing_data, noop - GH_AW_PROMPT_297e2c4c652c2e56_EOF + GH_AW_PROMPT_f6952047a99991ed_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/safe_outputs_push_to_pr_branch.md" - cat << 'GH_AW_PROMPT_297e2c4c652c2e56_EOF' + cat << 'GH_AW_PROMPT_f6952047a99991ed_EOF' The following GitHub context information is available for this workflow: @@ -223,7 +223,7 @@ jobs: {{/if}} - GH_AW_PROMPT_297e2c4c652c2e56_EOF + GH_AW_PROMPT_f6952047a99991ed_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/github_mcp_tools_with_safeoutputs_prompt.md" if [ "$GITHUB_EVENT_NAME" = "issue_comment" ] && [ -n "$GH_AW_IS_PR_COMMENT" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review_comment" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review" ]; then cat "${RUNNER_TEMP}/gh-aw/prompts/pr_context_prompt.md" @@ -231,11 +231,11 @@ jobs: if [ "$GITHUB_EVENT_NAME" = "issue_comment" ] && [ -n "$GH_AW_IS_PR_COMMENT" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review_comment" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review" ]; then cat "${RUNNER_TEMP}/gh-aw/prompts/pr_context_push_to_pr_branch_guidance.md" fi - cat << 'GH_AW_PROMPT_297e2c4c652c2e56_EOF' + cat << 'GH_AW_PROMPT_f6952047a99991ed_EOF' {{#runtime-import .github/workflows/shared/mood.md}} {{#runtime-import .github/workflows/mergefest.md}} - GH_AW_PROMPT_297e2c4c652c2e56_EOF + GH_AW_PROMPT_f6952047a99991ed_EOF } > "$GH_AW_PROMPT" - name: Interpolate variables and render templates uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 @@ -402,19 +402,19 @@ jobs: mkdir -p ${RUNNER_TEMP}/gh-aw/safeoutputs mkdir -p /tmp/gh-aw/safeoutputs mkdir -p /tmp/gh-aw/mcp-logs/safeoutputs - cat > ${RUNNER_TEMP}/gh-aw/safeoutputs/config.json << 'GH_AW_SAFE_OUTPUTS_CONFIG_865f927a5b569f5a_EOF' + cat > ${RUNNER_TEMP}/gh-aw/safeoutputs/config.json << 'GH_AW_SAFE_OUTPUTS_CONFIG_f15991d5b1f98bed_EOF' {"missing_data":{},"missing_tool":{},"noop":{"max":1,"report-as-issue":"true"},"push_to_pull_request_branch":{"if_no_changes":"warn","max_patch_size":1024,"protected_files":["package.json","bun.lockb","bunfig.toml","deno.json","deno.jsonc","deno.lock","global.json","NuGet.Config","Directory.Packages.props","mix.exs","mix.lock","go.mod","go.sum","stack.yaml","stack.yaml.lock","pom.xml","build.gradle","build.gradle.kts","settings.gradle","settings.gradle.kts","gradle.properties","package-lock.json","yarn.lock","pnpm-lock.yaml","npm-shrinkwrap.json","requirements.txt","Pipfile","Pipfile.lock","pyproject.toml","setup.py","setup.cfg","Gemfile","Gemfile.lock","uv.lock","CODEOWNERS"],"protected_path_prefixes":[".github/",".agents/"]}} - GH_AW_SAFE_OUTPUTS_CONFIG_865f927a5b569f5a_EOF + GH_AW_SAFE_OUTPUTS_CONFIG_f15991d5b1f98bed_EOF - name: Write Safe Outputs Tools run: | - cat > ${RUNNER_TEMP}/gh-aw/safeoutputs/tools_meta.json << 'GH_AW_SAFE_OUTPUTS_TOOLS_META_b9f5be2018cfcb9f_EOF' + cat > ${RUNNER_TEMP}/gh-aw/safeoutputs/tools_meta.json << 'GH_AW_SAFE_OUTPUTS_TOOLS_META_ac46e9d68a87fe54_EOF' { "description_suffixes": {}, "repo_params": {}, "dynamic_tools": [] } - GH_AW_SAFE_OUTPUTS_TOOLS_META_b9f5be2018cfcb9f_EOF - cat > ${RUNNER_TEMP}/gh-aw/safeoutputs/validation.json << 'GH_AW_SAFE_OUTPUTS_VALIDATION_100106990d6477ae_EOF' + GH_AW_SAFE_OUTPUTS_TOOLS_META_ac46e9d68a87fe54_EOF + cat > ${RUNNER_TEMP}/gh-aw/safeoutputs/validation.json << 'GH_AW_SAFE_OUTPUTS_VALIDATION_31c7a390be6ee8e3_EOF' { "missing_data": { "defaultMax": 20, @@ -494,7 +494,7 @@ jobs: } } } - GH_AW_SAFE_OUTPUTS_VALIDATION_100106990d6477ae_EOF + GH_AW_SAFE_OUTPUTS_VALIDATION_31c7a390be6ee8e3_EOF node ${RUNNER_TEMP}/gh-aw/actions/generate_safe_outputs_tools.cjs - name: Generate Safe Outputs MCP Server Config id: safe-outputs-config @@ -564,7 +564,7 @@ jobs: export MCP_GATEWAY_DOCKER_COMMAND='docker run -i --rm --network host -v /var/run/docker.sock:/var/run/docker.sock -e MCP_GATEWAY_PORT -e MCP_GATEWAY_DOMAIN -e MCP_GATEWAY_API_KEY -e MCP_GATEWAY_PAYLOAD_DIR -e MCP_GATEWAY_PAYLOAD_SIZE_THRESHOLD -e DEBUG -e MCP_GATEWAY_LOG_DIR -e GH_AW_MCP_LOG_DIR -e GH_AW_SAFE_OUTPUTS -e GH_AW_SAFE_OUTPUTS_CONFIG_PATH -e GH_AW_SAFE_OUTPUTS_TOOLS_PATH -e GH_AW_ASSETS_BRANCH -e GH_AW_ASSETS_MAX_SIZE_KB -e GH_AW_ASSETS_ALLOWED_EXTS -e DEFAULT_BRANCH -e GITHUB_MCP_SERVER_TOKEN -e GITHUB_MCP_GUARD_MIN_INTEGRITY -e GITHUB_MCP_GUARD_REPOS -e GITHUB_REPOSITORY -e GITHUB_SERVER_URL -e GITHUB_SHA -e GITHUB_WORKSPACE -e GITHUB_TOKEN -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RUN_ATTEMPT -e GITHUB_JOB -e GITHUB_ACTION -e GITHUB_EVENT_NAME -e GITHUB_EVENT_PATH -e GITHUB_ACTOR -e GITHUB_ACTOR_ID -e GITHUB_TRIGGERING_ACTOR -e GITHUB_WORKFLOW -e GITHUB_WORKFLOW_REF -e GITHUB_WORKFLOW_SHA -e GITHUB_REF -e GITHUB_REF_NAME -e GITHUB_REF_TYPE -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GH_AW_SAFE_OUTPUTS_PORT -e GH_AW_SAFE_OUTPUTS_API_KEY -v /tmp/gh-aw/mcp-payloads:/tmp/gh-aw/mcp-payloads:rw -v /opt:/opt:ro -v /tmp:/tmp:rw -v '"${GITHUB_WORKSPACE}"':'"${GITHUB_WORKSPACE}"':rw ghcr.io/github/gh-aw-mcpg:v0.2.11' mkdir -p /home/runner/.copilot - cat << GH_AW_MCP_CONFIG_ae86df47445bf165_EOF | bash ${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.sh + cat << GH_AW_MCP_CONFIG_ed81ab47f4de8735_EOF | bash ${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.sh { "mcpServers": { "github": { @@ -605,7 +605,7 @@ jobs: "payloadDir": "${MCP_GATEWAY_PAYLOAD_DIR}" } } - GH_AW_MCP_CONFIG_ae86df47445bf165_EOF + GH_AW_MCP_CONFIG_ed81ab47f4de8735_EOF - name: Download activation artifact uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: @@ -625,6 +625,7 @@ jobs: # --allow-tool shell(git add) # --allow-tool shell(git add:*) # --allow-tool shell(git branch) + # --allow-tool shell(git branch) # --allow-tool shell(git branch:*) # --allow-tool shell(git checkout) # --allow-tool shell(git checkout:*) @@ -633,6 +634,7 @@ jobs: # --allow-tool shell(git config) # --allow-tool shell(git diff) # --allow-tool shell(git fetch) + # --allow-tool shell(git format-patch) # --allow-tool shell(git log) # --allow-tool shell(git merge) # --allow-tool shell(git merge:*) @@ -645,10 +647,6 @@ jobs: # --allow-tool shell(grep) # --allow-tool shell(head) # --allow-tool shell(ls) - # --allow-tool shell(make fmt) - # --allow-tool shell(make lint) - # --allow-tool shell(make recompile) - # --allow-tool shell(make test-unit) # --allow-tool shell(pwd) # --allow-tool shell(sort) # --allow-tool shell(tail) @@ -662,7 +660,7 @@ jobs: touch /tmp/gh-aw/agent-step-summary.md # shellcheck disable=SC1003 sudo -E awf --container-workdir "${GITHUB_WORKSPACE}" --mount "${RUNNER_TEMP}/gh-aw:${RUNNER_TEMP}/gh-aw:ro" --mount "${RUNNER_TEMP}/gh-aw:/host${RUNNER_TEMP}/gh-aw:ro" --env-all --exclude-env COPILOT_GITHUB_TOKEN --exclude-env GITHUB_MCP_SERVER_TOKEN --exclude-env MCP_GATEWAY_API_KEY --allow-domains api.business.githubcopilot.com,api.enterprise.githubcopilot.com,api.github.com,api.githubcopilot.com,api.individual.githubcopilot.com,api.snapcraft.io,archive.ubuntu.com,azure.archive.ubuntu.com,crl.geotrust.com,crl.globalsign.com,crl.identrust.com,crl.sectigo.com,crl.thawte.com,crl.usertrust.com,crl.verisign.com,crl3.digicert.com,crl4.digicert.com,crls.ssl.com,github.com,host.docker.internal,json-schema.org,json.schemastore.org,keyserver.ubuntu.com,ocsp.digicert.com,ocsp.geotrust.com,ocsp.globalsign.com,ocsp.identrust.com,ocsp.sectigo.com,ocsp.ssl.com,ocsp.thawte.com,ocsp.usertrust.com,ocsp.verisign.com,packagecloud.io,packages.cloud.google.com,packages.microsoft.com,ppa.launchpad.net,raw.githubusercontent.com,registry.npmjs.org,s.symcb.com,s.symcd.com,security.ubuntu.com,telemetry.enterprise.githubcopilot.com,ts-crl.ws.symantec.com,ts-ocsp.ws.symantec.com,www.googleapis.com --log-level info --proxy-logs-dir /tmp/gh-aw/sandbox/firewall/logs --audit-dir /tmp/gh-aw/sandbox/firewall/audit --enable-host-access --image-tag 0.25.11 --skip-pull --enable-api-proxy \ - -- /bin/bash -c '/usr/local/bin/copilot --add-dir /tmp/gh-aw/ --log-level all --log-dir /tmp/gh-aw/sandbox/agent/logs/ --disable-builtin-mcps --allow-tool github --allow-tool safeoutputs --allow-tool '\''shell(cat)'\'' --allow-tool '\''shell(date)'\'' --allow-tool '\''shell(echo)'\'' --allow-tool '\''shell(git add)'\'' --allow-tool '\''shell(git add:*)'\'' --allow-tool '\''shell(git branch)'\'' --allow-tool '\''shell(git branch:*)'\'' --allow-tool '\''shell(git checkout)'\'' --allow-tool '\''shell(git checkout:*)'\'' --allow-tool '\''shell(git commit)'\'' --allow-tool '\''shell(git commit:*)'\'' --allow-tool '\''shell(git config)'\'' --allow-tool '\''shell(git diff)'\'' --allow-tool '\''shell(git fetch)'\'' --allow-tool '\''shell(git log)'\'' --allow-tool '\''shell(git merge)'\'' --allow-tool '\''shell(git merge:*)'\'' --allow-tool '\''shell(git pull)'\'' --allow-tool '\''shell(git reset)'\'' --allow-tool '\''shell(git rev-parse)'\'' --allow-tool '\''shell(git rm:*)'\'' --allow-tool '\''shell(git status)'\'' --allow-tool '\''shell(git switch:*)'\'' --allow-tool '\''shell(grep)'\'' --allow-tool '\''shell(head)'\'' --allow-tool '\''shell(ls)'\'' --allow-tool '\''shell(make fmt)'\'' --allow-tool '\''shell(make lint)'\'' --allow-tool '\''shell(make recompile)'\'' --allow-tool '\''shell(make test-unit)'\'' --allow-tool '\''shell(pwd)'\'' --allow-tool '\''shell(sort)'\'' --allow-tool '\''shell(tail)'\'' --allow-tool '\''shell(uniq)'\'' --allow-tool '\''shell(wc)'\'' --allow-tool '\''shell(yq)'\'' --allow-tool write --allow-all-paths --add-dir "${GITHUB_WORKSPACE}" --prompt "$(cat /tmp/gh-aw/aw-prompts/prompt.txt)"' 2>&1 | tee -a /tmp/gh-aw/agent-stdio.log + -- /bin/bash -c '/usr/local/bin/copilot --add-dir /tmp/gh-aw/ --log-level all --log-dir /tmp/gh-aw/sandbox/agent/logs/ --disable-builtin-mcps --allow-tool github --allow-tool safeoutputs --allow-tool '\''shell(cat)'\'' --allow-tool '\''shell(date)'\'' --allow-tool '\''shell(echo)'\'' --allow-tool '\''shell(git add)'\'' --allow-tool '\''shell(git add:*)'\'' --allow-tool '\''shell(git branch)'\'' --allow-tool '\''shell(git branch)'\'' --allow-tool '\''shell(git branch:*)'\'' --allow-tool '\''shell(git checkout)'\'' --allow-tool '\''shell(git checkout:*)'\'' --allow-tool '\''shell(git commit)'\'' --allow-tool '\''shell(git commit:*)'\'' --allow-tool '\''shell(git config)'\'' --allow-tool '\''shell(git diff)'\'' --allow-tool '\''shell(git fetch)'\'' --allow-tool '\''shell(git format-patch)'\'' --allow-tool '\''shell(git log)'\'' --allow-tool '\''shell(git merge)'\'' --allow-tool '\''shell(git merge:*)'\'' --allow-tool '\''shell(git pull)'\'' --allow-tool '\''shell(git reset)'\'' --allow-tool '\''shell(git rev-parse)'\'' --allow-tool '\''shell(git rm:*)'\'' --allow-tool '\''shell(git status)'\'' --allow-tool '\''shell(git switch:*)'\'' --allow-tool '\''shell(grep)'\'' --allow-tool '\''shell(head)'\'' --allow-tool '\''shell(ls)'\'' --allow-tool '\''shell(pwd)'\'' --allow-tool '\''shell(sort)'\'' --allow-tool '\''shell(tail)'\'' --allow-tool '\''shell(uniq)'\'' --allow-tool '\''shell(wc)'\'' --allow-tool '\''shell(yq)'\'' --allow-tool write --allow-all-paths --add-dir "${GITHUB_WORKSPACE}" --prompt "$(cat /tmp/gh-aw/aw-prompts/prompt.txt)"' 2>&1 | tee -a /tmp/gh-aw/agent-stdio.log env: COPILOT_AGENT_RUNNER_TYPE: STANDALONE COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }} diff --git a/.github/workflows/mergefest.md b/.github/workflows/mergefest.md index 14110d96c3a5..30e3835e627d 100644 --- a/.github/workflows/mergefest.md +++ b/.github/workflows/mergefest.md @@ -25,10 +25,8 @@ tools: - "git commit" - "git config" - "git branch" - - "make recompile" - - "make fmt" - - "make lint" - - "make test-unit" + - "git branch" + - "git format-patch" - "cat" - "echo" - "ls" @@ -213,7 +211,7 @@ git status --short | grep '^UU' || git status --short | grep '^AA' || true git merge --continue || git commit --no-edit -m "Resolve merge conflicts from main" ``` -6. **If there were .lock.yml conflicts, recompile workflows**: + -### 8. Format, Lint, Test, and Recompile + ### 9. Verify No Workflow YML Files Are Staged @@ -307,7 +305,7 @@ The `push-to-pull-request-branch` safe output will automatically: - **Be Careful**: This operation modifies the PR branch directly - **Never Commit Workflow YMLs**: Always exclude `.github/workflows/*.yml` files - **Recompile After Lock File Conflicts**: Run `make recompile` if `.lock.yml` files had conflicts -- **Format, Lint, Test**: Always run `make fmt`, `make lint`, `make test-unit`, and `make recompile` after merge + - **Verify Before Pushing**: Always check what's staged before pushing - **Handle Conflicts Intelligently**: Use repository knowledge to resolve conflicts - **Document Actions**: Explain what was merged and any conflicts resolved From d3e32d7519623498b88623ab78d68c219905d825 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Fri, 3 Apr 2026 17:42:13 +0800 Subject: [PATCH 3/6] allow all --- .github/workflows/mergefest.lock.yml | 73 +++++++--------------------- .github/workflows/mergefest.md | 24 ++------- 2 files changed, 21 insertions(+), 76 deletions(-) diff --git a/.github/workflows/mergefest.lock.yml b/.github/workflows/mergefest.lock.yml index a4303cec6f49..b16e4f5123de 100644 --- a/.github/workflows/mergefest.lock.yml +++ b/.github/workflows/mergefest.lock.yml @@ -28,7 +28,7 @@ # Imports: # - shared/mood.md # -# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"0bf2ccb36ef60acd783330c51d2b454f55492abd0bc985efbe4d962c72e73976","compiler_version":"v0.65.6","strict":true,"agent_id":"copilot"} +# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"898d9ce6133254988c8f96cb722ffb0c70ffe278cdeed40d653955a6c3ef246e","compiler_version":"v0.65.6","strict":true,"agent_id":"copilot"} name: "Mergefest" "on": @@ -181,19 +181,19 @@ jobs: run: | bash ${RUNNER_TEMP}/gh-aw/actions/create_prompt_first.sh { - cat << 'GH_AW_PROMPT_f6952047a99991ed_EOF' + cat << 'GH_AW_PROMPT_225b8f639dd46a77_EOF' - GH_AW_PROMPT_f6952047a99991ed_EOF + GH_AW_PROMPT_225b8f639dd46a77_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/xpia.md" cat "${RUNNER_TEMP}/gh-aw/prompts/temp_folder_prompt.md" cat "${RUNNER_TEMP}/gh-aw/prompts/markdown.md" cat "${RUNNER_TEMP}/gh-aw/prompts/safe_outputs_prompt.md" - cat << 'GH_AW_PROMPT_f6952047a99991ed_EOF' + cat << 'GH_AW_PROMPT_225b8f639dd46a77_EOF' Tools: push_to_pull_request_branch, missing_tool, missing_data, noop - GH_AW_PROMPT_f6952047a99991ed_EOF + GH_AW_PROMPT_225b8f639dd46a77_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/safe_outputs_push_to_pr_branch.md" - cat << 'GH_AW_PROMPT_f6952047a99991ed_EOF' + cat << 'GH_AW_PROMPT_225b8f639dd46a77_EOF' The following GitHub context information is available for this workflow: @@ -223,7 +223,7 @@ jobs: {{/if}} - GH_AW_PROMPT_f6952047a99991ed_EOF + GH_AW_PROMPT_225b8f639dd46a77_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/github_mcp_tools_with_safeoutputs_prompt.md" if [ "$GITHUB_EVENT_NAME" = "issue_comment" ] && [ -n "$GH_AW_IS_PR_COMMENT" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review_comment" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review" ]; then cat "${RUNNER_TEMP}/gh-aw/prompts/pr_context_prompt.md" @@ -231,11 +231,11 @@ jobs: if [ "$GITHUB_EVENT_NAME" = "issue_comment" ] && [ -n "$GH_AW_IS_PR_COMMENT" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review_comment" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review" ]; then cat "${RUNNER_TEMP}/gh-aw/prompts/pr_context_push_to_pr_branch_guidance.md" fi - cat << 'GH_AW_PROMPT_f6952047a99991ed_EOF' + cat << 'GH_AW_PROMPT_225b8f639dd46a77_EOF' {{#runtime-import .github/workflows/shared/mood.md}} {{#runtime-import .github/workflows/mergefest.md}} - GH_AW_PROMPT_f6952047a99991ed_EOF + GH_AW_PROMPT_225b8f639dd46a77_EOF } > "$GH_AW_PROMPT" - name: Interpolate variables and render templates uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 @@ -402,19 +402,19 @@ jobs: mkdir -p ${RUNNER_TEMP}/gh-aw/safeoutputs mkdir -p /tmp/gh-aw/safeoutputs mkdir -p /tmp/gh-aw/mcp-logs/safeoutputs - cat > ${RUNNER_TEMP}/gh-aw/safeoutputs/config.json << 'GH_AW_SAFE_OUTPUTS_CONFIG_f15991d5b1f98bed_EOF' + cat > ${RUNNER_TEMP}/gh-aw/safeoutputs/config.json << 'GH_AW_SAFE_OUTPUTS_CONFIG_581002c18335587a_EOF' {"missing_data":{},"missing_tool":{},"noop":{"max":1,"report-as-issue":"true"},"push_to_pull_request_branch":{"if_no_changes":"warn","max_patch_size":1024,"protected_files":["package.json","bun.lockb","bunfig.toml","deno.json","deno.jsonc","deno.lock","global.json","NuGet.Config","Directory.Packages.props","mix.exs","mix.lock","go.mod","go.sum","stack.yaml","stack.yaml.lock","pom.xml","build.gradle","build.gradle.kts","settings.gradle","settings.gradle.kts","gradle.properties","package-lock.json","yarn.lock","pnpm-lock.yaml","npm-shrinkwrap.json","requirements.txt","Pipfile","Pipfile.lock","pyproject.toml","setup.py","setup.cfg","Gemfile","Gemfile.lock","uv.lock","CODEOWNERS"],"protected_path_prefixes":[".github/",".agents/"]}} - GH_AW_SAFE_OUTPUTS_CONFIG_f15991d5b1f98bed_EOF + GH_AW_SAFE_OUTPUTS_CONFIG_581002c18335587a_EOF - name: Write Safe Outputs Tools run: | - cat > ${RUNNER_TEMP}/gh-aw/safeoutputs/tools_meta.json << 'GH_AW_SAFE_OUTPUTS_TOOLS_META_ac46e9d68a87fe54_EOF' + cat > ${RUNNER_TEMP}/gh-aw/safeoutputs/tools_meta.json << 'GH_AW_SAFE_OUTPUTS_TOOLS_META_b99ef13599b68b8e_EOF' { "description_suffixes": {}, "repo_params": {}, "dynamic_tools": [] } - GH_AW_SAFE_OUTPUTS_TOOLS_META_ac46e9d68a87fe54_EOF - cat > ${RUNNER_TEMP}/gh-aw/safeoutputs/validation.json << 'GH_AW_SAFE_OUTPUTS_VALIDATION_31c7a390be6ee8e3_EOF' + GH_AW_SAFE_OUTPUTS_TOOLS_META_b99ef13599b68b8e_EOF + cat > ${RUNNER_TEMP}/gh-aw/safeoutputs/validation.json << 'GH_AW_SAFE_OUTPUTS_VALIDATION_713ae3f96a59ba34_EOF' { "missing_data": { "defaultMax": 20, @@ -494,7 +494,7 @@ jobs: } } } - GH_AW_SAFE_OUTPUTS_VALIDATION_31c7a390be6ee8e3_EOF + GH_AW_SAFE_OUTPUTS_VALIDATION_713ae3f96a59ba34_EOF node ${RUNNER_TEMP}/gh-aw/actions/generate_safe_outputs_tools.cjs - name: Generate Safe Outputs MCP Server Config id: safe-outputs-config @@ -564,7 +564,7 @@ jobs: export MCP_GATEWAY_DOCKER_COMMAND='docker run -i --rm --network host -v /var/run/docker.sock:/var/run/docker.sock -e MCP_GATEWAY_PORT -e MCP_GATEWAY_DOMAIN -e MCP_GATEWAY_API_KEY -e MCP_GATEWAY_PAYLOAD_DIR -e MCP_GATEWAY_PAYLOAD_SIZE_THRESHOLD -e DEBUG -e MCP_GATEWAY_LOG_DIR -e GH_AW_MCP_LOG_DIR -e GH_AW_SAFE_OUTPUTS -e GH_AW_SAFE_OUTPUTS_CONFIG_PATH -e GH_AW_SAFE_OUTPUTS_TOOLS_PATH -e GH_AW_ASSETS_BRANCH -e GH_AW_ASSETS_MAX_SIZE_KB -e GH_AW_ASSETS_ALLOWED_EXTS -e DEFAULT_BRANCH -e GITHUB_MCP_SERVER_TOKEN -e GITHUB_MCP_GUARD_MIN_INTEGRITY -e GITHUB_MCP_GUARD_REPOS -e GITHUB_REPOSITORY -e GITHUB_SERVER_URL -e GITHUB_SHA -e GITHUB_WORKSPACE -e GITHUB_TOKEN -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RUN_ATTEMPT -e GITHUB_JOB -e GITHUB_ACTION -e GITHUB_EVENT_NAME -e GITHUB_EVENT_PATH -e GITHUB_ACTOR -e GITHUB_ACTOR_ID -e GITHUB_TRIGGERING_ACTOR -e GITHUB_WORKFLOW -e GITHUB_WORKFLOW_REF -e GITHUB_WORKFLOW_SHA -e GITHUB_REF -e GITHUB_REF_NAME -e GITHUB_REF_TYPE -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GH_AW_SAFE_OUTPUTS_PORT -e GH_AW_SAFE_OUTPUTS_API_KEY -v /tmp/gh-aw/mcp-payloads:/tmp/gh-aw/mcp-payloads:rw -v /opt:/opt:ro -v /tmp:/tmp:rw -v '"${GITHUB_WORKSPACE}"':'"${GITHUB_WORKSPACE}"':rw ghcr.io/github/gh-aw-mcpg:v0.2.11' mkdir -p /home/runner/.copilot - cat << GH_AW_MCP_CONFIG_ed81ab47f4de8735_EOF | bash ${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.sh + cat << GH_AW_MCP_CONFIG_9c5e2164c5f8d3b7_EOF | bash ${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.sh { "mcpServers": { "github": { @@ -605,7 +605,7 @@ jobs: "payloadDir": "${MCP_GATEWAY_PAYLOAD_DIR}" } } - GH_AW_MCP_CONFIG_ed81ab47f4de8735_EOF + GH_AW_MCP_CONFIG_9c5e2164c5f8d3b7_EOF - name: Download activation artifact uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: @@ -617,50 +617,13 @@ jobs: - name: Execute GitHub Copilot CLI id: agentic_execution # Copilot CLI tool arguments (sorted): - # --allow-tool github - # --allow-tool safeoutputs - # --allow-tool shell(cat) - # --allow-tool shell(date) - # --allow-tool shell(echo) - # --allow-tool shell(git add) - # --allow-tool shell(git add:*) - # --allow-tool shell(git branch) - # --allow-tool shell(git branch) - # --allow-tool shell(git branch:*) - # --allow-tool shell(git checkout) - # --allow-tool shell(git checkout:*) - # --allow-tool shell(git commit) - # --allow-tool shell(git commit:*) - # --allow-tool shell(git config) - # --allow-tool shell(git diff) - # --allow-tool shell(git fetch) - # --allow-tool shell(git format-patch) - # --allow-tool shell(git log) - # --allow-tool shell(git merge) - # --allow-tool shell(git merge:*) - # --allow-tool shell(git pull) - # --allow-tool shell(git reset) - # --allow-tool shell(git rev-parse) - # --allow-tool shell(git rm:*) - # --allow-tool shell(git status) - # --allow-tool shell(git switch:*) - # --allow-tool shell(grep) - # --allow-tool shell(head) - # --allow-tool shell(ls) - # --allow-tool shell(pwd) - # --allow-tool shell(sort) - # --allow-tool shell(tail) - # --allow-tool shell(uniq) - # --allow-tool shell(wc) - # --allow-tool shell(yq) - # --allow-tool write timeout-minutes: 10 run: | set -o pipefail touch /tmp/gh-aw/agent-step-summary.md # shellcheck disable=SC1003 sudo -E awf --container-workdir "${GITHUB_WORKSPACE}" --mount "${RUNNER_TEMP}/gh-aw:${RUNNER_TEMP}/gh-aw:ro" --mount "${RUNNER_TEMP}/gh-aw:/host${RUNNER_TEMP}/gh-aw:ro" --env-all --exclude-env COPILOT_GITHUB_TOKEN --exclude-env GITHUB_MCP_SERVER_TOKEN --exclude-env MCP_GATEWAY_API_KEY --allow-domains api.business.githubcopilot.com,api.enterprise.githubcopilot.com,api.github.com,api.githubcopilot.com,api.individual.githubcopilot.com,api.snapcraft.io,archive.ubuntu.com,azure.archive.ubuntu.com,crl.geotrust.com,crl.globalsign.com,crl.identrust.com,crl.sectigo.com,crl.thawte.com,crl.usertrust.com,crl.verisign.com,crl3.digicert.com,crl4.digicert.com,crls.ssl.com,github.com,host.docker.internal,json-schema.org,json.schemastore.org,keyserver.ubuntu.com,ocsp.digicert.com,ocsp.geotrust.com,ocsp.globalsign.com,ocsp.identrust.com,ocsp.sectigo.com,ocsp.ssl.com,ocsp.thawte.com,ocsp.usertrust.com,ocsp.verisign.com,packagecloud.io,packages.cloud.google.com,packages.microsoft.com,ppa.launchpad.net,raw.githubusercontent.com,registry.npmjs.org,s.symcb.com,s.symcd.com,security.ubuntu.com,telemetry.enterprise.githubcopilot.com,ts-crl.ws.symantec.com,ts-ocsp.ws.symantec.com,www.googleapis.com --log-level info --proxy-logs-dir /tmp/gh-aw/sandbox/firewall/logs --audit-dir /tmp/gh-aw/sandbox/firewall/audit --enable-host-access --image-tag 0.25.11 --skip-pull --enable-api-proxy \ - -- /bin/bash -c '/usr/local/bin/copilot --add-dir /tmp/gh-aw/ --log-level all --log-dir /tmp/gh-aw/sandbox/agent/logs/ --disable-builtin-mcps --allow-tool github --allow-tool safeoutputs --allow-tool '\''shell(cat)'\'' --allow-tool '\''shell(date)'\'' --allow-tool '\''shell(echo)'\'' --allow-tool '\''shell(git add)'\'' --allow-tool '\''shell(git add:*)'\'' --allow-tool '\''shell(git branch)'\'' --allow-tool '\''shell(git branch)'\'' --allow-tool '\''shell(git branch:*)'\'' --allow-tool '\''shell(git checkout)'\'' --allow-tool '\''shell(git checkout:*)'\'' --allow-tool '\''shell(git commit)'\'' --allow-tool '\''shell(git commit:*)'\'' --allow-tool '\''shell(git config)'\'' --allow-tool '\''shell(git diff)'\'' --allow-tool '\''shell(git fetch)'\'' --allow-tool '\''shell(git format-patch)'\'' --allow-tool '\''shell(git log)'\'' --allow-tool '\''shell(git merge)'\'' --allow-tool '\''shell(git merge:*)'\'' --allow-tool '\''shell(git pull)'\'' --allow-tool '\''shell(git reset)'\'' --allow-tool '\''shell(git rev-parse)'\'' --allow-tool '\''shell(git rm:*)'\'' --allow-tool '\''shell(git status)'\'' --allow-tool '\''shell(git switch:*)'\'' --allow-tool '\''shell(grep)'\'' --allow-tool '\''shell(head)'\'' --allow-tool '\''shell(ls)'\'' --allow-tool '\''shell(pwd)'\'' --allow-tool '\''shell(sort)'\'' --allow-tool '\''shell(tail)'\'' --allow-tool '\''shell(uniq)'\'' --allow-tool '\''shell(wc)'\'' --allow-tool '\''shell(yq)'\'' --allow-tool write --allow-all-paths --add-dir "${GITHUB_WORKSPACE}" --prompt "$(cat /tmp/gh-aw/aw-prompts/prompt.txt)"' 2>&1 | tee -a /tmp/gh-aw/agent-stdio.log + -- /bin/bash -c '/usr/local/bin/copilot --add-dir /tmp/gh-aw/ --log-level all --log-dir /tmp/gh-aw/sandbox/agent/logs/ --disable-builtin-mcps --allow-all-tools --allow-all-paths --add-dir "${GITHUB_WORKSPACE}" --prompt "$(cat /tmp/gh-aw/aw-prompts/prompt.txt)"' 2>&1 | tee -a /tmp/gh-aw/agent-stdio.log env: COPILOT_AGENT_RUNNER_TYPE: STANDALONE COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }} diff --git a/.github/workflows/mergefest.md b/.github/workflows/mergefest.md index 30e3835e627d..497a3ec5d9a6 100644 --- a/.github/workflows/mergefest.md +++ b/.github/workflows/mergefest.md @@ -12,25 +12,7 @@ permissions: engine: copilot tools: bash: - - "git fetch" - - "git checkout" - - "git pull" - - "git merge" - - "git status" - - "git diff" - - "git log" - - "git rev-parse" - - "git reset" - - "git add" - - "git commit" - - "git config" - - "git branch" - - "git branch" - - "git format-patch" - - "cat" - - "echo" - - "ls" - - "grep" + - "*" edit: github: toolsets: [pull_requests, repos] @@ -304,8 +286,8 @@ The `push-to-pull-request-branch` safe output will automatically: - **Be Careful**: This operation modifies the PR branch directly - **Never Commit Workflow YMLs**: Always exclude `.github/workflows/*.yml` files -- **Recompile After Lock File Conflicts**: Run `make recompile` if `.lock.yml` files had conflicts - + - **Verify Before Pushing**: Always check what's staged before pushing - **Handle Conflicts Intelligently**: Use repository knowledge to resolve conflicts - **Document Actions**: Explain what was merged and any conflicts resolved From d62d093eecc712c96044af268d9baa1c2c101eb9 Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Wed, 22 Apr 2026 23:51:02 +0000 Subject: [PATCH 4/6] Configurations: 'specification/monitoringservice/resource-manager/Microsoft.Monitor/Slis/tspconfig.yaml', and CommitSHA: 'd32a3f6cc49c6dd6604161f8c7cee7c95a84c578' in SpecRepo: 'https://github.com/Azure/azure-rest-api-specs' Pipeline run: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=6195147 Refer to https://eng.ms/docs/products/azure-developer-experience/develop/sdk-release/sdk-release-prerequisites to prepare for SDK release. --- eng/versioning/version_client.txt | 1 + .../CHANGELOG.md | 8 + .../README.md | 102 ++++ .../SAMPLE.md | 160 ++++++ .../pom.xml | 74 +++ .../monitor/slis/SlisManager.java | 280 ++++++++++ .../monitor/slis/fluent/SlisClient.java | 125 +++++ .../slis/fluent/SlisManagementClient.java | 48 ++ .../monitor/slis/fluent/models/SliInner.java | 184 +++++++ .../slis/fluent/models/package-info.java | 8 + .../monitor/slis/fluent/package-info.java | 8 + .../implementation/ResourceManagerUtils.java | 195 +++++++ .../monitor/slis/implementation/SliImpl.java | 54 ++ .../slis/implementation/SlisClientImpl.java | 514 ++++++++++++++++++ .../monitor/slis/implementation/SlisImpl.java | 86 +++ .../SlisManagementClientBuilder.java | 122 +++++ .../SlisManagementClientImpl.java | 292 ++++++++++ .../implementation/models/SliListResult.java | 95 ++++ .../slis/implementation/package-info.java | 8 + .../monitor/slis/models/AmwAccount.java | 114 ++++ .../monitor/slis/models/Baseline.java | 146 +++++ .../slis/models/BaselineProperties.java | 88 +++ .../monitor/slis/models/Category.java | 51 ++ .../monitor/slis/models/Condition.java | 199 +++++++ .../slis/models/ConditionOperator.java | 101 ++++ .../models/EvaluationCalculationType.java | 51 ++ .../monitor/slis/models/EvaluationType.java | 51 ++ .../monitor/slis/models/ExecutionState.java | 92 ++++ .../slis/models/ManagedServiceIdentity.java | 154 ++++++ .../models/ManagedServiceIdentityType.java | 62 +++ .../monitor/slis/models/Metric.java | 92 ++++ .../slis/models/ProvisioningState.java | 56 ++ .../monitor/slis/models/SamplingType.java | 61 +++ .../monitor/slis/models/ScalarFunction.java | 61 +++ .../monitor/slis/models/Signal.java | 116 ++++ .../monitor/slis/models/SignalSource.java | 286 ++++++++++ .../monitor/slis/models/Sli.java | 62 +++ .../monitor/slis/models/SliProperties.java | 169 ++++++ .../monitor/slis/models/SliResource.java | 348 ++++++++++++ .../monitor/slis/models/Slis.java | 115 ++++ .../slis/models/SpatialAggregation.java | 116 ++++ .../slis/models/SpatialAggregationType.java | 66 +++ .../slis/models/TemporalAggregation.java | 114 ++++ .../slis/models/TemporalAggregationType.java | 87 +++ .../slis/models/UserAssignedIdentity.java | 89 +++ .../slis/models/WindowUptimeCriteria.java | 115 ++++ .../WindowUptimeCriteriaComparator.java | 61 +++ .../monitor/slis/models/package-info.java | 8 + .../monitor/slis/package-info.java | 8 + .../src/main/java/module-info.java | 16 + ...resourcemanager-monitor-slis_metadata.json | 1 + .../proxy-config.json | 1 + .../reflect-config.json | 1 + ...re-resourcemanager-monitor-slis.properties | 1 + .../generated/SlisCreateOrUpdateSamples.java | 89 +++ .../slis/generated/SlisDeleteSamples.java | 22 + .../slis/generated/SlisGetSamples.java | 22 + .../generated/SlisListByParentSamples.java | 22 + .../slis/generated/AmwAccountTests.java | 27 + .../generated/BaselinePropertiesTests.java | 34 ++ .../monitor/slis/generated/BaselineTests.java | 33 ++ .../slis/generated/ConditionTests.java | 41 ++ .../slis/generated/ExecutionStateTests.java | 19 + .../ManagedServiceIdentityTests.java | 44 ++ .../monitor/slis/generated/MetricTests.java | 19 + .../slis/generated/SignalSourceTests.java | 74 +++ .../monitor/slis/generated/SignalTests.java | 108 ++++ .../monitor/slis/generated/SliInnerTests.java | 390 +++++++++++++ .../slis/generated/SliListResultTests.java | 182 +++++++ .../slis/generated/SliPropertiesTests.java | 319 +++++++++++ .../slis/generated/SliResourceTests.java | 289 ++++++++++ ...isCreateOrUpdateWithResponseMockTests.java | 260 +++++++++ ...eByResourceGroupWithResponseMockTests.java | 33 ++ .../SlisGetWithResponseMockTests.java | 115 ++++ .../generated/SlisListByParentMockTests.java | 230 ++++++++ .../generated/SpatialAggregationTests.java | 30 + .../generated/TemporalAggregationTests.java | 29 + .../generated/UserAssignedIdentityTests.java | 23 + .../generated/WindowUptimeCriteriaTests.java | 29 + .../tsp-location.yaml | 4 + sdk/monitor/ci.yml | 73 +-- sdk/monitor/pom.xml | 19 +- 82 files changed, 8060 insertions(+), 42 deletions(-) create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/CHANGELOG.md create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/README.md create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/SAMPLE.md create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/pom.xml create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/SlisManager.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/SlisClient.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/SlisManagementClient.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/models/SliInner.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/models/package-info.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/package-info.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/ResourceManagerUtils.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SliImpl.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisClientImpl.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisImpl.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisManagementClientBuilder.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisManagementClientImpl.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/models/SliListResult.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/package-info.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/AmwAccount.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Baseline.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/BaselineProperties.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Category.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Condition.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ConditionOperator.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/EvaluationCalculationType.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/EvaluationType.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ExecutionState.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ManagedServiceIdentity.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ManagedServiceIdentityType.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Metric.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ProvisioningState.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SamplingType.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ScalarFunction.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Signal.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SignalSource.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Sli.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SliProperties.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SliResource.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Slis.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SpatialAggregation.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SpatialAggregationType.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/TemporalAggregation.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/TemporalAggregationType.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/UserAssignedIdentity.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/WindowUptimeCriteria.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/WindowUptimeCriteriaComparator.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/package-info.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/package-info.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/module-info.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/META-INF/azure-resourcemanager-monitor-slis_metadata.json create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-slis/proxy-config.json create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-slis/reflect-config.json create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/azure-resourcemanager-monitor-slis.properties create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisCreateOrUpdateSamples.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisDeleteSamples.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisGetSamples.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisListByParentSamples.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/AmwAccountTests.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/BaselinePropertiesTests.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/BaselineTests.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/ConditionTests.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/ExecutionStateTests.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/ManagedServiceIdentityTests.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/MetricTests.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SignalSourceTests.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SignalTests.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliInnerTests.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliListResultTests.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliPropertiesTests.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliResourceTests.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisCreateOrUpdateWithResponseMockTests.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisDeleteByResourceGroupWithResponseMockTests.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisGetWithResponseMockTests.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisListByParentMockTests.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SpatialAggregationTests.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/TemporalAggregationTests.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/UserAssignedIdentityTests.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/WindowUptimeCriteriaTests.java create mode 100644 sdk/monitor/azure-resourcemanager-monitor-slis/tsp-location.yaml diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 8ae547d6b658..0730bf91a8f1 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -525,6 +525,7 @@ com.azure.resourcemanager:azure-resourcemanager-appnetwork;1.0.0-beta.1;1.0.0-be com.azure.resourcemanager:azure-resourcemanager-servicegroups;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-horizondb;1.0.0-beta.1;1.0.0-beta.1 com.azure.resourcemanager:azure-resourcemanager-relationships;1.0.0-beta.1;1.0.0-beta.1 +com.azure.resourcemanager:azure-resourcemanager-monitor-slis;1.0.0-beta.1;1.0.0-beta.1 com.azure.tools:azure-sdk-archetype;1.0.0;1.2.0-beta.1 com.azure.tools:azure-sdk-build-tool;1.0.0;1.1.0-beta.1 com.azure.v2:azure-client-sdk-parent;2.0.0-beta.2;2.0.0-beta.2 diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/CHANGELOG.md b/sdk/monitor/azure-resourcemanager-monitor-slis/CHANGELOG.md new file mode 100644 index 000000000000..08d1f26ba2c9 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 1.0.0-beta.1 (2026-04-22) + +- Azure Resource Manager Slis client library for Java. This package contains Microsoft Azure SDK for Slis Management SDK. Package api-version 2025-03-01-preview. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). +### Features Added + +- Initial release for the azure-resourcemanager-monitor-slis Java SDK. diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/README.md b/sdk/monitor/azure-resourcemanager-monitor-slis/README.md new file mode 100644 index 000000000000..84f448afb1e8 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/README.md @@ -0,0 +1,102 @@ +# Azure Resource Manager Slis client library for Java + +Azure Resource Manager Slis client library for Java. + +This package contains Microsoft Azure SDK for Slis Management SDK. Package api-version 2025-03-01-preview. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). + +## We'd love to hear your feedback + +We're always working on improving our products and the way we communicate with our users. So we'd love to learn what's working and how we can do better. + +If you haven't already, please take a few minutes to [complete this short survey][survey] we have put together. + +Thank you in advance for your collaboration. We really appreciate your time! + +## Documentation + +Various documentation is available to help you get started + +- [API reference documentation][docs] + +## Getting started + +### Prerequisites + +- [Java Development Kit (JDK)][jdk] with version 8 or above +- [Azure Subscription][azure_subscription] + +### Adding the package to your product + +[//]: # ({x-version-update-start;com.azure.resourcemanager:azure-resourcemanager-monitor-slis;current}) +```xml + + com.azure.resourcemanager + azure-resourcemanager-monitor-slis + 1.0.0-beta.1 + +``` +[//]: # ({x-version-update-end}) + +### Include the recommended packages + +Azure Management Libraries require a `TokenCredential` implementation for authentication and an `HttpClient` implementation for HTTP client. + +[Azure Identity][azure_identity] and [Azure Core Netty HTTP][azure_core_http_netty] packages provide the default implementation. + +### Authentication + +Microsoft Entra ID token authentication relies on the [credential class][azure_identity_credentials] from [Azure Identity][azure_identity] package. + +Azure subscription ID can be configured via `AZURE_SUBSCRIPTION_ID` environment variable. + +Assuming the use of the `DefaultAzureCredential` credential class, the client can be authenticated using the following code: + +```java +AzureProfile profile = new AzureProfile(AzureCloud.AZURE_PUBLIC_CLOUD); +TokenCredential credential = new DefaultAzureCredentialBuilder() + .authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint()) + .build(); +SlisManager manager = SlisManager + .authenticate(credential, profile); +``` + +The sample code assumes global Azure. Please change the `AzureCloud.AZURE_PUBLIC_CLOUD` variable if otherwise. + +See [Authentication][authenticate] for more options. + +## Key concepts + +See [API design][design] for general introduction on design and key concepts on Azure Management Libraries. + +## Examples + +[Code snippets and samples](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/monitor/azure-resourcemanager-monitor-slis/SAMPLE.md) + + +## Troubleshooting + +## Next steps + +## Contributing + +For details on contributing to this repository, see the [contributing guide][cg]. + +This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For more information see the [Code of Conduct FAQ][coc_faq] or contact with any additional questions or comments. + + +[survey]: https://microsoft.qualtrics.com/jfe/form/SV_ehN0lIk2FKEBkwd?Q_CHL=DOCS +[docs]: https://azure.github.io/azure-sdk-for-java/ +[jdk]: https://learn.microsoft.com/azure/developer/java/fundamentals/ +[azure_subscription]: https://azure.microsoft.com/free/ +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity +[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/identity/azure-identity#credentials +[azure_core_http_netty]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core-http-netty +[authenticate]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/AUTH.md +[design]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/DESIGN.md +[cg]: https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/SAMPLE.md b/sdk/monitor/azure-resourcemanager-monitor-slis/SAMPLE.md new file mode 100644 index 000000000000..d7d077f280cb --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/SAMPLE.md @@ -0,0 +1,160 @@ +# Code snippets and samples + + +## Slis + +- [CreateOrUpdate](#slis_createorupdate) +- [Delete](#slis_delete) +- [Get](#slis_get) +- [ListByParent](#slis_listbyparent) +### Slis_CreateOrUpdate + +```java +import com.azure.resourcemanager.monitor.slis.fluent.models.SliInner; +import com.azure.resourcemanager.monitor.slis.models.AmwAccount; +import com.azure.resourcemanager.monitor.slis.models.Baseline; +import com.azure.resourcemanager.monitor.slis.models.BaselineProperties; +import com.azure.resourcemanager.monitor.slis.models.Category; +import com.azure.resourcemanager.monitor.slis.models.Condition; +import com.azure.resourcemanager.monitor.slis.models.ConditionOperator; +import com.azure.resourcemanager.monitor.slis.models.EvaluationCalculationType; +import com.azure.resourcemanager.monitor.slis.models.EvaluationType; +import com.azure.resourcemanager.monitor.slis.models.Signal; +import com.azure.resourcemanager.monitor.slis.models.SignalSource; +import com.azure.resourcemanager.monitor.slis.models.SliProperties; +import com.azure.resourcemanager.monitor.slis.models.SliResource; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregation; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregation; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteria; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteriaComparator; +import java.util.Arrays; + +/** + * Samples for Slis CreateOrUpdate. + */ +public final class SlisCreateOrUpdateSamples { + /* + * x-ms-original-file: 2025-03-01-preview/Slis_CreateOrUpdate.json + */ + /** + * Sample code: CreateSli. + * + * @param manager Entry point to SlisManager. + */ + public static void createSli(com.azure.resourcemanager.monitor.slis.SlisManager manager) { + manager.slis() + .createOrUpdateWithResponse("testSG", "testSli", new SliInner().withProperties(new SliResource() + .withDescription("Measures the performance characteristics of the GetContosoUsers() API. ") + .withCategory(Category.LATENCY) + .withEvaluationType(EvaluationType.WINDOW_BASED) + .withDestinationAmwAccounts(Arrays.asList(new AmwAccount() + .withResourceId( + "/subscriptions//resourcegroups//providers/microsoft.monitor/accounts/") + .withIdentity( + "/subscriptions//resourcegroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/"))) + .withBaselineProperties(new BaselineProperties().withBaseline(new Baseline().withValue(99.0) + .withEvaluationPeriodDays(30) + .withEvaluationCalculationType(EvaluationCalculationType.CALENDAR_DAYS))) + .withEnableAlert(true) + .withSliProperties(new SliProperties().withSignals(new Signal().withSignalSources(Arrays.asList( + new SignalSource().withSignalSourceId("A") + .withSourceAmwAccountManagedIdentity( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity") + .withSourceAmwAccountResourceId( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/microsoft.monitor/accounts/myAccount") + .withMetricNamespace("ContosoMetricsWest") + .withMetricName("Stamp1Latency") + .withFilters(Arrays.asList(new Condition().withDimensionName("ApiName") + .withOperator(ConditionOperator.EQUAL) + .withValue("GetContosoUsers"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.AVERAGE) + .withDimensions(Arrays.asList("Region", "ResponseCode"))) + .withTemporalAggregation(new TemporalAggregation().withType(TemporalAggregationType.AVERAGE) + .withWindowSizeMinutes(5)), + new SignalSource().withSignalSourceId("B") + .withSourceAmwAccountManagedIdentity( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity") + .withSourceAmwAccountResourceId( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/microsoft.monitor/accounts/myAccount") + .withMetricNamespace("ContosoMetricsEast") + .withMetricName("Stamp2Latency") + .withFilters(Arrays.asList(new Condition().withDimensionName("ApiName") + .withOperator(ConditionOperator.EQUAL) + .withValue("GetContosoUsers"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.AVERAGE) + .withDimensions(Arrays.asList("Region", "ResponseCode"))) + .withTemporalAggregation(new TemporalAggregation().withType(TemporalAggregationType.AVERAGE) + .withWindowSizeMinutes(5)))) + .withSignalFormula("(A + B) /2")) + .withWindowUptimeCriteria(new WindowUptimeCriteria().withTarget(95.0) + .withComparator(WindowUptimeCriteriaComparator.GREATER_THAN_OR_EQUAL)))), + com.azure.core.util.Context.NONE); + } +} +``` + +### Slis_Delete + +```java +/** + * Samples for Slis Delete. + */ +public final class SlisDeleteSamples { + /* + * x-ms-original-file: 2025-03-01-preview/Slis_Delete.json + */ + /** + * Sample code: DeleteSli. + * + * @param manager Entry point to SlisManager. + */ + public static void deleteSli(com.azure.resourcemanager.monitor.slis.SlisManager manager) { + manager.slis().deleteByResourceGroupWithResponse("testSG", "testSli", com.azure.core.util.Context.NONE); + } +} +``` + +### Slis_Get + +```java +/** + * Samples for Slis Get. + */ +public final class SlisGetSamples { + /* + * x-ms-original-file: 2025-03-01-preview/Slis_Get.json + */ + /** + * Sample code: GetSli. + * + * @param manager Entry point to SlisManager. + */ + public static void getSli(com.azure.resourcemanager.monitor.slis.SlisManager manager) { + manager.slis().getWithResponse("testSG", "testSli", com.azure.core.util.Context.NONE); + } +} +``` + +### Slis_ListByParent + +```java +/** + * Samples for Slis ListByParent. + */ +public final class SlisListByParentSamples { + /* + * x-ms-original-file: 2025-03-01-preview/Slis_ListByParent.json + */ + /** + * Sample code: SlisListByParent. + * + * @param manager Entry point to SlisManager. + */ + public static void slisListByParent(com.azure.resourcemanager.monitor.slis.SlisManager manager) { + manager.slis().listByParent("testSG", com.azure.core.util.Context.NONE); + } +} +``` + diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/pom.xml b/sdk/monitor/azure-resourcemanager-monitor-slis/pom.xml new file mode 100644 index 000000000000..3642f391e2b0 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/pom.xml @@ -0,0 +1,74 @@ + + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure.resourcemanager + azure-resourcemanager-monitor-slis + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for Slis Management + This package contains Microsoft Azure SDK for Slis Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Package api-version 2025-03-01-preview. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + 0 + 0 + true + + + + com.azure + azure-core + 1.57.1 + + + com.azure + azure-core-management + 1.19.3 + + + com.azure + azure-core-test + 1.27.0-beta.14 + test + + + com.azure + azure-identity + 1.18.2 + test + + + diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/SlisManager.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/SlisManager.java new file mode 100644 index 000000000000..6a8c014d906a --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/SlisManager.java @@ -0,0 +1,280 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis; + +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.monitor.slis.fluent.SlisManagementClient; +import com.azure.resourcemanager.monitor.slis.implementation.SlisImpl; +import com.azure.resourcemanager.monitor.slis.implementation.SlisManagementClientBuilder; +import com.azure.resourcemanager.monitor.slis.models.Slis; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Entry point to SlisManager. + */ +public final class SlisManager { + private Slis slis; + + private final SlisManagementClient clientObject; + + private SlisManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = new SlisManagementClientBuilder().pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of Slis service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Slis service API instance. + */ + public static SlisManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return configure().authenticate(credential, profile); + } + + /** + * Creates an instance of Slis service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the Slis service API instance. + */ + public static SlisManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new SlisManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create SlisManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new SlisManager.Configurable(); + } + + /** + * The Configurable allowing configurations to be set. + */ + public static final class Configurable { + private static final ClientLogger LOGGER = new ClientLogger(Configurable.class); + private static final String SDK_VERSION = "version"; + private static final Map PROPERTIES + = CoreUtils.getProperties("azure-resourcemanager-monitor-slis.properties"); + + private HttpClient httpClient; + private HttpLogOptions httpLogOptions; + private final List policies = new ArrayList<>(); + private final List scopes = new ArrayList<>(); + private RetryPolicy retryPolicy; + private RetryOptions retryOptions; + private Duration defaultPollInterval; + + private Configurable() { + } + + /** + * Sets the http client. + * + * @param httpClient the HTTP client. + * @return the configurable object itself. + */ + public Configurable withHttpClient(HttpClient httpClient) { + this.httpClient = Objects.requireNonNull(httpClient, "'httpClient' cannot be null."); + return this; + } + + /** + * Sets the logging options to the HTTP pipeline. + * + * @param httpLogOptions the HTTP log options. + * @return the configurable object itself. + */ + public Configurable withLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = Objects.requireNonNull(httpLogOptions, "'httpLogOptions' cannot be null."); + return this; + } + + /** + * Adds the pipeline policy to the HTTP pipeline. + * + * @param policy the HTTP pipeline policy. + * @return the configurable object itself. + */ + public Configurable withPolicy(HttpPipelinePolicy policy) { + this.policies.add(Objects.requireNonNull(policy, "'policy' cannot be null.")); + return this; + } + + /** + * Adds the scope to permission sets. + * + * @param scope the scope. + * @return the configurable object itself. + */ + public Configurable withScope(String scope) { + this.scopes.add(Objects.requireNonNull(scope, "'scope' cannot be null.")); + return this; + } + + /** + * Sets the retry policy to the HTTP pipeline. + * + * @param retryPolicy the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = Objects.requireNonNull(retryPolicy, "'retryPolicy' cannot be null."); + return this; + } + + /** + * Sets the retry options for the HTTP pipeline retry policy. + *

+ * This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}. + * + * @param retryOptions the retry options for the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryOptions(RetryOptions retryOptions) { + this.retryOptions = Objects.requireNonNull(retryOptions, "'retryOptions' cannot be null."); + return this; + } + + /** + * Sets the default poll interval, used when service does not provide "Retry-After" header. + * + * @param defaultPollInterval the default poll interval. + * @return the configurable object itself. + */ + public Configurable withDefaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval + = Objects.requireNonNull(defaultPollInterval, "'defaultPollInterval' cannot be null."); + if (this.defaultPollInterval.isNegative()) { + throw LOGGER + .logExceptionAsError(new IllegalArgumentException("'defaultPollInterval' cannot be negative")); + } + return this; + } + + /** + * Creates an instance of Slis service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Slis service API instance. + */ + public SlisManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + + StringBuilder userAgentBuilder = new StringBuilder(); + userAgentBuilder.append("azsdk-java") + .append("-") + .append("com.azure.resourcemanager.monitor.slis") + .append("/") + .append(clientVersion); + if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) { + userAgentBuilder.append(" (") + .append(Configuration.getGlobalConfiguration().get("java.version")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.name")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.version")) + .append("; auto-generated)"); + } else { + userAgentBuilder.append(" (auto-generated)"); + } + + if (scopes.isEmpty()) { + scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default"); + } + if (retryPolicy == null) { + if (retryOptions != null) { + retryPolicy = new RetryPolicy(retryOptions); + } else { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + } + List policies = new ArrayList<>(); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); + policies.add(new AddHeadersFromContextPolicy()); + policies.add(new RequestIdPolicy()); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .collect(Collectors.toList())); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy); + policies.add(new AddDatePolicy()); + policies.add(new BearerTokenAuthenticationPolicy(credential, scopes.toArray(new String[0]))); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .collect(Collectors.toList())); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(httpClient) + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .build(); + return new SlisManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** + * Gets the resource collection API of Slis. + * + * @return Resource collection API of Slis. + */ + public Slis slis() { + if (this.slis == null) { + this.slis = new SlisImpl(clientObject.getSlis(), this); + } + return slis; + } + + /** + * Gets wrapped service client SlisManagementClient providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + * + * @return Wrapped service client SlisManagementClient. + */ + public SlisManagementClient serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/SlisClient.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/SlisClient.java new file mode 100644 index 000000000000..9a7e921bc200 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/SlisClient.java @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.resourcemanager.monitor.slis.fluent.models.SliInner; + +/** + * An instance of this class provides access to all the operations defined in SlisClient. + */ +public interface SlisClient { + /** + * Gets an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an SLI resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(String serviceGroupName, String sliName, Context context); + + /** + * Gets an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an SLI resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SliInner get(String serviceGroupName, String sliName); + + /** + * Creates or updates an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an SLI resource within the ProviderHub along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createOrUpdateWithResponse(String serviceGroupName, String sliName, SliInner resource, + Context context); + + /** + * Creates or updates an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an SLI resource within the ProviderHub. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SliInner createOrUpdate(String serviceGroupName, String sliName, SliInner resource); + + /** + * Deletes an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response deleteWithResponse(String serviceGroupName, String sliName, Context context); + + /** + * Deletes an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String serviceGroupName, String sliName); + + /** + * Lists all SLI resources under a parent resource. + * + * @param serviceGroupName The name of the service group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByParent(String serviceGroupName); + + /** + * Lists all SLI resources under a parent resource. + * + * @param serviceGroupName The name of the service group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByParent(String serviceGroupName, Context context); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/SlisManagementClient.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/SlisManagementClient.java new file mode 100644 index 000000000000..75feaeb2b8da --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/SlisManagementClient.java @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** + * The interface for SlisManagementClient class. + */ +public interface SlisManagementClient { + /** + * Gets Service host. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + HttpPipeline getHttpPipeline(); + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + Duration getDefaultPollInterval(); + + /** + * Gets the SlisClient object to access its operations. + * + * @return the SlisClient object. + */ + SlisClient getSlis(); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/models/SliInner.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/models/SliInner.java new file mode 100644 index 000000000000..b224d1be1016 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/models/SliInner.java @@ -0,0 +1,184 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.ProxyResource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.slis.models.SliResource; +import java.io.IOException; + +/** + * Represents an SLI resource within the ProviderHub. + */ +@Fluent +public final class SliInner extends ProxyResource { + /* + * The resource-specific properties for this resource. + */ + private SliResource properties; + + /* + * The managed service identities assigned to this resource. + */ + private ManagedServiceIdentity identity; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of SliInner class. + */ + public SliInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public SliResource properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the SliInner object itself. + */ + public SliInner withProperties(SliResource properties) { + this.properties = properties; + return this; + } + + /** + * Get the identity property: The managed service identities assigned to this resource. + * + * @return the identity value. + */ + public ManagedServiceIdentity identity() { + return this.identity; + } + + /** + * Set the identity property: The managed service identities assigned to this resource. + * + * @param identity the identity value to set. + * @return the SliInner object itself. + */ + public SliInner withIdentity(ManagedServiceIdentity identity) { + this.identity = identity; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("properties", this.properties); + jsonWriter.writeJsonField("identity", this.identity); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SliInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SliInner if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SliInner. + */ + public static SliInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SliInner deserializedSliInner = new SliInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedSliInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedSliInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedSliInner.type = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedSliInner.properties = SliResource.fromJson(reader); + } else if ("identity".equals(fieldName)) { + deserializedSliInner.identity = ManagedServiceIdentity.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedSliInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedSliInner; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/models/package-info.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/models/package-info.java new file mode 100644 index 000000000000..abc7fcd7c1f8 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/models/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the inner data models for SlisManagementClient. + */ +package com.azure.resourcemanager.monitor.slis.fluent.models; diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/package-info.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/package-info.java new file mode 100644 index 000000000000..1987114f0822 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/fluent/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the service clients for SlisManagementClient. + */ +package com.azure.resourcemanager.monitor.slis.fluent; diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/ResourceManagerUtils.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/ResourceManagerUtils.java new file mode 100644 index 000000000000..e83fad7c0eb1 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/ResourceManagerUtils.java @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.implementation; + +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.util.CoreUtils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import reactor.core.publisher.Flux; + +final class ResourceManagerUtils { + private ResourceManagerUtils() { + } + + static String getValueFromIdByName(String id, String name) { + if (id == null) { + return null; + } + Iterator itr = Arrays.stream(id.split("/")).iterator(); + while (itr.hasNext()) { + String part = itr.next(); + if (part != null && !part.trim().isEmpty()) { + if (part.equalsIgnoreCase(name)) { + if (itr.hasNext()) { + return itr.next(); + } else { + return null; + } + } + } + } + return null; + } + + static String getValueFromIdByParameterName(String id, String pathTemplate, String parameterName) { + if (id == null || pathTemplate == null) { + return null; + } + String parameterNameParentheses = "{" + parameterName + "}"; + List idSegmentsReverted = Arrays.asList(id.split("/")); + List pathSegments = Arrays.asList(pathTemplate.split("/")); + Collections.reverse(idSegmentsReverted); + Iterator idItrReverted = idSegmentsReverted.iterator(); + int pathIndex = pathSegments.size(); + while (idItrReverted.hasNext() && pathIndex > 0) { + String idSegment = idItrReverted.next(); + String pathSegment = pathSegments.get(--pathIndex); + if (!CoreUtils.isNullOrEmpty(idSegment) && !CoreUtils.isNullOrEmpty(pathSegment)) { + if (pathSegment.equalsIgnoreCase(parameterNameParentheses)) { + if (pathIndex == 0 || (pathIndex == 1 && pathSegments.get(0).isEmpty())) { + List segments = new ArrayList<>(); + segments.add(idSegment); + idItrReverted.forEachRemaining(segments::add); + Collections.reverse(segments); + if (!segments.isEmpty() && segments.get(0).isEmpty()) { + segments.remove(0); + } + return String.join("/", segments); + } else { + return idSegment; + } + } + } + } + return null; + } + + static PagedIterable mapPage(PagedIterable pageIterable, Function mapper) { + return new PagedIterableImpl<>(pageIterable, mapper); + } + + private static final class PagedIterableImpl extends PagedIterable { + + private final PagedIterable pagedIterable; + private final Function mapper; + private final Function, PagedResponse> pageMapper; + + private PagedIterableImpl(PagedIterable pagedIterable, Function mapper) { + super(PagedFlux.create(() -> (continuationToken, pageSize) -> Flux + .fromStream(pagedIterable.streamByPage().map(getPageMapper(mapper))))); + this.pagedIterable = pagedIterable; + this.mapper = mapper; + this.pageMapper = getPageMapper(mapper); + } + + private static Function, PagedResponse> getPageMapper(Function mapper) { + return page -> new PagedResponseBase(page.getRequest(), page.getStatusCode(), page.getHeaders(), + page.getElements().stream().map(mapper).collect(Collectors.toList()), page.getContinuationToken(), + null); + } + + @Override + public Stream stream() { + return pagedIterable.stream().map(mapper); + } + + @Override + public Stream> streamByPage() { + return pagedIterable.streamByPage().map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken) { + return pagedIterable.streamByPage(continuationToken).map(pageMapper); + } + + @Override + public Stream> streamByPage(int preferredPageSize) { + return pagedIterable.streamByPage(preferredPageSize).map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken, int preferredPageSize) { + return pagedIterable.streamByPage(continuationToken, preferredPageSize).map(pageMapper); + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(pagedIterable.iterator(), mapper); + } + + @Override + public Iterable> iterableByPage() { + return new IterableImpl<>(pagedIterable.iterableByPage(), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken), pageMapper); + } + + @Override + public Iterable> iterableByPage(int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(preferredPageSize), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken, preferredPageSize), pageMapper); + } + } + + private static final class IteratorImpl implements Iterator { + + private final Iterator iterator; + private final Function mapper; + + private IteratorImpl(Iterator iterator, Function mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public S next() { + return mapper.apply(iterator.next()); + } + + @Override + public void remove() { + iterator.remove(); + } + } + + private static final class IterableImpl implements Iterable { + + private final Iterable iterable; + private final Function mapper; + + private IterableImpl(Iterable iterable, Function mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(iterable.iterator(), mapper); + } + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SliImpl.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SliImpl.java new file mode 100644 index 000000000000..4d5c97db8d35 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SliImpl.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.implementation; + +import com.azure.core.management.SystemData; +import com.azure.resourcemanager.monitor.slis.fluent.models.SliInner; +import com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.slis.models.Sli; +import com.azure.resourcemanager.monitor.slis.models.SliResource; + +public final class SliImpl implements Sli { + private SliInner innerObject; + + private final com.azure.resourcemanager.monitor.slis.SlisManager serviceManager; + + SliImpl(SliInner innerObject, com.azure.resourcemanager.monitor.slis.SlisManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public SliResource properties() { + return this.innerModel().properties(); + } + + public ManagedServiceIdentity identity() { + return this.innerModel().identity(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public SliInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.monitor.slis.SlisManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisClientImpl.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisClientImpl.java new file mode 100644 index 000000000000..235c53cb06a4 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisClientImpl.java @@ -0,0 +1,514 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.resourcemanager.monitor.slis.fluent.SlisClient; +import com.azure.resourcemanager.monitor.slis.fluent.models.SliInner; +import com.azure.resourcemanager.monitor.slis.implementation.models.SliListResult; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in SlisClient. + */ +public final class SlisClientImpl implements SlisClient { + /** + * The proxy service used to perform REST calls. + */ + private final SlisService service; + + /** + * The service client containing this operation class. + */ + private final SlisManagementClientImpl client; + + /** + * Initializes an instance of SlisClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SlisClientImpl(SlisManagementClientImpl client) { + this.service = RestProxy.create(SlisService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for SlisManagementClientSlis to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "SlisManagementClientSlis") + public interface SlisService { + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.Monitor/slis/{sliName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get(@HostParam("endpoint") String endpoint, + @PathParam("serviceGroupName") String serviceGroupName, @QueryParam("api-version") String apiVersion, + @PathParam("sliName") String sliName, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.Monitor/slis/{sliName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response getSync(@HostParam("endpoint") String endpoint, + @PathParam("serviceGroupName") String serviceGroupName, @QueryParam("api-version") String apiVersion, + @PathParam("sliName") String sliName, @HeaderParam("Accept") String accept, Context context); + + @Put("/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.Monitor/slis/{sliName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createOrUpdate(@HostParam("endpoint") String endpoint, + @PathParam("serviceGroupName") String serviceGroupName, @QueryParam("api-version") String apiVersion, + @PathParam("sliName") String sliName, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") SliInner resource, Context context); + + @Put("/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.Monitor/slis/{sliName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response createOrUpdateSync(@HostParam("endpoint") String endpoint, + @PathParam("serviceGroupName") String serviceGroupName, @QueryParam("api-version") String apiVersion, + @PathParam("sliName") String sliName, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") SliInner resource, Context context); + + @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" }) + @Delete("/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.Monitor/slis/{sliName}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete(@HostParam("endpoint") String endpoint, + @PathParam("serviceGroupName") String serviceGroupName, @QueryParam("api-version") String apiVersion, + @PathParam("sliName") String sliName, Context context); + + @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" }) + @Delete("/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.Monitor/slis/{sliName}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response deleteSync(@HostParam("endpoint") String endpoint, + @PathParam("serviceGroupName") String serviceGroupName, @QueryParam("api-version") String apiVersion, + @PathParam("sliName") String sliName, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.Monitor/slis") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByParent(@HostParam("endpoint") String endpoint, + @PathParam("serviceGroupName") String serviceGroupName, @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.Management/serviceGroups/{serviceGroupName}/providers/Microsoft.Monitor/slis") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response listByParentSync(@HostParam("endpoint") String endpoint, + @PathParam("serviceGroupName") String serviceGroupName, @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByParentNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response listByParentNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, Context context); + } + + /** + * Gets an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an SLI resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String serviceGroupName, String sliName) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.get(this.client.getEndpoint(), serviceGroupName, + this.client.getApiVersion(), sliName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Gets an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an SLI resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String serviceGroupName, String sliName) { + return getWithResponseAsync(serviceGroupName, sliName).flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Gets an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an SLI resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String serviceGroupName, String sliName, Context context) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), serviceGroupName, this.client.getApiVersion(), sliName, + accept, context); + } + + /** + * Gets an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an SLI resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SliInner get(String serviceGroupName, String sliName) { + return getWithResponse(serviceGroupName, sliName, Context.NONE).getValue(); + } + + /** + * Creates or updates an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an SLI resource within the ProviderHub along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync(String serviceGroupName, String sliName, + SliInner resource) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), serviceGroupName, + this.client.getApiVersion(), sliName, contentType, accept, resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Creates or updates an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an SLI resource within the ProviderHub on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String serviceGroupName, String sliName, SliInner resource) { + return createOrUpdateWithResponseAsync(serviceGroupName, sliName, resource) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Creates or updates an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an SLI resource within the ProviderHub along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateWithResponse(String serviceGroupName, String sliName, SliInner resource, + Context context) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.client.getEndpoint(), serviceGroupName, this.client.getApiVersion(), + sliName, contentType, accept, resource, context); + } + + /** + * Creates or updates an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an SLI resource within the ProviderHub. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SliInner createOrUpdate(String serviceGroupName, String sliName, SliInner resource) { + return createOrUpdateWithResponse(serviceGroupName, sliName, resource, Context.NONE).getValue(); + } + + /** + * Deletes an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String serviceGroupName, String sliName) { + return FluxUtil + .withContext(context -> service.delete(this.client.getEndpoint(), serviceGroupName, + this.client.getApiVersion(), sliName, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Deletes an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String serviceGroupName, String sliName) { + return deleteWithResponseAsync(serviceGroupName, sliName).flatMap(ignored -> Mono.empty()); + } + + /** + * Deletes an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(String serviceGroupName, String sliName, Context context) { + return service.deleteSync(this.client.getEndpoint(), serviceGroupName, this.client.getApiVersion(), sliName, + context); + } + + /** + * Deletes an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String serviceGroupName, String sliName) { + deleteWithResponse(serviceGroupName, sliName, Context.NONE); + } + + /** + * Lists all SLI resources under a parent resource. + * + * @param serviceGroupName The name of the service group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByParentSinglePageAsync(String serviceGroupName) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByParent(this.client.getEndpoint(), serviceGroupName, + this.client.getApiVersion(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Lists all SLI resources under a parent resource. + * + * @param serviceGroupName The name of the service group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByParentAsync(String serviceGroupName) { + return new PagedFlux<>(() -> listByParentSinglePageAsync(serviceGroupName), + nextLink -> listByParentNextSinglePageAsync(nextLink)); + } + + /** + * Lists all SLI resources under a parent resource. + * + * @param serviceGroupName The name of the service group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listByParentSinglePage(String serviceGroupName) { + final String accept = "application/json"; + Response res = service.listByParentSync(this.client.getEndpoint(), serviceGroupName, + this.client.getApiVersion(), accept, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * Lists all SLI resources under a parent resource. + * + * @param serviceGroupName The name of the service group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listByParentSinglePage(String serviceGroupName, Context context) { + final String accept = "application/json"; + Response res = service.listByParentSync(this.client.getEndpoint(), serviceGroupName, + this.client.getApiVersion(), accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * Lists all SLI resources under a parent resource. + * + * @param serviceGroupName The name of the service group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByParent(String serviceGroupName) { + return new PagedIterable<>(() -> listByParentSinglePage(serviceGroupName), + nextLink -> listByParentNextSinglePage(nextLink)); + } + + /** + * Lists all SLI resources under a parent resource. + * + * @param serviceGroupName The name of the service group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByParent(String serviceGroupName, Context context) { + return new PagedIterable<>(() -> listByParentSinglePage(serviceGroupName, context), + nextLink -> listByParentNextSinglePage(nextLink, context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByParentNextSinglePageAsync(String nextLink) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByParentNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listByParentNextSinglePage(String nextLink) { + final String accept = "application/json"; + Response res + = service.listByParentNextSync(nextLink, this.client.getEndpoint(), accept, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listByParentNextSinglePage(String nextLink, Context context) { + final String accept = "application/json"; + Response res + = service.listByParentNextSync(nextLink, this.client.getEndpoint(), accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisImpl.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisImpl.java new file mode 100644 index 000000000000..8558674be7c7 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisImpl.java @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.monitor.slis.fluent.SlisClient; +import com.azure.resourcemanager.monitor.slis.fluent.models.SliInner; +import com.azure.resourcemanager.monitor.slis.models.Sli; +import com.azure.resourcemanager.monitor.slis.models.Slis; + +public final class SlisImpl implements Slis { + private static final ClientLogger LOGGER = new ClientLogger(SlisImpl.class); + + private final SlisClient innerClient; + + private final com.azure.resourcemanager.monitor.slis.SlisManager serviceManager; + + public SlisImpl(SlisClient innerClient, com.azure.resourcemanager.monitor.slis.SlisManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getWithResponse(String serviceGroupName, String sliName, Context context) { + Response inner = this.serviceClient().getWithResponse(serviceGroupName, sliName, context); + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new SliImpl(inner.getValue(), this.manager())); + } + + public Sli get(String serviceGroupName, String sliName) { + SliInner inner = this.serviceClient().get(serviceGroupName, sliName); + if (inner != null) { + return new SliImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response createOrUpdateWithResponse(String serviceGroupName, String sliName, SliInner resource, + Context context) { + Response inner + = this.serviceClient().createOrUpdateWithResponse(serviceGroupName, sliName, resource, context); + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new SliImpl(inner.getValue(), this.manager())); + } + + public Sli createOrUpdate(String serviceGroupName, String sliName, SliInner resource) { + SliInner inner = this.serviceClient().createOrUpdate(serviceGroupName, sliName, resource); + if (inner != null) { + return new SliImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response deleteByResourceGroupWithResponse(String serviceGroupName, String sliName, Context context) { + return this.serviceClient().deleteWithResponse(serviceGroupName, sliName, context); + } + + public void deleteByResourceGroup(String serviceGroupName, String sliName) { + this.serviceClient().delete(serviceGroupName, sliName); + } + + public PagedIterable listByParent(String serviceGroupName) { + PagedIterable inner = this.serviceClient().listByParent(serviceGroupName); + return ResourceManagerUtils.mapPage(inner, inner1 -> new SliImpl(inner1, this.manager())); + } + + public PagedIterable listByParent(String serviceGroupName, Context context) { + PagedIterable inner = this.serviceClient().listByParent(serviceGroupName, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new SliImpl(inner1, this.manager())); + } + + private SlisClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.monitor.slis.SlisManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisManagementClientBuilder.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisManagementClientBuilder.java new file mode 100644 index 000000000000..4ad38756ad63 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisManagementClientBuilder.java @@ -0,0 +1,122 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.implementation; + +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerAdapter; +import java.time.Duration; + +/** + * A builder for creating a new instance of the SlisManagementClientImpl type. + */ +@ServiceClientBuilder(serviceClients = { SlisManagementClientImpl.class }) +public final class SlisManagementClientBuilder { + /* + * Service host + */ + private String endpoint; + + /** + * Sets Service host. + * + * @param endpoint the endpoint value. + * @return the SlisManagementClientBuilder. + */ + public SlisManagementClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The environment to connect to + */ + private AzureEnvironment environment; + + /** + * Sets The environment to connect to. + * + * @param environment the environment value. + * @return the SlisManagementClientBuilder. + */ + public SlisManagementClientBuilder environment(AzureEnvironment environment) { + this.environment = environment; + return this; + } + + /* + * The HTTP pipeline to send requests through + */ + private HttpPipeline pipeline; + + /** + * Sets The HTTP pipeline to send requests through. + * + * @param pipeline the pipeline value. + * @return the SlisManagementClientBuilder. + */ + public SlisManagementClientBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + return this; + } + + /* + * The default poll interval for long-running operation + */ + private Duration defaultPollInterval; + + /** + * Sets The default poll interval for long-running operation. + * + * @param defaultPollInterval the defaultPollInterval value. + * @return the SlisManagementClientBuilder. + */ + public SlisManagementClientBuilder defaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = defaultPollInterval; + return this; + } + + /* + * The serializer to serialize an object into a string + */ + private SerializerAdapter serializerAdapter; + + /** + * Sets The serializer to serialize an object into a string. + * + * @param serializerAdapter the serializerAdapter value. + * @return the SlisManagementClientBuilder. + */ + public SlisManagementClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of SlisManagementClientImpl with the provided parameters. + * + * @return an instance of SlisManagementClientImpl. + */ + public SlisManagementClientImpl buildClient() { + String localEndpoint = (endpoint != null) ? endpoint : "https://management.azure.com"; + AzureEnvironment localEnvironment = (environment != null) ? environment : AzureEnvironment.AZURE; + HttpPipeline localPipeline = (pipeline != null) + ? pipeline + : new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(); + Duration localDefaultPollInterval + = (defaultPollInterval != null) ? defaultPollInterval : Duration.ofSeconds(30); + SerializerAdapter localSerializerAdapter = (serializerAdapter != null) + ? serializerAdapter + : SerializerFactory.createDefaultManagementSerializerAdapter(); + SlisManagementClientImpl client = new SlisManagementClientImpl(localPipeline, localSerializerAdapter, + localDefaultPollInterval, localEnvironment, localEndpoint); + return client; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisManagementClientImpl.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisManagementClientImpl.java new file mode 100644 index 000000000000..0b34032a4413 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisManagementClientImpl.java @@ -0,0 +1,292 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.implementation; + +import com.azure.core.annotation.ServiceClient; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpResponse; +import com.azure.core.http.rest.Response; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.exception.ManagementError; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.management.polling.PollerFactory; +import com.azure.core.management.polling.SyncPollerFactory; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.AsyncPollResponse; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.monitor.slis.fluent.SlisClient; +import com.azure.resourcemanager.monitor.slis.fluent.SlisManagementClient; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the SlisManagementClientImpl type. + */ +@ServiceClient(builder = SlisManagementClientBuilder.class) +public final class SlisManagementClientImpl implements SlisManagementClient { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Version parameter. + */ + private final String apiVersion; + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + public String getApiVersion() { + return this.apiVersion; + } + + /** + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The serializer to serialize an object into a string. + */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * The default poll interval for long-running operation. + */ + private final Duration defaultPollInterval; + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + public Duration getDefaultPollInterval() { + return this.defaultPollInterval; + } + + /** + * The SlisClient object to access its operations. + */ + private final SlisClient slis; + + /** + * Gets the SlisClient object to access its operations. + * + * @return the SlisClient object. + */ + public SlisClient getSlis() { + return this.slis; + } + + /** + * Initializes an instance of SlisManagementClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param defaultPollInterval The default poll interval for long-running operation. + * @param environment The Azure environment. + * @param endpoint Service host. + */ + SlisManagementClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + Duration defaultPollInterval, AzureEnvironment environment, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.endpoint = endpoint; + this.apiVersion = "2025-03-01-preview"; + this.slis = new SlisClientImpl(this); + } + + /** + * Gets default client context. + * + * @return the default client context. + */ + public Context getContext() { + return Context.NONE; + } + + /** + * Merges default client context with provided context. + * + * @param context the context to be merged with default client context. + * @return the merged context. + */ + public Context mergeContext(Context context) { + return CoreUtils.mergeContexts(this.getContext(), context); + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param httpPipeline the http pipeline. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return poller flux for poll result and final result. + */ + public PollerFlux, U> getLroResult(Mono>> activationResponse, + HttpPipeline httpPipeline, Type pollResultType, Type finalResultType, Context context) { + return PollerFactory.create(serializerAdapter, httpPipeline, pollResultType, finalResultType, + defaultPollInterval, activationResponse, context); + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return SyncPoller for poll result and final result. + */ + public SyncPoller, U> getLroResult(Response activationResponse, + Type pollResultType, Type finalResultType, Context context) { + return SyncPollerFactory.create(serializerAdapter, httpPipeline, pollResultType, finalResultType, + defaultPollInterval, () -> activationResponse, context); + } + + /** + * Gets the final result, or an error, based on last async poll response. + * + * @param response the last async poll response. + * @param type of poll result. + * @param type of final result. + * @return the final result, or an error. + */ + public Mono getLroFinalResultOrError(AsyncPollResponse, U> response) { + if (response.getStatus() != LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) { + String errorMessage; + ManagementError managementError = null; + HttpResponse errorResponse = null; + PollResult.Error lroError = response.getValue().getError(); + if (lroError != null) { + errorResponse = new HttpResponseImpl(lroError.getResponseStatusCode(), lroError.getResponseHeaders(), + lroError.getResponseBody()); + + errorMessage = response.getValue().getError().getMessage(); + String errorBody = response.getValue().getError().getResponseBody(); + if (errorBody != null) { + // try to deserialize error body to ManagementError + try { + managementError = this.getSerializerAdapter() + .deserialize(errorBody, ManagementError.class, SerializerEncoding.JSON); + if (managementError.getCode() == null || managementError.getMessage() == null) { + managementError = null; + } + } catch (IOException | RuntimeException ioe) { + LOGGER.logThrowableAsWarning(ioe); + } + } + } else { + // fallback to default error message + errorMessage = "Long running operation failed."; + } + if (managementError == null) { + // fallback to default ManagementError + managementError = new ManagementError(response.getStatus().toString(), errorMessage); + } + return Mono.error(new ManagementException(errorMessage, errorResponse, managementError)); + } else { + return response.getFinalResult(); + } + } + + private static final class HttpResponseImpl extends HttpResponse { + private final int statusCode; + + private final byte[] responseBody; + + private final HttpHeaders httpHeaders; + + HttpResponseImpl(int statusCode, HttpHeaders httpHeaders, String responseBody) { + super(null); + this.statusCode = statusCode; + this.httpHeaders = httpHeaders; + this.responseBody = responseBody == null ? null : responseBody.getBytes(StandardCharsets.UTF_8); + } + + public int getStatusCode() { + return statusCode; + } + + public String getHeaderValue(String s) { + return httpHeaders.getValue(HttpHeaderName.fromString(s)); + } + + public HttpHeaders getHeaders() { + return httpHeaders; + } + + public Flux getBody() { + return Flux.just(ByteBuffer.wrap(responseBody)); + } + + public Mono getBodyAsByteArray() { + return Mono.just(responseBody); + } + + public Mono getBodyAsString() { + return Mono.just(new String(responseBody, StandardCharsets.UTF_8)); + } + + public Mono getBodyAsString(Charset charset) { + return Mono.just(new String(responseBody, charset)); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(SlisManagementClientImpl.class); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/models/SliListResult.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/models/SliListResult.java new file mode 100644 index 000000000000..a7dca504d6b4 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/models/SliListResult.java @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.monitor.slis.fluent.models.SliInner; +import java.io.IOException; +import java.util.List; + +/** + * The response of a Sli list operation. + */ +@Immutable +public final class SliListResult implements JsonSerializable { + /* + * The Sli items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of SliListResult class. + */ + private SliListResult() { + } + + /** + * Get the value property: The Sli items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SliListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SliListResult if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SliListResult. + */ + public static SliListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SliListResult deserializedSliListResult = new SliListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value = reader.readArray(reader1 -> SliInner.fromJson(reader1)); + deserializedSliListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedSliListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedSliListResult; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/package-info.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/package-info.java new file mode 100644 index 000000000000..f74fcd62cf0e --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/implementation/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for SlisManagementClient. + */ +package com.azure.resourcemanager.monitor.slis.implementation; diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/AmwAccount.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/AmwAccount.java new file mode 100644 index 000000000000..20fb9f501b80 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/AmwAccount.java @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents an Azure Monitor Workspace (AMW) account used for emitting metrics. + */ +@Fluent +public final class AmwAccount implements JsonSerializable { + /* + * The ARM resource ID of the account where metrics are emitted. + */ + private String resourceId; + + /* + * The ARM resource ID of the managed identity with access to the source account. + */ + private String identity; + + /** + * Creates an instance of AmwAccount class. + */ + public AmwAccount() { + } + + /** + * Get the resourceId property: The ARM resource ID of the account where metrics are emitted. + * + * @return the resourceId value. + */ + public String resourceId() { + return this.resourceId; + } + + /** + * Set the resourceId property: The ARM resource ID of the account where metrics are emitted. + * + * @param resourceId the resourceId value to set. + * @return the AmwAccount object itself. + */ + public AmwAccount withResourceId(String resourceId) { + this.resourceId = resourceId; + return this; + } + + /** + * Get the identity property: The ARM resource ID of the managed identity with access to the source account. + * + * @return the identity value. + */ + public String identity() { + return this.identity; + } + + /** + * Set the identity property: The ARM resource ID of the managed identity with access to the source account. + * + * @param identity the identity value to set. + * @return the AmwAccount object itself. + */ + public AmwAccount withIdentity(String identity) { + this.identity = identity; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("resourceId", this.resourceId); + jsonWriter.writeStringField("identity", this.identity); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AmwAccount from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AmwAccount if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AmwAccount. + */ + public static AmwAccount fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AmwAccount deserializedAmwAccount = new AmwAccount(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("resourceId".equals(fieldName)) { + deserializedAmwAccount.resourceId = reader.getString(); + } else if ("identity".equals(fieldName)) { + deserializedAmwAccount.identity = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedAmwAccount; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Baseline.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Baseline.java new file mode 100644 index 000000000000..8d2e16113178 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Baseline.java @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Defines the target parameters for a Slo baseline. + */ +@Fluent +public final class Baseline implements JsonSerializable { + /* + * The user-defined or Azure-defined target value used for comparison against the SLI value. + */ + private double value; + + /* + * The time frame (in days) used for SLI evaluation. + */ + private int evaluationPeriodDays; + + /* + * Specifies how evaluation is calculated, either based on calendar days or a rolling window. + */ + private EvaluationCalculationType evaluationCalculationType; + + /** + * Creates an instance of Baseline class. + */ + public Baseline() { + } + + /** + * Get the value property: The user-defined or Azure-defined target value used for comparison against the SLI value. + * + * @return the value value. + */ + public double value() { + return this.value; + } + + /** + * Set the value property: The user-defined or Azure-defined target value used for comparison against the SLI value. + * + * @param value the value value to set. + * @return the Baseline object itself. + */ + public Baseline withValue(double value) { + this.value = value; + return this; + } + + /** + * Get the evaluationPeriodDays property: The time frame (in days) used for SLI evaluation. + * + * @return the evaluationPeriodDays value. + */ + public int evaluationPeriodDays() { + return this.evaluationPeriodDays; + } + + /** + * Set the evaluationPeriodDays property: The time frame (in days) used for SLI evaluation. + * + * @param evaluationPeriodDays the evaluationPeriodDays value to set. + * @return the Baseline object itself. + */ + public Baseline withEvaluationPeriodDays(int evaluationPeriodDays) { + this.evaluationPeriodDays = evaluationPeriodDays; + return this; + } + + /** + * Get the evaluationCalculationType property: Specifies how evaluation is calculated, either based on calendar days + * or a rolling window. + * + * @return the evaluationCalculationType value. + */ + public EvaluationCalculationType evaluationCalculationType() { + return this.evaluationCalculationType; + } + + /** + * Set the evaluationCalculationType property: Specifies how evaluation is calculated, either based on calendar days + * or a rolling window. + * + * @param evaluationCalculationType the evaluationCalculationType value to set. + * @return the Baseline object itself. + */ + public Baseline withEvaluationCalculationType(EvaluationCalculationType evaluationCalculationType) { + this.evaluationCalculationType = evaluationCalculationType; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("value", this.value); + jsonWriter.writeIntField("evaluationPeriodDays", this.evaluationPeriodDays); + jsonWriter.writeStringField("evaluationCalculationType", + this.evaluationCalculationType == null ? null : this.evaluationCalculationType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Baseline from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Baseline if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the Baseline. + */ + public static Baseline fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Baseline deserializedBaseline = new Baseline(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + deserializedBaseline.value = reader.getDouble(); + } else if ("evaluationPeriodDays".equals(fieldName)) { + deserializedBaseline.evaluationPeriodDays = reader.getInt(); + } else if ("evaluationCalculationType".equals(fieldName)) { + deserializedBaseline.evaluationCalculationType + = EvaluationCalculationType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedBaseline; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/BaselineProperties.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/BaselineProperties.java new file mode 100644 index 000000000000..993db29463b6 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/BaselineProperties.java @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Defines the properties of a baseline. + */ +@Fluent +public final class BaselineProperties implements JsonSerializable { + /* + * Defines the baseline target, which is compared against the SLI value to determine compliance. + */ + private Baseline baseline; + + /** + * Creates an instance of BaselineProperties class. + */ + public BaselineProperties() { + } + + /** + * Get the baseline property: Defines the baseline target, which is compared against the SLI value to determine + * compliance. + * + * @return the baseline value. + */ + public Baseline baseline() { + return this.baseline; + } + + /** + * Set the baseline property: Defines the baseline target, which is compared against the SLI value to determine + * compliance. + * + * @param baseline the baseline value to set. + * @return the BaselineProperties object itself. + */ + public BaselineProperties withBaseline(Baseline baseline) { + this.baseline = baseline; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("baseline", this.baseline); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BaselineProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BaselineProperties if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the BaselineProperties. + */ + public static BaselineProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BaselineProperties deserializedBaselineProperties = new BaselineProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("baseline".equals(fieldName)) { + deserializedBaselineProperties.baseline = Baseline.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedBaselineProperties; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Category.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Category.java new file mode 100644 index 000000000000..fa58e55f3e1d --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Category.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines the category of an SLI. + */ +public final class Category extends ExpandableStringEnum { + /** + * Indicates availability-related metrics. + */ + public static final Category AVAILABILITY = fromString("Availability"); + + /** + * Indicates latency-related metrics. + */ + public static final Category LATENCY = fromString("Latency"); + + /** + * Creates a new instance of Category value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public Category() { + } + + /** + * Creates or finds a Category from its string representation. + * + * @param name a name to look for. + * @return the corresponding Category. + */ + public static Category fromString(String name) { + return fromString(name, Category.class); + } + + /** + * Gets known Category values. + * + * @return known Category values. + */ + public static Collection values() { + return values(Category.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Condition.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Condition.java new file mode 100644 index 000000000000..8232abe3bd6e --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Condition.java @@ -0,0 +1,199 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents a filtering condition. + */ +@Fluent +public final class Condition implements JsonSerializable { + /* + * Dimension name used in filtering. + */ + private String dimensionName; + + /* + * Scalar function applied for filtering. + */ + private ScalarFunction scalarFunction; + + /* + * Defines the sampling type. + */ + private SamplingType samplingType; + + /* + * Operator used in the filtering condition. + */ + private ConditionOperator operator; + + /* + * Value used in filtering. + */ + private String value; + + /** + * Creates an instance of Condition class. + */ + public Condition() { + } + + /** + * Get the dimensionName property: Dimension name used in filtering. + * + * @return the dimensionName value. + */ + public String dimensionName() { + return this.dimensionName; + } + + /** + * Set the dimensionName property: Dimension name used in filtering. + * + * @param dimensionName the dimensionName value to set. + * @return the Condition object itself. + */ + public Condition withDimensionName(String dimensionName) { + this.dimensionName = dimensionName; + return this; + } + + /** + * Get the scalarFunction property: Scalar function applied for filtering. + * + * @return the scalarFunction value. + */ + public ScalarFunction scalarFunction() { + return this.scalarFunction; + } + + /** + * Set the scalarFunction property: Scalar function applied for filtering. + * + * @param scalarFunction the scalarFunction value to set. + * @return the Condition object itself. + */ + public Condition withScalarFunction(ScalarFunction scalarFunction) { + this.scalarFunction = scalarFunction; + return this; + } + + /** + * Get the samplingType property: Defines the sampling type. + * + * @return the samplingType value. + */ + public SamplingType samplingType() { + return this.samplingType; + } + + /** + * Set the samplingType property: Defines the sampling type. + * + * @param samplingType the samplingType value to set. + * @return the Condition object itself. + */ + public Condition withSamplingType(SamplingType samplingType) { + this.samplingType = samplingType; + return this; + } + + /** + * Get the operator property: Operator used in the filtering condition. + * + * @return the operator value. + */ + public ConditionOperator operator() { + return this.operator; + } + + /** + * Set the operator property: Operator used in the filtering condition. + * + * @param operator the operator value to set. + * @return the Condition object itself. + */ + public Condition withOperator(ConditionOperator operator) { + this.operator = operator; + return this; + } + + /** + * Get the value property: Value used in filtering. + * + * @return the value value. + */ + public String value() { + return this.value; + } + + /** + * Set the value property: Value used in filtering. + * + * @param value the value value to set. + * @return the Condition object itself. + */ + public Condition withValue(String value) { + this.value = value; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("operator", this.operator == null ? null : this.operator.toString()); + jsonWriter.writeStringField("value", this.value); + jsonWriter.writeStringField("dimensionName", this.dimensionName); + jsonWriter.writeStringField("scalarFunction", + this.scalarFunction == null ? null : this.scalarFunction.toString()); + jsonWriter.writeStringField("samplingType", this.samplingType == null ? null : this.samplingType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Condition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Condition if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the Condition. + */ + public static Condition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Condition deserializedCondition = new Condition(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("operator".equals(fieldName)) { + deserializedCondition.operator = ConditionOperator.fromString(reader.getString()); + } else if ("value".equals(fieldName)) { + deserializedCondition.value = reader.getString(); + } else if ("dimensionName".equals(fieldName)) { + deserializedCondition.dimensionName = reader.getString(); + } else if ("scalarFunction".equals(fieldName)) { + deserializedCondition.scalarFunction = ScalarFunction.fromString(reader.getString()); + } else if ("samplingType".equals(fieldName)) { + deserializedCondition.samplingType = SamplingType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedCondition; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ConditionOperator.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ConditionOperator.java new file mode 100644 index 000000000000..dc12609a7648 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ConditionOperator.java @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines operators used in filter conditions. + */ +public final class ConditionOperator extends ExpandableStringEnum { + /** + * Equal to. + */ + public static final ConditionOperator EQUAL = fromString("=="); + + /** + * Not equal to. + */ + public static final ConditionOperator NOT_EQUAL = fromString("!="); + + /** + * Less than. + */ + public static final ConditionOperator LESS_THAN = fromString("<"); + + /** + * Less than or equal to. + */ + public static final ConditionOperator LESS_THAN_OR_EQUAL = fromString("<="); + + /** + * Greater than. + */ + public static final ConditionOperator GREATER_THAN = fromString(">"); + + /** + * Greater than or equal to. + */ + public static final ConditionOperator GREATER_THAN_OR_EQUAL = fromString(">="); + + /** + * In operator. + */ + public static final ConditionOperator IN = fromString("@in"); + + /** + * Not in. + */ + public static final ConditionOperator NOT_IN = fromString("!in"); + + /** + * Starts with. + */ + public static final ConditionOperator STARTS_WITH = fromString("startswith"); + + /** + * Does not start with. + */ + public static final ConditionOperator NOT_STARTS_WITH = fromString("!startswith"); + + /** + * Contains the value. + */ + public static final ConditionOperator CONTAINS = fromString("contains"); + + /** + * Does not contain the value. + */ + public static final ConditionOperator NOT_CONTAINS = fromString("!contains"); + + /** + * Creates a new instance of ConditionOperator value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ConditionOperator() { + } + + /** + * Creates or finds a ConditionOperator from its string representation. + * + * @param name a name to look for. + * @return the corresponding ConditionOperator. + */ + public static ConditionOperator fromString(String name) { + return fromString(name, ConditionOperator.class); + } + + /** + * Gets known ConditionOperator values. + * + * @return known ConditionOperator values. + */ + public static Collection values() { + return values(ConditionOperator.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/EvaluationCalculationType.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/EvaluationCalculationType.java new file mode 100644 index 000000000000..4af8c53228b3 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/EvaluationCalculationType.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Specifies the method for evaluation calculation. + */ +public final class EvaluationCalculationType extends ExpandableStringEnum { + /** + * Calculates evaluation based on a fixed calendar period. + */ + public static final EvaluationCalculationType CALENDAR_DAYS = fromString("CalendarDays"); + + /** + * Calculates evaluation using a rolling time window. + */ + public static final EvaluationCalculationType ROLLING_DAYS = fromString("RollingDays"); + + /** + * Creates a new instance of EvaluationCalculationType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public EvaluationCalculationType() { + } + + /** + * Creates or finds a EvaluationCalculationType from its string representation. + * + * @param name a name to look for. + * @return the corresponding EvaluationCalculationType. + */ + public static EvaluationCalculationType fromString(String name) { + return fromString(name, EvaluationCalculationType.class); + } + + /** + * Gets known EvaluationCalculationType values. + * + * @return known EvaluationCalculationType values. + */ + public static Collection values() { + return values(EvaluationCalculationType.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/EvaluationType.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/EvaluationType.java new file mode 100644 index 000000000000..0f26f7693bba --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/EvaluationType.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Specifies how the SLI is evaluated. + */ +public final class EvaluationType extends ExpandableStringEnum { + /** + * Evaluates SLI based on time windows. + */ + public static final EvaluationType WINDOW_BASED = fromString("WindowBased"); + + /** + * Evaluates SLI based on request counts. + */ + public static final EvaluationType REQUEST_BASED = fromString("RequestBased"); + + /** + * Creates a new instance of EvaluationType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public EvaluationType() { + } + + /** + * Creates or finds a EvaluationType from its string representation. + * + * @param name a name to look for. + * @return the corresponding EvaluationType. + */ + public static EvaluationType fromString(String name) { + return fromString(name, EvaluationType.class); + } + + /** + * Gets known EvaluationType values. + * + * @return known EvaluationType values. + */ + public static Collection values() { + return values(EvaluationType.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ExecutionState.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ExecutionState.java new file mode 100644 index 000000000000..3b858c2eaa3a --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ExecutionState.java @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents the current execution state of an SLI. + */ +@Immutable +public final class ExecutionState implements JsonSerializable { + /* + * The execution state value. + */ + private String state; + + /* + * A descriptive message related to the execution state. + */ + private String message; + + /** + * Creates an instance of ExecutionState class. + */ + private ExecutionState() { + } + + /** + * Get the state property: The execution state value. + * + * @return the state value. + */ + public String state() { + return this.state; + } + + /** + * Get the message property: A descriptive message related to the execution state. + * + * @return the message value. + */ + public String message() { + return this.message; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("state", this.state); + jsonWriter.writeStringField("message", this.message); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExecutionState from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExecutionState if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ExecutionState. + */ + public static ExecutionState fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ExecutionState deserializedExecutionState = new ExecutionState(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("state".equals(fieldName)) { + deserializedExecutionState.state = reader.getString(); + } else if ("message".equals(fieldName)) { + deserializedExecutionState.message = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedExecutionState; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ManagedServiceIdentity.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ManagedServiceIdentity.java new file mode 100644 index 000000000000..878aa458e9e8 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ManagedServiceIdentity.java @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * Managed service identity (system assigned and/or user assigned identities). + */ +@Fluent +public final class ManagedServiceIdentity implements JsonSerializable { + /* + * The service principal ID of the system assigned identity. This property will only be provided for a system + * assigned identity. + */ + private String principalId; + + /* + * The tenant ID of the system assigned identity. This property will only be provided for a system assigned + * identity. + */ + private String tenantId; + + /* + * The type of managed identity assigned to this resource. + */ + private ManagedServiceIdentityType type; + + /* + * The identities assigned to this resource by the user. + */ + private Map userAssignedIdentities; + + /** + * Creates an instance of ManagedServiceIdentity class. + */ + public ManagedServiceIdentity() { + } + + /** + * Get the principalId property: The service principal ID of the system assigned identity. This property will only + * be provided for a system assigned identity. + * + * @return the principalId value. + */ + public String principalId() { + return this.principalId; + } + + /** + * Get the tenantId property: The tenant ID of the system assigned identity. This property will only be provided for + * a system assigned identity. + * + * @return the tenantId value. + */ + public String tenantId() { + return this.tenantId; + } + + /** + * Get the type property: The type of managed identity assigned to this resource. + * + * @return the type value. + */ + public ManagedServiceIdentityType type() { + return this.type; + } + + /** + * Set the type property: The type of managed identity assigned to this resource. + * + * @param type the type value to set. + * @return the ManagedServiceIdentity object itself. + */ + public ManagedServiceIdentity withType(ManagedServiceIdentityType type) { + this.type = type; + return this; + } + + /** + * Get the userAssignedIdentities property: The identities assigned to this resource by the user. + * + * @return the userAssignedIdentities value. + */ + public Map userAssignedIdentities() { + return this.userAssignedIdentities; + } + + /** + * Set the userAssignedIdentities property: The identities assigned to this resource by the user. + * + * @param userAssignedIdentities the userAssignedIdentities value to set. + * @return the ManagedServiceIdentity object itself. + */ + public ManagedServiceIdentity withUserAssignedIdentities(Map userAssignedIdentities) { + this.userAssignedIdentities = userAssignedIdentities; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeMapField("userAssignedIdentities", this.userAssignedIdentities, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ManagedServiceIdentity from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ManagedServiceIdentity if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ManagedServiceIdentity. + */ + public static ManagedServiceIdentity fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ManagedServiceIdentity deserializedManagedServiceIdentity = new ManagedServiceIdentity(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedManagedServiceIdentity.type = ManagedServiceIdentityType.fromString(reader.getString()); + } else if ("principalId".equals(fieldName)) { + deserializedManagedServiceIdentity.principalId = reader.getString(); + } else if ("tenantId".equals(fieldName)) { + deserializedManagedServiceIdentity.tenantId = reader.getString(); + } else if ("userAssignedIdentities".equals(fieldName)) { + Map userAssignedIdentities + = reader.readMap(reader1 -> UserAssignedIdentity.fromJson(reader1)); + deserializedManagedServiceIdentity.userAssignedIdentities = userAssignedIdentities; + } else { + reader.skipChildren(); + } + } + + return deserializedManagedServiceIdentity; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ManagedServiceIdentityType.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ManagedServiceIdentityType.java new file mode 100644 index 000000000000..cb067549e237 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ManagedServiceIdentityType.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + */ +public final class ManagedServiceIdentityType extends ExpandableStringEnum { + /** + * No managed identity. + */ + public static final ManagedServiceIdentityType NONE = fromString("None"); + + /** + * System assigned managed identity. + */ + public static final ManagedServiceIdentityType SYSTEM_ASSIGNED = fromString("SystemAssigned"); + + /** + * User assigned managed identity. + */ + public static final ManagedServiceIdentityType USER_ASSIGNED = fromString("UserAssigned"); + + /** + * System and user assigned managed identity. + */ + public static final ManagedServiceIdentityType SYSTEM_ASSIGNED_USER_ASSIGNED + = fromString("SystemAssigned,UserAssigned"); + + /** + * Creates a new instance of ManagedServiceIdentityType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ManagedServiceIdentityType() { + } + + /** + * Creates or finds a ManagedServiceIdentityType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ManagedServiceIdentityType. + */ + public static ManagedServiceIdentityType fromString(String name) { + return fromString(name, ManagedServiceIdentityType.class); + } + + /** + * Gets known ManagedServiceIdentityType values. + * + * @return known ManagedServiceIdentityType values. + */ + public static Collection values() { + return values(ManagedServiceIdentityType.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Metric.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Metric.java new file mode 100644 index 000000000000..4be57462a7d6 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Metric.java @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Defines a metric in the destination AMW account. + */ +@Immutable +public final class Metric implements JsonSerializable { + /* + * The namespace of the metric. + */ + private String metricNamespace; + + /* + * The name of the metric. + */ + private String metricName; + + /** + * Creates an instance of Metric class. + */ + private Metric() { + } + + /** + * Get the metricNamespace property: The namespace of the metric. + * + * @return the metricNamespace value. + */ + public String metricNamespace() { + return this.metricNamespace; + } + + /** + * Get the metricName property: The name of the metric. + * + * @return the metricName value. + */ + public String metricName() { + return this.metricName; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("metricNamespace", this.metricNamespace); + jsonWriter.writeStringField("metricName", this.metricName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Metric from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Metric if the JsonReader was pointing to an instance of it, or null if it was pointing to + * JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the Metric. + */ + public static Metric fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Metric deserializedMetric = new Metric(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("metricNamespace".equals(fieldName)) { + deserializedMetric.metricNamespace = reader.getString(); + } else if ("metricName".equals(fieldName)) { + deserializedMetric.metricName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedMetric; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ProvisioningState.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ProvisioningState.java new file mode 100644 index 000000000000..369642bc877c --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ProvisioningState.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Represents the provisioning state of the SLI resource. + */ +public final class ProvisioningState extends ExpandableStringEnum { + /** + * Resource has been created. + */ + public static final ProvisioningState SUCCEEDED = fromString("Succeeded"); + + /** + * Resource creation failed. + */ + public static final ProvisioningState FAILED = fromString("Failed"); + + /** + * Resource creation was canceled. + */ + public static final ProvisioningState CANCELED = fromString("Canceled"); + + /** + * Creates a new instance of ProvisioningState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ProvisioningState() { + } + + /** + * Creates or finds a ProvisioningState from its string representation. + * + * @param name a name to look for. + * @return the corresponding ProvisioningState. + */ + public static ProvisioningState fromString(String name) { + return fromString(name, ProvisioningState.class); + } + + /** + * Gets known ProvisioningState values. + * + * @return known ProvisioningState values. + */ + public static Collection values() { + return values(ProvisioningState.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SamplingType.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SamplingType.java new file mode 100644 index 000000000000..eae669b0ff0e --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SamplingType.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines the available sampling types. + */ +public final class SamplingType extends ExpandableStringEnum { + /** + * Maximum value. + */ + public static final SamplingType MAX = fromString("max"); + + /** + * Minimum value. + */ + public static final SamplingType MIN = fromString("min"); + + /** + * Average value. + */ + public static final SamplingType AVG = fromString("avg"); + + /** + * Summation. + */ + public static final SamplingType SUM = fromString("sum"); + + /** + * Creates a new instance of SamplingType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public SamplingType() { + } + + /** + * Creates or finds a SamplingType from its string representation. + * + * @param name a name to look for. + * @return the corresponding SamplingType. + */ + public static SamplingType fromString(String name) { + return fromString(name, SamplingType.class); + } + + /** + * Gets known SamplingType values. + * + * @return known SamplingType values. + */ + public static Collection values() { + return values(SamplingType.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ScalarFunction.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ScalarFunction.java new file mode 100644 index 000000000000..61d0bbc2ff75 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/ScalarFunction.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines scalar functions used in filtering. + */ +public final class ScalarFunction extends ExpandableStringEnum { + /** + * Maximum value. + */ + public static final ScalarFunction MAX = fromString("max"); + + /** + * Minimum value. + */ + public static final ScalarFunction MIN = fromString("min"); + + /** + * Average value. + */ + public static final ScalarFunction AVG = fromString("avg"); + + /** + * Summation. + */ + public static final ScalarFunction SUM = fromString("sum"); + + /** + * Creates a new instance of ScalarFunction value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ScalarFunction() { + } + + /** + * Creates or finds a ScalarFunction from its string representation. + * + * @param name a name to look for. + * @return the corresponding ScalarFunction. + */ + public static ScalarFunction fromString(String name) { + return fromString(name, ScalarFunction.class); + } + + /** + * Gets known ScalarFunction values. + * + * @return known ScalarFunction values. + */ + public static Collection values() { + return values(ScalarFunction.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Signal.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Signal.java new file mode 100644 index 000000000000..f371fcb324fa --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Signal.java @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Represents a signal model used in SLI calculations. + */ +@Fluent +public final class Signal implements JsonSerializable { + /* + * Sources of metrics used for SLIs. + */ + private List signalSources; + + /* + * Mathematical formula used to combine multiple metrics. + */ + private String signalFormula; + + /** + * Creates an instance of Signal class. + */ + public Signal() { + } + + /** + * Get the signalSources property: Sources of metrics used for SLIs. + * + * @return the signalSources value. + */ + public List signalSources() { + return this.signalSources; + } + + /** + * Set the signalSources property: Sources of metrics used for SLIs. + * + * @param signalSources the signalSources value to set. + * @return the Signal object itself. + */ + public Signal withSignalSources(List signalSources) { + this.signalSources = signalSources; + return this; + } + + /** + * Get the signalFormula property: Mathematical formula used to combine multiple metrics. + * + * @return the signalFormula value. + */ + public String signalFormula() { + return this.signalFormula; + } + + /** + * Set the signalFormula property: Mathematical formula used to combine multiple metrics. + * + * @param signalFormula the signalFormula value to set. + * @return the Signal object itself. + */ + public Signal withSignalFormula(String signalFormula) { + this.signalFormula = signalFormula; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("signalSources", this.signalSources, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("signalFormula", this.signalFormula); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Signal from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Signal if the JsonReader was pointing to an instance of it, or null if it was pointing to + * JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the Signal. + */ + public static Signal fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Signal deserializedSignal = new Signal(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("signalSources".equals(fieldName)) { + List signalSources = reader.readArray(reader1 -> SignalSource.fromJson(reader1)); + deserializedSignal.signalSources = signalSources; + } else if ("signalFormula".equals(fieldName)) { + deserializedSignal.signalFormula = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedSignal; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SignalSource.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SignalSource.java new file mode 100644 index 000000000000..32c3501c3efa --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SignalSource.java @@ -0,0 +1,286 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Represents a signal source used in SLIs. + */ +@Fluent +public final class SignalSource implements JsonSerializable { + /* + * Unique identifier for the signal source. + */ + private String signalSourceId; + + /* + * Managed identity for authenticating the signal source. + */ + private String sourceAmwAccountManagedIdentity; + + /* + * Resource ID of the source AMW account. + */ + private String sourceAmwAccountResourceId; + + /* + * Namespace of the metric. + */ + private String metricNamespace; + + /* + * Name of the metric. + */ + private String metricName; + + /* + * Filters applied to modify signal values. + */ + private List filters; + + /* + * Defines how measurements are aggregated across multiple time series. + */ + private SpatialAggregation spatialAggregation; + + /* + * Defines how measurements are aggregated over a specific time window within the same time series. + */ + private TemporalAggregation temporalAggregation; + + /** + * Creates an instance of SignalSource class. + */ + public SignalSource() { + } + + /** + * Get the signalSourceId property: Unique identifier for the signal source. + * + * @return the signalSourceId value. + */ + public String signalSourceId() { + return this.signalSourceId; + } + + /** + * Set the signalSourceId property: Unique identifier for the signal source. + * + * @param signalSourceId the signalSourceId value to set. + * @return the SignalSource object itself. + */ + public SignalSource withSignalSourceId(String signalSourceId) { + this.signalSourceId = signalSourceId; + return this; + } + + /** + * Get the sourceAmwAccountManagedIdentity property: Managed identity for authenticating the signal source. + * + * @return the sourceAmwAccountManagedIdentity value. + */ + public String sourceAmwAccountManagedIdentity() { + return this.sourceAmwAccountManagedIdentity; + } + + /** + * Set the sourceAmwAccountManagedIdentity property: Managed identity for authenticating the signal source. + * + * @param sourceAmwAccountManagedIdentity the sourceAmwAccountManagedIdentity value to set. + * @return the SignalSource object itself. + */ + public SignalSource withSourceAmwAccountManagedIdentity(String sourceAmwAccountManagedIdentity) { + this.sourceAmwAccountManagedIdentity = sourceAmwAccountManagedIdentity; + return this; + } + + /** + * Get the sourceAmwAccountResourceId property: Resource ID of the source AMW account. + * + * @return the sourceAmwAccountResourceId value. + */ + public String sourceAmwAccountResourceId() { + return this.sourceAmwAccountResourceId; + } + + /** + * Set the sourceAmwAccountResourceId property: Resource ID of the source AMW account. + * + * @param sourceAmwAccountResourceId the sourceAmwAccountResourceId value to set. + * @return the SignalSource object itself. + */ + public SignalSource withSourceAmwAccountResourceId(String sourceAmwAccountResourceId) { + this.sourceAmwAccountResourceId = sourceAmwAccountResourceId; + return this; + } + + /** + * Get the metricNamespace property: Namespace of the metric. + * + * @return the metricNamespace value. + */ + public String metricNamespace() { + return this.metricNamespace; + } + + /** + * Set the metricNamespace property: Namespace of the metric. + * + * @param metricNamespace the metricNamespace value to set. + * @return the SignalSource object itself. + */ + public SignalSource withMetricNamespace(String metricNamespace) { + this.metricNamespace = metricNamespace; + return this; + } + + /** + * Get the metricName property: Name of the metric. + * + * @return the metricName value. + */ + public String metricName() { + return this.metricName; + } + + /** + * Set the metricName property: Name of the metric. + * + * @param metricName the metricName value to set. + * @return the SignalSource object itself. + */ + public SignalSource withMetricName(String metricName) { + this.metricName = metricName; + return this; + } + + /** + * Get the filters property: Filters applied to modify signal values. + * + * @return the filters value. + */ + public List filters() { + return this.filters; + } + + /** + * Set the filters property: Filters applied to modify signal values. + * + * @param filters the filters value to set. + * @return the SignalSource object itself. + */ + public SignalSource withFilters(List filters) { + this.filters = filters; + return this; + } + + /** + * Get the spatialAggregation property: Defines how measurements are aggregated across multiple time series. + * + * @return the spatialAggregation value. + */ + public SpatialAggregation spatialAggregation() { + return this.spatialAggregation; + } + + /** + * Set the spatialAggregation property: Defines how measurements are aggregated across multiple time series. + * + * @param spatialAggregation the spatialAggregation value to set. + * @return the SignalSource object itself. + */ + public SignalSource withSpatialAggregation(SpatialAggregation spatialAggregation) { + this.spatialAggregation = spatialAggregation; + return this; + } + + /** + * Get the temporalAggregation property: Defines how measurements are aggregated over a specific time window within + * the same time series. + * + * @return the temporalAggregation value. + */ + public TemporalAggregation temporalAggregation() { + return this.temporalAggregation; + } + + /** + * Set the temporalAggregation property: Defines how measurements are aggregated over a specific time window within + * the same time series. + * + * @param temporalAggregation the temporalAggregation value to set. + * @return the SignalSource object itself. + */ + public SignalSource withTemporalAggregation(TemporalAggregation temporalAggregation) { + this.temporalAggregation = temporalAggregation; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("signalSourceId", this.signalSourceId); + jsonWriter.writeStringField("sourceAmwAccountManagedIdentity", this.sourceAmwAccountManagedIdentity); + jsonWriter.writeStringField("sourceAmwAccountResourceId", this.sourceAmwAccountResourceId); + jsonWriter.writeStringField("metricNamespace", this.metricNamespace); + jsonWriter.writeStringField("metricName", this.metricName); + jsonWriter.writeArrayField("filters", this.filters, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("spatialAggregation", this.spatialAggregation); + jsonWriter.writeJsonField("temporalAggregation", this.temporalAggregation); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SignalSource from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SignalSource if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SignalSource. + */ + public static SignalSource fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SignalSource deserializedSignalSource = new SignalSource(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("signalSourceId".equals(fieldName)) { + deserializedSignalSource.signalSourceId = reader.getString(); + } else if ("sourceAmwAccountManagedIdentity".equals(fieldName)) { + deserializedSignalSource.sourceAmwAccountManagedIdentity = reader.getString(); + } else if ("sourceAmwAccountResourceId".equals(fieldName)) { + deserializedSignalSource.sourceAmwAccountResourceId = reader.getString(); + } else if ("metricNamespace".equals(fieldName)) { + deserializedSignalSource.metricNamespace = reader.getString(); + } else if ("metricName".equals(fieldName)) { + deserializedSignalSource.metricName = reader.getString(); + } else if ("filters".equals(fieldName)) { + List filters = reader.readArray(reader1 -> Condition.fromJson(reader1)); + deserializedSignalSource.filters = filters; + } else if ("spatialAggregation".equals(fieldName)) { + deserializedSignalSource.spatialAggregation = SpatialAggregation.fromJson(reader); + } else if ("temporalAggregation".equals(fieldName)) { + deserializedSignalSource.temporalAggregation = TemporalAggregation.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedSignalSource; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Sli.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Sli.java new file mode 100644 index 000000000000..a287bb06cdf8 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Sli.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.management.SystemData; +import com.azure.resourcemanager.monitor.slis.fluent.models.SliInner; + +/** + * An immutable client-side representation of Sli. + */ +public interface Sli { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + SliResource properties(); + + /** + * Gets the identity property: The managed service identities assigned to this resource. + * + * @return the identity value. + */ + ManagedServiceIdentity identity(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the inner com.azure.resourcemanager.monitor.slis.fluent.models.SliInner object. + * + * @return the inner object. + */ + SliInner innerModel(); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SliProperties.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SliProperties.java new file mode 100644 index 000000000000..b106b5612385 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SliProperties.java @@ -0,0 +1,169 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Defines the properties of an SLI. + */ +@Fluent +public final class SliProperties implements JsonSerializable { + /* + * Represents good signals used in request-based SLI calculations. + */ + private Signal goodSignals; + + /* + * Represents total signals used in request-based SLI calculations. + */ + private Signal totalSignals; + + /* + * Signals used for window-based SLI calculations. + */ + private Signal signals; + + /* + * Defines the uptime criteria for window-based SLIs. + */ + private WindowUptimeCriteria windowUptimeCriteria; + + /** + * Creates an instance of SliProperties class. + */ + public SliProperties() { + } + + /** + * Get the goodSignals property: Represents good signals used in request-based SLI calculations. + * + * @return the goodSignals value. + */ + public Signal goodSignals() { + return this.goodSignals; + } + + /** + * Set the goodSignals property: Represents good signals used in request-based SLI calculations. + * + * @param goodSignals the goodSignals value to set. + * @return the SliProperties object itself. + */ + public SliProperties withGoodSignals(Signal goodSignals) { + this.goodSignals = goodSignals; + return this; + } + + /** + * Get the totalSignals property: Represents total signals used in request-based SLI calculations. + * + * @return the totalSignals value. + */ + public Signal totalSignals() { + return this.totalSignals; + } + + /** + * Set the totalSignals property: Represents total signals used in request-based SLI calculations. + * + * @param totalSignals the totalSignals value to set. + * @return the SliProperties object itself. + */ + public SliProperties withTotalSignals(Signal totalSignals) { + this.totalSignals = totalSignals; + return this; + } + + /** + * Get the signals property: Signals used for window-based SLI calculations. + * + * @return the signals value. + */ + public Signal signals() { + return this.signals; + } + + /** + * Set the signals property: Signals used for window-based SLI calculations. + * + * @param signals the signals value to set. + * @return the SliProperties object itself. + */ + public SliProperties withSignals(Signal signals) { + this.signals = signals; + return this; + } + + /** + * Get the windowUptimeCriteria property: Defines the uptime criteria for window-based SLIs. + * + * @return the windowUptimeCriteria value. + */ + public WindowUptimeCriteria windowUptimeCriteria() { + return this.windowUptimeCriteria; + } + + /** + * Set the windowUptimeCriteria property: Defines the uptime criteria for window-based SLIs. + * + * @param windowUptimeCriteria the windowUptimeCriteria value to set. + * @return the SliProperties object itself. + */ + public SliProperties withWindowUptimeCriteria(WindowUptimeCriteria windowUptimeCriteria) { + this.windowUptimeCriteria = windowUptimeCriteria; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("goodSignals", this.goodSignals); + jsonWriter.writeJsonField("totalSignals", this.totalSignals); + jsonWriter.writeJsonField("signals", this.signals); + jsonWriter.writeJsonField("windowUptimeCriteria", this.windowUptimeCriteria); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SliProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SliProperties if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the SliProperties. + */ + public static SliProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SliProperties deserializedSliProperties = new SliProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("goodSignals".equals(fieldName)) { + deserializedSliProperties.goodSignals = Signal.fromJson(reader); + } else if ("totalSignals".equals(fieldName)) { + deserializedSliProperties.totalSignals = Signal.fromJson(reader); + } else if ("signals".equals(fieldName)) { + deserializedSliProperties.signals = Signal.fromJson(reader); + } else if ("windowUptimeCriteria".equals(fieldName)) { + deserializedSliProperties.windowUptimeCriteria = WindowUptimeCriteria.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedSliProperties; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SliResource.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SliResource.java new file mode 100644 index 000000000000..20e813f69a4a --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SliResource.java @@ -0,0 +1,348 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.List; + +/** + * Defines the root level properties of an SLI resource. + */ +@Fluent +public final class SliResource implements JsonSerializable { + /* + * Indicates the provisioning status of the last operation. + */ + private ProvisioningState provisioningState; + + /* + * A user-provided description of the SLI, with a maximum length of 1000 characters. + */ + private String description; + + /* + * Specifies the category of the SLI, used to classify signals such as Availability and Latency. + */ + private Category category; + + /* + * Determines how the SLI is evaluatedโ€”either based on request counts or time windows. + */ + private EvaluationType evaluationType; + + /* + * Indicates the current execution status of the SLI resource in ARM responses. + */ + private ExecutionState executionState; + + /* + * Destination AMW accounts. + */ + private List destinationAmwAccounts; + + /* + * The destination Azure Monitor Workspace (AMW) accounts where the SLI emits metrics. + */ + private List destinationMetrics; + + /* + * Defines the SLO baseline associated with the SLI. + */ + private BaselineProperties baselineProperties; + + /* + * The streaming rule Id associated with the Sli resource. + */ + private String streamingRuleId; + + /* + * The streaming rule last updated timestamp associated with the Sli resource. + */ + private OffsetDateTime streamingRuleLastUpdatedTimestamp; + + /* + * A flag to determine whether alert is enabled. + */ + private boolean enableAlert; + + /* + * Defines the SLI properties associated with the SLI. + */ + private SliProperties sliProperties; + + /** + * Creates an instance of SliResource class. + */ + public SliResource() { + } + + /** + * Get the provisioningState property: Indicates the provisioning status of the last operation. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Get the description property: A user-provided description of the SLI, with a maximum length of 1000 characters. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Set the description property: A user-provided description of the SLI, with a maximum length of 1000 characters. + * + * @param description the description value to set. + * @return the SliResource object itself. + */ + public SliResource withDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the category property: Specifies the category of the SLI, used to classify signals such as Availability and + * Latency. + * + * @return the category value. + */ + public Category category() { + return this.category; + } + + /** + * Set the category property: Specifies the category of the SLI, used to classify signals such as Availability and + * Latency. + * + * @param category the category value to set. + * @return the SliResource object itself. + */ + public SliResource withCategory(Category category) { + this.category = category; + return this; + } + + /** + * Get the evaluationType property: Determines how the SLI is evaluatedโ€”either based on request counts or time + * windows. + * + * @return the evaluationType value. + */ + public EvaluationType evaluationType() { + return this.evaluationType; + } + + /** + * Set the evaluationType property: Determines how the SLI is evaluatedโ€”either based on request counts or time + * windows. + * + * @param evaluationType the evaluationType value to set. + * @return the SliResource object itself. + */ + public SliResource withEvaluationType(EvaluationType evaluationType) { + this.evaluationType = evaluationType; + return this; + } + + /** + * Get the executionState property: Indicates the current execution status of the SLI resource in ARM responses. + * + * @return the executionState value. + */ + public ExecutionState executionState() { + return this.executionState; + } + + /** + * Get the destinationAmwAccounts property: Destination AMW accounts. + * + * @return the destinationAmwAccounts value. + */ + public List destinationAmwAccounts() { + return this.destinationAmwAccounts; + } + + /** + * Set the destinationAmwAccounts property: Destination AMW accounts. + * + * @param destinationAmwAccounts the destinationAmwAccounts value to set. + * @return the SliResource object itself. + */ + public SliResource withDestinationAmwAccounts(List destinationAmwAccounts) { + this.destinationAmwAccounts = destinationAmwAccounts; + return this; + } + + /** + * Get the destinationMetrics property: The destination Azure Monitor Workspace (AMW) accounts where the SLI emits + * metrics. + * + * @return the destinationMetrics value. + */ + public List destinationMetrics() { + return this.destinationMetrics; + } + + /** + * Get the baselineProperties property: Defines the SLO baseline associated with the SLI. + * + * @return the baselineProperties value. + */ + public BaselineProperties baselineProperties() { + return this.baselineProperties; + } + + /** + * Set the baselineProperties property: Defines the SLO baseline associated with the SLI. + * + * @param baselineProperties the baselineProperties value to set. + * @return the SliResource object itself. + */ + public SliResource withBaselineProperties(BaselineProperties baselineProperties) { + this.baselineProperties = baselineProperties; + return this; + } + + /** + * Get the streamingRuleId property: The streaming rule Id associated with the Sli resource. + * + * @return the streamingRuleId value. + */ + public String streamingRuleId() { + return this.streamingRuleId; + } + + /** + * Get the streamingRuleLastUpdatedTimestamp property: The streaming rule last updated timestamp associated with the + * Sli resource. + * + * @return the streamingRuleLastUpdatedTimestamp value. + */ + public OffsetDateTime streamingRuleLastUpdatedTimestamp() { + return this.streamingRuleLastUpdatedTimestamp; + } + + /** + * Get the enableAlert property: A flag to determine whether alert is enabled. + * + * @return the enableAlert value. + */ + public boolean enableAlert() { + return this.enableAlert; + } + + /** + * Set the enableAlert property: A flag to determine whether alert is enabled. + * + * @param enableAlert the enableAlert value to set. + * @return the SliResource object itself. + */ + public SliResource withEnableAlert(boolean enableAlert) { + this.enableAlert = enableAlert; + return this; + } + + /** + * Get the sliProperties property: Defines the SLI properties associated with the SLI. + * + * @return the sliProperties value. + */ + public SliProperties sliProperties() { + return this.sliProperties; + } + + /** + * Set the sliProperties property: Defines the SLI properties associated with the SLI. + * + * @param sliProperties the sliProperties value to set. + * @return the SliResource object itself. + */ + public SliResource withSliProperties(SliProperties sliProperties) { + this.sliProperties = sliProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeStringField("category", this.category == null ? null : this.category.toString()); + jsonWriter.writeStringField("evaluationType", + this.evaluationType == null ? null : this.evaluationType.toString()); + jsonWriter.writeArrayField("destinationAmwAccounts", this.destinationAmwAccounts, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("baselineProperties", this.baselineProperties); + jsonWriter.writeBooleanField("enableAlert", this.enableAlert); + jsonWriter.writeJsonField("sliProperties", this.sliProperties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SliResource from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SliResource if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SliResource. + */ + public static SliResource fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SliResource deserializedSliResource = new SliResource(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("description".equals(fieldName)) { + deserializedSliResource.description = reader.getString(); + } else if ("category".equals(fieldName)) { + deserializedSliResource.category = Category.fromString(reader.getString()); + } else if ("evaluationType".equals(fieldName)) { + deserializedSliResource.evaluationType = EvaluationType.fromString(reader.getString()); + } else if ("destinationAmwAccounts".equals(fieldName)) { + List destinationAmwAccounts = reader.readArray(reader1 -> AmwAccount.fromJson(reader1)); + deserializedSliResource.destinationAmwAccounts = destinationAmwAccounts; + } else if ("baselineProperties".equals(fieldName)) { + deserializedSliResource.baselineProperties = BaselineProperties.fromJson(reader); + } else if ("enableAlert".equals(fieldName)) { + deserializedSliResource.enableAlert = reader.getBoolean(); + } else if ("sliProperties".equals(fieldName)) { + deserializedSliResource.sliProperties = SliProperties.fromJson(reader); + } else if ("provisioningState".equals(fieldName)) { + deserializedSliResource.provisioningState = ProvisioningState.fromString(reader.getString()); + } else if ("executionState".equals(fieldName)) { + deserializedSliResource.executionState = ExecutionState.fromJson(reader); + } else if ("destinationMetrics".equals(fieldName)) { + List destinationMetrics = reader.readArray(reader1 -> Metric.fromJson(reader1)); + deserializedSliResource.destinationMetrics = destinationMetrics; + } else if ("streamingRuleId".equals(fieldName)) { + deserializedSliResource.streamingRuleId = reader.getString(); + } else if ("streamingRuleLastUpdatedTimestamp".equals(fieldName)) { + deserializedSliResource.streamingRuleLastUpdatedTimestamp = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + + return deserializedSliResource; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Slis.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Slis.java new file mode 100644 index 000000000000..2545e93f784e --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/Slis.java @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.resourcemanager.monitor.slis.fluent.models.SliInner; + +/** + * Resource collection API of Slis. + */ +public interface Slis { + /** + * Gets an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an SLI resource along with {@link Response}. + */ + Response getWithResponse(String serviceGroupName, String sliName, Context context); + + /** + * Gets an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an SLI resource. + */ + Sli get(String serviceGroupName, String sliName); + + /** + * Creates or updates an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an SLI resource within the ProviderHub along with {@link Response}. + */ + Response createOrUpdateWithResponse(String serviceGroupName, String sliName, SliInner resource, + Context context); + + /** + * Creates or updates an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an SLI resource within the ProviderHub. + */ + Sli createOrUpdate(String serviceGroupName, String sliName, SliInner resource); + + /** + * Deletes an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteByResourceGroupWithResponse(String serviceGroupName, String sliName, Context context); + + /** + * Deletes an SLI resource. + * + * @param serviceGroupName The name of the service group. + * @param sliName Name of the SLI that is given by the user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteByResourceGroup(String serviceGroupName, String sliName); + + /** + * Lists all SLI resources under a parent resource. + * + * @param serviceGroupName The name of the service group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByParent(String serviceGroupName); + + /** + * Lists all SLI resources under a parent resource. + * + * @param serviceGroupName The name of the service group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Sli list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByParent(String serviceGroupName, Context context); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SpatialAggregation.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SpatialAggregation.java new file mode 100644 index 000000000000..58a5593f48ea --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SpatialAggregation.java @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Represents the spatial aggregation model. + */ +@Fluent +public final class SpatialAggregation implements JsonSerializable { + /* + * Type of spatial aggregation. + */ + private SpatialAggregationType type; + + /* + * Dimensions considered for spatial aggregation. + */ + private List dimensions; + + /** + * Creates an instance of SpatialAggregation class. + */ + public SpatialAggregation() { + } + + /** + * Get the type property: Type of spatial aggregation. + * + * @return the type value. + */ + public SpatialAggregationType type() { + return this.type; + } + + /** + * Set the type property: Type of spatial aggregation. + * + * @param type the type value to set. + * @return the SpatialAggregation object itself. + */ + public SpatialAggregation withType(SpatialAggregationType type) { + this.type = type; + return this; + } + + /** + * Get the dimensions property: Dimensions considered for spatial aggregation. + * + * @return the dimensions value. + */ + public List dimensions() { + return this.dimensions; + } + + /** + * Set the dimensions property: Dimensions considered for spatial aggregation. + * + * @param dimensions the dimensions value to set. + * @return the SpatialAggregation object itself. + */ + public SpatialAggregation withDimensions(List dimensions) { + this.dimensions = dimensions; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeArrayField("dimensions", this.dimensions, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpatialAggregation from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpatialAggregation if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SpatialAggregation. + */ + public static SpatialAggregation fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SpatialAggregation deserializedSpatialAggregation = new SpatialAggregation(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedSpatialAggregation.type = SpatialAggregationType.fromString(reader.getString()); + } else if ("dimensions".equals(fieldName)) { + List dimensions = reader.readArray(reader1 -> reader1.getString()); + deserializedSpatialAggregation.dimensions = dimensions; + } else { + reader.skipChildren(); + } + } + + return deserializedSpatialAggregation; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SpatialAggregationType.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SpatialAggregationType.java new file mode 100644 index 000000000000..afcf1b64afff --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/SpatialAggregationType.java @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines the available spatial aggregation types for aggregating measurements across multiple time series. + */ +public final class SpatialAggregationType extends ExpandableStringEnum { + /** + * Average value. + */ + public static final SpatialAggregationType AVERAGE = fromString("Average"); + + /** + * Minimum value. + */ + public static final SpatialAggregationType MIN = fromString("Min"); + + /** + * Maximum value. + */ + public static final SpatialAggregationType MAX = fromString("Max"); + + /** + * Summation. + */ + public static final SpatialAggregationType SUM = fromString("Sum"); + + /** + * Count of occurrences. + */ + public static final SpatialAggregationType COUNT = fromString("Count"); + + /** + * Creates a new instance of SpatialAggregationType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public SpatialAggregationType() { + } + + /** + * Creates or finds a SpatialAggregationType from its string representation. + * + * @param name a name to look for. + * @return the corresponding SpatialAggregationType. + */ + public static SpatialAggregationType fromString(String name) { + return fromString(name, SpatialAggregationType.class); + } + + /** + * Gets known SpatialAggregationType values. + * + * @return known SpatialAggregationType values. + */ + public static Collection values() { + return values(SpatialAggregationType.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/TemporalAggregation.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/TemporalAggregation.java new file mode 100644 index 000000000000..cc0c4f4d01a9 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/TemporalAggregation.java @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents temporal aggregation settings. + */ +@Fluent +public final class TemporalAggregation implements JsonSerializable { + /* + * Type of temporal aggregation. + */ + private TemporalAggregationType type; + + /* + * Time window size for aggregation, in minutes. + */ + private Integer windowSizeMinutes; + + /** + * Creates an instance of TemporalAggregation class. + */ + public TemporalAggregation() { + } + + /** + * Get the type property: Type of temporal aggregation. + * + * @return the type value. + */ + public TemporalAggregationType type() { + return this.type; + } + + /** + * Set the type property: Type of temporal aggregation. + * + * @param type the type value to set. + * @return the TemporalAggregation object itself. + */ + public TemporalAggregation withType(TemporalAggregationType type) { + this.type = type; + return this; + } + + /** + * Get the windowSizeMinutes property: Time window size for aggregation, in minutes. + * + * @return the windowSizeMinutes value. + */ + public Integer windowSizeMinutes() { + return this.windowSizeMinutes; + } + + /** + * Set the windowSizeMinutes property: Time window size for aggregation, in minutes. + * + * @param windowSizeMinutes the windowSizeMinutes value to set. + * @return the TemporalAggregation object itself. + */ + public TemporalAggregation withWindowSizeMinutes(Integer windowSizeMinutes) { + this.windowSizeMinutes = windowSizeMinutes; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeNumberField("windowSizeMinutes", this.windowSizeMinutes); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TemporalAggregation from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TemporalAggregation if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the TemporalAggregation. + */ + public static TemporalAggregation fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TemporalAggregation deserializedTemporalAggregation = new TemporalAggregation(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedTemporalAggregation.type = TemporalAggregationType.fromString(reader.getString()); + } else if ("windowSizeMinutes".equals(fieldName)) { + deserializedTemporalAggregation.windowSizeMinutes = reader.getNullable(JsonReader::getInt); + } else { + reader.skipChildren(); + } + } + + return deserializedTemporalAggregation; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/TemporalAggregationType.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/TemporalAggregationType.java new file mode 100644 index 000000000000..277388ad7af8 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/TemporalAggregationType.java @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines the available temporal aggregation types for aggregating measurements over a specific time window within the + * same time series. + */ +public final class TemporalAggregationType extends ExpandableStringEnum { + /** + * Average value. + */ + public static final TemporalAggregationType AVERAGE = fromString("Average"); + + /** + * Minimum value. + */ + public static final TemporalAggregationType MIN = fromString("Min"); + + /** + * Maximum value. + */ + public static final TemporalAggregationType MAX = fromString("Max"); + + /** + * Summation. + */ + public static final TemporalAggregationType SUM = fromString("Sum"); + + /** + * Rate over time. + */ + public static final TemporalAggregationType RATE = fromString("Rate"); + + /** + * Instance rate. + */ + public static final TemporalAggregationType IRATE = fromString("IRate"); + + /** + * Delta over time. + */ + public static final TemporalAggregationType DELTA = fromString("Delta"); + + /** + * Instance delta. + */ + public static final TemporalAggregationType IDELTA = fromString("IDelta"); + + /** + * Increase over time. + */ + public static final TemporalAggregationType INCREASE = fromString("Increase"); + + /** + * Creates a new instance of TemporalAggregationType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public TemporalAggregationType() { + } + + /** + * Creates or finds a TemporalAggregationType from its string representation. + * + * @param name a name to look for. + * @return the corresponding TemporalAggregationType. + */ + public static TemporalAggregationType fromString(String name) { + return fromString(name, TemporalAggregationType.class); + } + + /** + * Gets known TemporalAggregationType values. + * + * @return known TemporalAggregationType values. + */ + public static Collection values() { + return values(TemporalAggregationType.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/UserAssignedIdentity.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/UserAssignedIdentity.java new file mode 100644 index 000000000000..a31bf744731f --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/UserAssignedIdentity.java @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * User assigned identity properties. + */ +@Immutable +public final class UserAssignedIdentity implements JsonSerializable { + /* + * The principal ID of the assigned identity. + */ + private String principalId; + + /* + * The client ID of the assigned identity. + */ + private String clientId; + + /** + * Creates an instance of UserAssignedIdentity class. + */ + public UserAssignedIdentity() { + } + + /** + * Get the principalId property: The principal ID of the assigned identity. + * + * @return the principalId value. + */ + public String principalId() { + return this.principalId; + } + + /** + * Get the clientId property: The client ID of the assigned identity. + * + * @return the clientId value. + */ + public String clientId() { + return this.clientId; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UserAssignedIdentity from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UserAssignedIdentity if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the UserAssignedIdentity. + */ + public static UserAssignedIdentity fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UserAssignedIdentity deserializedUserAssignedIdentity = new UserAssignedIdentity(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("principalId".equals(fieldName)) { + deserializedUserAssignedIdentity.principalId = reader.getString(); + } else if ("clientId".equals(fieldName)) { + deserializedUserAssignedIdentity.clientId = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedUserAssignedIdentity; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/WindowUptimeCriteria.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/WindowUptimeCriteria.java new file mode 100644 index 000000000000..950bc19dca62 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/WindowUptimeCriteria.java @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents criteria for determining uptime in window-based SLIs. + */ +@Fluent +public final class WindowUptimeCriteria implements JsonSerializable { + /* + * Threshold value used to determine uptime. + */ + private double target; + + /* + * Comparison operator used for uptime evaluation. + */ + private WindowUptimeCriteriaComparator comparator; + + /** + * Creates an instance of WindowUptimeCriteria class. + */ + public WindowUptimeCriteria() { + } + + /** + * Get the target property: Threshold value used to determine uptime. + * + * @return the target value. + */ + public double target() { + return this.target; + } + + /** + * Set the target property: Threshold value used to determine uptime. + * + * @param target the target value to set. + * @return the WindowUptimeCriteria object itself. + */ + public WindowUptimeCriteria withTarget(double target) { + this.target = target; + return this; + } + + /** + * Get the comparator property: Comparison operator used for uptime evaluation. + * + * @return the comparator value. + */ + public WindowUptimeCriteriaComparator comparator() { + return this.comparator; + } + + /** + * Set the comparator property: Comparison operator used for uptime evaluation. + * + * @param comparator the comparator value to set. + * @return the WindowUptimeCriteria object itself. + */ + public WindowUptimeCriteria withComparator(WindowUptimeCriteriaComparator comparator) { + this.comparator = comparator; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("target", this.target); + jsonWriter.writeStringField("comparator", this.comparator == null ? null : this.comparator.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of WindowUptimeCriteria from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of WindowUptimeCriteria if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the WindowUptimeCriteria. + */ + public static WindowUptimeCriteria fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + WindowUptimeCriteria deserializedWindowUptimeCriteria = new WindowUptimeCriteria(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("target".equals(fieldName)) { + deserializedWindowUptimeCriteria.target = reader.getDouble(); + } else if ("comparator".equals(fieldName)) { + deserializedWindowUptimeCriteria.comparator + = WindowUptimeCriteriaComparator.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedWindowUptimeCriteria; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/WindowUptimeCriteriaComparator.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/WindowUptimeCriteriaComparator.java new file mode 100644 index 000000000000..0e13d5709c17 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/WindowUptimeCriteriaComparator.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines comparison operators for window uptime criteria. + */ +public final class WindowUptimeCriteriaComparator extends ExpandableStringEnum { + /** + * Less than the target value. + */ + public static final WindowUptimeCriteriaComparator LESS_THAN = fromString("<"); + + /** + * Greater than the target value. + */ + public static final WindowUptimeCriteriaComparator GREATER_THAN = fromString(">"); + + /** + * Less than or equal to the target value. + */ + public static final WindowUptimeCriteriaComparator LESS_THAN_OR_EQUAL = fromString("<="); + + /** + * Greater than or equal to the target value. + */ + public static final WindowUptimeCriteriaComparator GREATER_THAN_OR_EQUAL = fromString(">="); + + /** + * Creates a new instance of WindowUptimeCriteriaComparator value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public WindowUptimeCriteriaComparator() { + } + + /** + * Creates or finds a WindowUptimeCriteriaComparator from its string representation. + * + * @param name a name to look for. + * @return the corresponding WindowUptimeCriteriaComparator. + */ + public static WindowUptimeCriteriaComparator fromString(String name) { + return fromString(name, WindowUptimeCriteriaComparator.class); + } + + /** + * Gets known WindowUptimeCriteriaComparator values. + * + * @return known WindowUptimeCriteriaComparator values. + */ + public static Collection values() { + return values(WindowUptimeCriteriaComparator.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/package-info.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/package-info.java new file mode 100644 index 000000000000..fbea1bd2e68a --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/models/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for SlisManagementClient. + */ +package com.azure.resourcemanager.monitor.slis.models; diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/package-info.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/package-info.java new file mode 100644 index 000000000000..cbdaf8b2354e --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/com/azure/resourcemanager/monitor/slis/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for SlisManagementClient. + */ +package com.azure.resourcemanager.monitor.slis; diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/module-info.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/module-info.java new file mode 100644 index 000000000000..ea4862ecbc58 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/java/module-info.java @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +module com.azure.resourcemanager.monitor.slis { + requires transitive com.azure.core.management; + + exports com.azure.resourcemanager.monitor.slis; + exports com.azure.resourcemanager.monitor.slis.fluent; + exports com.azure.resourcemanager.monitor.slis.fluent.models; + exports com.azure.resourcemanager.monitor.slis.models; + + opens com.azure.resourcemanager.monitor.slis.fluent.models to com.azure.core; + opens com.azure.resourcemanager.monitor.slis.models to com.azure.core; + opens com.azure.resourcemanager.monitor.slis.implementation.models to com.azure.core; +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/META-INF/azure-resourcemanager-monitor-slis_metadata.json b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/META-INF/azure-resourcemanager-monitor-slis_metadata.json new file mode 100644 index 000000000000..5e94dcb485a5 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/META-INF/azure-resourcemanager-monitor-slis_metadata.json @@ -0,0 +1 @@ +{"flavor":"azure","apiVersions":{"Microsoft.Monitor":"2025-03-01-preview"},"crossLanguageDefinitions":{"com.azure.resourcemanager.monitor.slis.fluent.SlisClient":"Microsoft.Monitor.Slis","com.azure.resourcemanager.monitor.slis.fluent.SlisClient.createOrUpdate":"Microsoft.Monitor.Slis.createOrUpdate","com.azure.resourcemanager.monitor.slis.fluent.SlisClient.createOrUpdateWithResponse":"Microsoft.Monitor.Slis.createOrUpdate","com.azure.resourcemanager.monitor.slis.fluent.SlisClient.delete":"Microsoft.Monitor.Slis.delete","com.azure.resourcemanager.monitor.slis.fluent.SlisClient.deleteWithResponse":"Microsoft.Monitor.Slis.delete","com.azure.resourcemanager.monitor.slis.fluent.SlisClient.get":"Microsoft.Monitor.Slis.get","com.azure.resourcemanager.monitor.slis.fluent.SlisClient.getWithResponse":"Microsoft.Monitor.Slis.get","com.azure.resourcemanager.monitor.slis.fluent.SlisClient.listByParent":"Microsoft.Monitor.Slis.listByParent","com.azure.resourcemanager.monitor.slis.fluent.SlisManagementClient":"Microsoft.Monitor","com.azure.resourcemanager.monitor.slis.fluent.models.SliInner":"Microsoft.Monitor.Sli","com.azure.resourcemanager.monitor.slis.implementation.SlisManagementClientBuilder":"Microsoft.Monitor","com.azure.resourcemanager.monitor.slis.implementation.models.SliListResult":"Azure.ResourceManager.ResourceListResult","com.azure.resourcemanager.monitor.slis.models.AmwAccount":"Microsoft.Monitor.AmwAccount","com.azure.resourcemanager.monitor.slis.models.Baseline":"Microsoft.Monitor.Baseline","com.azure.resourcemanager.monitor.slis.models.BaselineProperties":"Microsoft.Monitor.BaselineProperties","com.azure.resourcemanager.monitor.slis.models.Category":"Microsoft.Monitor.Category","com.azure.resourcemanager.monitor.slis.models.Condition":"Microsoft.Monitor.Condition","com.azure.resourcemanager.monitor.slis.models.ConditionOperator":"Microsoft.Monitor.ConditionOperator","com.azure.resourcemanager.monitor.slis.models.EvaluationCalculationType":"Microsoft.Monitor.EvaluationCalculationType","com.azure.resourcemanager.monitor.slis.models.EvaluationType":"Microsoft.Monitor.EvaluationType","com.azure.resourcemanager.monitor.slis.models.ExecutionState":"Microsoft.Monitor.ExecutionState","com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentity":"Azure.ResourceManager.CommonTypes.ManagedServiceIdentity","com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentityType":"Azure.ResourceManager.CommonTypes.ManagedServiceIdentityType","com.azure.resourcemanager.monitor.slis.models.Metric":"Microsoft.Monitor.Metric","com.azure.resourcemanager.monitor.slis.models.ProvisioningState":"Microsoft.Monitor.ProvisioningState","com.azure.resourcemanager.monitor.slis.models.SamplingType":"Microsoft.Monitor.SamplingType","com.azure.resourcemanager.monitor.slis.models.ScalarFunction":"Microsoft.Monitor.ScalarFunction","com.azure.resourcemanager.monitor.slis.models.Signal":"Microsoft.Monitor.Signal","com.azure.resourcemanager.monitor.slis.models.SignalSource":"Microsoft.Monitor.SignalSource","com.azure.resourcemanager.monitor.slis.models.SliProperties":"Microsoft.Monitor.SliProperties","com.azure.resourcemanager.monitor.slis.models.SliResource":"Microsoft.Monitor.SliResource","com.azure.resourcemanager.monitor.slis.models.SpatialAggregation":"Microsoft.Monitor.SpatialAggregation","com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType":"Microsoft.Monitor.SpatialAggregationType","com.azure.resourcemanager.monitor.slis.models.TemporalAggregation":"Microsoft.Monitor.TemporalAggregation","com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType":"Microsoft.Monitor.TemporalAggregationType","com.azure.resourcemanager.monitor.slis.models.UserAssignedIdentity":"Azure.ResourceManager.CommonTypes.UserAssignedIdentity","com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteria":"Microsoft.Monitor.WindowUptimeCriteria","com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteriaComparator":"Microsoft.Monitor.WindowUptimeCriteriaComparator"},"generatedFiles":["src/main/java/com/azure/resourcemanager/monitor/slis/SlisManager.java","src/main/java/com/azure/resourcemanager/monitor/slis/fluent/SlisClient.java","src/main/java/com/azure/resourcemanager/monitor/slis/fluent/SlisManagementClient.java","src/main/java/com/azure/resourcemanager/monitor/slis/fluent/models/SliInner.java","src/main/java/com/azure/resourcemanager/monitor/slis/fluent/models/package-info.java","src/main/java/com/azure/resourcemanager/monitor/slis/fluent/package-info.java","src/main/java/com/azure/resourcemanager/monitor/slis/implementation/ResourceManagerUtils.java","src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SliImpl.java","src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisClientImpl.java","src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisImpl.java","src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisManagementClientBuilder.java","src/main/java/com/azure/resourcemanager/monitor/slis/implementation/SlisManagementClientImpl.java","src/main/java/com/azure/resourcemanager/monitor/slis/implementation/models/SliListResult.java","src/main/java/com/azure/resourcemanager/monitor/slis/implementation/package-info.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/AmwAccount.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/Baseline.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/BaselineProperties.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/Category.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/Condition.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/ConditionOperator.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/EvaluationCalculationType.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/EvaluationType.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/ExecutionState.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/ManagedServiceIdentity.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/ManagedServiceIdentityType.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/Metric.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/ProvisioningState.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/SamplingType.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/ScalarFunction.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/Signal.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/SignalSource.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/Sli.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/SliProperties.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/SliResource.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/Slis.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/SpatialAggregation.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/SpatialAggregationType.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/TemporalAggregation.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/TemporalAggregationType.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/UserAssignedIdentity.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/WindowUptimeCriteria.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/WindowUptimeCriteriaComparator.java","src/main/java/com/azure/resourcemanager/monitor/slis/models/package-info.java","src/main/java/com/azure/resourcemanager/monitor/slis/package-info.java","src/main/java/module-info.java"]} \ No newline at end of file diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-slis/proxy-config.json b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-slis/proxy-config.json new file mode 100644 index 000000000000..d7da7e9b3915 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-slis/proxy-config.json @@ -0,0 +1 @@ +[["com.azure.resourcemanager.monitor.slis.implementation.SlisClientImpl$SlisService"]] \ No newline at end of file diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-slis/reflect-config.json b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-slis/reflect-config.json new file mode 100644 index 000000000000..0637a088a01e --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-slis/reflect-config.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/azure-resourcemanager-monitor-slis.properties b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/azure-resourcemanager-monitor-slis.properties new file mode 100644 index 000000000000..defbd48204e4 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/main/resources/azure-resourcemanager-monitor-slis.properties @@ -0,0 +1 @@ +version=${project.version} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisCreateOrUpdateSamples.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisCreateOrUpdateSamples.java new file mode 100644 index 000000000000..db27ed508ffc --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisCreateOrUpdateSamples.java @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.resourcemanager.monitor.slis.fluent.models.SliInner; +import com.azure.resourcemanager.monitor.slis.models.AmwAccount; +import com.azure.resourcemanager.monitor.slis.models.Baseline; +import com.azure.resourcemanager.monitor.slis.models.BaselineProperties; +import com.azure.resourcemanager.monitor.slis.models.Category; +import com.azure.resourcemanager.monitor.slis.models.Condition; +import com.azure.resourcemanager.monitor.slis.models.ConditionOperator; +import com.azure.resourcemanager.monitor.slis.models.EvaluationCalculationType; +import com.azure.resourcemanager.monitor.slis.models.EvaluationType; +import com.azure.resourcemanager.monitor.slis.models.Signal; +import com.azure.resourcemanager.monitor.slis.models.SignalSource; +import com.azure.resourcemanager.monitor.slis.models.SliProperties; +import com.azure.resourcemanager.monitor.slis.models.SliResource; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregation; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregation; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteria; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteriaComparator; +import java.util.Arrays; + +/** + * Samples for Slis CreateOrUpdate. + */ +public final class SlisCreateOrUpdateSamples { + /* + * x-ms-original-file: 2025-03-01-preview/Slis_CreateOrUpdate.json + */ + /** + * Sample code: CreateSli. + * + * @param manager Entry point to SlisManager. + */ + public static void createSli(com.azure.resourcemanager.monitor.slis.SlisManager manager) { + manager.slis() + .createOrUpdateWithResponse("testSG", "testSli", new SliInner().withProperties(new SliResource() + .withDescription("Measures the performance characteristics of the GetContosoUsers() API. ") + .withCategory(Category.LATENCY) + .withEvaluationType(EvaluationType.WINDOW_BASED) + .withDestinationAmwAccounts(Arrays.asList(new AmwAccount() + .withResourceId( + "/subscriptions//resourcegroups//providers/microsoft.monitor/accounts/") + .withIdentity( + "/subscriptions//resourcegroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/"))) + .withBaselineProperties(new BaselineProperties().withBaseline(new Baseline().withValue(99.0) + .withEvaluationPeriodDays(30) + .withEvaluationCalculationType(EvaluationCalculationType.CALENDAR_DAYS))) + .withEnableAlert(true) + .withSliProperties(new SliProperties().withSignals(new Signal().withSignalSources(Arrays.asList( + new SignalSource().withSignalSourceId("A") + .withSourceAmwAccountManagedIdentity( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity") + .withSourceAmwAccountResourceId( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/microsoft.monitor/accounts/myAccount") + .withMetricNamespace("ContosoMetricsWest") + .withMetricName("Stamp1Latency") + .withFilters(Arrays.asList(new Condition().withDimensionName("ApiName") + .withOperator(ConditionOperator.EQUAL) + .withValue("GetContosoUsers"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.AVERAGE) + .withDimensions(Arrays.asList("Region", "ResponseCode"))) + .withTemporalAggregation(new TemporalAggregation().withType(TemporalAggregationType.AVERAGE) + .withWindowSizeMinutes(5)), + new SignalSource().withSignalSourceId("B") + .withSourceAmwAccountManagedIdentity( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity") + .withSourceAmwAccountResourceId( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/microsoft.monitor/accounts/myAccount") + .withMetricNamespace("ContosoMetricsEast") + .withMetricName("Stamp2Latency") + .withFilters(Arrays.asList(new Condition().withDimensionName("ApiName") + .withOperator(ConditionOperator.EQUAL) + .withValue("GetContosoUsers"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.AVERAGE) + .withDimensions(Arrays.asList("Region", "ResponseCode"))) + .withTemporalAggregation(new TemporalAggregation().withType(TemporalAggregationType.AVERAGE) + .withWindowSizeMinutes(5)))) + .withSignalFormula("(A + B) /2")) + .withWindowUptimeCriteria(new WindowUptimeCriteria().withTarget(95.0) + .withComparator(WindowUptimeCriteriaComparator.GREATER_THAN_OR_EQUAL)))), + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisDeleteSamples.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisDeleteSamples.java new file mode 100644 index 000000000000..211731845048 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisDeleteSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +/** + * Samples for Slis Delete. + */ +public final class SlisDeleteSamples { + /* + * x-ms-original-file: 2025-03-01-preview/Slis_Delete.json + */ + /** + * Sample code: DeleteSli. + * + * @param manager Entry point to SlisManager. + */ + public static void deleteSli(com.azure.resourcemanager.monitor.slis.SlisManager manager) { + manager.slis().deleteByResourceGroupWithResponse("testSG", "testSli", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisGetSamples.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisGetSamples.java new file mode 100644 index 000000000000..828f4169edcc --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisGetSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +/** + * Samples for Slis Get. + */ +public final class SlisGetSamples { + /* + * x-ms-original-file: 2025-03-01-preview/Slis_Get.json + */ + /** + * Sample code: GetSli. + * + * @param manager Entry point to SlisManager. + */ + public static void getSli(com.azure.resourcemanager.monitor.slis.SlisManager manager) { + manager.slis().getWithResponse("testSG", "testSli", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisListByParentSamples.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisListByParentSamples.java new file mode 100644 index 000000000000..bdb6397371cf --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/samples/java/com/azure/resourcemanager/monitor/slis/generated/SlisListByParentSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +/** + * Samples for Slis ListByParent. + */ +public final class SlisListByParentSamples { + /* + * x-ms-original-file: 2025-03-01-preview/Slis_ListByParent.json + */ + /** + * Sample code: SlisListByParent. + * + * @param manager Entry point to SlisManager. + */ + public static void slisListByParent(com.azure.resourcemanager.monitor.slis.SlisManager manager) { + manager.slis().listByParent("testSG", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/AmwAccountTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/AmwAccountTests.java new file mode 100644 index 000000000000..383c615b1a13 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/AmwAccountTests.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.AmwAccount; +import org.junit.jupiter.api.Assertions; + +public final class AmwAccountTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + AmwAccount model + = BinaryData.fromString("{\"resourceId\":\"mcy\",\"identity\":\"pwlbjnpg\"}").toObject(AmwAccount.class); + Assertions.assertEquals("mcy", model.resourceId()); + Assertions.assertEquals("pwlbjnpg", model.identity()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + AmwAccount model = new AmwAccount().withResourceId("mcy").withIdentity("pwlbjnpg"); + model = BinaryData.fromObject(model).toObject(AmwAccount.class); + Assertions.assertEquals("mcy", model.resourceId()); + Assertions.assertEquals("pwlbjnpg", model.identity()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/BaselinePropertiesTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/BaselinePropertiesTests.java new file mode 100644 index 000000000000..29f242b13839 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/BaselinePropertiesTests.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.Baseline; +import com.azure.resourcemanager.monitor.slis.models.BaselineProperties; +import com.azure.resourcemanager.monitor.slis.models.EvaluationCalculationType; +import org.junit.jupiter.api.Assertions; + +public final class BaselinePropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + BaselineProperties model = BinaryData.fromString( + "{\"baseline\":{\"value\":42.583161707778174,\"evaluationPeriodDays\":317621756,\"evaluationCalculationType\":\"CalendarDays\"}}") + .toObject(BaselineProperties.class); + Assertions.assertEquals(42.583161707778174, model.baseline().value()); + Assertions.assertEquals(317621756, model.baseline().evaluationPeriodDays()); + Assertions.assertEquals(EvaluationCalculationType.CALENDAR_DAYS, model.baseline().evaluationCalculationType()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + BaselineProperties model = new BaselineProperties().withBaseline(new Baseline().withValue(42.583161707778174) + .withEvaluationPeriodDays(317621756) + .withEvaluationCalculationType(EvaluationCalculationType.CALENDAR_DAYS)); + model = BinaryData.fromObject(model).toObject(BaselineProperties.class); + Assertions.assertEquals(42.583161707778174, model.baseline().value()); + Assertions.assertEquals(317621756, model.baseline().evaluationPeriodDays()); + Assertions.assertEquals(EvaluationCalculationType.CALENDAR_DAYS, model.baseline().evaluationCalculationType()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/BaselineTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/BaselineTests.java new file mode 100644 index 000000000000..9a23cd179fa9 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/BaselineTests.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.Baseline; +import com.azure.resourcemanager.monitor.slis.models.EvaluationCalculationType; +import org.junit.jupiter.api.Assertions; + +public final class BaselineTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + Baseline model = BinaryData.fromString( + "{\"value\":13.988969723738675,\"evaluationPeriodDays\":1696341054,\"evaluationCalculationType\":\"RollingDays\"}") + .toObject(Baseline.class); + Assertions.assertEquals(13.988969723738675, model.value()); + Assertions.assertEquals(1696341054, model.evaluationPeriodDays()); + Assertions.assertEquals(EvaluationCalculationType.ROLLING_DAYS, model.evaluationCalculationType()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + Baseline model = new Baseline().withValue(13.988969723738675) + .withEvaluationPeriodDays(1696341054) + .withEvaluationCalculationType(EvaluationCalculationType.ROLLING_DAYS); + model = BinaryData.fromObject(model).toObject(Baseline.class); + Assertions.assertEquals(13.988969723738675, model.value()); + Assertions.assertEquals(1696341054, model.evaluationPeriodDays()); + Assertions.assertEquals(EvaluationCalculationType.ROLLING_DAYS, model.evaluationCalculationType()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/ConditionTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/ConditionTests.java new file mode 100644 index 000000000000..57a17e5ab01c --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/ConditionTests.java @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.Condition; +import com.azure.resourcemanager.monitor.slis.models.ConditionOperator; +import com.azure.resourcemanager.monitor.slis.models.SamplingType; +import com.azure.resourcemanager.monitor.slis.models.ScalarFunction; +import org.junit.jupiter.api.Assertions; + +public final class ConditionTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + Condition model = BinaryData.fromString( + "{\"dimensionName\":\"fssxqukkfplg\",\"scalarFunction\":\"sum\",\"samplingType\":\"sum\",\"operator\":\"!startswith\",\"value\":\"jzkdeslpvlopwi\"}") + .toObject(Condition.class); + Assertions.assertEquals("fssxqukkfplg", model.dimensionName()); + Assertions.assertEquals(ScalarFunction.SUM, model.scalarFunction()); + Assertions.assertEquals(SamplingType.SUM, model.samplingType()); + Assertions.assertEquals(ConditionOperator.NOT_STARTS_WITH, model.operator()); + Assertions.assertEquals("jzkdeslpvlopwi", model.value()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + Condition model = new Condition().withDimensionName("fssxqukkfplg") + .withScalarFunction(ScalarFunction.SUM) + .withSamplingType(SamplingType.SUM) + .withOperator(ConditionOperator.NOT_STARTS_WITH) + .withValue("jzkdeslpvlopwi"); + model = BinaryData.fromObject(model).toObject(Condition.class); + Assertions.assertEquals("fssxqukkfplg", model.dimensionName()); + Assertions.assertEquals(ScalarFunction.SUM, model.scalarFunction()); + Assertions.assertEquals(SamplingType.SUM, model.samplingType()); + Assertions.assertEquals(ConditionOperator.NOT_STARTS_WITH, model.operator()); + Assertions.assertEquals("jzkdeslpvlopwi", model.value()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/ExecutionStateTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/ExecutionStateTests.java new file mode 100644 index 000000000000..0745d247f989 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/ExecutionStateTests.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.ExecutionState; +import org.junit.jupiter.api.Assertions; + +public final class ExecutionStateTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + ExecutionState model + = BinaryData.fromString("{\"state\":\"v\",\"message\":\"dgwdslfhot\"}").toObject(ExecutionState.class); + Assertions.assertEquals("v", model.state()); + Assertions.assertEquals("dgwdslfhot", model.message()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/ManagedServiceIdentityTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/ManagedServiceIdentityTests.java new file mode 100644 index 000000000000..d3c956994582 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/ManagedServiceIdentityTests.java @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.slis.models.UserAssignedIdentity; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class ManagedServiceIdentityTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + ManagedServiceIdentity model = BinaryData.fromString( + "{\"principalId\":\"m\",\"tenantId\":\"qupedeojnab\",\"type\":\"UserAssigned\",\"userAssignedIdentities\":{\"krdqmh\":{\"principalId\":\"txp\",\"clientId\":\"ebtfhvpesap\"},\"scwsv\":{\"principalId\":\"dhtldwkyz\",\"clientId\":\"utknc\"},\"kvceoveilovnotyf\":{\"principalId\":\"otogtwrupqs\",\"clientId\":\"nmic\"}}}") + .toObject(ManagedServiceIdentity.class); + Assertions.assertEquals(ManagedServiceIdentityType.USER_ASSIGNED, model.type()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + ManagedServiceIdentity model = new ManagedServiceIdentity().withType(ManagedServiceIdentityType.USER_ASSIGNED) + .withUserAssignedIdentities(mapOf("krdqmh", new UserAssignedIdentity(), "scwsv", new UserAssignedIdentity(), + "kvceoveilovnotyf", new UserAssignedIdentity())); + model = BinaryData.fromObject(model).toObject(ManagedServiceIdentity.class); + Assertions.assertEquals(ManagedServiceIdentityType.USER_ASSIGNED, model.type()); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/MetricTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/MetricTests.java new file mode 100644 index 000000000000..4ceee66c431a --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/MetricTests.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.Metric; +import org.junit.jupiter.api.Assertions; + +public final class MetricTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + Metric model = BinaryData.fromString("{\"metricNamespace\":\"cftadeh\",\"metricName\":\"nltyfsoppusuesnz\"}") + .toObject(Metric.class); + Assertions.assertEquals("cftadeh", model.metricNamespace()); + Assertions.assertEquals("nltyfsoppusuesnz", model.metricName()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SignalSourceTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SignalSourceTests.java new file mode 100644 index 000000000000..ba53ada72045 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SignalSourceTests.java @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.Condition; +import com.azure.resourcemanager.monitor.slis.models.ConditionOperator; +import com.azure.resourcemanager.monitor.slis.models.SamplingType; +import com.azure.resourcemanager.monitor.slis.models.ScalarFunction; +import com.azure.resourcemanager.monitor.slis.models.SignalSource; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregation; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregation; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class SignalSourceTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SignalSource model = BinaryData.fromString( + "{\"signalSourceId\":\"bxu\",\"sourceAmwAccountManagedIdentity\":\"wbhqwal\",\"sourceAmwAccountResourceId\":\"uzyoxaep\",\"metricNamespace\":\"kzjancuxrhdwbav\",\"metricName\":\"bniwdj\",\"filters\":[{\"dimensionName\":\"tsdbpgn\",\"scalarFunction\":\"max\",\"samplingType\":\"avg\",\"operator\":\"!in\",\"value\":\"zxbzpfzabglc\"}],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[\"wtctyqi\",\"lbbovplw\",\"bhvgy\",\"gu\"]},\"temporalAggregation\":{\"type\":\"Delta\",\"windowSizeMinutes\":1732351990}}") + .toObject(SignalSource.class); + Assertions.assertEquals("bxu", model.signalSourceId()); + Assertions.assertEquals("wbhqwal", model.sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("uzyoxaep", model.sourceAmwAccountResourceId()); + Assertions.assertEquals("kzjancuxrhdwbav", model.metricNamespace()); + Assertions.assertEquals("bniwdj", model.metricName()); + Assertions.assertEquals("tsdbpgn", model.filters().get(0).dimensionName()); + Assertions.assertEquals(ScalarFunction.MAX, model.filters().get(0).scalarFunction()); + Assertions.assertEquals(SamplingType.AVG, model.filters().get(0).samplingType()); + Assertions.assertEquals(ConditionOperator.NOT_IN, model.filters().get(0).operator()); + Assertions.assertEquals("zxbzpfzabglc", model.filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.AVERAGE, model.spatialAggregation().type()); + Assertions.assertEquals("wtctyqi", model.spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.DELTA, model.temporalAggregation().type()); + Assertions.assertEquals(1732351990, model.temporalAggregation().windowSizeMinutes()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + SignalSource model = new SignalSource().withSignalSourceId("bxu") + .withSourceAmwAccountManagedIdentity("wbhqwal") + .withSourceAmwAccountResourceId("uzyoxaep") + .withMetricNamespace("kzjancuxrhdwbav") + .withMetricName("bniwdj") + .withFilters(Arrays.asList(new Condition().withDimensionName("tsdbpgn") + .withScalarFunction(ScalarFunction.MAX) + .withSamplingType(SamplingType.AVG) + .withOperator(ConditionOperator.NOT_IN) + .withValue("zxbzpfzabglc"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.AVERAGE) + .withDimensions(Arrays.asList("wtctyqi", "lbbovplw", "bhvgy", "gu"))) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.DELTA).withWindowSizeMinutes(1732351990)); + model = BinaryData.fromObject(model).toObject(SignalSource.class); + Assertions.assertEquals("bxu", model.signalSourceId()); + Assertions.assertEquals("wbhqwal", model.sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("uzyoxaep", model.sourceAmwAccountResourceId()); + Assertions.assertEquals("kzjancuxrhdwbav", model.metricNamespace()); + Assertions.assertEquals("bniwdj", model.metricName()); + Assertions.assertEquals("tsdbpgn", model.filters().get(0).dimensionName()); + Assertions.assertEquals(ScalarFunction.MAX, model.filters().get(0).scalarFunction()); + Assertions.assertEquals(SamplingType.AVG, model.filters().get(0).samplingType()); + Assertions.assertEquals(ConditionOperator.NOT_IN, model.filters().get(0).operator()); + Assertions.assertEquals("zxbzpfzabglc", model.filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.AVERAGE, model.spatialAggregation().type()); + Assertions.assertEquals("wtctyqi", model.spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.DELTA, model.temporalAggregation().type()); + Assertions.assertEquals(1732351990, model.temporalAggregation().windowSizeMinutes()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SignalTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SignalTests.java new file mode 100644 index 000000000000..4f768ffca48a --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SignalTests.java @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.Condition; +import com.azure.resourcemanager.monitor.slis.models.ConditionOperator; +import com.azure.resourcemanager.monitor.slis.models.SamplingType; +import com.azure.resourcemanager.monitor.slis.models.ScalarFunction; +import com.azure.resourcemanager.monitor.slis.models.Signal; +import com.azure.resourcemanager.monitor.slis.models.SignalSource; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregation; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregation; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class SignalTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + Signal model = BinaryData.fromString( + "{\"signalSources\":[{\"signalSourceId\":\"jhtxfvgxbfsmxne\",\"sourceAmwAccountManagedIdentity\":\"mpvecxgodebfqk\",\"sourceAmwAccountResourceId\":\"rbmpukgri\",\"metricNamespace\":\"flz\",\"metricName\":\"fbxzpuzycisp\",\"filters\":[{\"dimensionName\":\"ahmgkbrp\",\"scalarFunction\":\"min\",\"samplingType\":\"avg\",\"operator\":\"startswith\",\"value\":\"nuqqkpikadrgvt\"},{\"dimensionName\":\"gnbuy\",\"scalarFunction\":\"avg\",\"samplingType\":\"max\",\"operator\":\"contains\",\"value\":\"mebf\"},{\"dimensionName\":\"arbu\",\"scalarFunction\":\"sum\",\"samplingType\":\"min\",\"operator\":\"!contains\",\"value\":\"azzmhjrunmpxt\"}],\"spatialAggregation\":{\"type\":\"Sum\",\"dimensions\":[\"hrbnlankxmyskpbh\"]},\"temporalAggregation\":{\"type\":\"Sum\",\"windowSizeMinutes\":1326044907}},{\"signalSourceId\":\"kcxywnyt\",\"sourceAmwAccountManagedIdentity\":\"rsyn\",\"sourceAmwAccountResourceId\":\"qidybyx\",\"metricNamespace\":\"zfcl\",\"metricName\":\"aaxdbabphlwrq\",\"filters\":[{\"dimensionName\":\"tsthsucocm\",\"scalarFunction\":\"sum\",\"samplingType\":\"max\",\"operator\":\"!=\",\"value\":\"t\"}],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[\"wrqpue\"]},\"temporalAggregation\":{\"type\":\"Max\",\"windowSizeMinutes\":1618897040}}],\"signalFormula\":\"ywbiexzfeyueax\"}") + .toObject(Signal.class); + Assertions.assertEquals("jhtxfvgxbfsmxne", model.signalSources().get(0).signalSourceId()); + Assertions.assertEquals("mpvecxgodebfqk", model.signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("rbmpukgri", model.signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("flz", model.signalSources().get(0).metricNamespace()); + Assertions.assertEquals("fbxzpuzycisp", model.signalSources().get(0).metricName()); + Assertions.assertEquals("ahmgkbrp", model.signalSources().get(0).filters().get(0).dimensionName()); + Assertions.assertEquals(ScalarFunction.MIN, model.signalSources().get(0).filters().get(0).scalarFunction()); + Assertions.assertEquals(SamplingType.AVG, model.signalSources().get(0).filters().get(0).samplingType()); + Assertions.assertEquals(ConditionOperator.STARTS_WITH, + model.signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("nuqqkpikadrgvt", model.signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.SUM, model.signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("hrbnlankxmyskpbh", + model.signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.SUM, model.signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(1326044907, model.signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("ywbiexzfeyueax", model.signalFormula()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + Signal model = new Signal().withSignalSources(Arrays.asList( + new SignalSource().withSignalSourceId("jhtxfvgxbfsmxne") + .withSourceAmwAccountManagedIdentity("mpvecxgodebfqk") + .withSourceAmwAccountResourceId("rbmpukgri") + .withMetricNamespace("flz") + .withMetricName("fbxzpuzycisp") + .withFilters(Arrays.asList( + new Condition().withDimensionName("ahmgkbrp") + .withScalarFunction(ScalarFunction.MIN) + .withSamplingType(SamplingType.AVG) + .withOperator(ConditionOperator.STARTS_WITH) + .withValue("nuqqkpikadrgvt"), + new Condition().withDimensionName("gnbuy") + .withScalarFunction(ScalarFunction.AVG) + .withSamplingType(SamplingType.MAX) + .withOperator(ConditionOperator.CONTAINS) + .withValue("mebf"), + new Condition().withDimensionName("arbu") + .withScalarFunction(ScalarFunction.SUM) + .withSamplingType(SamplingType.MIN) + .withOperator(ConditionOperator.NOT_CONTAINS) + .withValue("azzmhjrunmpxt"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.SUM) + .withDimensions(Arrays.asList("hrbnlankxmyskpbh"))) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.SUM).withWindowSizeMinutes(1326044907)), + new SignalSource().withSignalSourceId("kcxywnyt") + .withSourceAmwAccountManagedIdentity("rsyn") + .withSourceAmwAccountResourceId("qidybyx") + .withMetricNamespace("zfcl") + .withMetricName("aaxdbabphlwrq") + .withFilters(Arrays.asList(new Condition().withDimensionName("tsthsucocm") + .withScalarFunction(ScalarFunction.SUM) + .withSamplingType(SamplingType.MAX) + .withOperator(ConditionOperator.NOT_EQUAL) + .withValue("t"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.COUNT) + .withDimensions(Arrays.asList("wrqpue"))) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.MAX).withWindowSizeMinutes(1618897040)))) + .withSignalFormula("ywbiexzfeyueax"); + model = BinaryData.fromObject(model).toObject(Signal.class); + Assertions.assertEquals("jhtxfvgxbfsmxne", model.signalSources().get(0).signalSourceId()); + Assertions.assertEquals("mpvecxgodebfqk", model.signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("rbmpukgri", model.signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("flz", model.signalSources().get(0).metricNamespace()); + Assertions.assertEquals("fbxzpuzycisp", model.signalSources().get(0).metricName()); + Assertions.assertEquals("ahmgkbrp", model.signalSources().get(0).filters().get(0).dimensionName()); + Assertions.assertEquals(ScalarFunction.MIN, model.signalSources().get(0).filters().get(0).scalarFunction()); + Assertions.assertEquals(SamplingType.AVG, model.signalSources().get(0).filters().get(0).samplingType()); + Assertions.assertEquals(ConditionOperator.STARTS_WITH, + model.signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("nuqqkpikadrgvt", model.signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.SUM, model.signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("hrbnlankxmyskpbh", + model.signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.SUM, model.signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(1326044907, model.signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("ywbiexzfeyueax", model.signalFormula()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliInnerTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliInnerTests.java new file mode 100644 index 000000000000..77e756bd3111 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliInnerTests.java @@ -0,0 +1,390 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.fluent.models.SliInner; +import com.azure.resourcemanager.monitor.slis.models.AmwAccount; +import com.azure.resourcemanager.monitor.slis.models.Baseline; +import com.azure.resourcemanager.monitor.slis.models.BaselineProperties; +import com.azure.resourcemanager.monitor.slis.models.Category; +import com.azure.resourcemanager.monitor.slis.models.Condition; +import com.azure.resourcemanager.monitor.slis.models.ConditionOperator; +import com.azure.resourcemanager.monitor.slis.models.EvaluationCalculationType; +import com.azure.resourcemanager.monitor.slis.models.EvaluationType; +import com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.slis.models.Signal; +import com.azure.resourcemanager.monitor.slis.models.SignalSource; +import com.azure.resourcemanager.monitor.slis.models.SliProperties; +import com.azure.resourcemanager.monitor.slis.models.SliResource; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregation; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregation; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType; +import com.azure.resourcemanager.monitor.slis.models.UserAssignedIdentity; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteria; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteriaComparator; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class SliInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SliInner model = BinaryData.fromString( + "{\"properties\":{\"provisioningState\":\"Succeeded\",\"description\":\"quvgjxpybczme\",\"category\":\"Availability\",\"evaluationType\":\"RequestBased\",\"executionState\":{\"state\":\"opb\",\"message\":\"h\"},\"destinationAmwAccounts\":[{\"resourceId\":\"pidgsybbejhphoyc\",\"identity\":\"sx\"}],\"destinationMetrics\":[{\"metricNamespace\":\"hdxbmtqio\",\"metricName\":\"jzehtb\"},{\"metricNamespace\":\"ufpo\",\"metricName\":\"noi\"}],\"baselineProperties\":{\"baseline\":{\"value\":28.301840077728546,\"evaluationPeriodDays\":4771592,\"evaluationCalculationType\":\"CalendarDays\"}},\"streamingRuleId\":\"ybqsoqijg\",\"streamingRuleLastUpdatedTimestamp\":\"2021-10-01T09:23:29Z\",\"enableAlert\":true,\"sliProperties\":{\"goodSignals\":{\"signalSources\":[{\"signalSourceId\":\"zlobcufpd\",\"sourceAmwAccountManagedIdentity\":\"nrbtcqqjnq\",\"sourceAmwAccountResourceId\":\"lhqgnufooojy\",\"metricNamespace\":\"ifsqesaagdfmg\",\"metricName\":\"zlhjxrifkwmrvkt\",\"filters\":[{\"operator\":\"<\",\"value\":\"nt\"},{\"operator\":\"==\",\"value\":\"ipa\"},{\"operator\":\"startswith\",\"value\":\"ajpsquc\"}],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Rate\"}},{\"signalSourceId\":\"yf\",\"sourceAmwAccountManagedIdentity\":\"kfo\",\"sourceAmwAccountResourceId\":\"knygjofjddeq\",\"metricNamespace\":\"rd\",\"metricName\":\"upewnwreitjzy\",\"filters\":[{\"operator\":\"!contains\",\"value\":\"sarhmofc\"},{\"operator\":\">\",\"value\":\"smy\"}],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Average\"}},{\"signalSourceId\":\"dtmlxhekuksjt\",\"sourceAmwAccountManagedIdentity\":\"ukcdmparcryuanzw\",\"sourceAmwAccountResourceId\":\"xzdxtayrlhmwh\",\"metricNamespace\":\"pmrqobm\",\"metricName\":\"u\",\"filters\":[{\"operator\":\"startswith\",\"value\":\"ryrtihfxtijbpzv\"},{\"operator\":\">\",\"value\":\"wzsymglzufcy\"},{\"operator\":\"!startswith\",\"value\":\"ohdbihanufh\"},{\"operator\":\"!contains\",\"value\":\"bj\"}],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Min\"}},{\"signalSourceId\":\"git\",\"sourceAmwAccountManagedIdentity\":\"xqhabi\",\"sourceAmwAccountResourceId\":\"pikxwczbyscnpqxu\",\"metricNamespace\":\"ivyqniwbybrkxvd\",\"metricName\":\"mjgr\",\"filters\":[{\"operator\":\"!in\",\"value\":\"vukxgau\"},{\"operator\":\"!in\",\"value\":\"cs\"}],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Max\"}}],\"signalFormula\":\"jcny\"},\"totalSignals\":{\"signalSources\":[{\"signalSourceId\":\"kryhtnapczwlokj\",\"sourceAmwAccountManagedIdentity\":\"emkkvnipjox\",\"sourceAmwAccountResourceId\":\"jnchgej\",\"metricNamespace\":\"podmailzydehojwy\",\"metricName\":\"huxinpmqnj\",\"filters\":[{\"operator\":\"@in\",\"value\":\"ixjsprozvcputeg\"},{\"operator\":\"!=\",\"value\":\"wmfdatscmdvpjhul\"},{\"operator\":\"<\",\"value\":\"uvm\"}],\"spatialAggregation\":{\"type\":\"Sum\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Average\"}},{\"signalSourceId\":\"zkrwfn\",\"sourceAmwAccountManagedIdentity\":\"iodjp\",\"sourceAmwAccountResourceId\":\"lwejdpv\",\"metricNamespace\":\"ryo\",\"metricName\":\"psoacctazakljl\",\"filters\":[{\"operator\":\"!=\",\"value\":\"cr\"},{\"operator\":\"==\",\"value\":\"fdfdosygexpa\"},{\"operator\":\"startswith\",\"value\":\"akhmsbzjhcrz\"},{\"operator\":\">\",\"value\":\"dphlxaolt\"}],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Sum\"}}],\"signalFormula\":\"rgqjbpfzfsinzg\"},\"signals\":{\"signalSources\":[{\"signalSourceId\":\"jrwzox\",\"sourceAmwAccountManagedIdentity\":\"j\",\"sourceAmwAccountResourceId\":\"felluwfzitonpe\",\"metricNamespace\":\"fpjkjlxofp\",\"metricName\":\"vhpfxxypininmay\",\"filters\":[{\"operator\":\">\",\"value\":\"bbkpodep\"},{\"operator\":\">\",\"value\":\"ginuvamih\"},{\"operator\":\"contains\",\"value\":\"gnarxzxtheo\"}],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Sum\"}},{\"signalSourceId\":\"ivyevcciqihnhun\",\"sourceAmwAccountManagedIdentity\":\"bwjzr\",\"sourceAmwAccountResourceId\":\"fygxgispemvtzfk\",\"metricNamespace\":\"fublj\",\"metricName\":\"fxqeof\",\"filters\":[{\"operator\":\">\",\"value\":\"qjhqjbas\"},{\"operator\":\"!in\",\"value\":\"smjqulngsntnbyb\"},{\"operator\":\"contains\",\"value\":\"gc\"},{\"operator\":\"contains\",\"value\":\"wclxxwrl\"}],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Rate\"}},{\"signalSourceId\":\"uskcqvkocrcj\",\"sourceAmwAccountManagedIdentity\":\"kwt\",\"sourceAmwAccountResourceId\":\"hxbnjbiksqrg\",\"metricNamespace\":\"ssainqpjwnzll\",\"metricName\":\"fmppe\",\"filters\":[{\"operator\":\"!in\",\"value\":\"mgxsab\"},{\"operator\":\"<\",\"value\":\"qduujitcjczdz\"},{\"operator\":\"@in\",\"value\":\"ndhkrw\"},{\"operator\":\"<=\",\"value\":\"appd\"}],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Average\"}},{\"signalSourceId\":\"kvwrwjfeu\",\"sourceAmwAccountManagedIdentity\":\"nhutjeltmrldhugj\",\"sourceAmwAccountResourceId\":\"zdatqxhocdg\",\"metricNamespace\":\"ablgphuticndvk\",\"metricName\":\"ozwyiftyhxhuro\",\"filters\":[{\"operator\":\"!startswith\",\"value\":\"yxolniwp\"},{\"operator\":\"==\",\"value\":\"ukjfkgiawxklr\"},{\"operator\":\"@in\",\"value\":\"lwckbasyypnddhs\"}],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Delta\"}}],\"signalFormula\":\"acphejkoty\"},\"windowUptimeCriteria\":{\"target\":17.641552819912953,\"comparator\":\"<=\"}}},\"identity\":{\"principalId\":\"ndlik\",\"tenantId\":\"qkgfgibma\",\"type\":\"SystemAssigned\",\"userAssignedIdentities\":{\"kzsmodm\":{\"principalId\":\"qsrxybzqqed\",\"clientId\":\"tbciqfouflmm\"},\"umkdosvqwhbmd\":{\"principalId\":\"ougpbkwt\",\"clientId\":\"tduqktapspwgcuer\"},\"q\":{\"principalId\":\"bjf\",\"clientId\":\"gmbmbexppbh\"},\"igjyjg\":{\"principalId\":\"ol\",\"clientId\":\"fpsalgbqu\"}}},\"id\":\"aoyfhrtxilnerkuj\",\"name\":\"s\",\"type\":\"l\"}") + .toObject(SliInner.class); + Assertions.assertEquals("quvgjxpybczme", model.properties().description()); + Assertions.assertEquals(Category.AVAILABILITY, model.properties().category()); + Assertions.assertEquals(EvaluationType.REQUEST_BASED, model.properties().evaluationType()); + Assertions.assertEquals("pidgsybbejhphoyc", model.properties().destinationAmwAccounts().get(0).resourceId()); + Assertions.assertEquals("sx", model.properties().destinationAmwAccounts().get(0).identity()); + Assertions.assertEquals(28.301840077728546, model.properties().baselineProperties().baseline().value()); + Assertions.assertEquals(4771592, model.properties().baselineProperties().baseline().evaluationPeriodDays()); + Assertions.assertEquals(EvaluationCalculationType.CALENDAR_DAYS, + model.properties().baselineProperties().baseline().evaluationCalculationType()); + Assertions.assertTrue(model.properties().enableAlert()); + Assertions.assertEquals("zlobcufpd", + model.properties().sliProperties().goodSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("nrbtcqqjnq", + model.properties().sliProperties().goodSignals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("lhqgnufooojy", + model.properties().sliProperties().goodSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("ifsqesaagdfmg", + model.properties().sliProperties().goodSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("zlhjxrifkwmrvkt", + model.properties().sliProperties().goodSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(ConditionOperator.LESS_THAN, + model.properties().sliProperties().goodSignals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("nt", + model.properties().sliProperties().goodSignals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.MAX, + model.properties().sliProperties().goodSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals(TemporalAggregationType.RATE, + model.properties().sliProperties().goodSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals("jcny", model.properties().sliProperties().goodSignals().signalFormula()); + Assertions.assertEquals("kryhtnapczwlokj", + model.properties().sliProperties().totalSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("emkkvnipjox", + model.properties().sliProperties().totalSignals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("jnchgej", + model.properties().sliProperties().totalSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("podmailzydehojwy", + model.properties().sliProperties().totalSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("huxinpmqnj", + model.properties().sliProperties().totalSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(ConditionOperator.IN, + model.properties().sliProperties().totalSignals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("ixjsprozvcputeg", + model.properties().sliProperties().totalSignals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.SUM, + model.properties().sliProperties().totalSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals(TemporalAggregationType.AVERAGE, + model.properties().sliProperties().totalSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals("rgqjbpfzfsinzg", model.properties().sliProperties().totalSignals().signalFormula()); + Assertions.assertEquals("jrwzox", + model.properties().sliProperties().signals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("j", + model.properties().sliProperties().signals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("felluwfzitonpe", + model.properties().sliProperties().signals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("fpjkjlxofp", + model.properties().sliProperties().signals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("vhpfxxypininmay", + model.properties().sliProperties().signals().signalSources().get(0).metricName()); + Assertions.assertEquals(ConditionOperator.GREATER_THAN, + model.properties().sliProperties().signals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("bbkpodep", + model.properties().sliProperties().signals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.COUNT, + model.properties().sliProperties().signals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals(TemporalAggregationType.SUM, + model.properties().sliProperties().signals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals("acphejkoty", model.properties().sliProperties().signals().signalFormula()); + Assertions.assertEquals(17.641552819912953, model.properties().sliProperties().windowUptimeCriteria().target()); + Assertions.assertEquals(WindowUptimeCriteriaComparator.LESS_THAN_OR_EQUAL, + model.properties().sliProperties().windowUptimeCriteria().comparator()); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED, model.identity().type()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + SliInner model + = new SliInner() + .withProperties(new SliResource().withDescription("quvgjxpybczme") + .withCategory(Category.AVAILABILITY) + .withEvaluationType(EvaluationType.REQUEST_BASED) + .withDestinationAmwAccounts( + Arrays.asList(new AmwAccount().withResourceId("pidgsybbejhphoyc").withIdentity("sx"))) + .withBaselineProperties( + new BaselineProperties().withBaseline(new Baseline().withValue(28.301840077728546) + .withEvaluationPeriodDays(4771592) + .withEvaluationCalculationType(EvaluationCalculationType.CALENDAR_DAYS))) + .withEnableAlert(true) + .withSliProperties(new SliProperties() + .withGoodSignals(new Signal() + .withSignalSources(Arrays.asList( + new SignalSource().withSignalSourceId("zlobcufpd") + .withSourceAmwAccountManagedIdentity("nrbtcqqjnq") + .withSourceAmwAccountResourceId("lhqgnufooojy") + .withMetricNamespace("ifsqesaagdfmg") + .withMetricName("zlhjxrifkwmrvkt") + .withFilters(Arrays.asList( + new Condition().withOperator(ConditionOperator.LESS_THAN).withValue("nt"), + new Condition().withOperator(ConditionOperator.EQUAL).withValue("ipa"), + new Condition() + .withOperator(ConditionOperator.STARTS_WITH) + .withValue("ajpsquc"))) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.MAX) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.RATE)), + new SignalSource().withSignalSourceId("yf") + .withSourceAmwAccountManagedIdentity("kfo") + .withSourceAmwAccountResourceId("knygjofjddeq") + .withMetricNamespace("rd") + .withMetricName("upewnwreitjzy") + .withFilters(Arrays.asList( + new Condition() + .withOperator(ConditionOperator.NOT_CONTAINS) + .withValue("sarhmofc"), + new Condition().withOperator(ConditionOperator.GREATER_THAN).withValue("smy"))) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.COUNT) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.AVERAGE)), + new SignalSource().withSignalSourceId("dtmlxhekuksjt") + .withSourceAmwAccountManagedIdentity("ukcdmparcryuanzw") + .withSourceAmwAccountResourceId("xzdxtayrlhmwh") + .withMetricNamespace("pmrqobm") + .withMetricName("u") + .withFilters(Arrays.asList( + new Condition().withOperator(ConditionOperator.STARTS_WITH) + .withValue("ryrtihfxtijbpzv"), + new Condition().withOperator(ConditionOperator.GREATER_THAN) + .withValue("wzsymglzufcy"), + new Condition().withOperator(ConditionOperator.NOT_STARTS_WITH) + .withValue("ohdbihanufh"), + new Condition().withOperator(ConditionOperator.NOT_CONTAINS).withValue("bj"))) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.COUNT) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.MIN)), + new SignalSource().withSignalSourceId("git") + .withSourceAmwAccountManagedIdentity("xqhabi") + .withSourceAmwAccountResourceId("pikxwczbyscnpqxu") + .withMetricNamespace("ivyqniwbybrkxvd") + .withMetricName("mjgr") + .withFilters(Arrays.asList( + new Condition().withOperator(ConditionOperator.NOT_IN).withValue("vukxgau"), + new Condition().withOperator(ConditionOperator.NOT_IN).withValue("cs"))) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.MIN) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.MAX)))) + .withSignalFormula("jcny")) + .withTotalSignals(new Signal() + .withSignalSources(Arrays.asList( + new SignalSource().withSignalSourceId("kryhtnapczwlokj") + .withSourceAmwAccountManagedIdentity("emkkvnipjox") + .withSourceAmwAccountResourceId("jnchgej") + .withMetricNamespace("podmailzydehojwy") + .withMetricName("huxinpmqnj") + .withFilters(Arrays.asList( + new Condition().withOperator(ConditionOperator.IN).withValue("ixjsprozvcputeg"), + new Condition() + .withOperator(ConditionOperator.NOT_EQUAL) + .withValue("wmfdatscmdvpjhul"), + new Condition().withOperator(ConditionOperator.LESS_THAN).withValue("uvm"))) + .withSpatialAggregation(new SpatialAggregation() + .withType(SpatialAggregationType.SUM) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.AVERAGE)), + new SignalSource().withSignalSourceId("zkrwfn") + .withSourceAmwAccountManagedIdentity("iodjp") + .withSourceAmwAccountResourceId("lwejdpv") + .withMetricNamespace("ryo") + .withMetricName("psoacctazakljl") + .withFilters(Arrays.asList( + new Condition().withOperator(ConditionOperator.NOT_EQUAL).withValue("cr"), + new Condition().withOperator(ConditionOperator.EQUAL).withValue("fdfdosygexpa"), + new Condition().withOperator(ConditionOperator.STARTS_WITH) + .withValue("akhmsbzjhcrz"), + new Condition().withOperator(ConditionOperator.GREATER_THAN) + .withValue("dphlxaolt"))) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.MAX) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.SUM)))) + .withSignalFormula("rgqjbpfzfsinzg")) + .withSignals(new Signal() + .withSignalSources(Arrays.asList(new SignalSource().withSignalSourceId("jrwzox") + .withSourceAmwAccountManagedIdentity("j") + .withSourceAmwAccountResourceId("felluwfzitonpe") + .withMetricNamespace("fpjkjlxofp") + .withMetricName("vhpfxxypininmay") + .withFilters(Arrays.asList( + new Condition().withOperator(ConditionOperator.GREATER_THAN).withValue("bbkpodep"), + new Condition().withOperator(ConditionOperator.GREATER_THAN).withValue("ginuvamih"), + new Condition().withOperator(ConditionOperator.CONTAINS).withValue("gnarxzxtheo"))) + .withSpatialAggregation(new SpatialAggregation() + .withType(SpatialAggregationType.COUNT) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.SUM)), + new SignalSource().withSignalSourceId("ivyevcciqihnhun") + .withSourceAmwAccountManagedIdentity("bwjzr") + .withSourceAmwAccountResourceId("fygxgispemvtzfk") + .withMetricNamespace("fublj") + .withMetricName("fxqeof") + .withFilters(Arrays.asList(new Condition() + .withOperator(ConditionOperator.GREATER_THAN) + .withValue("qjhqjbas"), + new Condition().withOperator(ConditionOperator.NOT_IN) + .withValue("smjqulngsntnbyb"), + new Condition().withOperator(ConditionOperator.CONTAINS).withValue("gc"), + new Condition().withOperator(ConditionOperator.CONTAINS).withValue("wclxxwrl"))) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.AVERAGE) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.RATE)), + new SignalSource().withSignalSourceId("uskcqvkocrcj") + .withSourceAmwAccountManagedIdentity("kwt") + .withSourceAmwAccountResourceId("hxbnjbiksqrg") + .withMetricNamespace("ssainqpjwnzll") + .withMetricName("fmppe") + .withFilters(Arrays.asList( + new Condition().withOperator(ConditionOperator.NOT_IN).withValue("mgxsab"), + new Condition().withOperator(ConditionOperator.LESS_THAN) + .withValue("qduujitcjczdz"), + new Condition().withOperator(ConditionOperator.IN).withValue("ndhkrw"), + new Condition() + .withOperator(ConditionOperator.LESS_THAN_OR_EQUAL) + .withValue("appd"))) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.AVERAGE) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.AVERAGE)), + new SignalSource().withSignalSourceId("kvwrwjfeu") + .withSourceAmwAccountManagedIdentity("nhutjeltmrldhugj") + .withSourceAmwAccountResourceId("zdatqxhocdg") + .withMetricNamespace("ablgphuticndvk") + .withMetricName("ozwyiftyhxhuro") + .withFilters(Arrays.asList(new Condition() + .withOperator(ConditionOperator.NOT_STARTS_WITH) + .withValue("yxolniwp"), + new Condition() + .withOperator(ConditionOperator.EQUAL) + .withValue("ukjfkgiawxklr"), + new Condition().withOperator(ConditionOperator.IN) + .withValue("lwckbasyypnddhs"))) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.MAX) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.DELTA)))) + .withSignalFormula("acphejkoty")) + .withWindowUptimeCriteria(new WindowUptimeCriteria().withTarget(17.641552819912953) + .withComparator(WindowUptimeCriteriaComparator.LESS_THAN_OR_EQUAL)))) + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.SYSTEM_ASSIGNED) + .withUserAssignedIdentities( + mapOf("kzsmodm", new UserAssignedIdentity(), "umkdosvqwhbmd", new UserAssignedIdentity(), "q", + new UserAssignedIdentity(), "igjyjg", new UserAssignedIdentity()))); + model = BinaryData.fromObject(model).toObject(SliInner.class); + Assertions.assertEquals("quvgjxpybczme", model.properties().description()); + Assertions.assertEquals(Category.AVAILABILITY, model.properties().category()); + Assertions.assertEquals(EvaluationType.REQUEST_BASED, model.properties().evaluationType()); + Assertions.assertEquals("pidgsybbejhphoyc", model.properties().destinationAmwAccounts().get(0).resourceId()); + Assertions.assertEquals("sx", model.properties().destinationAmwAccounts().get(0).identity()); + Assertions.assertEquals(28.301840077728546, model.properties().baselineProperties().baseline().value()); + Assertions.assertEquals(4771592, model.properties().baselineProperties().baseline().evaluationPeriodDays()); + Assertions.assertEquals(EvaluationCalculationType.CALENDAR_DAYS, + model.properties().baselineProperties().baseline().evaluationCalculationType()); + Assertions.assertTrue(model.properties().enableAlert()); + Assertions.assertEquals("zlobcufpd", + model.properties().sliProperties().goodSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("nrbtcqqjnq", + model.properties().sliProperties().goodSignals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("lhqgnufooojy", + model.properties().sliProperties().goodSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("ifsqesaagdfmg", + model.properties().sliProperties().goodSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("zlhjxrifkwmrvkt", + model.properties().sliProperties().goodSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(ConditionOperator.LESS_THAN, + model.properties().sliProperties().goodSignals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("nt", + model.properties().sliProperties().goodSignals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.MAX, + model.properties().sliProperties().goodSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals(TemporalAggregationType.RATE, + model.properties().sliProperties().goodSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals("jcny", model.properties().sliProperties().goodSignals().signalFormula()); + Assertions.assertEquals("kryhtnapczwlokj", + model.properties().sliProperties().totalSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("emkkvnipjox", + model.properties().sliProperties().totalSignals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("jnchgej", + model.properties().sliProperties().totalSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("podmailzydehojwy", + model.properties().sliProperties().totalSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("huxinpmqnj", + model.properties().sliProperties().totalSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(ConditionOperator.IN, + model.properties().sliProperties().totalSignals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("ixjsprozvcputeg", + model.properties().sliProperties().totalSignals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.SUM, + model.properties().sliProperties().totalSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals(TemporalAggregationType.AVERAGE, + model.properties().sliProperties().totalSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals("rgqjbpfzfsinzg", model.properties().sliProperties().totalSignals().signalFormula()); + Assertions.assertEquals("jrwzox", + model.properties().sliProperties().signals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("j", + model.properties().sliProperties().signals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("felluwfzitonpe", + model.properties().sliProperties().signals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("fpjkjlxofp", + model.properties().sliProperties().signals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("vhpfxxypininmay", + model.properties().sliProperties().signals().signalSources().get(0).metricName()); + Assertions.assertEquals(ConditionOperator.GREATER_THAN, + model.properties().sliProperties().signals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("bbkpodep", + model.properties().sliProperties().signals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.COUNT, + model.properties().sliProperties().signals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals(TemporalAggregationType.SUM, + model.properties().sliProperties().signals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals("acphejkoty", model.properties().sliProperties().signals().signalFormula()); + Assertions.assertEquals(17.641552819912953, model.properties().sliProperties().windowUptimeCriteria().target()); + Assertions.assertEquals(WindowUptimeCriteriaComparator.LESS_THAN_OR_EQUAL, + model.properties().sliProperties().windowUptimeCriteria().comparator()); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED, model.identity().type()); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliListResultTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliListResultTests.java new file mode 100644 index 000000000000..a01ad30e0e61 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliListResultTests.java @@ -0,0 +1,182 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.implementation.models.SliListResult; +import com.azure.resourcemanager.monitor.slis.models.Category; +import com.azure.resourcemanager.monitor.slis.models.EvaluationCalculationType; +import com.azure.resourcemanager.monitor.slis.models.EvaluationType; +import com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteriaComparator; +import org.junit.jupiter.api.Assertions; + +public final class SliListResultTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SliListResult model = BinaryData.fromString( + "{\"value\":[{\"properties\":{\"provisioningState\":\"Failed\",\"description\":\"rmclfplphoxu\",\"category\":\"Availability\",\"evaluationType\":\"WindowBased\",\"executionState\":{\"state\":\"abgy\",\"message\":\"sbj\"},\"destinationAmwAccounts\":[{\"resourceId\":\"zq\",\"identity\":\"gxywpmue\"},{\"resourceId\":\"fjz\",\"identity\":\"fqkquj\"},{\"resourceId\":\"dsuyonobgla\",\"identity\":\"cq\"},{\"resourceId\":\"tcc\",\"identity\":\"g\"}],\"destinationMetrics\":[{\"metricNamespace\":\"xy\",\"metricName\":\"lmoyrx\"}],\"baselineProperties\":{\"baseline\":{\"value\":91.75911917706165,\"evaluationPeriodDays\":76468143,\"evaluationCalculationType\":\"CalendarDays\"}},\"streamingRuleId\":\"pz\",\"streamingRuleLastUpdatedTimestamp\":\"2021-05-21T05:23:51Z\",\"enableAlert\":false,\"sliProperties\":{\"goodSignals\":{\"signalSources\":[{\"signalSourceId\":\"hl\",\"sourceAmwAccountManagedIdentity\":\"qj\",\"sourceAmwAccountResourceId\":\"hckfrlhrx\",\"metricNamespace\":\"bkyvp\",\"metricName\":\"ca\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Sum\"}},{\"signalSourceId\":\"bpzkafkuwbc\",\"sourceAmwAccountManagedIdentity\":\"nwbmeh\",\"sourceAmwAccountResourceId\":\"seyvj\",\"metricNamespace\":\"srtslhspkdeem\",\"metricName\":\"ofmxagkvtmelmqkr\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Delta\"}}],\"signalFormula\":\"vljua\"},\"totalSignals\":{\"signalSources\":[{\"signalSourceId\":\"uhcdhm\",\"sourceAmwAccountManagedIdentity\":\"ualaexqpvfadmw\",\"sourceAmwAccountResourceId\":\"rcrgvx\",\"metricNamespace\":\"vgomz\",\"metricName\":\"fmisg\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Increase\"}},{\"signalSourceId\":\"b\",\"sourceAmwAccountManagedIdentity\":\"e\",\"sourceAmwAccountResourceId\":\"dawkzbali\",\"metricNamespace\":\"urqhaka\",\"metricName\":\"hashsfwxosow\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Max\"}},{\"signalSourceId\":\"ugicjooxdjebw\",\"sourceAmwAccountManagedIdentity\":\"ucww\",\"sourceAmwAccountResourceId\":\"vo\",\"metricNamespace\":\"bvmeuecivy\",\"metricName\":\"zceuojgjrw\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Min\"}}],\"signalFormula\":\"iotwmcdytdxwit\"},\"signals\":{\"signalSources\":[{\"signalSourceId\":\"jawgqwg\",\"sourceAmwAccountManagedIdentity\":\"hniskxfbkpyc\",\"sourceAmwAccountResourceId\":\"klwndnhjdauwhv\",\"metricNamespace\":\"l\",\"metricName\":\"zbtd\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Max\"}}],\"signalFormula\":\"jznb\"},\"windowUptimeCriteria\":{\"target\":6.623657803570204,\"comparator\":\">\"}}},\"identity\":{\"principalId\":\"rzqlveu\",\"tenantId\":\"upjm\",\"type\":\"SystemAssigned,UserAssigned\",\"userAssignedIdentities\":{\"xzvlvqhjkbegib\":{\"principalId\":\"bbcswsrtjri\",\"clientId\":\"rbpbewtghfgblcg\"},\"tzjuzgwyzmhtxo\":{\"principalId\":\"mxiebw\",\"clientId\":\"loayqcgw\"},\"rwmdyvxqtay\":{\"principalId\":\"mtsavjcbpwxqp\",\"clientId\":\"knftguvriuh\"}}},\"id\":\"ww\",\"name\":\"oyq\",\"type\":\"exrmcqibycnojvk\"},{\"properties\":{\"provisioningState\":\"Succeeded\",\"description\":\"qsgzvahapj\",\"category\":\"Latency\",\"evaluationType\":\"WindowBased\",\"executionState\":{\"state\":\"vgqzcjrvxd\",\"message\":\"lmwlxkvugfhzo\"},\"destinationAmwAccounts\":[{\"resourceId\":\"wjvzunluthnn\",\"identity\":\"rnxipei\"},{\"resourceId\":\"pjzu\",\"identity\":\"e\"},{\"resourceId\":\"xdult\",\"identity\":\"kzbbtd\"},{\"resourceId\":\"umveekgpwozuhkf\",\"identity\":\"bsjyofdx\"}],\"destinationMetrics\":[{\"metricNamespace\":\"sd\",\"metricName\":\"touwaboekqv\"}],\"baselineProperties\":{\"baseline\":{\"value\":52.428353050864814,\"evaluationPeriodDays\":109250802,\"evaluationCalculationType\":\"CalendarDays\"}},\"streamingRuleId\":\"vbxwyjsflhh\",\"streamingRuleLastUpdatedTimestamp\":\"2020-12-20T13:53:44Z\",\"enableAlert\":true,\"sliProperties\":{\"goodSignals\":{\"signalSources\":[{\"signalSourceId\":\"ixisxyawjoy\",\"sourceAmwAccountManagedIdentity\":\"qcslyjpkiid\",\"sourceAmwAccountResourceId\":\"yexz\",\"metricNamespace\":\"eli\",\"metricName\":\"hnrztfol\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"IDelta\"}},{\"signalSourceId\":\"xknalaulppg\",\"sourceAmwAccountManagedIdentity\":\"dtpnapnyiropuhp\",\"sourceAmwAccountResourceId\":\"gvpgy\",\"metricNamespace\":\"gqgitxmedjvcsl\",\"metricName\":\"n\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"IDelta\"}},{\"signalSourceId\":\"ncw\",\"sourceAmwAccountManagedIdentity\":\"zhxgktrmgucn\",\"sourceAmwAccountResourceId\":\"pkteo\",\"metricNamespace\":\"llwptfdy\",\"metricName\":\"pfqbuaceopzf\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Delta\"}},{\"signalSourceId\":\"huaoppp\",\"sourceAmwAccountManagedIdentity\":\"qeqxo\",\"sourceAmwAccountResourceId\":\"z\",\"metricNamespace\":\"ahzxctobgbk\",\"metricName\":\"moizpos\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Max\"}}],\"signalFormula\":\"rcfbunrm\"},\"totalSignals\":{\"signalSources\":[{\"signalSourceId\":\"hhkxbp\",\"sourceAmwAccountManagedIdentity\":\"jy\",\"sourceAmwAccountResourceId\":\"jhxxjyn\",\"metricNamespace\":\"u\",\"metricName\":\"ivkrtsw\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Max\"}},{\"signalSourceId\":\"zvszj\",\"sourceAmwAccountManagedIdentity\":\"auvjfdxxivet\",\"sourceAmwAccountResourceId\":\"t\",\"metricNamespace\":\"qaqtdoqmcbxvwvxy\",\"metricName\":\"lqbhsf\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Max\"}}],\"signalFormula\":\"lyt\"},\"signals\":{\"signalSources\":[{\"signalSourceId\":\"mpew\",\"sourceAmwAccountManagedIdentity\":\"wfbkrvrns\",\"sourceAmwAccountResourceId\":\"shqjohxcrsbf\",\"metricNamespace\":\"vasrruvwb\",\"metricName\":\"sqfsubcgjbirxb\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"IDelta\"}},{\"signalSourceId\":\"srfbjfdtwss\",\"sourceAmwAccountManagedIdentity\":\"t\",\"sourceAmwAccountResourceId\":\"tpvjzbexilzznfqq\",\"metricNamespace\":\"vwpm\",\"metricName\":\"taruoujmkcj\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Increase\"}},{\"signalSourceId\":\"ytjrybnwjewgdr\",\"sourceAmwAccountManagedIdentity\":\"ervnaenqpehi\",\"sourceAmwAccountResourceId\":\"doy\",\"metricNamespace\":\"mifthnzdnd\",\"metricName\":\"l\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"IRate\"}}],\"signalFormula\":\"yq\"},\"windowUptimeCriteria\":{\"target\":36.90142308535591,\"comparator\":\"<=\"}}},\"identity\":{\"principalId\":\"avhqlkth\",\"tenantId\":\"aqolbgycduiertg\",\"type\":\"None\",\"userAssignedIdentities\":{\"lzpswiydm\":{\"principalId\":\"aolps\",\"clientId\":\"qlfmmdnbb\"},\"dbzm\":{\"principalId\":\"yhz\",\"clientId\":\"ss\"}}},\"id\":\"dfznudaodv\",\"name\":\"zbn\",\"type\":\"blylpstdbh\"},{\"properties\":{\"provisioningState\":\"Canceled\",\"description\":\"zdzucerscdntnevf\",\"category\":\"Availability\",\"evaluationType\":\"RequestBased\",\"executionState\":{\"state\":\"ygtdsslswt\",\"message\":\"eriofzpyqs\"},\"destinationAmwAccounts\":[{\"resourceId\":\"wab\",\"identity\":\"ets\"},{\"resourceId\":\"hszhedplvwiwu\",\"identity\":\"mwmbes\"},{\"resourceId\":\"dnkwwtppjflcxog\",\"identity\":\"okonzmnsikvmkqz\"},{\"resourceId\":\"qqkdltfzxmhhvhgu\",\"identity\":\"eodkwobda\"}],\"destinationMetrics\":[{\"metricNamespace\":\"ibqdxbxwakbogqx\",\"metricName\":\"dlkzgxhuri\"},{\"metricNamespace\":\"lbpodxunk\",\"metricName\":\"ebxmubyynt\"},{\"metricNamespace\":\"lrb\",\"metricName\":\"tkoievseotgq\"}],\"baselineProperties\":{\"baseline\":{\"value\":4.886296094520515,\"evaluationPeriodDays\":407342571,\"evaluationCalculationType\":\"RollingDays\"}},\"streamingRuleId\":\"wlauwzizxbmpg\",\"streamingRuleLastUpdatedTimestamp\":\"2021-07-24T09:20:41Z\",\"enableAlert\":true,\"sliProperties\":{\"goodSignals\":{\"signalSources\":[{\"signalSourceId\":\"muvp\",\"sourceAmwAccountManagedIdentity\":\"ttdumorppxebmnzb\",\"sourceAmwAccountResourceId\":\"bhjpglkfgohdne\",\"metricNamespace\":\"el\",\"metricName\":\"phsdyhto\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Increase\"}},{\"signalSourceId\":\"kd\",\"sourceAmwAccountManagedIdentity\":\"wwquuvxzxclvithh\",\"sourceAmwAccountResourceId\":\"zonosgg\",\"metricNamespace\":\"hcohfwdsjnk\",\"metricName\":\"ljuti\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Rate\"}},{\"signalSourceId\":\"acffgdkzzewkfvhq\",\"sourceAmwAccountManagedIdentity\":\"railvpnppfuf\",\"sourceAmwAccountResourceId\":\"rwdmhdlxyjrxsa\",\"metricNamespace\":\"afcnih\",\"metricName\":\"wqapnedgfbcvk\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Rate\"}},{\"signalSourceId\":\"vpk\",\"sourceAmwAccountManagedIdentity\":\"qdcvdrhvoo\",\"sourceAmwAccountResourceId\":\"sotbob\",\"metricNamespace\":\"dopcjwvnh\",\"metricName\":\"ld\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Sum\"}}],\"signalFormula\":\"xcxrsl\"},\"totalSignals\":{\"signalSources\":[{\"signalSourceId\":\"twuoegrpkhjwni\",\"sourceAmwAccountManagedIdentity\":\"qsluicp\",\"sourceAmwAccountResourceId\":\"ggkzzlvmbmpa\",\"metricNamespace\":\"modfvuefywsbpfvm\",\"metricName\":\"yhrfouyftaakcpw\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Rate\"}}],\"signalFormula\":\"vqtmnub\"},\"signals\":{\"signalSources\":[{\"signalSourceId\":\"pzk\",\"sourceAmwAccountManagedIdentity\":\"mond\",\"sourceAmwAccountResourceId\":\"mquxvypo\",\"metricNamespace\":\"gkopkwhojvpajqgx\",\"metricName\":\"smocmbq\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Average\"}},{\"signalSourceId\":\"mkcxozapvh\",\"sourceAmwAccountManagedIdentity\":\"lxprglyatddckcbc\",\"sourceAmwAccountResourceId\":\"ejrjxgciqibrho\",\"metricNamespace\":\"xsdqrhzoymibmrqy\",\"metricName\":\"bahwfl\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Delta\"}},{\"signalSourceId\":\"dtmhrkwofyyvoqa\",\"sourceAmwAccountManagedIdentity\":\"piexpbtgiw\",\"sourceAmwAccountResourceId\":\"wo\",\"metricNamespace\":\"nwashrtd\",\"metricName\":\"kcnqxwbpo\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Average\"}}],\"signalFormula\":\"pi\"},\"windowUptimeCriteria\":{\"target\":37.028919775226754,\"comparator\":\">\"}}},\"identity\":{\"principalId\":\"pqiiobyuqe\",\"tenantId\":\"qlpqwcciuq\",\"type\":\"UserAssigned\",\"userAssignedIdentities\":{\"mhykojoxafnndl\":{\"principalId\":\"t\",\"clientId\":\"vfbtkuwh\"},\"ovljxywsu\":{\"principalId\":\"chkoymkcdyh\",\"clientId\":\"kkpwdreqnovvq\"}}},\"id\":\"yrs\",\"name\":\"dsytgadgvr\",\"type\":\"ea\"}],\"nextLink\":\"e\"}") + .toObject(SliListResult.class); + Assertions.assertEquals("rmclfplphoxu", model.value().get(0).properties().description()); + Assertions.assertEquals(Category.AVAILABILITY, model.value().get(0).properties().category()); + Assertions.assertEquals(EvaluationType.WINDOW_BASED, model.value().get(0).properties().evaluationType()); + Assertions.assertEquals("zq", model.value().get(0).properties().destinationAmwAccounts().get(0).resourceId()); + Assertions.assertEquals("gxywpmue", + model.value().get(0).properties().destinationAmwAccounts().get(0).identity()); + Assertions.assertEquals(91.75911917706165, + model.value().get(0).properties().baselineProperties().baseline().value()); + Assertions.assertEquals(76468143, + model.value().get(0).properties().baselineProperties().baseline().evaluationPeriodDays()); + Assertions.assertEquals(EvaluationCalculationType.CALENDAR_DAYS, + model.value().get(0).properties().baselineProperties().baseline().evaluationCalculationType()); + Assertions.assertFalse(model.value().get(0).properties().enableAlert()); + Assertions.assertEquals("hl", + model.value().get(0).properties().sliProperties().goodSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("qj", + model.value() + .get(0) + .properties() + .sliProperties() + .goodSignals() + .signalSources() + .get(0) + .sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("hckfrlhrx", + model.value() + .get(0) + .properties() + .sliProperties() + .goodSignals() + .signalSources() + .get(0) + .sourceAmwAccountResourceId()); + Assertions.assertEquals("bkyvp", + model.value().get(0).properties().sliProperties().goodSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("ca", + model.value().get(0).properties().sliProperties().goodSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(SpatialAggregationType.MIN, + model.value() + .get(0) + .properties() + .sliProperties() + .goodSignals() + .signalSources() + .get(0) + .spatialAggregation() + .type()); + Assertions.assertEquals(TemporalAggregationType.SUM, + model.value() + .get(0) + .properties() + .sliProperties() + .goodSignals() + .signalSources() + .get(0) + .temporalAggregation() + .type()); + Assertions.assertEquals("vljua", + model.value().get(0).properties().sliProperties().goodSignals().signalFormula()); + Assertions.assertEquals("uhcdhm", + model.value().get(0).properties().sliProperties().totalSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("ualaexqpvfadmw", + model.value() + .get(0) + .properties() + .sliProperties() + .totalSignals() + .signalSources() + .get(0) + .sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("rcrgvx", + model.value() + .get(0) + .properties() + .sliProperties() + .totalSignals() + .signalSources() + .get(0) + .sourceAmwAccountResourceId()); + Assertions.assertEquals("vgomz", + model.value().get(0).properties().sliProperties().totalSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("fmisg", + model.value().get(0).properties().sliProperties().totalSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(SpatialAggregationType.MIN, + model.value() + .get(0) + .properties() + .sliProperties() + .totalSignals() + .signalSources() + .get(0) + .spatialAggregation() + .type()); + Assertions.assertEquals(TemporalAggregationType.INCREASE, + model.value() + .get(0) + .properties() + .sliProperties() + .totalSignals() + .signalSources() + .get(0) + .temporalAggregation() + .type()); + Assertions.assertEquals("iotwmcdytdxwit", + model.value().get(0).properties().sliProperties().totalSignals().signalFormula()); + Assertions.assertEquals("jawgqwg", + model.value().get(0).properties().sliProperties().signals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("hniskxfbkpyc", + model.value() + .get(0) + .properties() + .sliProperties() + .signals() + .signalSources() + .get(0) + .sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("klwndnhjdauwhv", + model.value() + .get(0) + .properties() + .sliProperties() + .signals() + .signalSources() + .get(0) + .sourceAmwAccountResourceId()); + Assertions.assertEquals("l", + model.value().get(0).properties().sliProperties().signals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("zbtd", + model.value().get(0).properties().sliProperties().signals().signalSources().get(0).metricName()); + Assertions.assertEquals(SpatialAggregationType.MAX, + model.value() + .get(0) + .properties() + .sliProperties() + .signals() + .signalSources() + .get(0) + .spatialAggregation() + .type()); + Assertions.assertEquals(TemporalAggregationType.MAX, + model.value() + .get(0) + .properties() + .sliProperties() + .signals() + .signalSources() + .get(0) + .temporalAggregation() + .type()); + Assertions.assertEquals("jznb", model.value().get(0).properties().sliProperties().signals().signalFormula()); + Assertions.assertEquals(6.623657803570204, + model.value().get(0).properties().sliProperties().windowUptimeCriteria().target()); + Assertions.assertEquals(WindowUptimeCriteriaComparator.GREATER_THAN, + model.value().get(0).properties().sliProperties().windowUptimeCriteria().comparator()); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED, + model.value().get(0).identity().type()); + Assertions.assertEquals("e", model.nextLink()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliPropertiesTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliPropertiesTests.java new file mode 100644 index 000000000000..b421dd41e8b3 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliPropertiesTests.java @@ -0,0 +1,319 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.Condition; +import com.azure.resourcemanager.monitor.slis.models.ConditionOperator; +import com.azure.resourcemanager.monitor.slis.models.SamplingType; +import com.azure.resourcemanager.monitor.slis.models.ScalarFunction; +import com.azure.resourcemanager.monitor.slis.models.Signal; +import com.azure.resourcemanager.monitor.slis.models.SignalSource; +import com.azure.resourcemanager.monitor.slis.models.SliProperties; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregation; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregation; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteria; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteriaComparator; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class SliPropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SliProperties model = BinaryData.fromString( + "{\"goodSignals\":{\"signalSources\":[{\"signalSourceId\":\"dmoh\",\"sourceAmwAccountManagedIdentity\":\"tbqvudw\",\"sourceAmwAccountResourceId\":\"dndnvow\",\"metricNamespace\":\"ujjugwdkcglh\",\"metricName\":\"lazjdyggdtjixhbk\",\"filters\":[{\"dimensionName\":\"qweykhmenev\",\"scalarFunction\":\"min\",\"samplingType\":\"avg\",\"operator\":\"!contains\",\"value\":\"hybcibv\"},{\"dimensionName\":\"dcsi\",\"scalarFunction\":\"sum\",\"samplingType\":\"min\",\"operator\":\"startswith\",\"value\":\"mdectehfiqscjey\"},{\"dimensionName\":\"hezrkgq\",\"scalarFunction\":\"sum\",\"samplingType\":\"min\",\"operator\":\">\",\"value\":\"o\"},{\"dimensionName\":\"mkqsleyyv\",\"scalarFunction\":\"sum\",\"samplingType\":\"max\",\"operator\":\"<=\",\"value\":\"cattpngjcrcczsq\"}],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[\"vmdajvnysou\",\"q\",\"canoaeupf\",\"yhltrpmopjmcm\"]},\"temporalAggregation\":{\"type\":\"IDelta\",\"windowSizeMinutes\":860799201}},{\"signalSourceId\":\"kthfui\",\"sourceAmwAccountManagedIdentity\":\"aodsfcpkv\",\"sourceAmwAccountResourceId\":\"odpuozmyzydag\",\"metricNamespace\":\"uaxbezyiuokkt\",\"metricName\":\"hrdxwzywqsmbs\",\"filters\":[{\"dimensionName\":\"xim\",\"scalarFunction\":\"max\",\"samplingType\":\"max\",\"operator\":\"startswith\",\"value\":\"sfksy\"},{\"dimensionName\":\"dystkiiuxhqyud\",\"scalarFunction\":\"sum\",\"samplingType\":\"max\",\"operator\":\"==\",\"value\":\"b\"},{\"dimensionName\":\"czvyifq\",\"scalarFunction\":\"min\",\"samplingType\":\"avg\",\"operator\":\"!startswith\",\"value\":\"sllr\"}],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[\"d\",\"watkpnpulexxb\",\"zwtruwiqzbqjvsov\"]},\"temporalAggregation\":{\"type\":\"IDelta\",\"windowSizeMinutes\":1785940860}},{\"signalSourceId\":\"acspkwl\",\"sourceAmwAccountManagedIdentity\":\"zdobpxjmflbvvnch\",\"sourceAmwAccountResourceId\":\"kcciwwzjuqkhr\",\"metricNamespace\":\"ajiwkuo\",\"metricName\":\"oskg\",\"filters\":[{\"dimensionName\":\"uuimjmvxieduug\",\"scalarFunction\":\"max\",\"samplingType\":\"sum\",\"operator\":\"!=\",\"value\":\"f\"},{\"dimensionName\":\"aos\",\"scalarFunction\":\"max\",\"samplingType\":\"avg\",\"operator\":\"<\",\"value\":\"npc\"}],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[\"cohslkev\",\"eggzfb\",\"hfmvfaxkffe\"]},\"temporalAggregation\":{\"type\":\"Average\",\"windowSizeMinutes\":378191098}}],\"signalFormula\":\"lvmezyvshxmzsbbz\"},\"totalSignals\":{\"signalSources\":[{\"signalSourceId\":\"igrxwburvjxxjn\",\"sourceAmwAccountManagedIdentity\":\"pydptko\",\"sourceAmwAccountResourceId\":\"nkoukn\",\"metricNamespace\":\"udwtiukbl\",\"metricName\":\"ngkpocipazy\",\"filters\":[{\"dimensionName\":\"gukgjnpiucgygevq\",\"scalarFunction\":\"sum\",\"samplingType\":\"max\",\"operator\":\"!=\",\"value\":\"rbpizc\"}],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[\"j\",\"dpydn\",\"yhxdeoejzicwi\",\"sjttgzfbish\"]},\"temporalAggregation\":{\"type\":\"IRate\",\"windowSizeMinutes\":1326905161}}],\"signalFormula\":\"ajdeyeamdphaga\"},\"signals\":{\"signalSources\":[{\"signalSourceId\":\"uxwgipwho\",\"sourceAmwAccountManagedIdentity\":\"ow\",\"sourceAmwAccountResourceId\":\"gshwankixz\",\"metricNamespace\":\"injep\",\"metricName\":\"ttmrywnuzoqf\",\"filters\":[{\"dimensionName\":\"qzrnkcqvyxlwhz\",\"scalarFunction\":\"avg\",\"samplingType\":\"sum\",\"operator\":\"startswith\",\"value\":\"oqqnwvlryav\"},{\"dimensionName\":\"heun\",\"scalarFunction\":\"sum\",\"samplingType\":\"min\",\"operator\":\"==\",\"value\":\"xzko\"}],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[\"uko\",\"lyaxuc\",\"nuqszfkbey\",\"ewrmjmwvvjektc\"]},\"temporalAggregation\":{\"type\":\"Min\",\"windowSizeMinutes\":1562497596}},{\"signalSourceId\":\"hwlrsf\",\"sourceAmwAccountManagedIdentity\":\"rzpwvlqdqgbiq\",\"sourceAmwAccountResourceId\":\"lihkaetcktvfc\",\"metricNamespace\":\"vf\",\"metricName\":\"nkymuctqhjfbebrj\",\"filters\":[{\"dimensionName\":\"rfuwutt\",\"scalarFunction\":\"sum\",\"samplingType\":\"sum\",\"operator\":\"!in\",\"value\":\"birphxepcyva\"}],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[\"ljkyqxjvuuj\",\"gidokgjljyoxgvcl\"]},\"temporalAggregation\":{\"type\":\"Sum\",\"windowSizeMinutes\":794855452}}],\"signalFormula\":\"ncghkje\"},\"windowUptimeCriteria\":{\"target\":56.497059361324276,\"comparator\":\"<=\"}}") + .toObject(SliProperties.class); + Assertions.assertEquals("dmoh", model.goodSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("tbqvudw", + model.goodSignals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("dndnvow", model.goodSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("ujjugwdkcglh", model.goodSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("lazjdyggdtjixhbk", model.goodSignals().signalSources().get(0).metricName()); + Assertions.assertEquals("qweykhmenev", + model.goodSignals().signalSources().get(0).filters().get(0).dimensionName()); + Assertions.assertEquals(ScalarFunction.MIN, + model.goodSignals().signalSources().get(0).filters().get(0).scalarFunction()); + Assertions.assertEquals(SamplingType.AVG, + model.goodSignals().signalSources().get(0).filters().get(0).samplingType()); + Assertions.assertEquals(ConditionOperator.NOT_CONTAINS, + model.goodSignals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("hybcibv", model.goodSignals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.MIN, + model.goodSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("vmdajvnysou", + model.goodSignals().signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.IDELTA, + model.goodSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(860799201, + model.goodSignals().signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("lvmezyvshxmzsbbz", model.goodSignals().signalFormula()); + Assertions.assertEquals("igrxwburvjxxjn", model.totalSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("pydptko", + model.totalSignals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("nkoukn", model.totalSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("udwtiukbl", model.totalSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("ngkpocipazy", model.totalSignals().signalSources().get(0).metricName()); + Assertions.assertEquals("gukgjnpiucgygevq", + model.totalSignals().signalSources().get(0).filters().get(0).dimensionName()); + Assertions.assertEquals(ScalarFunction.SUM, + model.totalSignals().signalSources().get(0).filters().get(0).scalarFunction()); + Assertions.assertEquals(SamplingType.MAX, + model.totalSignals().signalSources().get(0).filters().get(0).samplingType()); + Assertions.assertEquals(ConditionOperator.NOT_EQUAL, + model.totalSignals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("rbpizc", model.totalSignals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.AVERAGE, + model.totalSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("j", + model.totalSignals().signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.IRATE, + model.totalSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(1326905161, + model.totalSignals().signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("ajdeyeamdphaga", model.totalSignals().signalFormula()); + Assertions.assertEquals("uxwgipwho", model.signals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("ow", model.signals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("gshwankixz", model.signals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("injep", model.signals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("ttmrywnuzoqf", model.signals().signalSources().get(0).metricName()); + Assertions.assertEquals("qzrnkcqvyxlwhz", + model.signals().signalSources().get(0).filters().get(0).dimensionName()); + Assertions.assertEquals(ScalarFunction.AVG, + model.signals().signalSources().get(0).filters().get(0).scalarFunction()); + Assertions.assertEquals(SamplingType.SUM, + model.signals().signalSources().get(0).filters().get(0).samplingType()); + Assertions.assertEquals(ConditionOperator.STARTS_WITH, + model.signals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("oqqnwvlryav", model.signals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.MIN, + model.signals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("uko", model.signals().signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.MIN, + model.signals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(1562497596, + model.signals().signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("ncghkje", model.signals().signalFormula()); + Assertions.assertEquals(56.497059361324276, model.windowUptimeCriteria().target()); + Assertions.assertEquals(WindowUptimeCriteriaComparator.LESS_THAN_OR_EQUAL, + model.windowUptimeCriteria().comparator()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + SliProperties model + = new SliProperties() + .withGoodSignals(new Signal() + .withSignalSources(Arrays.asList( + new SignalSource().withSignalSourceId("dmoh") + .withSourceAmwAccountManagedIdentity("tbqvudw") + .withSourceAmwAccountResourceId("dndnvow") + .withMetricNamespace("ujjugwdkcglh") + .withMetricName("lazjdyggdtjixhbk") + .withFilters(Arrays.asList( + new Condition().withDimensionName("qweykhmenev") + .withScalarFunction(ScalarFunction.MIN) + .withSamplingType(SamplingType.AVG) + .withOperator(ConditionOperator.NOT_CONTAINS) + .withValue("hybcibv"), + new Condition().withDimensionName("dcsi") + .withScalarFunction(ScalarFunction.SUM) + .withSamplingType(SamplingType.MIN) + .withOperator(ConditionOperator.STARTS_WITH) + .withValue("mdectehfiqscjey"), + new Condition().withDimensionName("hezrkgq") + .withScalarFunction(ScalarFunction.SUM) + .withSamplingType(SamplingType.MIN) + .withOperator(ConditionOperator.GREATER_THAN) + .withValue("o"), + new Condition().withDimensionName("mkqsleyyv") + .withScalarFunction(ScalarFunction.SUM) + .withSamplingType(SamplingType.MAX) + .withOperator(ConditionOperator.LESS_THAN_OR_EQUAL) + .withValue("cattpngjcrcczsq"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.MIN) + .withDimensions(Arrays.asList("vmdajvnysou", "q", "canoaeupf", "yhltrpmopjmcm"))) + .withTemporalAggregation(new TemporalAggregation().withType( + TemporalAggregationType.IDELTA) + .withWindowSizeMinutes(860799201)), + new SignalSource().withSignalSourceId("kthfui") + .withSourceAmwAccountManagedIdentity("aodsfcpkv") + .withSourceAmwAccountResourceId("odpuozmyzydag") + .withMetricNamespace("uaxbezyiuokkt") + .withMetricName("hrdxwzywqsmbs") + .withFilters(Arrays.asList( + new Condition().withDimensionName("xim") + .withScalarFunction(ScalarFunction.MAX) + .withSamplingType(SamplingType.MAX) + .withOperator(ConditionOperator.STARTS_WITH) + .withValue("sfksy"), + new Condition().withDimensionName("dystkiiuxhqyud") + .withScalarFunction(ScalarFunction.SUM) + .withSamplingType(SamplingType.MAX) + .withOperator(ConditionOperator.EQUAL) + .withValue("b"), + new Condition().withDimensionName("czvyifq") + .withScalarFunction(ScalarFunction.MIN) + .withSamplingType(SamplingType.AVG) + .withOperator(ConditionOperator.NOT_STARTS_WITH) + .withValue("sllr"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.MIN) + .withDimensions(Arrays.asList("d", "watkpnpulexxb", "zwtruwiqzbqjvsov"))) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.IDELTA) + .withWindowSizeMinutes(1785940860)), + new SignalSource().withSignalSourceId("acspkwl") + .withSourceAmwAccountManagedIdentity("zdobpxjmflbvvnch") + .withSourceAmwAccountResourceId("kcciwwzjuqkhr") + .withMetricNamespace("ajiwkuo") + .withMetricName("oskg") + .withFilters(Arrays.asList( + new Condition().withDimensionName("uuimjmvxieduug") + .withScalarFunction(ScalarFunction.MAX) + .withSamplingType(SamplingType.SUM) + .withOperator(ConditionOperator.NOT_EQUAL) + .withValue("f"), + new Condition().withDimensionName("aos") + .withScalarFunction(ScalarFunction.MAX) + .withSamplingType(SamplingType.AVG) + .withOperator(ConditionOperator.LESS_THAN) + .withValue("npc"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.MIN) + .withDimensions(Arrays.asList("cohslkev", "eggzfb", "hfmvfaxkffe"))) + .withTemporalAggregation(new TemporalAggregation().withType(TemporalAggregationType.AVERAGE) + .withWindowSizeMinutes(378191098)))) + .withSignalFormula("lvmezyvshxmzsbbz")) + .withTotalSignals( + new Signal() + .withSignalSources(Arrays.asList(new SignalSource().withSignalSourceId("igrxwburvjxxjn") + .withSourceAmwAccountManagedIdentity("pydptko") + .withSourceAmwAccountResourceId("nkoukn") + .withMetricNamespace("udwtiukbl") + .withMetricName("ngkpocipazy") + .withFilters(Arrays.asList(new Condition().withDimensionName("gukgjnpiucgygevq") + .withScalarFunction(ScalarFunction.SUM) + .withSamplingType(SamplingType.MAX) + .withOperator(ConditionOperator.NOT_EQUAL) + .withValue("rbpizc"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.AVERAGE) + .withDimensions(Arrays.asList("j", "dpydn", "yhxdeoejzicwi", "sjttgzfbish"))) + .withTemporalAggregation(new TemporalAggregation().withType(TemporalAggregationType.IRATE) + .withWindowSizeMinutes(1326905161)))) + .withSignalFormula("ajdeyeamdphaga")) + .withSignals(new Signal().withSignalSources(Arrays.asList( + new SignalSource().withSignalSourceId("uxwgipwho") + .withSourceAmwAccountManagedIdentity("ow") + .withSourceAmwAccountResourceId("gshwankixz") + .withMetricNamespace("injep") + .withMetricName("ttmrywnuzoqf") + .withFilters(Arrays.asList( + new Condition().withDimensionName("qzrnkcqvyxlwhz") + .withScalarFunction(ScalarFunction.AVG) + .withSamplingType(SamplingType.SUM) + .withOperator(ConditionOperator.STARTS_WITH) + .withValue("oqqnwvlryav"), + new Condition().withDimensionName("heun") + .withScalarFunction(ScalarFunction.SUM) + .withSamplingType(SamplingType.MIN) + .withOperator(ConditionOperator.EQUAL) + .withValue("xzko"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.MIN) + .withDimensions(Arrays.asList("uko", "lyaxuc", "nuqszfkbey", "ewrmjmwvvjektc"))) + .withTemporalAggregation(new TemporalAggregation().withType(TemporalAggregationType.MIN) + .withWindowSizeMinutes(1562497596)), + new SignalSource().withSignalSourceId("hwlrsf") + .withSourceAmwAccountManagedIdentity("rzpwvlqdqgbiq") + .withSourceAmwAccountResourceId("lihkaetcktvfc") + .withMetricNamespace("vf") + .withMetricName("nkymuctqhjfbebrj") + .withFilters(Arrays.asList(new Condition().withDimensionName("rfuwutt") + .withScalarFunction(ScalarFunction.SUM) + .withSamplingType(SamplingType.SUM) + .withOperator(ConditionOperator.NOT_IN) + .withValue("birphxepcyva"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.AVERAGE) + .withDimensions(Arrays.asList("ljkyqxjvuuj", "gidokgjljyoxgvcl"))) + .withTemporalAggregation(new TemporalAggregation().withType(TemporalAggregationType.SUM) + .withWindowSizeMinutes(794855452)))) + .withSignalFormula("ncghkje")) + .withWindowUptimeCriteria(new WindowUptimeCriteria().withTarget(56.497059361324276) + .withComparator(WindowUptimeCriteriaComparator.LESS_THAN_OR_EQUAL)); + model = BinaryData.fromObject(model).toObject(SliProperties.class); + Assertions.assertEquals("dmoh", model.goodSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("tbqvudw", + model.goodSignals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("dndnvow", model.goodSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("ujjugwdkcglh", model.goodSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("lazjdyggdtjixhbk", model.goodSignals().signalSources().get(0).metricName()); + Assertions.assertEquals("qweykhmenev", + model.goodSignals().signalSources().get(0).filters().get(0).dimensionName()); + Assertions.assertEquals(ScalarFunction.MIN, + model.goodSignals().signalSources().get(0).filters().get(0).scalarFunction()); + Assertions.assertEquals(SamplingType.AVG, + model.goodSignals().signalSources().get(0).filters().get(0).samplingType()); + Assertions.assertEquals(ConditionOperator.NOT_CONTAINS, + model.goodSignals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("hybcibv", model.goodSignals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.MIN, + model.goodSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("vmdajvnysou", + model.goodSignals().signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.IDELTA, + model.goodSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(860799201, + model.goodSignals().signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("lvmezyvshxmzsbbz", model.goodSignals().signalFormula()); + Assertions.assertEquals("igrxwburvjxxjn", model.totalSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("pydptko", + model.totalSignals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("nkoukn", model.totalSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("udwtiukbl", model.totalSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("ngkpocipazy", model.totalSignals().signalSources().get(0).metricName()); + Assertions.assertEquals("gukgjnpiucgygevq", + model.totalSignals().signalSources().get(0).filters().get(0).dimensionName()); + Assertions.assertEquals(ScalarFunction.SUM, + model.totalSignals().signalSources().get(0).filters().get(0).scalarFunction()); + Assertions.assertEquals(SamplingType.MAX, + model.totalSignals().signalSources().get(0).filters().get(0).samplingType()); + Assertions.assertEquals(ConditionOperator.NOT_EQUAL, + model.totalSignals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("rbpizc", model.totalSignals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.AVERAGE, + model.totalSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("j", + model.totalSignals().signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.IRATE, + model.totalSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(1326905161, + model.totalSignals().signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("ajdeyeamdphaga", model.totalSignals().signalFormula()); + Assertions.assertEquals("uxwgipwho", model.signals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("ow", model.signals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("gshwankixz", model.signals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("injep", model.signals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("ttmrywnuzoqf", model.signals().signalSources().get(0).metricName()); + Assertions.assertEquals("qzrnkcqvyxlwhz", + model.signals().signalSources().get(0).filters().get(0).dimensionName()); + Assertions.assertEquals(ScalarFunction.AVG, + model.signals().signalSources().get(0).filters().get(0).scalarFunction()); + Assertions.assertEquals(SamplingType.SUM, + model.signals().signalSources().get(0).filters().get(0).samplingType()); + Assertions.assertEquals(ConditionOperator.STARTS_WITH, + model.signals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("oqqnwvlryav", model.signals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.MIN, + model.signals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("uko", model.signals().signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.MIN, + model.signals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(1562497596, + model.signals().signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("ncghkje", model.signals().signalFormula()); + Assertions.assertEquals(56.497059361324276, model.windowUptimeCriteria().target()); + Assertions.assertEquals(WindowUptimeCriteriaComparator.LESS_THAN_OR_EQUAL, + model.windowUptimeCriteria().comparator()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliResourceTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliResourceTests.java new file mode 100644 index 000000000000..5fe836485370 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SliResourceTests.java @@ -0,0 +1,289 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.AmwAccount; +import com.azure.resourcemanager.monitor.slis.models.Baseline; +import com.azure.resourcemanager.monitor.slis.models.BaselineProperties; +import com.azure.resourcemanager.monitor.slis.models.Category; +import com.azure.resourcemanager.monitor.slis.models.Condition; +import com.azure.resourcemanager.monitor.slis.models.ConditionOperator; +import com.azure.resourcemanager.monitor.slis.models.EvaluationCalculationType; +import com.azure.resourcemanager.monitor.slis.models.EvaluationType; +import com.azure.resourcemanager.monitor.slis.models.Signal; +import com.azure.resourcemanager.monitor.slis.models.SignalSource; +import com.azure.resourcemanager.monitor.slis.models.SliProperties; +import com.azure.resourcemanager.monitor.slis.models.SliResource; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregation; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregation; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteria; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteriaComparator; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class SliResourceTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SliResource model = BinaryData.fromString( + "{\"provisioningState\":\"Failed\",\"description\":\"vfqawrlyxwjkcpr\",\"category\":\"Latency\",\"evaluationType\":\"WindowBased\",\"executionState\":{\"state\":\"xgjvtbv\",\"message\":\"sszdnru\"},\"destinationAmwAccounts\":[{\"resourceId\":\"guhmuouqfpr\",\"identity\":\"zw\"},{\"resourceId\":\"nguitnwuizgazxu\",\"identity\":\"izuckyfihrfidfvz\"}],\"destinationMetrics\":[{\"metricNamespace\":\"uht\",\"metricName\":\"mwisdkfthwxmnt\"},{\"metricNamespace\":\"i\",\"metricName\":\"aop\"},{\"metricNamespace\":\"km\",\"metricName\":\"jcmmxdcufufsrp\"},{\"metricNamespace\":\"mzidnsezcxtb\",\"metricName\":\"sgfyccsnew\"}],\"baselineProperties\":{\"baseline\":{\"value\":54.537750032723274,\"evaluationPeriodDays\":44464100,\"evaluationCalculationType\":\"RollingDays\"}},\"streamingRuleId\":\"iachbo\",\"streamingRuleLastUpdatedTimestamp\":\"2021-05-15T06:55:08Z\",\"enableAlert\":false,\"sliProperties\":{\"goodSignals\":{\"signalSources\":[{\"signalSourceId\":\"osfqpteehzzv\",\"sourceAmwAccountManagedIdentity\":\"pyqr\",\"sourceAmwAccountResourceId\":\"mzinpvswjdk\",\"metricNamespace\":\"rsoodqxhcrmnoh\",\"metricName\":\"t\",\"filters\":[{\"operator\":\"==\",\"value\":\"h\"}],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[\"ifiyipjxsqwpgrj\",\"znorcj\",\"vsnb\",\"xqabnmocpcysh\"]},\"temporalAggregation\":{\"type\":\"IRate\",\"windowSizeMinutes\":2023442123}}],\"signalFormula\":\"fblj\"},\"totalSignals\":{\"signalSources\":[{\"signalSourceId\":\"btoqcjmkljavbqid\",\"sourceAmwAccountManagedIdentity\":\"qajzyulpkudjkr\",\"sourceAmwAccountResourceId\":\"khbzhfepgzg\",\"metricNamespace\":\"e\",\"metricName\":\"zloc\",\"filters\":[{\"operator\":\"startswith\",\"value\":\"paierh\"},{\"operator\":\"<=\",\"value\":\"csglum\"}],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[\"tjaodxobnb\",\"xkqpxo\",\"ajionpimexgstxg\",\"po\"]},\"temporalAggregation\":{\"type\":\"Rate\",\"windowSizeMinutes\":1107396913}},{\"signalSourceId\":\"ajrmvdjwzrlovmc\",\"sourceAmwAccountManagedIdentity\":\"whijcoejctbza\",\"sourceAmwAccountResourceId\":\"s\",\"metricNamespace\":\"sycbkbfk\",\"metricName\":\"ukdkexxppofmxa\",\"filters\":[{\"operator\":\"==\",\"value\":\"jpgd\"}],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[\"c\",\"j\",\"hvpmoue\",\"hd\"]},\"temporalAggregation\":{\"type\":\"Increase\",\"windowSizeMinutes\":738311617}},{\"signalSourceId\":\"qeojnxqbzvddntw\",\"sourceAmwAccountManagedIdentity\":\"deicbtwnpzao\",\"sourceAmwAccountResourceId\":\"vuhrhcffcyddgl\",\"metricNamespace\":\"jthjqkwpyei\",\"metricName\":\"xmqci\",\"filters\":[{\"operator\":\">\",\"value\":\"hkh\"}],\"spatialAggregation\":{\"type\":\"Sum\",\"dimensions\":[\"igdtopbob\",\"og\",\"m\",\"w\"]},\"temporalAggregation\":{\"type\":\"Increase\",\"windowSizeMinutes\":248377661}}],\"signalFormula\":\"uhrzayvvt\"},\"signals\":{\"signalSources\":[{\"signalSourceId\":\"dfgiot\",\"sourceAmwAccountManagedIdentity\":\"ftutqxlngxlefgu\",\"sourceAmwAccountResourceId\":\"nxkrx\",\"metricNamespace\":\"qmi\",\"metricName\":\"tthzrvqd\",\"filters\":[{\"operator\":\"startswith\",\"value\":\"hjybigehoqfbo\"},{\"operator\":\"<\",\"value\":\"kanyktzlcuiywg\"}],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[\"gndrvynh\",\"gpphrcgyn\",\"ocpecfvmmco\",\"fsxlzevgbmqjqa\"]},\"temporalAggregation\":{\"type\":\"Increase\",\"windowSizeMinutes\":138991761}},{\"signalSourceId\":\"mivkwlzuvcc\",\"sourceAmwAccountManagedIdentity\":\"wnfnbacf\",\"sourceAmwAccountResourceId\":\"onlebxetqgtzxdpn\",\"metricNamespace\":\"bqqwxrj\",\"metricName\":\"eallnwsubisnj\",\"filters\":[{\"operator\":\"contains\",\"value\":\"mngnzscxaqw\"},{\"operator\":\"startswith\",\"value\":\"chcbonqvpkvlrxnj\"},{\"operator\":\"<\",\"value\":\"seiphe\"},{\"operator\":\"@in\",\"value\":\"lokeyy\"}],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[\"jbdlwtgrhpdjpju\"]},\"temporalAggregation\":{\"type\":\"Increase\",\"windowSizeMinutes\":1012728769}}],\"signalFormula\":\"azjpqyegualhbxxh\"},\"windowUptimeCriteria\":{\"target\":38.92750235772227,\"comparator\":\">=\"}}}") + .toObject(SliResource.class); + Assertions.assertEquals("vfqawrlyxwjkcpr", model.description()); + Assertions.assertEquals(Category.LATENCY, model.category()); + Assertions.assertEquals(EvaluationType.WINDOW_BASED, model.evaluationType()); + Assertions.assertEquals("guhmuouqfpr", model.destinationAmwAccounts().get(0).resourceId()); + Assertions.assertEquals("zw", model.destinationAmwAccounts().get(0).identity()); + Assertions.assertEquals(54.537750032723274, model.baselineProperties().baseline().value()); + Assertions.assertEquals(44464100, model.baselineProperties().baseline().evaluationPeriodDays()); + Assertions.assertEquals(EvaluationCalculationType.ROLLING_DAYS, + model.baselineProperties().baseline().evaluationCalculationType()); + Assertions.assertFalse(model.enableAlert()); + Assertions.assertEquals("osfqpteehzzv", + model.sliProperties().goodSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("pyqr", + model.sliProperties().goodSignals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("mzinpvswjdk", + model.sliProperties().goodSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("rsoodqxhcrmnoh", + model.sliProperties().goodSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("t", model.sliProperties().goodSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(ConditionOperator.EQUAL, + model.sliProperties().goodSignals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("h", + model.sliProperties().goodSignals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.COUNT, + model.sliProperties().goodSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("ifiyipjxsqwpgrj", + model.sliProperties().goodSignals().signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.IRATE, + model.sliProperties().goodSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(2023442123, + model.sliProperties().goodSignals().signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("fblj", model.sliProperties().goodSignals().signalFormula()); + Assertions.assertEquals("btoqcjmkljavbqid", + model.sliProperties().totalSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("qajzyulpkudjkr", + model.sliProperties().totalSignals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("khbzhfepgzg", + model.sliProperties().totalSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("e", model.sliProperties().totalSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("zloc", model.sliProperties().totalSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(ConditionOperator.STARTS_WITH, + model.sliProperties().totalSignals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("paierh", + model.sliProperties().totalSignals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.AVERAGE, + model.sliProperties().totalSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("tjaodxobnb", + model.sliProperties().totalSignals().signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.RATE, + model.sliProperties().totalSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(1107396913, + model.sliProperties().totalSignals().signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("uhrzayvvt", model.sliProperties().totalSignals().signalFormula()); + Assertions.assertEquals("dfgiot", model.sliProperties().signals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("ftutqxlngxlefgu", + model.sliProperties().signals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("nxkrx", + model.sliProperties().signals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("qmi", model.sliProperties().signals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("tthzrvqd", model.sliProperties().signals().signalSources().get(0).metricName()); + Assertions.assertEquals(ConditionOperator.STARTS_WITH, + model.sliProperties().signals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("hjybigehoqfbo", + model.sliProperties().signals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.COUNT, + model.sliProperties().signals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("gndrvynh", + model.sliProperties().signals().signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.INCREASE, + model.sliProperties().signals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(138991761, + model.sliProperties().signals().signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("azjpqyegualhbxxh", model.sliProperties().signals().signalFormula()); + Assertions.assertEquals(38.92750235772227, model.sliProperties().windowUptimeCriteria().target()); + Assertions.assertEquals(WindowUptimeCriteriaComparator.GREATER_THAN_OR_EQUAL, + model.sliProperties().windowUptimeCriteria().comparator()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + SliResource model = new SliResource().withDescription("vfqawrlyxwjkcpr") + .withCategory(Category.LATENCY) + .withEvaluationType(EvaluationType.WINDOW_BASED) + .withDestinationAmwAccounts(Arrays.asList(new AmwAccount().withResourceId("guhmuouqfpr").withIdentity("zw"), + new AmwAccount().withResourceId("nguitnwuizgazxu").withIdentity("izuckyfihrfidfvz"))) + .withBaselineProperties(new BaselineProperties().withBaseline(new Baseline().withValue(54.537750032723274) + .withEvaluationPeriodDays(44464100) + .withEvaluationCalculationType(EvaluationCalculationType.ROLLING_DAYS))) + .withEnableAlert(false) + .withSliProperties(new SliProperties() + .withGoodSignals(new Signal().withSignalSources(Arrays.asList(new SignalSource() + .withSignalSourceId("osfqpteehzzv") + .withSourceAmwAccountManagedIdentity("pyqr") + .withSourceAmwAccountResourceId("mzinpvswjdk") + .withMetricNamespace("rsoodqxhcrmnoh") + .withMetricName("t") + .withFilters(Arrays.asList(new Condition().withOperator(ConditionOperator.EQUAL).withValue("h"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.COUNT) + .withDimensions(Arrays.asList("ifiyipjxsqwpgrj", "znorcj", "vsnb", "xqabnmocpcysh"))) + .withTemporalAggregation(new TemporalAggregation().withType(TemporalAggregationType.IRATE) + .withWindowSizeMinutes(2023442123)))) + .withSignalFormula("fblj")) + .withTotalSignals( + new Signal() + .withSignalSources(Arrays.asList( + new SignalSource().withSignalSourceId("btoqcjmkljavbqid") + .withSourceAmwAccountManagedIdentity("qajzyulpkudjkr") + .withSourceAmwAccountResourceId("khbzhfepgzg") + .withMetricNamespace("e") + .withMetricName("zloc") + .withFilters(Arrays.asList( + new Condition().withOperator(ConditionOperator.STARTS_WITH).withValue("paierh"), + new Condition().withOperator(ConditionOperator.LESS_THAN_OR_EQUAL) + .withValue("csglum"))) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.AVERAGE) + .withDimensions(Arrays.asList("tjaodxobnb", "xkqpxo", "ajionpimexgstxg", "po"))) + .withTemporalAggregation(new TemporalAggregation() + .withType(TemporalAggregationType.RATE) + .withWindowSizeMinutes(1107396913)), + new SignalSource().withSignalSourceId("ajrmvdjwzrlovmc") + .withSourceAmwAccountManagedIdentity("whijcoejctbza") + .withSourceAmwAccountResourceId("s") + .withMetricNamespace("sycbkbfk") + .withMetricName("ukdkexxppofmxa") + .withFilters(Arrays + .asList(new Condition().withOperator(ConditionOperator.EQUAL).withValue("jpgd"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.MAX) + .withDimensions(Arrays.asList("c", "j", "hvpmoue", "hd"))) + .withTemporalAggregation(new TemporalAggregation() + .withType(TemporalAggregationType.INCREASE) + .withWindowSizeMinutes(738311617)), + new SignalSource() + .withSignalSourceId("qeojnxqbzvddntw") + .withSourceAmwAccountManagedIdentity("deicbtwnpzao") + .withSourceAmwAccountResourceId("vuhrhcffcyddgl") + .withMetricNamespace("jthjqkwpyei") + .withMetricName("xmqci") + .withFilters(Arrays.asList( + new Condition().withOperator(ConditionOperator.GREATER_THAN).withValue("hkh"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.SUM) + .withDimensions(Arrays.asList("igdtopbob", "og", "m", "w"))) + .withTemporalAggregation(new TemporalAggregation() + .withType(TemporalAggregationType.INCREASE) + .withWindowSizeMinutes(248377661)))) + .withSignalFormula("uhrzayvvt")) + .withSignals(new Signal().withSignalSources(Arrays.asList( + new SignalSource().withSignalSourceId("dfgiot") + .withSourceAmwAccountManagedIdentity("ftutqxlngxlefgu") + .withSourceAmwAccountResourceId("nxkrx") + .withMetricNamespace("qmi") + .withMetricName("tthzrvqd") + .withFilters(Arrays.asList( + new Condition().withOperator(ConditionOperator.STARTS_WITH).withValue("hjybigehoqfbo"), + new Condition().withOperator(ConditionOperator.LESS_THAN).withValue("kanyktzlcuiywg"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.COUNT) + .withDimensions(Arrays.asList("gndrvynh", "gpphrcgyn", "ocpecfvmmco", "fsxlzevgbmqjqa"))) + .withTemporalAggregation(new TemporalAggregation().withType(TemporalAggregationType.INCREASE) + .withWindowSizeMinutes(138991761)), + new SignalSource().withSignalSourceId("mivkwlzuvcc") + .withSourceAmwAccountManagedIdentity("wnfnbacf") + .withSourceAmwAccountResourceId("onlebxetqgtzxdpn") + .withMetricNamespace("bqqwxrj") + .withMetricName("eallnwsubisnj") + .withFilters(Arrays.asList( + new Condition().withOperator(ConditionOperator.CONTAINS).withValue("mngnzscxaqw"), + new Condition().withOperator(ConditionOperator.STARTS_WITH).withValue("chcbonqvpkvlrxnj"), + new Condition().withOperator(ConditionOperator.LESS_THAN).withValue("seiphe"), + new Condition().withOperator(ConditionOperator.IN).withValue("lokeyy"))) + .withSpatialAggregation(new SpatialAggregation().withType(SpatialAggregationType.MIN) + .withDimensions(Arrays.asList("jbdlwtgrhpdjpju"))) + .withTemporalAggregation(new TemporalAggregation().withType(TemporalAggregationType.INCREASE) + .withWindowSizeMinutes(1012728769)))) + .withSignalFormula("azjpqyegualhbxxh")) + .withWindowUptimeCriteria(new WindowUptimeCriteria().withTarget(38.92750235772227) + .withComparator(WindowUptimeCriteriaComparator.GREATER_THAN_OR_EQUAL))); + model = BinaryData.fromObject(model).toObject(SliResource.class); + Assertions.assertEquals("vfqawrlyxwjkcpr", model.description()); + Assertions.assertEquals(Category.LATENCY, model.category()); + Assertions.assertEquals(EvaluationType.WINDOW_BASED, model.evaluationType()); + Assertions.assertEquals("guhmuouqfpr", model.destinationAmwAccounts().get(0).resourceId()); + Assertions.assertEquals("zw", model.destinationAmwAccounts().get(0).identity()); + Assertions.assertEquals(54.537750032723274, model.baselineProperties().baseline().value()); + Assertions.assertEquals(44464100, model.baselineProperties().baseline().evaluationPeriodDays()); + Assertions.assertEquals(EvaluationCalculationType.ROLLING_DAYS, + model.baselineProperties().baseline().evaluationCalculationType()); + Assertions.assertFalse(model.enableAlert()); + Assertions.assertEquals("osfqpteehzzv", + model.sliProperties().goodSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("pyqr", + model.sliProperties().goodSignals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("mzinpvswjdk", + model.sliProperties().goodSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("rsoodqxhcrmnoh", + model.sliProperties().goodSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("t", model.sliProperties().goodSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(ConditionOperator.EQUAL, + model.sliProperties().goodSignals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("h", + model.sliProperties().goodSignals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.COUNT, + model.sliProperties().goodSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("ifiyipjxsqwpgrj", + model.sliProperties().goodSignals().signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.IRATE, + model.sliProperties().goodSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(2023442123, + model.sliProperties().goodSignals().signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("fblj", model.sliProperties().goodSignals().signalFormula()); + Assertions.assertEquals("btoqcjmkljavbqid", + model.sliProperties().totalSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("qajzyulpkudjkr", + model.sliProperties().totalSignals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("khbzhfepgzg", + model.sliProperties().totalSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("e", model.sliProperties().totalSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("zloc", model.sliProperties().totalSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(ConditionOperator.STARTS_WITH, + model.sliProperties().totalSignals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("paierh", + model.sliProperties().totalSignals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.AVERAGE, + model.sliProperties().totalSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("tjaodxobnb", + model.sliProperties().totalSignals().signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.RATE, + model.sliProperties().totalSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(1107396913, + model.sliProperties().totalSignals().signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("uhrzayvvt", model.sliProperties().totalSignals().signalFormula()); + Assertions.assertEquals("dfgiot", model.sliProperties().signals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("ftutqxlngxlefgu", + model.sliProperties().signals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("nxkrx", + model.sliProperties().signals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("qmi", model.sliProperties().signals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("tthzrvqd", model.sliProperties().signals().signalSources().get(0).metricName()); + Assertions.assertEquals(ConditionOperator.STARTS_WITH, + model.sliProperties().signals().signalSources().get(0).filters().get(0).operator()); + Assertions.assertEquals("hjybigehoqfbo", + model.sliProperties().signals().signalSources().get(0).filters().get(0).value()); + Assertions.assertEquals(SpatialAggregationType.COUNT, + model.sliProperties().signals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals("gndrvynh", + model.sliProperties().signals().signalSources().get(0).spatialAggregation().dimensions().get(0)); + Assertions.assertEquals(TemporalAggregationType.INCREASE, + model.sliProperties().signals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals(138991761, + model.sliProperties().signals().signalSources().get(0).temporalAggregation().windowSizeMinutes()); + Assertions.assertEquals("azjpqyegualhbxxh", model.sliProperties().signals().signalFormula()); + Assertions.assertEquals(38.92750235772227, model.sliProperties().windowUptimeCriteria().target()); + Assertions.assertEquals(WindowUptimeCriteriaComparator.GREATER_THAN_OR_EQUAL, + model.sliProperties().windowUptimeCriteria().comparator()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisCreateOrUpdateWithResponseMockTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisCreateOrUpdateWithResponseMockTests.java new file mode 100644 index 000000000000..f4b04d21f34d --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisCreateOrUpdateWithResponseMockTests.java @@ -0,0 +1,260 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.monitor.slis.SlisManager; +import com.azure.resourcemanager.monitor.slis.fluent.models.SliInner; +import com.azure.resourcemanager.monitor.slis.models.AmwAccount; +import com.azure.resourcemanager.monitor.slis.models.Baseline; +import com.azure.resourcemanager.monitor.slis.models.BaselineProperties; +import com.azure.resourcemanager.monitor.slis.models.Category; +import com.azure.resourcemanager.monitor.slis.models.EvaluationCalculationType; +import com.azure.resourcemanager.monitor.slis.models.EvaluationType; +import com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.slis.models.Signal; +import com.azure.resourcemanager.monitor.slis.models.SignalSource; +import com.azure.resourcemanager.monitor.slis.models.Sli; +import com.azure.resourcemanager.monitor.slis.models.SliProperties; +import com.azure.resourcemanager.monitor.slis.models.SliResource; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregation; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregation; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType; +import com.azure.resourcemanager.monitor.slis.models.UserAssignedIdentity; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteria; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteriaComparator; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SlisCreateOrUpdateWithResponseMockTests { + @Test + public void testCreateOrUpdateWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"provisioningState\":\"Failed\",\"description\":\"lhalnswh\",\"category\":\"Availability\",\"evaluationType\":\"WindowBased\",\"executionState\":{\"state\":\"hka\",\"message\":\"witqscywuggwoluh\"},\"destinationAmwAccounts\":[{\"resourceId\":\"bwemhairs\",\"identity\":\"rgzdwmsweyp\"},{\"resourceId\":\"w\",\"identity\":\"xggicccnxqhuexmk\"}],\"destinationMetrics\":[{\"metricNamespace\":\"stvlzywemhzrnc\",\"metricName\":\"dtclusiypb\"},{\"metricNamespace\":\"fgytguslfeadcyg\",\"metricName\":\"ukyhejhzis\"},{\"metricNamespace\":\"gfpelolppvksrpqv\",\"metricName\":\"jzraehtwdwrf\"}],\"baselineProperties\":{\"baseline\":{\"value\":33.494544229054966,\"evaluationPeriodDays\":767551661,\"evaluationCalculationType\":\"RollingDays\"}},\"streamingRuleId\":\"rcdlbhshfwpr\",\"streamingRuleLastUpdatedTimestamp\":\"2021-11-29T07:17:38Z\",\"enableAlert\":true,\"sliProperties\":{\"goodSignals\":{\"signalSources\":[{\"signalSourceId\":\"ty\",\"sourceAmwAccountManagedIdentity\":\"hevxcced\",\"sourceAmwAccountResourceId\":\"pnmdyodnwzxltjcv\",\"metricNamespace\":\"hlt\",\"metricName\":\"ugcxnavvwxq\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Min\"}},{\"signalSourceId\":\"qunyowxwlmdjr\",\"sourceAmwAccountManagedIdentity\":\"vfgbvfvpdboda\",\"sourceAmwAccountResourceId\":\"izsjqlhkrr\",\"metricNamespace\":\"bdeibqipqk\",\"metricName\":\"hvxndzwmkrefajpj\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Rate\"}}],\"signalFormula\":\"kqnyh\"},\"totalSignals\":{\"signalSources\":[{\"signalSourceId\":\"j\",\"sourceAmwAccountManagedIdentity\":\"jivfxzsjabib\",\"sourceAmwAccountResourceId\":\"ystawfsdjpvkvp\",\"metricNamespace\":\"jxbkzbzkdvn\",\"metricName\":\"jabudurgkakmo\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Average\"}}],\"signalFormula\":\"jjklff\"},\"signals\":{\"signalSources\":[{\"signalSourceId\":\"uwqlgzrfzeey\",\"sourceAmwAccountManagedIdentity\":\"bizikayuhq\",\"sourceAmwAccountResourceId\":\"bjbsybb\",\"metricNamespace\":\"wrv\",\"metricName\":\"ldgmfpgvmpip\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Delta\"}}],\"signalFormula\":\"thaqfxssmwu\"},\"windowUptimeCriteria\":{\"target\":31.752490870226723,\"comparator\":\">\"}}},\"identity\":{\"principalId\":\"zpdrhneu\",\"tenantId\":\"wqkdwytisibi\",\"type\":\"SystemAssigned\",\"userAssignedIdentities\":{\"anlfzxiavrmbz\":{\"principalId\":\"kpzi\",\"clientId\":\"j\"},\"nwoiind\":{\"principalId\":\"okixrjqcir\",\"clientId\":\"pfrlazsz\"}}},\"id\":\"wp\",\"name\":\"ylwbtlhflsjcdhsz\",\"type\":\"jvfbgofelja\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + SlisManager manager = SlisManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + Sli response + = manager.slis() + .createOrUpdateWithResponse("atdooaojkniod", "oo", new SliInner() + .withProperties(new SliResource().withDescription("ujhemmsbvdkcrodt") + .withCategory(Category.LATENCY) + .withEvaluationType(EvaluationType.REQUEST_BASED) + .withDestinationAmwAccounts(Arrays.asList( + new AmwAccount().withResourceId("cjvefkdlfo").withIdentity("kggkfpa"), + new AmwAccount().withResourceId("ao").withIdentity("pulpqblylsyxk"))) + .withBaselineProperties(new BaselineProperties().withBaseline(new Baseline() + .withValue(13.059784474144799) + .withEvaluationPeriodDays(993241324) + .withEvaluationCalculationType(EvaluationCalculationType.ROLLING_DAYS))) + .withEnableAlert(false) + .withSliProperties(new SliProperties().withGoodSignals(new Signal() + .withSignalSources(Arrays.asList(new SignalSource().withSignalSourceId("v") + .withSourceAmwAccountManagedIdentity("jjxd") + .withSourceAmwAccountResourceId("rbuukzclewyhmlwp") + .withMetricNamespace("ztzp") + .withMetricName("fn") + .withFilters(Arrays.asList()) + .withSpatialAggregation(new SpatialAggregation() + .withType(SpatialAggregationType.COUNT) + .withDimensions(Arrays.asList())) + .withTemporalAggregation(new TemporalAggregation().withType( + TemporalAggregationType.MAX)), + new SignalSource().withSignalSourceId("wyfzqwhxxbuyqa") + .withSourceAmwAccountManagedIdentity("zfeqztppri") + .withSourceAmwAccountResourceId("lxorjaltolmncws") + .withMetricNamespace("bqwcsdbnwdcf") + .withMetricName("ucqdpfuvglsb") + .withFilters(Arrays.asList()) + .withSpatialAggregation( + new SpatialAggregation() + .withType(SpatialAggregationType.COUNT) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.SUM)), + new SignalSource().withSignalSourceId("anvx") + .withSourceAmwAccountManagedIdentity("vtvudutncormr") + .withSourceAmwAccountResourceId("xqtvcofu") + .withMetricNamespace("f") + .withMetricName("vkg") + .withFilters(Arrays.asList()) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.COUNT) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.RATE)), + new SignalSource() + .withSignalSourceId("gdknnqv") + .withSourceAmwAccountManagedIdentity("aznqntoru") + .withSourceAmwAccountResourceId("sgsahmkycgr") + .withMetricNamespace("uwjuetaeburuvdmo") + .withMetricName("s") + .withFilters(Arrays.asList()) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.AVERAGE) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.IRATE)))) + .withSignalFormula("xwabmqoe")) + .withTotalSignals(new Signal() + .withSignalSources(Arrays.asList( + new SignalSource().withSignalSourceId("frvtpuqu") + .withSourceAmwAccountManagedIdentity("mqlgk") + .withSourceAmwAccountResourceId("btndo") + .withMetricNamespace("ongbjcnt") + .withMetricName("jitcjedftwwaez") + .withFilters(Arrays.asList()) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.SUM) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.SUM)), + new SignalSource().withSignalSourceId("v") + .withSourceAmwAccountManagedIdentity("c") + .withSourceAmwAccountResourceId("zfoqouicybxar") + .withMetricNamespace("gszufoxciqopid") + .withMetricName("amcio") + .withFilters(Arrays.asList()) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.MAX) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.MIN)))) + .withSignalFormula("haz")) + .withSignals(new Signal() + .withSignalSources(Arrays.asList( + new SignalSource().withSignalSourceId("nz") + .withSourceAmwAccountManagedIdentity("onlwntoeg") + .withSourceAmwAccountResourceId("kdwbwhkszz") + .withMetricNamespace("mrv") + .withMetricName("xztvbtqgsfraoyzk") + .withFilters(Arrays.asList()) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.AVERAGE) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.AVERAGE)), + new SignalSource().withSignalSourceId("tlmngu") + .withSourceAmwAccountManagedIdentity("aw") + .withSourceAmwAccountResourceId("aldsy") + .withMetricNamespace("uximerqfobw") + .withMetricName("znkbykutwpfhpagm") + .withFilters(Arrays.asList()) + .withSpatialAggregation( + new SpatialAggregation().withType(SpatialAggregationType.MAX) + .withDimensions(Arrays.asList())) + .withTemporalAggregation( + new TemporalAggregation().withType(TemporalAggregationType.RATE)))) + .withSignalFormula("kdsnfdsdoakgtdl")) + .withWindowUptimeCriteria(new WindowUptimeCriteria().withTarget(85.74386556222765) + .withComparator(WindowUptimeCriteriaComparator.GREATER_THAN)))) + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.SYSTEM_ASSIGNED) + .withUserAssignedIdentities( + mapOf("enuuzkopbm", new UserAssignedIdentity(), "mlmz", new UserAssignedIdentity()))), + com.azure.core.util.Context.NONE) + .getValue(); + + Assertions.assertEquals("lhalnswh", response.properties().description()); + Assertions.assertEquals(Category.AVAILABILITY, response.properties().category()); + Assertions.assertEquals(EvaluationType.WINDOW_BASED, response.properties().evaluationType()); + Assertions.assertEquals("bwemhairs", response.properties().destinationAmwAccounts().get(0).resourceId()); + Assertions.assertEquals("rgzdwmsweyp", response.properties().destinationAmwAccounts().get(0).identity()); + Assertions.assertEquals(33.494544229054966, response.properties().baselineProperties().baseline().value()); + Assertions.assertEquals(767551661, + response.properties().baselineProperties().baseline().evaluationPeriodDays()); + Assertions.assertEquals(EvaluationCalculationType.ROLLING_DAYS, + response.properties().baselineProperties().baseline().evaluationCalculationType()); + Assertions.assertTrue(response.properties().enableAlert()); + Assertions.assertEquals("ty", + response.properties().sliProperties().goodSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("hevxcced", + response.properties() + .sliProperties() + .goodSignals() + .signalSources() + .get(0) + .sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("pnmdyodnwzxltjcv", + response.properties().sliProperties().goodSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("hlt", + response.properties().sliProperties().goodSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("ugcxnavvwxq", + response.properties().sliProperties().goodSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(SpatialAggregationType.MIN, + response.properties().sliProperties().goodSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals(TemporalAggregationType.MIN, + response.properties().sliProperties().goodSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals("kqnyh", response.properties().sliProperties().goodSignals().signalFormula()); + Assertions.assertEquals("j", + response.properties().sliProperties().totalSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("jivfxzsjabib", + response.properties() + .sliProperties() + .totalSignals() + .signalSources() + .get(0) + .sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("ystawfsdjpvkvp", + response.properties().sliProperties().totalSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("jxbkzbzkdvn", + response.properties().sliProperties().totalSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("jabudurgkakmo", + response.properties().sliProperties().totalSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(SpatialAggregationType.MAX, + response.properties().sliProperties().totalSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals(TemporalAggregationType.AVERAGE, + response.properties().sliProperties().totalSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals("jjklff", response.properties().sliProperties().totalSignals().signalFormula()); + Assertions.assertEquals("uwqlgzrfzeey", + response.properties().sliProperties().signals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("bizikayuhq", + response.properties().sliProperties().signals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("bjbsybb", + response.properties().sliProperties().signals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("wrv", + response.properties().sliProperties().signals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("ldgmfpgvmpip", + response.properties().sliProperties().signals().signalSources().get(0).metricName()); + Assertions.assertEquals(SpatialAggregationType.MAX, + response.properties().sliProperties().signals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals(TemporalAggregationType.DELTA, + response.properties().sliProperties().signals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals("thaqfxssmwu", response.properties().sliProperties().signals().signalFormula()); + Assertions.assertEquals(31.752490870226723, + response.properties().sliProperties().windowUptimeCriteria().target()); + Assertions.assertEquals(WindowUptimeCriteriaComparator.GREATER_THAN, + response.properties().sliProperties().windowUptimeCriteria().comparator()); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED, response.identity().type()); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisDeleteByResourceGroupWithResponseMockTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisDeleteByResourceGroupWithResponseMockTests.java new file mode 100644 index 000000000000..ff20a50132fd --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisDeleteByResourceGroupWithResponseMockTests.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.monitor.slis.SlisManager; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SlisDeleteByResourceGroupWithResponseMockTests { + @Test + public void testDeleteWithResponse() throws Exception { + String responseStr = "{}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + SlisManager manager = SlisManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + manager.slis().deleteByResourceGroupWithResponse("rqmq", "ldvriiiojnalghfk", com.azure.core.util.Context.NONE); + + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisGetWithResponseMockTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisGetWithResponseMockTests.java new file mode 100644 index 000000000000..4c7abc77286f --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisGetWithResponseMockTests.java @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.monitor.slis.SlisManager; +import com.azure.resourcemanager.monitor.slis.models.Category; +import com.azure.resourcemanager.monitor.slis.models.EvaluationCalculationType; +import com.azure.resourcemanager.monitor.slis.models.EvaluationType; +import com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.slis.models.Sli; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteriaComparator; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SlisGetWithResponseMockTests { + @Test + public void testGetWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"provisioningState\":\"Failed\",\"description\":\"fpubjibwwi\",\"category\":\"Latency\",\"evaluationType\":\"RequestBased\",\"executionState\":{\"state\":\"qkvpuvksgplsakn\",\"message\":\"fsynljphuop\"},\"destinationAmwAccounts\":[{\"resourceId\":\"dlqiyntorzih\",\"identity\":\"eosjswsr\"},{\"resourceId\":\"slyzrpzbchckqq\",\"identity\":\"qioxi\"},{\"resourceId\":\"suiizynkedyat\",\"identity\":\"wyhqmibzyhwits\"}],\"destinationMetrics\":[{\"metricNamespace\":\"yynpcdpumnzgmwz\",\"metricName\":\"mabiknsorgjhxb\"}],\"baselineProperties\":{\"baseline\":{\"value\":50.25586250539239,\"evaluationPeriodDays\":1166597262,\"evaluationCalculationType\":\"RollingDays\"}},\"streamingRuleId\":\"rlkdmtncvokotl\",\"streamingRuleLastUpdatedTimestamp\":\"2021-09-05T12:27:29Z\",\"enableAlert\":false,\"sliProperties\":{\"goodSignals\":{\"signalSources\":[{\"signalSourceId\":\"syocogjltdtbnnha\",\"sourceAmwAccountManagedIdentity\":\"oocrkvcikhnv\",\"sourceAmwAccountResourceId\":\"amqgxqquezikyw\",\"metricNamespace\":\"gxk\",\"metricName\":\"lla\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Min\"}},{\"signalSourceId\":\"lwuip\",\"sourceAmwAccountManagedIdentity\":\"ccjzkzivgvv\",\"sourceAmwAccountResourceId\":\"nayrhyrnxxmueedn\",\"metricNamespace\":\"rdvstkwqqtch\",\"metricName\":\"alm\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Sum\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"IRate\"}}],\"signalFormula\":\"d\"},\"totalSignals\":{\"signalSources\":[{\"signalSourceId\":\"gdv\",\"sourceAmwAccountManagedIdentity\":\"vgpiohgwxrt\",\"sourceAmwAccountResourceId\":\"udxepxgyqagv\",\"metricNamespace\":\"vmnpkukghimdblx\",\"metricName\":\"wi\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Average\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Sum\"}},{\"signalSourceId\":\"jhfjxwm\",\"sourceAmwAccountManagedIdentity\":\"zk\",\"sourceAmwAccountResourceId\":\"foqreyfkzik\",\"metricNamespace\":\"jawneaiv\",\"metricName\":\"wczelpci\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Increase\"}}],\"signalFormula\":\"sfeaenwabfat\"},\"signals\":{\"signalSources\":[{\"signalSourceId\":\"dxbjhwuaanozj\",\"sourceAmwAccountManagedIdentity\":\"sphyoulpjrvxa\",\"sourceAmwAccountResourceId\":\"l\",\"metricNamespace\":\"vimjwos\",\"metricName\":\"tx\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Sum\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Average\"}},{\"signalSourceId\":\"skfc\",\"sourceAmwAccountManagedIdentity\":\"tq\",\"sourceAmwAccountResourceId\":\"miekkezzikhlyfjh\",\"metricNamespace\":\"gqggebdunygae\",\"metricName\":\"idb\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Rate\"}},{\"signalSourceId\":\"t\",\"sourceAmwAccountManagedIdentity\":\"xllrxcyjm\",\"sourceAmwAccountResourceId\":\"a\",\"metricNamespace\":\"su\",\"metricName\":\"arm\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Rate\"}},{\"signalSourceId\":\"mjsjqb\",\"sourceAmwAccountManagedIdentity\":\"hhyxxrw\",\"sourceAmwAccountResourceId\":\"yc\",\"metricNamespace\":\"duhpk\",\"metricName\":\"kgymareqnajxqug\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Max\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Delta\"}}],\"signalFormula\":\"ycubeddgs\"},\"windowUptimeCriteria\":{\"target\":74.75268861048747,\"comparator\":\">=\"}}},\"identity\":{\"principalId\":\"qal\",\"tenantId\":\"mnjijpxacqqudf\",\"type\":\"UserAssigned\",\"userAssignedIdentities\":{\"evfdnwnwm\":{\"principalId\":\"aaabjyvayff\",\"clientId\":\"rzrtuzqogsex\"},\"thzvaytdwkqbrqu\":{\"principalId\":\"zsyyceuzso\",\"clientId\":\"judpfrxt\"},\"oaxoruzfgsqu\":{\"principalId\":\"axhexiilivp\",\"clientId\":\"iirqtd\"}}},\"id\":\"xrxxlep\",\"name\":\"ramxjezwlwnw\",\"type\":\"uqlcvydy\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + SlisManager manager = SlisManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + Sli response + = manager.slis().getWithResponse("nzar", "wlquuijfqkace", com.azure.core.util.Context.NONE).getValue(); + + Assertions.assertEquals("fpubjibwwi", response.properties().description()); + Assertions.assertEquals(Category.LATENCY, response.properties().category()); + Assertions.assertEquals(EvaluationType.REQUEST_BASED, response.properties().evaluationType()); + Assertions.assertEquals("dlqiyntorzih", response.properties().destinationAmwAccounts().get(0).resourceId()); + Assertions.assertEquals("eosjswsr", response.properties().destinationAmwAccounts().get(0).identity()); + Assertions.assertEquals(50.25586250539239, response.properties().baselineProperties().baseline().value()); + Assertions.assertEquals(1166597262, + response.properties().baselineProperties().baseline().evaluationPeriodDays()); + Assertions.assertEquals(EvaluationCalculationType.ROLLING_DAYS, + response.properties().baselineProperties().baseline().evaluationCalculationType()); + Assertions.assertFalse(response.properties().enableAlert()); + Assertions.assertEquals("syocogjltdtbnnha", + response.properties().sliProperties().goodSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("oocrkvcikhnv", + response.properties() + .sliProperties() + .goodSignals() + .signalSources() + .get(0) + .sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("amqgxqquezikyw", + response.properties().sliProperties().goodSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("gxk", + response.properties().sliProperties().goodSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("lla", + response.properties().sliProperties().goodSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(SpatialAggregationType.MAX, + response.properties().sliProperties().goodSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals(TemporalAggregationType.MIN, + response.properties().sliProperties().goodSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals("d", response.properties().sliProperties().goodSignals().signalFormula()); + Assertions.assertEquals("gdv", + response.properties().sliProperties().totalSignals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("vgpiohgwxrt", + response.properties() + .sliProperties() + .totalSignals() + .signalSources() + .get(0) + .sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("udxepxgyqagv", + response.properties().sliProperties().totalSignals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("vmnpkukghimdblx", + response.properties().sliProperties().totalSignals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("wi", + response.properties().sliProperties().totalSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(SpatialAggregationType.AVERAGE, + response.properties().sliProperties().totalSignals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals(TemporalAggregationType.SUM, + response.properties().sliProperties().totalSignals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals("sfeaenwabfat", response.properties().sliProperties().totalSignals().signalFormula()); + Assertions.assertEquals("dxbjhwuaanozj", + response.properties().sliProperties().signals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("sphyoulpjrvxa", + response.properties().sliProperties().signals().signalSources().get(0).sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("l", + response.properties().sliProperties().signals().signalSources().get(0).sourceAmwAccountResourceId()); + Assertions.assertEquals("vimjwos", + response.properties().sliProperties().signals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("tx", + response.properties().sliProperties().signals().signalSources().get(0).metricName()); + Assertions.assertEquals(SpatialAggregationType.SUM, + response.properties().sliProperties().signals().signalSources().get(0).spatialAggregation().type()); + Assertions.assertEquals(TemporalAggregationType.AVERAGE, + response.properties().sliProperties().signals().signalSources().get(0).temporalAggregation().type()); + Assertions.assertEquals("ycubeddgs", response.properties().sliProperties().signals().signalFormula()); + Assertions.assertEquals(74.75268861048747, + response.properties().sliProperties().windowUptimeCriteria().target()); + Assertions.assertEquals(WindowUptimeCriteriaComparator.GREATER_THAN_OR_EQUAL, + response.properties().sliProperties().windowUptimeCriteria().comparator()); + Assertions.assertEquals(ManagedServiceIdentityType.USER_ASSIGNED, response.identity().type()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisListByParentMockTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisListByParentMockTests.java new file mode 100644 index 000000000000..96e01a0cdcf3 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SlisListByParentMockTests.java @@ -0,0 +1,230 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.monitor.slis.SlisManager; +import com.azure.resourcemanager.monitor.slis.models.Category; +import com.azure.resourcemanager.monitor.slis.models.EvaluationCalculationType; +import com.azure.resourcemanager.monitor.slis.models.EvaluationType; +import com.azure.resourcemanager.monitor.slis.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.slis.models.Sli; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteriaComparator; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SlisListByParentMockTests { + @Test + public void testListByParent() throws Exception { + String responseStr + = "{\"value\":[{\"properties\":{\"provisioningState\":\"Canceled\",\"description\":\"ahhxvrh\",\"category\":\"Availability\",\"evaluationType\":\"RequestBased\",\"executionState\":{\"state\":\"pjgwwspug\",\"message\":\"tqs\"},\"destinationAmwAccounts\":[{\"resourceId\":\"qxujxukndxd\",\"identity\":\"grjguufzd\"},{\"resourceId\":\"syqtfi\",\"identity\":\"whbotzingamv\"},{\"resourceId\":\"phoszqz\",\"identity\":\"dphqamv\"},{\"resourceId\":\"kfwynw\",\"identity\":\"vtbvkayh\"}],\"destinationMetrics\":[{\"metricNamespace\":\"vyqia\",\"metricName\":\"kzwpcnpw\"}],\"baselineProperties\":{\"baseline\":{\"value\":55.10261161552592,\"evaluationPeriodDays\":48409211,\"evaluationCalculationType\":\"RollingDays\"}},\"streamingRuleId\":\"gvvs\",\"streamingRuleLastUpdatedTimestamp\":\"2021-10-01T18:08:28Z\",\"enableAlert\":false,\"sliProperties\":{\"goodSignals\":{\"signalSources\":[{\"signalSourceId\":\"uq\",\"sourceAmwAccountManagedIdentity\":\"hwyg\",\"sourceAmwAccountResourceId\":\"lvdnkfx\",\"metricNamespace\":\"semdwzrmu\",\"metricName\":\"apfcqdpsq\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Sum\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"IRate\"}}],\"signalFormula\":\"psvuoymgc\"},\"totalSignals\":{\"signalSources\":[{\"signalSourceId\":\"vezrypqlmfeo\",\"sourceAmwAccountManagedIdentity\":\"erqwkyhkobopg\",\"sourceAmwAccountResourceId\":\"edkowepbqpcrfk\",\"metricNamespace\":\"wccsnjvcdwxlpqek\",\"metricName\":\"tn\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Count\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Min\"}}],\"signalFormula\":\"jsyingwfqatm\"},\"signals\":{\"signalSources\":[{\"signalSourceId\":\"tmdvypgikdgs\",\"sourceAmwAccountManagedIdentity\":\"ywkbirryuzhlhkjo\",\"sourceAmwAccountResourceId\":\"rvqqaatj\",\"metricNamespace\":\"nrvgoupmfiibfgg\",\"metricName\":\"ioolvrwxkvtkkgll\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"Min\"}},{\"signalSourceId\":\"ygvjayvblmh\",\"sourceAmwAccountManagedIdentity\":\"k\",\"sourceAmwAccountResourceId\":\"uhbxvvy\",\"metricNamespace\":\"gsopbyrqufegxu\",\"metricName\":\"wz\",\"filters\":[],\"spatialAggregation\":{\"type\":\"Min\",\"dimensions\":[]},\"temporalAggregation\":{\"type\":\"IRate\"}}],\"signalFormula\":\"hlmctlpdngitvgb\"},\"windowUptimeCriteria\":{\"target\":79.06151231394061,\"comparator\":\"<\"}}},\"identity\":{\"principalId\":\"myijejvegr\",\"tenantId\":\"pna\",\"type\":\"SystemAssigned,UserAssigned\",\"userAssignedIdentities\":{\"nhyjsv\":{\"principalId\":\"cbdreaxhcexd\",\"clientId\":\"vqahqkghtpwi\"},\"jqppyostronzmy\":{\"principalId\":\"cxzbfvoowvr\",\"clientId\":\"t\"},\"afxtsgum\":{\"principalId\":\"fipns\",\"clientId\":\"mcwaekrrjr\"},\"felfktg\":{\"principalId\":\"glikkxwslolb\",\"clientId\":\"vuzlm\"}}},\"id\":\"crpw\",\"name\":\"xeznoi\",\"type\":\"brnjwmw\"}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + SlisManager manager = SlisManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + PagedIterable response = manager.slis().listByParent("tvsexsowuel", com.azure.core.util.Context.NONE); + + Assertions.assertEquals("ahhxvrh", response.iterator().next().properties().description()); + Assertions.assertEquals(Category.AVAILABILITY, response.iterator().next().properties().category()); + Assertions.assertEquals(EvaluationType.REQUEST_BASED, response.iterator().next().properties().evaluationType()); + Assertions.assertEquals("qxujxukndxd", + response.iterator().next().properties().destinationAmwAccounts().get(0).resourceId()); + Assertions.assertEquals("grjguufzd", + response.iterator().next().properties().destinationAmwAccounts().get(0).identity()); + Assertions.assertEquals(55.10261161552592, + response.iterator().next().properties().baselineProperties().baseline().value()); + Assertions.assertEquals(48409211, + response.iterator().next().properties().baselineProperties().baseline().evaluationPeriodDays()); + Assertions.assertEquals(EvaluationCalculationType.ROLLING_DAYS, + response.iterator().next().properties().baselineProperties().baseline().evaluationCalculationType()); + Assertions.assertFalse(response.iterator().next().properties().enableAlert()); + Assertions.assertEquals("uq", + response.iterator() + .next() + .properties() + .sliProperties() + .goodSignals() + .signalSources() + .get(0) + .signalSourceId()); + Assertions.assertEquals("hwyg", + response.iterator() + .next() + .properties() + .sliProperties() + .goodSignals() + .signalSources() + .get(0) + .sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("lvdnkfx", + response.iterator() + .next() + .properties() + .sliProperties() + .goodSignals() + .signalSources() + .get(0) + .sourceAmwAccountResourceId()); + Assertions.assertEquals("semdwzrmu", + response.iterator() + .next() + .properties() + .sliProperties() + .goodSignals() + .signalSources() + .get(0) + .metricNamespace()); + Assertions.assertEquals("apfcqdpsq", + response.iterator().next().properties().sliProperties().goodSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(SpatialAggregationType.SUM, + response.iterator() + .next() + .properties() + .sliProperties() + .goodSignals() + .signalSources() + .get(0) + .spatialAggregation() + .type()); + Assertions.assertEquals(TemporalAggregationType.IRATE, + response.iterator() + .next() + .properties() + .sliProperties() + .goodSignals() + .signalSources() + .get(0) + .temporalAggregation() + .type()); + Assertions.assertEquals("psvuoymgc", + response.iterator().next().properties().sliProperties().goodSignals().signalFormula()); + Assertions.assertEquals("vezrypqlmfeo", + response.iterator() + .next() + .properties() + .sliProperties() + .totalSignals() + .signalSources() + .get(0) + .signalSourceId()); + Assertions.assertEquals("erqwkyhkobopg", + response.iterator() + .next() + .properties() + .sliProperties() + .totalSignals() + .signalSources() + .get(0) + .sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("edkowepbqpcrfk", + response.iterator() + .next() + .properties() + .sliProperties() + .totalSignals() + .signalSources() + .get(0) + .sourceAmwAccountResourceId()); + Assertions.assertEquals("wccsnjvcdwxlpqek", + response.iterator() + .next() + .properties() + .sliProperties() + .totalSignals() + .signalSources() + .get(0) + .metricNamespace()); + Assertions.assertEquals("tn", + response.iterator().next().properties().sliProperties().totalSignals().signalSources().get(0).metricName()); + Assertions.assertEquals(SpatialAggregationType.COUNT, + response.iterator() + .next() + .properties() + .sliProperties() + .totalSignals() + .signalSources() + .get(0) + .spatialAggregation() + .type()); + Assertions.assertEquals(TemporalAggregationType.MIN, + response.iterator() + .next() + .properties() + .sliProperties() + .totalSignals() + .signalSources() + .get(0) + .temporalAggregation() + .type()); + Assertions.assertEquals("jsyingwfqatm", + response.iterator().next().properties().sliProperties().totalSignals().signalFormula()); + Assertions.assertEquals("tmdvypgikdgs", + response.iterator().next().properties().sliProperties().signals().signalSources().get(0).signalSourceId()); + Assertions.assertEquals("ywkbirryuzhlhkjo", + response.iterator() + .next() + .properties() + .sliProperties() + .signals() + .signalSources() + .get(0) + .sourceAmwAccountManagedIdentity()); + Assertions.assertEquals("rvqqaatj", + response.iterator() + .next() + .properties() + .sliProperties() + .signals() + .signalSources() + .get(0) + .sourceAmwAccountResourceId()); + Assertions.assertEquals("nrvgoupmfiibfgg", + response.iterator().next().properties().sliProperties().signals().signalSources().get(0).metricNamespace()); + Assertions.assertEquals("ioolvrwxkvtkkgll", + response.iterator().next().properties().sliProperties().signals().signalSources().get(0).metricName()); + Assertions.assertEquals(SpatialAggregationType.MIN, + response.iterator() + .next() + .properties() + .sliProperties() + .signals() + .signalSources() + .get(0) + .spatialAggregation() + .type()); + Assertions.assertEquals(TemporalAggregationType.MIN, + response.iterator() + .next() + .properties() + .sliProperties() + .signals() + .signalSources() + .get(0) + .temporalAggregation() + .type()); + Assertions.assertEquals("hlmctlpdngitvgb", + response.iterator().next().properties().sliProperties().signals().signalFormula()); + Assertions.assertEquals(79.06151231394061, + response.iterator().next().properties().sliProperties().windowUptimeCriteria().target()); + Assertions.assertEquals(WindowUptimeCriteriaComparator.LESS_THAN, + response.iterator().next().properties().sliProperties().windowUptimeCriteria().comparator()); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED, + response.iterator().next().identity().type()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SpatialAggregationTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SpatialAggregationTests.java new file mode 100644 index 000000000000..41d40d16ac55 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/SpatialAggregationTests.java @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregation; +import com.azure.resourcemanager.monitor.slis.models.SpatialAggregationType; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class SpatialAggregationTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SpatialAggregation model = BinaryData.fromString("{\"type\":\"Max\",\"dimensions\":[\"hxpkd\",\"zb\"]}") + .toObject(SpatialAggregation.class); + Assertions.assertEquals(SpatialAggregationType.MAX, model.type()); + Assertions.assertEquals("hxpkd", model.dimensions().get(0)); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + SpatialAggregation model = new SpatialAggregation().withType(SpatialAggregationType.MAX) + .withDimensions(Arrays.asList("hxpkd", "zb")); + model = BinaryData.fromObject(model).toObject(SpatialAggregation.class); + Assertions.assertEquals(SpatialAggregationType.MAX, model.type()); + Assertions.assertEquals("hxpkd", model.dimensions().get(0)); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/TemporalAggregationTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/TemporalAggregationTests.java new file mode 100644 index 000000000000..b1c57fc3bc6b --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/TemporalAggregationTests.java @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregation; +import com.azure.resourcemanager.monitor.slis.models.TemporalAggregationType; +import org.junit.jupiter.api.Assertions; + +public final class TemporalAggregationTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + TemporalAggregation model = BinaryData.fromString("{\"type\":\"Max\",\"windowSizeMinutes\":718463085}") + .toObject(TemporalAggregation.class); + Assertions.assertEquals(TemporalAggregationType.MAX, model.type()); + Assertions.assertEquals(718463085, model.windowSizeMinutes()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + TemporalAggregation model + = new TemporalAggregation().withType(TemporalAggregationType.MAX).withWindowSizeMinutes(718463085); + model = BinaryData.fromObject(model).toObject(TemporalAggregation.class); + Assertions.assertEquals(TemporalAggregationType.MAX, model.type()); + Assertions.assertEquals(718463085, model.windowSizeMinutes()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/UserAssignedIdentityTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/UserAssignedIdentityTests.java new file mode 100644 index 000000000000..e188a23a4a4a --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/UserAssignedIdentityTests.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.UserAssignedIdentity; + +public final class UserAssignedIdentityTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + UserAssignedIdentity model + = BinaryData.fromString("{\"principalId\":\"cnjbkcnxdhbt\",\"clientId\":\"phywpnvj\"}") + .toObject(UserAssignedIdentity.class); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + UserAssignedIdentity model = new UserAssignedIdentity(); + model = BinaryData.fromObject(model).toObject(UserAssignedIdentity.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/WindowUptimeCriteriaTests.java b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/WindowUptimeCriteriaTests.java new file mode 100644 index 000000000000..f8e8fd3a8cf5 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/src/test/java/com/azure/resourcemanager/monitor/slis/generated/WindowUptimeCriteriaTests.java @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.slis.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteria; +import com.azure.resourcemanager.monitor.slis.models.WindowUptimeCriteriaComparator; +import org.junit.jupiter.api.Assertions; + +public final class WindowUptimeCriteriaTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + WindowUptimeCriteria model = BinaryData.fromString("{\"target\":69.3418872608996,\"comparator\":\"<\"}") + .toObject(WindowUptimeCriteria.class); + Assertions.assertEquals(69.3418872608996, model.target()); + Assertions.assertEquals(WindowUptimeCriteriaComparator.LESS_THAN, model.comparator()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + WindowUptimeCriteria model = new WindowUptimeCriteria().withTarget(69.3418872608996) + .withComparator(WindowUptimeCriteriaComparator.LESS_THAN); + model = BinaryData.fromObject(model).toObject(WindowUptimeCriteria.class); + Assertions.assertEquals(69.3418872608996, model.target()); + Assertions.assertEquals(WindowUptimeCriteriaComparator.LESS_THAN, model.comparator()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/tsp-location.yaml b/sdk/monitor/azure-resourcemanager-monitor-slis/tsp-location.yaml new file mode 100644 index 000000000000..b22197448f69 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/monitoringservice/resource-manager/Microsoft.Monitor/Slis +commit: d32a3f6cc49c6dd6604161f8c7cee7c95a84c578 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/monitor/ci.yml b/sdk/monitor/ci.yml index 40b8d119c616..92f152a46816 100644 --- a/sdk/monitor/ci.yml +++ b/sdk/monitor/ci.yml @@ -42,38 +42,42 @@ pr: - sdk/monitor/azure-resourcemanager-monitor/pom.xml parameters: -- name: release_dependsonlivetests - displayName: 'Release depends on live tests' - type: boolean - default: true -- name: release_azuremonitoringestion - displayName: 'azure-monitor-ingestion' - type: boolean - default: true -- name: release_azuremonitoropentelemetryexporter - displayName: 'azure-monitor-opentelemetry-exporter' - type: boolean - default: true -- name: release_azuremonitoropentelemetryautoconfigure - displayName: 'azure-monitor-opentelemetry-autoconfigure' - type: boolean - default: true -- name: release_azuremonitorquery - displayName: 'azure-monitor-query' - type: boolean - default: true -- name: release_azuremonitorquerylogs - displayName: 'azure-monitor-query-logs' - type: boolean - default: true -- name: release_azuremonitorquerymetrics - displayName: 'azure-monitor-query-metrics' - type: boolean - default: true -- name: release_azureresourcemanagermonitor - displayName: 'azure-resourcemanager-monitor' - type: boolean - default: false + - name: release_dependsonlivetests + displayName: Release depends on live tests + type: boolean + default: true + - name: release_azuremonitoringestion + displayName: azure-monitor-ingestion + type: boolean + default: true + - name: release_azuremonitoropentelemetryexporter + displayName: azure-monitor-opentelemetry-exporter + type: boolean + default: true + - name: release_azuremonitoropentelemetryautoconfigure + displayName: azure-monitor-opentelemetry-autoconfigure + type: boolean + default: true + - name: release_azuremonitorquery + displayName: azure-monitor-query + type: boolean + default: true + - name: release_azuremonitorquerylogs + displayName: azure-monitor-query-logs + type: boolean + default: true + - name: release_azuremonitorquerymetrics + displayName: azure-monitor-query-metrics + type: boolean + default: true + - name: release_azureresourcemanagermonitor + displayName: azure-resourcemanager-monitor + type: boolean + default: false + - name: release_azureresourcemanagermonitorslis + displayName: azure-resourcemanager-monitor-slis + type: boolean + default: false extends: template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml @@ -108,11 +112,14 @@ extends: groupId: com.azure.resourcemanager safeName: azureresourcemanagermonitor releaseInBatch: ${{ parameters.release_azureresourcemanagermonitor }} + - name: azure-resourcemanager-monitor-slis + groupId: com.azure.resourcemanager + safeName: azureresourcemanagermonitorslis + releaseInBatch: ${{ parameters.release_azureresourcemanagermonitorslis }} AdditionalModules: - name: azure-monitor-query-perf groupId: com.azure - name: azure-monitor-ingestion-perf groupId: com.azure - # required by the above perf library - name: perf-test-core groupId: com.azure diff --git a/sdk/monitor/pom.xml b/sdk/monitor/pom.xml index cdaa5e7aa1ee..21c722066070 100644 --- a/sdk/monitor/pom.xml +++ b/sdk/monitor/pom.xml @@ -10,14 +10,15 @@ 1.0.0 - azure-monitor-ingestion - azure-monitor-ingestion-perf - azure-monitor-opentelemetry-exporter - azure-monitor-opentelemetry-autoconfigure - azure-monitor-query - azure-monitor-query-logs - azure-monitor-query-metrics - azure-monitor-query-perf - azure-resourcemanager-monitor + azure-monitor-ingestion + azure-monitor-ingestion-perf + azure-monitor-opentelemetry-autoconfigure + azure-monitor-opentelemetry-exporter + azure-monitor-query + azure-monitor-query-logs + azure-monitor-query-metrics + azure-monitor-query-perf + azure-resourcemanager-monitor + azure-resourcemanager-monitor-slis From 4ef7ac0d2e72ea3a1408260312987239f5a4123e Mon Sep 17 00:00:00 2001 From: Saleel Kattiyat Date: Fri, 24 Apr 2026 10:37:02 -0700 Subject: [PATCH 5/6] Update CHANGELOG with initial preview features Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../azure-resourcemanager-monitor-slis/CHANGELOG.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sdk/monitor/azure-resourcemanager-monitor-slis/CHANGELOG.md b/sdk/monitor/azure-resourcemanager-monitor-slis/CHANGELOG.md index 08d1f26ba2c9..38b732e10d23 100644 --- a/sdk/monitor/azure-resourcemanager-monitor-slis/CHANGELOG.md +++ b/sdk/monitor/azure-resourcemanager-monitor-slis/CHANGELOG.md @@ -2,7 +2,13 @@ ## 1.0.0-beta.1 (2026-04-22) -- Azure Resource Manager Slis client library for Java. This package contains Microsoft Azure SDK for Slis Management SDK. Package api-version 2025-03-01-preview. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). ### Features Added -- Initial release for the azure-resourcemanager-monitor-slis Java SDK. +- Initial preview release of `azure-resourcemanager-monitor-slis` for managing + Service Level Indicator (SLI) resources under the `Microsoft.Monitor` namespace. +- Support for SLI resource CRUD operations: create or update, get, delete, and list. +- SLI evaluation with Availability and Latency categories, supporting both + window-based and request-based evaluation types with configurable signal sources, + aggregation, and SLO baselines. +- Integration with Azure Monitor Workspace (AMW) accounts for metric emission, + with managed identity and alert support. From a1a0b05bd122865bcb0acd02e5e64207ef3b46e7 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Mon, 27 Apr 2026 10:03:23 +0800 Subject: [PATCH 6/6] Remove files incorrectly merged from fork --- .gitattributes | 2 - .github/workflows/mergefest.lock.yml | 1202 -------------------------- .github/workflows/mergefest.md | 331 ------- .github/workflows/shared/mood.md | 1 - 4 files changed, 1536 deletions(-) delete mode 100644 .github/workflows/mergefest.lock.yml delete mode 100644 .github/workflows/mergefest.md delete mode 100644 .github/workflows/shared/mood.md diff --git a/.gitattributes b/.gitattributes index f5c8d439f920..e6fd58130684 100644 --- a/.gitattributes +++ b/.gitattributes @@ -27,5 +27,3 @@ *.jar binary *.so binary *.war binary - -.github/workflows/*.lock.yml linguist-generated=true merge=ours \ No newline at end of file diff --git a/.github/workflows/mergefest.lock.yml b/.github/workflows/mergefest.lock.yml deleted file mode 100644 index b16e4f5123de..000000000000 --- a/.github/workflows/mergefest.lock.yml +++ /dev/null @@ -1,1202 +0,0 @@ -# ___ _ _ -# / _ \ | | (_) -# | |_| | __ _ ___ _ __ | |_ _ ___ -# | _ |/ _` |/ _ \ '_ \| __| |/ __| -# | | | | (_| | __/ | | | |_| | (__ -# \_| |_/\__, |\___|_| |_|\__|_|\___| -# __/ | -# _ _ |___/ -# | | | | / _| | -# | | | | ___ _ __ _ __| |_| | _____ ____ -# | |/\| |/ _ \ '__| |/ /| _| |/ _ \ \ /\ / / ___| -# \ /\ / (_) | | | | ( | | | | (_) \ V V /\__ \ -# \/ \/ \___/|_| |_|\_\|_| |_|\___/ \_/\_/ |___/ -# -# This file was automatically generated by gh-aw (v0.65.6). DO NOT EDIT. -# -# To update this file, edit github/gh-aw/.github/workflows/mergefest.md@852cb06ad52958b402ed982b69957ffc57ca0619 and run: -# gh aw compile -# Not all edits will cause changes to this file. -# -# For more information: https://github.github.com/gh-aw/introduction/overview/ -# -# Automatically merges the main branch into pull request branches when invoked with /mergefest command -# -# Source: github/gh-aw/.github/workflows/mergefest.md@852cb06ad52958b402ed982b69957ffc57ca0619 -# -# Resolved workflow manifest: -# Imports: -# - shared/mood.md -# -# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"898d9ce6133254988c8f96cb722ffb0c70ffe278cdeed40d653955a6c3ef246e","compiler_version":"v0.65.6","strict":true,"agent_id":"copilot"} - -name: "Mergefest" -"on": - issue_comment: - types: - - created - - edited - -permissions: {} - -concurrency: - group: "gh-aw-${{ github.workflow }}-${{ github.event.issue.number || github.event.pull_request.number || github.run_id }}" - -run-name: "Mergefest" - -jobs: - activation: - needs: pre_activation - if: "needs.pre_activation.outputs.activated == 'true' && (github.event_name == 'issue_comment' && (startsWith(github.event.comment.body, '/mergefest ') || startsWith(github.event.comment.body, '/mergefest\n') || github.event.comment.body == '/mergefest') && github.event.issue.pull_request != null)" - runs-on: ubuntu-slim - permissions: - contents: read - discussions: write - issues: write - pull-requests: write - outputs: - body: ${{ steps.sanitized.outputs.body }} - comment_id: ${{ steps.add-comment.outputs.comment-id }} - comment_repo: ${{ steps.add-comment.outputs.comment-repo }} - comment_url: ${{ steps.add-comment.outputs.comment-url }} - lockdown_check_failed: ${{ steps.generate_aw_info.outputs.lockdown_check_failed == 'true' }} - model: ${{ steps.generate_aw_info.outputs.model }} - secret_verification_result: ${{ steps.validate-secret.outputs.verification_result }} - slash_command: ${{ needs.pre_activation.outputs.matched_command }} - text: ${{ steps.sanitized.outputs.text }} - title: ${{ steps.sanitized.outputs.title }} - steps: - - name: Setup Scripts - uses: github/gh-aw-actions/setup@31130b20a8fd3ef263acbe2091267c0aace07e09 # v0.65.6 - with: - destination: ${{ runner.temp }}/gh-aw/actions - - name: Generate agentic run info - id: generate_aw_info - env: - GH_AW_INFO_ENGINE_ID: "copilot" - GH_AW_INFO_ENGINE_NAME: "GitHub Copilot CLI" - GH_AW_INFO_MODEL: ${{ vars.GH_AW_MODEL_AGENT_COPILOT || 'auto' }} - GH_AW_INFO_VERSION: "latest" - GH_AW_INFO_AGENT_VERSION: "latest" - GH_AW_INFO_CLI_VERSION: "v0.65.6" - GH_AW_INFO_WORKFLOW_NAME: "Mergefest" - GH_AW_INFO_EXPERIMENTAL: "false" - GH_AW_INFO_SUPPORTS_TOOLS_ALLOWLIST: "true" - GH_AW_INFO_STAGED: "false" - GH_AW_INFO_ALLOWED_DOMAINS: '["defaults"]' - GH_AW_INFO_FIREWALL_ENABLED: "true" - GH_AW_INFO_AWF_VERSION: "v0.25.11" - GH_AW_INFO_AWMG_VERSION: "" - GH_AW_INFO_FIREWALL_TYPE: "squid" - GH_AW_COMPILED_STRICT: "true" - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 - with: - script: | - const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); - setupGlobals(core, github, context, exec, io); - const { main } = require('${{ runner.temp }}/gh-aw/actions/generate_aw_info.cjs'); - await main(core, context); - - name: Add eyes reaction for immediate feedback - id: react - if: github.event_name == 'issues' || github.event_name == 'issue_comment' || github.event_name == 'pull_request_review_comment' || github.event_name == 'discussion' || github.event_name == 'discussion_comment' || github.event_name == 'pull_request' && github.event.pull_request.head.repo.id == github.repository_id - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 - env: - GH_AW_REACTION: "eyes" - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); - setupGlobals(core, github, context, exec, io); - const { main } = require('${{ runner.temp }}/gh-aw/actions/add_reaction.cjs'); - await main(); - - name: Validate COPILOT_GITHUB_TOKEN secret - id: validate-secret - run: ${RUNNER_TEMP}/gh-aw/actions/validate_multi_secret.sh COPILOT_GITHUB_TOKEN 'GitHub Copilot CLI' https://github.github.com/gh-aw/reference/engines/#github-copilot-default - env: - COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }} - - name: Checkout .github and .agents folders - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - persist-credentials: false - sparse-checkout: | - .github - .agents - sparse-checkout-cone-mode: true - fetch-depth: 1 - - name: Check workflow file timestamps - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 - env: - GH_AW_WORKFLOW_FILE: "mergefest.lock.yml" - with: - script: | - const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); - setupGlobals(core, github, context, exec, io); - const { main } = require('${{ runner.temp }}/gh-aw/actions/check_workflow_timestamp_api.cjs'); - await main(); - - name: Check compile-agentic version - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 - env: - GH_AW_COMPILED_VERSION: "v0.65.6" - with: - script: | - const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); - setupGlobals(core, github, context, exec, io); - const { main } = require('${{ runner.temp }}/gh-aw/actions/check_version_updates.cjs'); - await main(); - - name: Compute current body text - id: sanitized - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 - with: - script: | - const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); - setupGlobals(core, github, context, exec, io); - const { main } = require('${{ runner.temp }}/gh-aw/actions/compute_text.cjs'); - await main(); - - name: Add comment with workflow run link - id: add-comment - if: github.event_name == 'issues' || github.event_name == 'issue_comment' || github.event_name == 'pull_request_review_comment' || github.event_name == 'discussion' || github.event_name == 'discussion_comment' || github.event_name == 'pull_request' && github.event.pull_request.head.repo.id == github.repository_id - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 - env: - GH_AW_WORKFLOW_NAME: "Mergefest" - with: - script: | - const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); - setupGlobals(core, github, context, exec, io); - const { main } = require('${{ runner.temp }}/gh-aw/actions/add_workflow_run_comment.cjs'); - await main(); - - name: Create prompt with built-in context - env: - GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt - GH_AW_SAFE_OUTPUTS: ${{ runner.temp }}/gh-aw/safeoutputs/outputs.jsonl - GH_AW_GITHUB_ACTOR: ${{ github.actor }} - GH_AW_GITHUB_EVENT_COMMENT_ID: ${{ github.event.comment.id }} - GH_AW_GITHUB_EVENT_DISCUSSION_NUMBER: ${{ github.event.discussion.number }} - GH_AW_GITHUB_EVENT_ISSUE_NUMBER: ${{ github.event.issue.number }} - GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }} - GH_AW_GITHUB_REPOSITORY: ${{ github.repository }} - GH_AW_GITHUB_RUN_ID: ${{ github.run_id }} - GH_AW_GITHUB_WORKSPACE: ${{ github.workspace }} - GH_AW_IS_PR_COMMENT: ${{ github.event.issue.pull_request && 'true' || '' }} - # poutine:ignore untrusted_checkout_exec - run: | - bash ${RUNNER_TEMP}/gh-aw/actions/create_prompt_first.sh - { - cat << 'GH_AW_PROMPT_225b8f639dd46a77_EOF' - - GH_AW_PROMPT_225b8f639dd46a77_EOF - cat "${RUNNER_TEMP}/gh-aw/prompts/xpia.md" - cat "${RUNNER_TEMP}/gh-aw/prompts/temp_folder_prompt.md" - cat "${RUNNER_TEMP}/gh-aw/prompts/markdown.md" - cat "${RUNNER_TEMP}/gh-aw/prompts/safe_outputs_prompt.md" - cat << 'GH_AW_PROMPT_225b8f639dd46a77_EOF' - - Tools: push_to_pull_request_branch, missing_tool, missing_data, noop - GH_AW_PROMPT_225b8f639dd46a77_EOF - cat "${RUNNER_TEMP}/gh-aw/prompts/safe_outputs_push_to_pr_branch.md" - cat << 'GH_AW_PROMPT_225b8f639dd46a77_EOF' - - - The following GitHub context information is available for this workflow: - {{#if __GH_AW_GITHUB_ACTOR__ }} - - **actor**: __GH_AW_GITHUB_ACTOR__ - {{/if}} - {{#if __GH_AW_GITHUB_REPOSITORY__ }} - - **repository**: __GH_AW_GITHUB_REPOSITORY__ - {{/if}} - {{#if __GH_AW_GITHUB_WORKSPACE__ }} - - **workspace**: __GH_AW_GITHUB_WORKSPACE__ - {{/if}} - {{#if __GH_AW_GITHUB_EVENT_ISSUE_NUMBER__ }} - - **issue-number**: #__GH_AW_GITHUB_EVENT_ISSUE_NUMBER__ - {{/if}} - {{#if __GH_AW_GITHUB_EVENT_DISCUSSION_NUMBER__ }} - - **discussion-number**: #__GH_AW_GITHUB_EVENT_DISCUSSION_NUMBER__ - {{/if}} - {{#if __GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER__ }} - - **pull-request-number**: #__GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER__ - {{/if}} - {{#if __GH_AW_GITHUB_EVENT_COMMENT_ID__ }} - - **comment-id**: __GH_AW_GITHUB_EVENT_COMMENT_ID__ - {{/if}} - {{#if __GH_AW_GITHUB_RUN_ID__ }} - - **workflow-run-id**: __GH_AW_GITHUB_RUN_ID__ - {{/if}} - - - GH_AW_PROMPT_225b8f639dd46a77_EOF - cat "${RUNNER_TEMP}/gh-aw/prompts/github_mcp_tools_with_safeoutputs_prompt.md" - if [ "$GITHUB_EVENT_NAME" = "issue_comment" ] && [ -n "$GH_AW_IS_PR_COMMENT" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review_comment" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review" ]; then - cat "${RUNNER_TEMP}/gh-aw/prompts/pr_context_prompt.md" - fi - if [ "$GITHUB_EVENT_NAME" = "issue_comment" ] && [ -n "$GH_AW_IS_PR_COMMENT" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review_comment" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review" ]; then - cat "${RUNNER_TEMP}/gh-aw/prompts/pr_context_push_to_pr_branch_guidance.md" - fi - cat << 'GH_AW_PROMPT_225b8f639dd46a77_EOF' - - {{#runtime-import .github/workflows/shared/mood.md}} - {{#runtime-import .github/workflows/mergefest.md}} - GH_AW_PROMPT_225b8f639dd46a77_EOF - } > "$GH_AW_PROMPT" - - name: Interpolate variables and render templates - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 - env: - GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt - GH_AW_GITHUB_ACTOR: ${{ github.actor }} - GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }} - GH_AW_GITHUB_REPOSITORY: ${{ github.repository }} - with: - script: | - const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); - setupGlobals(core, github, context, exec, io); - const { main } = require('${{ runner.temp }}/gh-aw/actions/interpolate_prompt.cjs'); - await main(); - - name: Substitute placeholders - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 - env: - GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt - GH_AW_GITHUB_ACTOR: ${{ github.actor }} - GH_AW_GITHUB_EVENT_COMMENT_ID: ${{ github.event.comment.id }} - GH_AW_GITHUB_EVENT_DISCUSSION_NUMBER: ${{ github.event.discussion.number }} - GH_AW_GITHUB_EVENT_ISSUE_NUMBER: ${{ github.event.issue.number }} - GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }} - GH_AW_GITHUB_REPOSITORY: ${{ github.repository }} - GH_AW_GITHUB_RUN_ID: ${{ github.run_id }} - GH_AW_GITHUB_WORKSPACE: ${{ github.workspace }} - GH_AW_IS_PR_COMMENT: ${{ github.event.issue.pull_request && 'true' || '' }} - GH_AW_NEEDS_PRE_ACTIVATION_OUTPUTS_ACTIVATED: ${{ needs.pre_activation.outputs.activated }} - GH_AW_NEEDS_PRE_ACTIVATION_OUTPUTS_MATCHED_COMMAND: ${{ needs.pre_activation.outputs.matched_command }} - with: - script: | - const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); - setupGlobals(core, github, context, exec, io); - - const substitutePlaceholders = require('${{ runner.temp }}/gh-aw/actions/substitute_placeholders.cjs'); - - // Call the substitution function - return await substitutePlaceholders({ - file: process.env.GH_AW_PROMPT, - substitutions: { - GH_AW_GITHUB_ACTOR: process.env.GH_AW_GITHUB_ACTOR, - GH_AW_GITHUB_EVENT_COMMENT_ID: process.env.GH_AW_GITHUB_EVENT_COMMENT_ID, - GH_AW_GITHUB_EVENT_DISCUSSION_NUMBER: process.env.GH_AW_GITHUB_EVENT_DISCUSSION_NUMBER, - GH_AW_GITHUB_EVENT_ISSUE_NUMBER: process.env.GH_AW_GITHUB_EVENT_ISSUE_NUMBER, - GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER: process.env.GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER, - GH_AW_GITHUB_REPOSITORY: process.env.GH_AW_GITHUB_REPOSITORY, - GH_AW_GITHUB_RUN_ID: process.env.GH_AW_GITHUB_RUN_ID, - GH_AW_GITHUB_WORKSPACE: process.env.GH_AW_GITHUB_WORKSPACE, - GH_AW_IS_PR_COMMENT: process.env.GH_AW_IS_PR_COMMENT, - GH_AW_NEEDS_PRE_ACTIVATION_OUTPUTS_ACTIVATED: process.env.GH_AW_NEEDS_PRE_ACTIVATION_OUTPUTS_ACTIVATED, - GH_AW_NEEDS_PRE_ACTIVATION_OUTPUTS_MATCHED_COMMAND: process.env.GH_AW_NEEDS_PRE_ACTIVATION_OUTPUTS_MATCHED_COMMAND - } - }); - - name: Validate prompt placeholders - env: - GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt - # poutine:ignore untrusted_checkout_exec - run: bash ${RUNNER_TEMP}/gh-aw/actions/validate_prompt_placeholders.sh - - name: Print prompt - env: - GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt - # poutine:ignore untrusted_checkout_exec - run: bash ${RUNNER_TEMP}/gh-aw/actions/print_prompt_summary.sh - - name: Upload activation artifact - if: success() - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7 - with: - name: activation - path: | - /tmp/gh-aw/aw_info.json - /tmp/gh-aw/aw-prompts/prompt.txt - retention-days: 1 - - agent: - needs: activation - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - pull-requests: read - env: - DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} - GH_AW_ASSETS_ALLOWED_EXTS: "" - GH_AW_ASSETS_BRANCH: "" - GH_AW_ASSETS_MAX_SIZE_KB: 0 - GH_AW_MCP_LOG_DIR: /tmp/gh-aw/mcp-logs/safeoutputs - GH_AW_WORKFLOW_ID_SANITIZED: mergefest - outputs: - checkout_pr_success: ${{ steps.checkout-pr.outputs.checkout_pr_success || 'true' }} - effective_tokens: ${{ steps.parse-mcp-gateway.outputs.effective_tokens }} - has_patch: ${{ steps.collect_output.outputs.has_patch }} - inference_access_error: ${{ steps.detect-inference-error.outputs.inference_access_error || 'false' }} - model: ${{ needs.activation.outputs.model }} - output: ${{ steps.collect_output.outputs.output }} - output_types: ${{ steps.collect_output.outputs.output_types }} - steps: - - name: Setup Scripts - uses: github/gh-aw-actions/setup@31130b20a8fd3ef263acbe2091267c0aace07e09 # v0.65.6 - with: - destination: ${{ runner.temp }}/gh-aw/actions - - name: Set runtime paths - id: set-runtime-paths - run: | - echo "GH_AW_SAFE_OUTPUTS=${RUNNER_TEMP}/gh-aw/safeoutputs/outputs.jsonl" >> "$GITHUB_OUTPUT" - echo "GH_AW_SAFE_OUTPUTS_CONFIG_PATH=${RUNNER_TEMP}/gh-aw/safeoutputs/config.json" >> "$GITHUB_OUTPUT" - echo "GH_AW_SAFE_OUTPUTS_TOOLS_PATH=${RUNNER_TEMP}/gh-aw/safeoutputs/tools.json" >> "$GITHUB_OUTPUT" - - name: Checkout repository - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - persist-credentials: false - - name: Create gh-aw temp directory - run: bash ${RUNNER_TEMP}/gh-aw/actions/create_gh_aw_tmp_dir.sh - - name: Configure gh CLI for GitHub Enterprise - run: bash ${RUNNER_TEMP}/gh-aw/actions/configure_gh_for_ghe.sh - env: - GH_TOKEN: ${{ github.token }} - - name: Setup Git configuration - run: "git config user.name \"github-actions[bot]\"\ngit config user.email \"github-actions[bot]@users.noreply.github.com\"\n\n# Create .gitignore to exclude workflow YAML files\ncat > /tmp/merge-gitignore << 'EOF'\n# Exclude all .yml files in .github/workflows/\n.github/workflows/*.yml\nEOF\n" - - - name: Configure Git credentials - env: - REPO_NAME: ${{ github.repository }} - SERVER_URL: ${{ github.server_url }} - run: | - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git config --global user.name "github-actions[bot]" - git config --global am.keepcr true - # Re-authenticate git with GitHub token - SERVER_URL_STRIPPED="${SERVER_URL#https://}" - git remote set-url origin "https://x-access-token:${{ github.token }}@${SERVER_URL_STRIPPED}/${REPO_NAME}.git" - echo "Git configured with standard GitHub Actions identity" - - name: Checkout PR branch - id: checkout-pr - if: | - github.event.pull_request || github.event.issue.pull_request - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 - env: - GH_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} - with: - github-token: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} - script: | - const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); - setupGlobals(core, github, context, exec, io); - const { main } = require('${{ runner.temp }}/gh-aw/actions/checkout_pr_branch.cjs'); - await main(); - - name: Install GitHub Copilot CLI - run: ${RUNNER_TEMP}/gh-aw/actions/install_copilot_cli.sh latest - - name: Install AWF binary - run: bash ${RUNNER_TEMP}/gh-aw/actions/install_awf_binary.sh v0.25.11 - - name: Determine automatic lockdown mode for GitHub MCP Server - id: determine-automatic-lockdown - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 - env: - GH_AW_GITHUB_TOKEN: ${{ secrets.GH_AW_GITHUB_TOKEN }} - GH_AW_GITHUB_MCP_SERVER_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN }} - with: - script: | - const determineAutomaticLockdown = require('${{ runner.temp }}/gh-aw/actions/determine_automatic_lockdown.cjs'); - await determineAutomaticLockdown(github, context, core); - - name: Download container images - run: bash ${RUNNER_TEMP}/gh-aw/actions/download_docker_images.sh ghcr.io/github/gh-aw-firewall/agent:0.25.11 ghcr.io/github/gh-aw-firewall/api-proxy:0.25.11 ghcr.io/github/gh-aw-firewall/squid:0.25.11 ghcr.io/github/gh-aw-mcpg:v0.2.11 ghcr.io/github/github-mcp-server:v0.32.0 node:lts-alpine - - name: Write Safe Outputs Config - run: | - mkdir -p ${RUNNER_TEMP}/gh-aw/safeoutputs - mkdir -p /tmp/gh-aw/safeoutputs - mkdir -p /tmp/gh-aw/mcp-logs/safeoutputs - cat > ${RUNNER_TEMP}/gh-aw/safeoutputs/config.json << 'GH_AW_SAFE_OUTPUTS_CONFIG_581002c18335587a_EOF' - {"missing_data":{},"missing_tool":{},"noop":{"max":1,"report-as-issue":"true"},"push_to_pull_request_branch":{"if_no_changes":"warn","max_patch_size":1024,"protected_files":["package.json","bun.lockb","bunfig.toml","deno.json","deno.jsonc","deno.lock","global.json","NuGet.Config","Directory.Packages.props","mix.exs","mix.lock","go.mod","go.sum","stack.yaml","stack.yaml.lock","pom.xml","build.gradle","build.gradle.kts","settings.gradle","settings.gradle.kts","gradle.properties","package-lock.json","yarn.lock","pnpm-lock.yaml","npm-shrinkwrap.json","requirements.txt","Pipfile","Pipfile.lock","pyproject.toml","setup.py","setup.cfg","Gemfile","Gemfile.lock","uv.lock","CODEOWNERS"],"protected_path_prefixes":[".github/",".agents/"]}} - GH_AW_SAFE_OUTPUTS_CONFIG_581002c18335587a_EOF - - name: Write Safe Outputs Tools - run: | - cat > ${RUNNER_TEMP}/gh-aw/safeoutputs/tools_meta.json << 'GH_AW_SAFE_OUTPUTS_TOOLS_META_b99ef13599b68b8e_EOF' - { - "description_suffixes": {}, - "repo_params": {}, - "dynamic_tools": [] - } - GH_AW_SAFE_OUTPUTS_TOOLS_META_b99ef13599b68b8e_EOF - cat > ${RUNNER_TEMP}/gh-aw/safeoutputs/validation.json << 'GH_AW_SAFE_OUTPUTS_VALIDATION_713ae3f96a59ba34_EOF' - { - "missing_data": { - "defaultMax": 20, - "fields": { - "alternatives": { - "type": "string", - "sanitize": true, - "maxLength": 256 - }, - "context": { - "type": "string", - "sanitize": true, - "maxLength": 256 - }, - "data_type": { - "type": "string", - "sanitize": true, - "maxLength": 128 - }, - "reason": { - "type": "string", - "sanitize": true, - "maxLength": 256 - } - } - }, - "missing_tool": { - "defaultMax": 20, - "fields": { - "alternatives": { - "type": "string", - "sanitize": true, - "maxLength": 512 - }, - "reason": { - "required": true, - "type": "string", - "sanitize": true, - "maxLength": 256 - }, - "tool": { - "type": "string", - "sanitize": true, - "maxLength": 128 - } - } - }, - "noop": { - "defaultMax": 1, - "fields": { - "message": { - "required": true, - "type": "string", - "sanitize": true, - "maxLength": 65000 - } - } - }, - "push_to_pull_request_branch": { - "defaultMax": 1, - "fields": { - "branch": { - "required": true, - "type": "string", - "sanitize": true, - "maxLength": 256 - }, - "message": { - "required": true, - "type": "string", - "sanitize": true, - "maxLength": 65000 - }, - "pull_request_number": { - "issueOrPRNumber": true - } - } - } - } - GH_AW_SAFE_OUTPUTS_VALIDATION_713ae3f96a59ba34_EOF - node ${RUNNER_TEMP}/gh-aw/actions/generate_safe_outputs_tools.cjs - - name: Generate Safe Outputs MCP Server Config - id: safe-outputs-config - run: | - # Generate a secure random API key (360 bits of entropy, 40+ chars) - # Mask immediately to prevent timing vulnerabilities - API_KEY=$(openssl rand -base64 45 | tr -d '/+=') - echo "::add-mask::${API_KEY}" - - PORT=3001 - - # Set outputs for next steps - { - echo "safe_outputs_api_key=${API_KEY}" - echo "safe_outputs_port=${PORT}" - } >> "$GITHUB_OUTPUT" - - echo "Safe Outputs MCP server will run on port ${PORT}" - - - name: Start Safe Outputs MCP HTTP Server - id: safe-outputs-start - env: - DEBUG: '*' - GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }} - GH_AW_SAFE_OUTPUTS_PORT: ${{ steps.safe-outputs-config.outputs.safe_outputs_port }} - GH_AW_SAFE_OUTPUTS_API_KEY: ${{ steps.safe-outputs-config.outputs.safe_outputs_api_key }} - GH_AW_SAFE_OUTPUTS_TOOLS_PATH: ${{ runner.temp }}/gh-aw/safeoutputs/tools.json - GH_AW_SAFE_OUTPUTS_CONFIG_PATH: ${{ runner.temp }}/gh-aw/safeoutputs/config.json - GH_AW_MCP_LOG_DIR: /tmp/gh-aw/mcp-logs/safeoutputs - run: | - # Environment variables are set above to prevent template injection - export DEBUG - export GH_AW_SAFE_OUTPUTS - export GH_AW_SAFE_OUTPUTS_PORT - export GH_AW_SAFE_OUTPUTS_API_KEY - export GH_AW_SAFE_OUTPUTS_TOOLS_PATH - export GH_AW_SAFE_OUTPUTS_CONFIG_PATH - export GH_AW_MCP_LOG_DIR - - bash ${RUNNER_TEMP}/gh-aw/actions/start_safe_outputs_server.sh - - - name: Start MCP Gateway - id: start-mcp-gateway - env: - GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }} - GH_AW_SAFE_OUTPUTS_API_KEY: ${{ steps.safe-outputs-start.outputs.api_key }} - GH_AW_SAFE_OUTPUTS_PORT: ${{ steps.safe-outputs-start.outputs.port }} - GITHUB_MCP_GUARD_MIN_INTEGRITY: ${{ steps.determine-automatic-lockdown.outputs.min_integrity }} - GITHUB_MCP_GUARD_REPOS: ${{ steps.determine-automatic-lockdown.outputs.repos }} - GITHUB_MCP_SERVER_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} - run: | - set -eo pipefail - mkdir -p /tmp/gh-aw/mcp-config - - # Export gateway environment variables for MCP config and gateway script - export MCP_GATEWAY_PORT="80" - export MCP_GATEWAY_DOMAIN="host.docker.internal" - MCP_GATEWAY_API_KEY=$(openssl rand -base64 45 | tr -d '/+=') - echo "::add-mask::${MCP_GATEWAY_API_KEY}" - export MCP_GATEWAY_API_KEY - export MCP_GATEWAY_PAYLOAD_DIR="/tmp/gh-aw/mcp-payloads" - mkdir -p "${MCP_GATEWAY_PAYLOAD_DIR}" - export MCP_GATEWAY_PAYLOAD_SIZE_THRESHOLD="524288" - export DEBUG="*" - - export GH_AW_ENGINE="copilot" - export MCP_GATEWAY_DOCKER_COMMAND='docker run -i --rm --network host -v /var/run/docker.sock:/var/run/docker.sock -e MCP_GATEWAY_PORT -e MCP_GATEWAY_DOMAIN -e MCP_GATEWAY_API_KEY -e MCP_GATEWAY_PAYLOAD_DIR -e MCP_GATEWAY_PAYLOAD_SIZE_THRESHOLD -e DEBUG -e MCP_GATEWAY_LOG_DIR -e GH_AW_MCP_LOG_DIR -e GH_AW_SAFE_OUTPUTS -e GH_AW_SAFE_OUTPUTS_CONFIG_PATH -e GH_AW_SAFE_OUTPUTS_TOOLS_PATH -e GH_AW_ASSETS_BRANCH -e GH_AW_ASSETS_MAX_SIZE_KB -e GH_AW_ASSETS_ALLOWED_EXTS -e DEFAULT_BRANCH -e GITHUB_MCP_SERVER_TOKEN -e GITHUB_MCP_GUARD_MIN_INTEGRITY -e GITHUB_MCP_GUARD_REPOS -e GITHUB_REPOSITORY -e GITHUB_SERVER_URL -e GITHUB_SHA -e GITHUB_WORKSPACE -e GITHUB_TOKEN -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RUN_ATTEMPT -e GITHUB_JOB -e GITHUB_ACTION -e GITHUB_EVENT_NAME -e GITHUB_EVENT_PATH -e GITHUB_ACTOR -e GITHUB_ACTOR_ID -e GITHUB_TRIGGERING_ACTOR -e GITHUB_WORKFLOW -e GITHUB_WORKFLOW_REF -e GITHUB_WORKFLOW_SHA -e GITHUB_REF -e GITHUB_REF_NAME -e GITHUB_REF_TYPE -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GH_AW_SAFE_OUTPUTS_PORT -e GH_AW_SAFE_OUTPUTS_API_KEY -v /tmp/gh-aw/mcp-payloads:/tmp/gh-aw/mcp-payloads:rw -v /opt:/opt:ro -v /tmp:/tmp:rw -v '"${GITHUB_WORKSPACE}"':'"${GITHUB_WORKSPACE}"':rw ghcr.io/github/gh-aw-mcpg:v0.2.11' - - mkdir -p /home/runner/.copilot - cat << GH_AW_MCP_CONFIG_9c5e2164c5f8d3b7_EOF | bash ${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.sh - { - "mcpServers": { - "github": { - "type": "stdio", - "container": "ghcr.io/github/github-mcp-server:v0.32.0", - "env": { - "GITHUB_HOST": "\${GITHUB_SERVER_URL}", - "GITHUB_PERSONAL_ACCESS_TOKEN": "\${GITHUB_MCP_SERVER_TOKEN}", - "GITHUB_READ_ONLY": "1", - "GITHUB_TOOLSETS": "pull_requests,repos" - }, - "guard-policies": { - "allow-only": { - "min-integrity": "$GITHUB_MCP_GUARD_MIN_INTEGRITY", - "repos": "$GITHUB_MCP_GUARD_REPOS" - } - } - }, - "safeoutputs": { - "type": "http", - "url": "http://host.docker.internal:$GH_AW_SAFE_OUTPUTS_PORT", - "headers": { - "Authorization": "\${GH_AW_SAFE_OUTPUTS_API_KEY}" - }, - "guard-policies": { - "write-sink": { - "accept": [ - "*" - ] - } - } - } - }, - "gateway": { - "port": $MCP_GATEWAY_PORT, - "domain": "${MCP_GATEWAY_DOMAIN}", - "apiKey": "${MCP_GATEWAY_API_KEY}", - "payloadDir": "${MCP_GATEWAY_PAYLOAD_DIR}" - } - } - GH_AW_MCP_CONFIG_9c5e2164c5f8d3b7_EOF - - name: Download activation artifact - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - name: activation - path: /tmp/gh-aw - - name: Clean git credentials - continue-on-error: true - run: bash ${RUNNER_TEMP}/gh-aw/actions/clean_git_credentials.sh - - name: Execute GitHub Copilot CLI - id: agentic_execution - # Copilot CLI tool arguments (sorted): - timeout-minutes: 10 - run: | - set -o pipefail - touch /tmp/gh-aw/agent-step-summary.md - # shellcheck disable=SC1003 - sudo -E awf --container-workdir "${GITHUB_WORKSPACE}" --mount "${RUNNER_TEMP}/gh-aw:${RUNNER_TEMP}/gh-aw:ro" --mount "${RUNNER_TEMP}/gh-aw:/host${RUNNER_TEMP}/gh-aw:ro" --env-all --exclude-env COPILOT_GITHUB_TOKEN --exclude-env GITHUB_MCP_SERVER_TOKEN --exclude-env MCP_GATEWAY_API_KEY --allow-domains api.business.githubcopilot.com,api.enterprise.githubcopilot.com,api.github.com,api.githubcopilot.com,api.individual.githubcopilot.com,api.snapcraft.io,archive.ubuntu.com,azure.archive.ubuntu.com,crl.geotrust.com,crl.globalsign.com,crl.identrust.com,crl.sectigo.com,crl.thawte.com,crl.usertrust.com,crl.verisign.com,crl3.digicert.com,crl4.digicert.com,crls.ssl.com,github.com,host.docker.internal,json-schema.org,json.schemastore.org,keyserver.ubuntu.com,ocsp.digicert.com,ocsp.geotrust.com,ocsp.globalsign.com,ocsp.identrust.com,ocsp.sectigo.com,ocsp.ssl.com,ocsp.thawte.com,ocsp.usertrust.com,ocsp.verisign.com,packagecloud.io,packages.cloud.google.com,packages.microsoft.com,ppa.launchpad.net,raw.githubusercontent.com,registry.npmjs.org,s.symcb.com,s.symcd.com,security.ubuntu.com,telemetry.enterprise.githubcopilot.com,ts-crl.ws.symantec.com,ts-ocsp.ws.symantec.com,www.googleapis.com --log-level info --proxy-logs-dir /tmp/gh-aw/sandbox/firewall/logs --audit-dir /tmp/gh-aw/sandbox/firewall/audit --enable-host-access --image-tag 0.25.11 --skip-pull --enable-api-proxy \ - -- /bin/bash -c '/usr/local/bin/copilot --add-dir /tmp/gh-aw/ --log-level all --log-dir /tmp/gh-aw/sandbox/agent/logs/ --disable-builtin-mcps --allow-all-tools --allow-all-paths --add-dir "${GITHUB_WORKSPACE}" --prompt "$(cat /tmp/gh-aw/aw-prompts/prompt.txt)"' 2>&1 | tee -a /tmp/gh-aw/agent-stdio.log - env: - COPILOT_AGENT_RUNNER_TYPE: STANDALONE - COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }} - COPILOT_MODEL: ${{ vars.GH_AW_MODEL_AGENT_COPILOT || '' }} - GH_AW_MCP_CONFIG: /home/runner/.copilot/mcp-config.json - GH_AW_PHASE: agent - GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt - GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }} - GH_AW_VERSION: v0.65.6 - GITHUB_API_URL: ${{ github.api_url }} - GITHUB_AW: true - GITHUB_HEAD_REF: ${{ github.head_ref }} - GITHUB_MCP_SERVER_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} - GITHUB_REF_NAME: ${{ github.ref_name }} - GITHUB_SERVER_URL: ${{ github.server_url }} - GITHUB_STEP_SUMMARY: /tmp/gh-aw/agent-step-summary.md - GITHUB_WORKSPACE: ${{ github.workspace }} - GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com - GIT_AUTHOR_NAME: github-actions[bot] - GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com - GIT_COMMITTER_NAME: github-actions[bot] - XDG_CONFIG_HOME: /home/runner - - name: Detect inference access error - id: detect-inference-error - if: always() - continue-on-error: true - run: bash ${RUNNER_TEMP}/gh-aw/actions/detect_inference_access_error.sh - - name: Configure Git credentials - env: - REPO_NAME: ${{ github.repository }} - SERVER_URL: ${{ github.server_url }} - run: | - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git config --global user.name "github-actions[bot]" - git config --global am.keepcr true - # Re-authenticate git with GitHub token - SERVER_URL_STRIPPED="${SERVER_URL#https://}" - git remote set-url origin "https://x-access-token:${{ github.token }}@${SERVER_URL_STRIPPED}/${REPO_NAME}.git" - echo "Git configured with standard GitHub Actions identity" - - name: Copy Copilot session state files to logs - if: always() - continue-on-error: true - run: bash ${RUNNER_TEMP}/gh-aw/actions/copy_copilot_session_state.sh - - name: Stop MCP Gateway - if: always() - continue-on-error: true - env: - MCP_GATEWAY_PORT: ${{ steps.start-mcp-gateway.outputs.gateway-port }} - MCP_GATEWAY_API_KEY: ${{ steps.start-mcp-gateway.outputs.gateway-api-key }} - GATEWAY_PID: ${{ steps.start-mcp-gateway.outputs.gateway-pid }} - run: | - bash ${RUNNER_TEMP}/gh-aw/actions/stop_mcp_gateway.sh "$GATEWAY_PID" - - name: Redact secrets in logs - if: always() - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 - with: - script: | - const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); - setupGlobals(core, github, context, exec, io); - const { main } = require('${{ runner.temp }}/gh-aw/actions/redact_secrets.cjs'); - await main(); - env: - GH_AW_SECRET_NAMES: 'COPILOT_GITHUB_TOKEN,GH_AW_GITHUB_MCP_SERVER_TOKEN,GH_AW_GITHUB_TOKEN,GITHUB_TOKEN' - SECRET_COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }} - SECRET_GH_AW_GITHUB_MCP_SERVER_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN }} - SECRET_GH_AW_GITHUB_TOKEN: ${{ secrets.GH_AW_GITHUB_TOKEN }} - SECRET_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Append agent step summary - if: always() - run: bash ${RUNNER_TEMP}/gh-aw/actions/append_agent_step_summary.sh - - name: Copy Safe Outputs - if: always() - env: - GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }} - run: | - mkdir -p /tmp/gh-aw - cp "$GH_AW_SAFE_OUTPUTS" /tmp/gh-aw/safeoutputs.jsonl 2>/dev/null || true - - name: Ingest agent output - id: collect_output - if: always() - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 - env: - GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }} - GH_AW_ALLOWED_DOMAINS: "api.business.githubcopilot.com,api.enterprise.githubcopilot.com,api.github.com,api.githubcopilot.com,api.individual.githubcopilot.com,api.snapcraft.io,archive.ubuntu.com,azure.archive.ubuntu.com,crl.geotrust.com,crl.globalsign.com,crl.identrust.com,crl.sectigo.com,crl.thawte.com,crl.usertrust.com,crl.verisign.com,crl3.digicert.com,crl4.digicert.com,crls.ssl.com,github.com,host.docker.internal,json-schema.org,json.schemastore.org,keyserver.ubuntu.com,ocsp.digicert.com,ocsp.geotrust.com,ocsp.globalsign.com,ocsp.identrust.com,ocsp.sectigo.com,ocsp.ssl.com,ocsp.thawte.com,ocsp.usertrust.com,ocsp.verisign.com,packagecloud.io,packages.cloud.google.com,packages.microsoft.com,ppa.launchpad.net,raw.githubusercontent.com,registry.npmjs.org,s.symcb.com,s.symcd.com,security.ubuntu.com,telemetry.enterprise.githubcopilot.com,ts-crl.ws.symantec.com,ts-ocsp.ws.symantec.com,www.googleapis.com" - GITHUB_SERVER_URL: ${{ github.server_url }} - GITHUB_API_URL: ${{ github.api_url }} - GH_AW_COMMAND: mergefest - with: - script: | - const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); - setupGlobals(core, github, context, exec, io); - const { main } = require('${{ runner.temp }}/gh-aw/actions/collect_ndjson_output.cjs'); - await main(); - - name: Parse agent logs for step summary - if: always() - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 - env: - GH_AW_AGENT_OUTPUT: /tmp/gh-aw/sandbox/agent/logs/ - with: - script: | - const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); - setupGlobals(core, github, context, exec, io); - const { main } = require('${{ runner.temp }}/gh-aw/actions/parse_copilot_log.cjs'); - await main(); - - name: Parse MCP Gateway logs for step summary - if: always() - id: parse-mcp-gateway - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 - with: - script: | - const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); - setupGlobals(core, github, context, exec, io); - const { main } = require('${{ runner.temp }}/gh-aw/actions/parse_mcp_gateway_log.cjs'); - await main(); - - name: Print firewall logs - if: always() - continue-on-error: true - env: - AWF_LOGS_DIR: /tmp/gh-aw/sandbox/firewall/logs - run: | - # Fix permissions on firewall logs so they can be uploaded as artifacts - # AWF runs with sudo, creating files owned by root - sudo chmod -R a+r /tmp/gh-aw/sandbox/firewall/logs 2>/dev/null || true - # Only run awf logs summary if awf command exists (it may not be installed if workflow failed before install step) - if command -v awf &> /dev/null; then - awf logs summary | tee -a "$GITHUB_STEP_SUMMARY" - else - echo 'AWF binary not installed, skipping firewall log summary' - fi - - name: Parse token usage for step summary - if: always() - continue-on-error: true - run: bash ${RUNNER_TEMP}/gh-aw/actions/parse_token_usage.sh - - name: Write agent output placeholder if missing - if: always() - run: | - if [ ! -f /tmp/gh-aw/agent_output.json ]; then - echo '{"items":[]}' > /tmp/gh-aw/agent_output.json - fi - - name: Upload agent artifacts - if: always() - continue-on-error: true - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7 - with: - name: agent - path: | - /tmp/gh-aw/aw-prompts/prompt.txt - /tmp/gh-aw/sandbox/agent/logs/ - /tmp/gh-aw/redacted-urls.log - /tmp/gh-aw/mcp-logs/ - /tmp/gh-aw/agent-stdio.log - /tmp/gh-aw/agent/ - /tmp/gh-aw/safeoutputs.jsonl - /tmp/gh-aw/agent_output.json - /tmp/gh-aw/aw-*.patch - /tmp/gh-aw/aw-*.bundle - if-no-files-found: ignore - - name: Upload firewall audit logs - if: always() - continue-on-error: true - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7 - with: - name: firewall-audit-logs - path: | - /tmp/gh-aw/sandbox/firewall/logs/ - /tmp/gh-aw/sandbox/firewall/audit/ - if-no-files-found: ignore - - conclusion: - needs: - - activation - - agent - - detection - - safe_outputs - if: always() && (needs.agent.result != 'skipped' || needs.activation.outputs.lockdown_check_failed == 'true') - runs-on: ubuntu-slim - permissions: - contents: write - pull-requests: write - concurrency: - group: "gh-aw-conclusion-mergefest" - cancel-in-progress: false - outputs: - noop_message: ${{ steps.noop.outputs.noop_message }} - tools_reported: ${{ steps.missing_tool.outputs.tools_reported }} - total_count: ${{ steps.missing_tool.outputs.total_count }} - steps: - - name: Setup Scripts - uses: github/gh-aw-actions/setup@31130b20a8fd3ef263acbe2091267c0aace07e09 # v0.65.6 - with: - destination: ${{ runner.temp }}/gh-aw/actions - - name: Download agent output artifact - id: download-agent-output - continue-on-error: true - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - name: agent - path: /tmp/gh-aw/ - - name: Setup agent output environment variable - id: setup-agent-output-env - if: steps.download-agent-output.outcome == 'success' - run: | - mkdir -p /tmp/gh-aw/ - find "/tmp/gh-aw/" -type f -print - echo "GH_AW_AGENT_OUTPUT=/tmp/gh-aw/agent_output.json" >> "$GITHUB_OUTPUT" - - name: Process No-Op Messages - id: noop - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 - env: - GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} - GH_AW_NOOP_MAX: "1" - GH_AW_WORKFLOW_NAME: "Mergefest" - GH_AW_WORKFLOW_SOURCE: "github/gh-aw/.github/workflows/mergefest.md@852cb06ad52958b402ed982b69957ffc57ca0619" - GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/github/gh-aw/blob/852cb06ad52958b402ed982b69957ffc57ca0619/.github/workflows/mergefest.md" - GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }} - GH_AW_NOOP_REPORT_AS_ISSUE: "true" - with: - github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} - script: | - const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); - setupGlobals(core, github, context, exec, io); - const { main } = require('${{ runner.temp }}/gh-aw/actions/handle_noop_message.cjs'); - await main(); - - name: Record Missing Tool - id: missing_tool - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 - env: - GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} - GH_AW_MISSING_TOOL_CREATE_ISSUE: "true" - GH_AW_WORKFLOW_NAME: "Mergefest" - GH_AW_WORKFLOW_SOURCE: "github/gh-aw/.github/workflows/mergefest.md@852cb06ad52958b402ed982b69957ffc57ca0619" - GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/github/gh-aw/blob/852cb06ad52958b402ed982b69957ffc57ca0619/.github/workflows/mergefest.md" - with: - github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} - script: | - const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); - setupGlobals(core, github, context, exec, io); - const { main } = require('${{ runner.temp }}/gh-aw/actions/missing_tool.cjs'); - await main(); - - name: Handle Agent Failure - id: handle_agent_failure - if: always() - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 - env: - GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} - GH_AW_WORKFLOW_NAME: "Mergefest" - GH_AW_WORKFLOW_SOURCE: "github/gh-aw/.github/workflows/mergefest.md@852cb06ad52958b402ed982b69957ffc57ca0619" - GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/github/gh-aw/blob/852cb06ad52958b402ed982b69957ffc57ca0619/.github/workflows/mergefest.md" - GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }} - GH_AW_WORKFLOW_ID: "mergefest" - GH_AW_ENGINE_ID: "copilot" - GH_AW_SECRET_VERIFICATION_RESULT: ${{ needs.activation.outputs.secret_verification_result }} - GH_AW_CHECKOUT_PR_SUCCESS: ${{ needs.agent.outputs.checkout_pr_success }} - GH_AW_INFERENCE_ACCESS_ERROR: ${{ needs.agent.outputs.inference_access_error }} - GH_AW_CODE_PUSH_FAILURE_ERRORS: ${{ needs.safe_outputs.outputs.code_push_failure_errors }} - GH_AW_CODE_PUSH_FAILURE_COUNT: ${{ needs.safe_outputs.outputs.code_push_failure_count }} - GH_AW_LOCKDOWN_CHECK_FAILED: ${{ needs.activation.outputs.lockdown_check_failed }} - GH_AW_GROUP_REPORTS: "false" - GH_AW_FAILURE_REPORT_AS_ISSUE: "true" - GH_AW_TIMEOUT_MINUTES: "10" - with: - github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} - script: | - const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); - setupGlobals(core, github, context, exec, io); - const { main } = require('${{ runner.temp }}/gh-aw/actions/handle_agent_failure.cjs'); - await main(); - - name: Update reaction comment with completion status - id: conclusion - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 - env: - GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} - GH_AW_COMMENT_ID: ${{ needs.activation.outputs.comment_id }} - GH_AW_COMMENT_REPO: ${{ needs.activation.outputs.comment_repo }} - GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - GH_AW_WORKFLOW_NAME: "Mergefest" - GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }} - GH_AW_DETECTION_CONCLUSION: ${{ needs.detection.outputs.detection_conclusion }} - with: - github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} - script: | - const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); - setupGlobals(core, github, context, exec, io); - const { main } = require('${{ runner.temp }}/gh-aw/actions/notify_comment_error.cjs'); - await main(); - - detection: - needs: agent - if: > - always() && needs.agent.result != 'skipped' && (needs.agent.outputs.output_types != '' || needs.agent.outputs.has_patch == 'true') - runs-on: ubuntu-latest - permissions: - contents: read - outputs: - detection_conclusion: ${{ steps.detection_conclusion.outputs.conclusion }} - detection_success: ${{ steps.detection_conclusion.outputs.success }} - steps: - - name: Setup Scripts - uses: github/gh-aw-actions/setup@31130b20a8fd3ef263acbe2091267c0aace07e09 # v0.65.6 - with: - destination: ${{ runner.temp }}/gh-aw/actions - - name: Download agent output artifact - id: download-agent-output - continue-on-error: true - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - name: agent - path: /tmp/gh-aw/ - - name: Setup agent output environment variable - id: setup-agent-output-env - if: steps.download-agent-output.outcome == 'success' - run: | - mkdir -p /tmp/gh-aw/ - find "/tmp/gh-aw/" -type f -print - echo "GH_AW_AGENT_OUTPUT=/tmp/gh-aw/agent_output.json" >> "$GITHUB_OUTPUT" - - name: Checkout repository for patch context - if: needs.agent.outputs.has_patch == 'true' - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - persist-credentials: false - # --- Threat Detection --- - - name: Download container images - run: bash ${RUNNER_TEMP}/gh-aw/actions/download_docker_images.sh ghcr.io/github/gh-aw-firewall/agent:0.25.11 ghcr.io/github/gh-aw-firewall/api-proxy:0.25.11 ghcr.io/github/gh-aw-firewall/squid:0.25.11 - - name: Check if detection needed - id: detection_guard - if: always() - env: - OUTPUT_TYPES: ${{ needs.agent.outputs.output_types }} - HAS_PATCH: ${{ needs.agent.outputs.has_patch }} - run: | - if [[ -n "$OUTPUT_TYPES" || "$HAS_PATCH" == "true" ]]; then - echo "run_detection=true" >> "$GITHUB_OUTPUT" - echo "Detection will run: output_types=$OUTPUT_TYPES, has_patch=$HAS_PATCH" - else - echo "run_detection=false" >> "$GITHUB_OUTPUT" - echo "Detection skipped: no agent outputs or patches to analyze" - fi - - name: Clear MCP configuration for detection - if: always() && steps.detection_guard.outputs.run_detection == 'true' - run: | - rm -f /tmp/gh-aw/mcp-config/mcp-servers.json - rm -f /home/runner/.copilot/mcp-config.json - rm -f "$GITHUB_WORKSPACE/.gemini/settings.json" - - name: Prepare threat detection files - if: always() && steps.detection_guard.outputs.run_detection == 'true' - run: | - mkdir -p /tmp/gh-aw/threat-detection/aw-prompts - cp /tmp/gh-aw/aw-prompts/prompt.txt /tmp/gh-aw/threat-detection/aw-prompts/prompt.txt 2>/dev/null || true - cp /tmp/gh-aw/agent_output.json /tmp/gh-aw/threat-detection/agent_output.json 2>/dev/null || true - for f in /tmp/gh-aw/aw-*.patch; do - [ -f "$f" ] && cp "$f" /tmp/gh-aw/threat-detection/ 2>/dev/null || true - done - for f in /tmp/gh-aw/aw-*.bundle; do - [ -f "$f" ] && cp "$f" /tmp/gh-aw/threat-detection/ 2>/dev/null || true - done - echo "Prepared threat detection files:" - ls -la /tmp/gh-aw/threat-detection/ 2>/dev/null || true - - name: Setup threat detection - if: always() && steps.detection_guard.outputs.run_detection == 'true' - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 - env: - WORKFLOW_NAME: "Mergefest" - WORKFLOW_DESCRIPTION: "Automatically merges the main branch into pull request branches when invoked with /mergefest command" - HAS_PATCH: ${{ needs.agent.outputs.has_patch }} - with: - script: | - const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); - setupGlobals(core, github, context, exec, io); - const { main } = require('${{ runner.temp }}/gh-aw/actions/setup_threat_detection.cjs'); - await main(); - - name: Ensure threat-detection directory and log - if: always() && steps.detection_guard.outputs.run_detection == 'true' - run: | - mkdir -p /tmp/gh-aw/threat-detection - touch /tmp/gh-aw/threat-detection/detection.log - - name: Install GitHub Copilot CLI - run: ${RUNNER_TEMP}/gh-aw/actions/install_copilot_cli.sh latest - - name: Install AWF binary - run: bash ${RUNNER_TEMP}/gh-aw/actions/install_awf_binary.sh v0.25.11 - - name: Execute GitHub Copilot CLI - if: always() && steps.detection_guard.outputs.run_detection == 'true' - id: detection_agentic_execution - # Copilot CLI tool arguments (sorted): - timeout-minutes: 20 - run: | - set -o pipefail - touch /tmp/gh-aw/agent-step-summary.md - # shellcheck disable=SC1003 - sudo -E awf --container-workdir "${GITHUB_WORKSPACE}" --mount "${RUNNER_TEMP}/gh-aw:${RUNNER_TEMP}/gh-aw:ro" --mount "${RUNNER_TEMP}/gh-aw:/host${RUNNER_TEMP}/gh-aw:ro" --env-all --exclude-env COPILOT_GITHUB_TOKEN --allow-domains api.business.githubcopilot.com,api.enterprise.githubcopilot.com,api.github.com,api.githubcopilot.com,api.individual.githubcopilot.com,github.com,host.docker.internal,telemetry.enterprise.githubcopilot.com --log-level info --proxy-logs-dir /tmp/gh-aw/sandbox/firewall/logs --audit-dir /tmp/gh-aw/sandbox/firewall/audit --enable-host-access --image-tag 0.25.11 --skip-pull --enable-api-proxy \ - -- /bin/bash -c '/usr/local/bin/copilot --add-dir /tmp/gh-aw/ --log-level all --log-dir /tmp/gh-aw/sandbox/agent/logs/ --disable-builtin-mcps --allow-all-tools --add-dir "${GITHUB_WORKSPACE}" --prompt "$(cat /tmp/gh-aw/aw-prompts/prompt.txt)"' 2>&1 | tee -a /tmp/gh-aw/threat-detection/detection.log - env: - COPILOT_AGENT_RUNNER_TYPE: STANDALONE - COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }} - COPILOT_MODEL: ${{ vars.GH_AW_MODEL_DETECTION_COPILOT || '' }} - GH_AW_PHASE: detection - GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt - GH_AW_VERSION: v0.65.6 - GITHUB_API_URL: ${{ github.api_url }} - GITHUB_AW: true - GITHUB_HEAD_REF: ${{ github.head_ref }} - GITHUB_REF_NAME: ${{ github.ref_name }} - GITHUB_SERVER_URL: ${{ github.server_url }} - GITHUB_STEP_SUMMARY: /tmp/gh-aw/agent-step-summary.md - GITHUB_WORKSPACE: ${{ github.workspace }} - GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com - GIT_AUTHOR_NAME: github-actions[bot] - GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com - GIT_COMMITTER_NAME: github-actions[bot] - XDG_CONFIG_HOME: /home/runner - - name: Upload threat detection log - if: always() && steps.detection_guard.outputs.run_detection == 'true' - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7 - with: - name: detection - path: /tmp/gh-aw/threat-detection/detection.log - if-no-files-found: ignore - - name: Parse and conclude threat detection - id: detection_conclusion - if: always() - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 - env: - RUN_DETECTION: ${{ steps.detection_guard.outputs.run_detection }} - with: - script: | - const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); - setupGlobals(core, github, context, exec, io); - const { main } = require('${{ runner.temp }}/gh-aw/actions/parse_threat_detection_results.cjs'); - await main(); - - pre_activation: - if: "github.event_name == 'issue_comment' && (startsWith(github.event.comment.body, '/mergefest ') || startsWith(github.event.comment.body, '/mergefest\n') || github.event.comment.body == '/mergefest') && github.event.issue.pull_request != null" - runs-on: ubuntu-slim - outputs: - activated: ${{ steps.check_membership.outputs.is_team_member == 'true' && steps.check_command_position.outputs.command_position_ok == 'true' }} - matched_command: ${{ steps.check_command_position.outputs.matched_command }} - steps: - - name: Setup Scripts - uses: github/gh-aw-actions/setup@31130b20a8fd3ef263acbe2091267c0aace07e09 # v0.65.6 - with: - destination: ${{ runner.temp }}/gh-aw/actions - - name: Check team membership for command workflow - id: check_membership - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 - env: - GH_AW_REQUIRED_ROLES: "admin,maintainer,write" - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); - setupGlobals(core, github, context, exec, io); - const { main } = require('${{ runner.temp }}/gh-aw/actions/check_membership.cjs'); - await main(); - - name: Check command position - id: check_command_position - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 - env: - GH_AW_COMMANDS: "[\"mergefest\"]" - with: - script: | - const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); - setupGlobals(core, github, context, exec, io); - const { main } = require('${{ runner.temp }}/gh-aw/actions/check_command_position.cjs'); - await main(); - - safe_outputs: - needs: - - activation - - agent - - detection - if: (!cancelled()) && needs.agent.result != 'skipped' && needs.detection.result == 'success' - runs-on: ubuntu-slim - permissions: - contents: write - pull-requests: write - timeout-minutes: 15 - env: - GH_AW_CALLER_WORKFLOW_ID: "${{ github.repository }}/mergefest" - GH_AW_EFFECTIVE_TOKENS: ${{ needs.agent.outputs.effective_tokens }} - GH_AW_ENGINE_ID: "copilot" - GH_AW_ENGINE_MODEL: ${{ needs.agent.outputs.model }} - GH_AW_WORKFLOW_ID: "mergefest" - GH_AW_WORKFLOW_NAME: "Mergefest" - GH_AW_WORKFLOW_SOURCE: "github/gh-aw/.github/workflows/mergefest.md@852cb06ad52958b402ed982b69957ffc57ca0619" - GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/github/gh-aw/blob/852cb06ad52958b402ed982b69957ffc57ca0619/.github/workflows/mergefest.md" - outputs: - code_push_failure_count: ${{ steps.process_safe_outputs.outputs.code_push_failure_count }} - code_push_failure_errors: ${{ steps.process_safe_outputs.outputs.code_push_failure_errors }} - create_discussion_error_count: ${{ steps.process_safe_outputs.outputs.create_discussion_error_count }} - create_discussion_errors: ${{ steps.process_safe_outputs.outputs.create_discussion_errors }} - process_safe_outputs_processed_count: ${{ steps.process_safe_outputs.outputs.processed_count }} - process_safe_outputs_temporary_id_map: ${{ steps.process_safe_outputs.outputs.temporary_id_map }} - push_commit_sha: ${{ steps.process_safe_outputs.outputs.push_commit_sha }} - push_commit_url: ${{ steps.process_safe_outputs.outputs.push_commit_url }} - steps: - - name: Setup Scripts - uses: github/gh-aw-actions/setup@31130b20a8fd3ef263acbe2091267c0aace07e09 # v0.65.6 - with: - destination: ${{ runner.temp }}/gh-aw/actions - - name: Download agent output artifact - id: download-agent-output - continue-on-error: true - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - name: agent - path: /tmp/gh-aw/ - - name: Setup agent output environment variable - id: setup-agent-output-env - if: steps.download-agent-output.outcome == 'success' - run: | - mkdir -p /tmp/gh-aw/ - find "/tmp/gh-aw/" -type f -print - echo "GH_AW_AGENT_OUTPUT=/tmp/gh-aw/agent_output.json" >> "$GITHUB_OUTPUT" - - name: Download patch artifact - continue-on-error: true - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - name: agent - path: /tmp/gh-aw/ - - name: Checkout repository - if: (!cancelled()) && needs.agent.result != 'skipped' && contains(needs.agent.outputs.output_types, 'push_to_pull_request_branch') - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - ref: ${{ github.base_ref || github.event.pull_request.base.ref || github.ref_name || github.event.repository.default_branch }} - token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} - persist-credentials: false - fetch-depth: 1 - - name: Configure Git credentials - if: (!cancelled()) && needs.agent.result != 'skipped' && contains(needs.agent.outputs.output_types, 'push_to_pull_request_branch') - env: - REPO_NAME: ${{ github.repository }} - SERVER_URL: ${{ github.server_url }} - GIT_TOKEN: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} - run: | - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git config --global user.name "github-actions[bot]" - git config --global am.keepcr true - # Re-authenticate git with GitHub token - SERVER_URL_STRIPPED="${SERVER_URL#https://}" - git remote set-url origin "https://x-access-token:${GIT_TOKEN}@${SERVER_URL_STRIPPED}/${REPO_NAME}.git" - echo "Git configured with standard GitHub Actions identity" - - name: Configure GH_HOST for enterprise compatibility - id: ghes-host-config - shell: bash - run: | - # Derive GH_HOST from GITHUB_SERVER_URL so the gh CLI targets the correct - # GitHub instance (GHES/GHEC). On github.com this is a harmless no-op. - GH_HOST="${GITHUB_SERVER_URL#https://}" - GH_HOST="${GH_HOST#http://}" - echo "GH_HOST=${GH_HOST}" >> "$GITHUB_ENV" - - name: Process Safe Outputs - id: process_safe_outputs - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 - env: - GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} - GH_AW_ALLOWED_DOMAINS: "api.business.githubcopilot.com,api.enterprise.githubcopilot.com,api.github.com,api.githubcopilot.com,api.individual.githubcopilot.com,api.snapcraft.io,archive.ubuntu.com,azure.archive.ubuntu.com,crl.geotrust.com,crl.globalsign.com,crl.identrust.com,crl.sectigo.com,crl.thawte.com,crl.usertrust.com,crl.verisign.com,crl3.digicert.com,crl4.digicert.com,crls.ssl.com,github.com,host.docker.internal,json-schema.org,json.schemastore.org,keyserver.ubuntu.com,ocsp.digicert.com,ocsp.geotrust.com,ocsp.globalsign.com,ocsp.identrust.com,ocsp.sectigo.com,ocsp.ssl.com,ocsp.thawte.com,ocsp.usertrust.com,ocsp.verisign.com,packagecloud.io,packages.cloud.google.com,packages.microsoft.com,ppa.launchpad.net,raw.githubusercontent.com,registry.npmjs.org,s.symcb.com,s.symcd.com,security.ubuntu.com,telemetry.enterprise.githubcopilot.com,ts-crl.ws.symantec.com,ts-ocsp.ws.symantec.com,www.googleapis.com" - GITHUB_SERVER_URL: ${{ github.server_url }} - GITHUB_API_URL: ${{ github.api_url }} - GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG: "{\"missing_data\":{},\"missing_tool\":{},\"noop\":{\"max\":1,\"report-as-issue\":\"true\"},\"push_to_pull_request_branch\":{\"if_no_changes\":\"warn\",\"max_patch_size\":1024,\"protected_files\":[\"package.json\",\"bun.lockb\",\"bunfig.toml\",\"deno.json\",\"deno.jsonc\",\"deno.lock\",\"global.json\",\"NuGet.Config\",\"Directory.Packages.props\",\"mix.exs\",\"mix.lock\",\"go.mod\",\"go.sum\",\"stack.yaml\",\"stack.yaml.lock\",\"pom.xml\",\"build.gradle\",\"build.gradle.kts\",\"settings.gradle\",\"settings.gradle.kts\",\"gradle.properties\",\"package-lock.json\",\"yarn.lock\",\"pnpm-lock.yaml\",\"npm-shrinkwrap.json\",\"requirements.txt\",\"Pipfile\",\"Pipfile.lock\",\"pyproject.toml\",\"setup.py\",\"setup.cfg\",\"Gemfile\",\"Gemfile.lock\",\"uv.lock\",\"CODEOWNERS\",\"AGENTS.md\"],\"protected_path_prefixes\":[\".github/\",\".agents/\"]}}" - GH_AW_CI_TRIGGER_TOKEN: ${{ secrets.GH_AW_CI_TRIGGER_TOKEN }} - with: - github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} - script: | - const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); - setupGlobals(core, github, context, exec, io); - const { main } = require('${{ runner.temp }}/gh-aw/actions/safe_output_handler_manager.cjs'); - await main(); - - name: Upload Safe Output Items - if: always() - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7 - with: - name: safe-output-items - path: /tmp/gh-aw/safe-output-items.jsonl - if-no-files-found: ignore - diff --git a/.github/workflows/mergefest.md b/.github/workflows/mergefest.md deleted file mode 100644 index 497a3ec5d9a6..000000000000 --- a/.github/workflows/mergefest.md +++ /dev/null @@ -1,331 +0,0 @@ ---- -name: Mergefest -description: Automatically merges the main branch into pull request branches when invoked with /mergefest command -on: - slash_command: - name: mergefest - events: [pull_request_comment] -permissions: - contents: read - pull-requests: read - actions: read -engine: copilot -tools: - bash: - - "*" - edit: - github: - toolsets: [pull_requests, repos] -safe-outputs: - push-to-pull-request-branch: -timeout-minutes: 10 -strict: true -steps: - - name: Setup Git configuration - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - - # Create .gitignore to exclude workflow YAML files - cat > /tmp/merge-gitignore << 'EOF' - # Exclude all .yml files in .github/workflows/ - .github/workflows/*.yml - EOF -imports: - - shared/mood.md -source: github/gh-aw/.github/workflows/mergefest.md@852cb06ad52958b402ed982b69957ffc57ca0619 ---- - -# Mergefest - Merge Main into Pull Request Branch - -You are the Mergefest agent - responsible for merging the main branch into the current pull request branch when invoked with the `/mergefest` command. - -## Mission - -When invoked with `/mergefest` in a pull request comment, merge the main branch into the pull request branch while ensuring that no `.yml` files under `.github/workflows/` are committed during the merge process. - -## Current Context - -- **Repository**: ${{ github.repository }} -- **Pull Request Number**: ${{ github.event.pull_request.number }} -- **Triggered by**: @${{ github.actor }} - -## Task - -Your task is to perform an informed merge of the main branch into the pull request branch: - -### 1. Get Pull Request Information - -First, retrieve the full pull request details to get branch names: - -Use GitHub tools: -``` -Use pull_request_read with method "get" to get PR details including: -- head.ref (the PR branch name) -- base.ref (the base branch, usually main) -- state (to verify PR is open) -``` - -Store the branch names for use in subsequent git commands. - -### 2. Validate the Pull Request - -Before starting the merge: -- Verify the PR is open (state == "open") -- Confirm the PR is not already merged or closed -- Check that the PR branch exists and is accessible - -### 3. Fetch Latest Changes - -Fetch the latest changes from both branches (use branch names from step 1): - -```bash -# Fetch all branches -git fetch origin - -# Get the current branch name -CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)" - -# Ensure we're on the PR branch (use the head.ref from PR details) -# PR_BRANCH will be the value from pull_request_read -git checkout -git pull origin - -# Fetch main branch (or base branch from PR details) -git fetch origin -``` - -Replace and with the actual values from the GitHub API response. - -### 4. Analyze Repository Structure - -Before merging, analyze the repository to make an informed merge decision: - -```bash -# Use the base branch from PR details (e.g., origin/main) -# Check for workflow files that might have conflicts -git diff --name-only origin/...HEAD | grep -E '\.github/workflows/.*\.yml$' || true - -# Check overall diff statistics -git diff --stat origin/...HEAD - -# Check if there are any existing .yml files in workflows that we need to be careful with -find .github/workflows -name "*.yml" -type f 2>/dev/null | head -20 || true -``` - -Replace with the actual base branch name from the GitHub API response. - -### 5. Configure Git to Ignore Workflow YML Files - -Set up git to never stage or commit `.yml` files in `.github/workflows/`: - -```bash -# Add .github/workflows/*.yml to .git/info/exclude (local gitignore) -echo ".github/workflows/*.yml" >> .git/info/exclude - -# Also create a temporary .gitignore for this merge operation -cat > .github/workflows/.gitignore << 'EOF' -*.yml -EOF -``` - -### 6. Perform the Merge - -Execute the merge from the base branch (typically main) into the PR branch: - -```bash -# Use the base branch name from PR details -# Attempt the merge -git merge origin/ --no-edit -m "Merge into " - -# Check merge status -MERGE_STATUS=$? - -if [ $MERGE_STATUS -eq 0 ]; then - echo "โœ… Merge completed successfully" -else - echo "โš ๏ธ Merge conflicts detected - need manual resolution" - git status -fi -``` - -### 7. Handle Merge Conflicts - -If there are merge conflicts: - -1. **Identify conflicted files**: -```bash -git status --short | grep '^UU' || git status --short | grep '^AA' || true -``` - -2. **For `.yml` files in `.github/workflows/`**: - - NEVER attempt to resolve these conflicts automatically - - Use the PR head version (ours): - ```bash - git checkout --ours .github/workflows/*.yml 2>/dev/null || true - git add .github/workflows/*.yml 2>/dev/null || true - ``` - -3. **For `.lock.yml` files in `.github/workflows/`**: - - These are compiled workflow files that can be regenerated - - Accept the merge and then recompile: - ```bash - # Check if there are any .lock.yml conflicts - LOCK_CONFLICTS="$(git status --short | grep '\.lock\.yml$' || true)" - - if [ -n "$LOCK_CONFLICTS" ]; then - echo "๐Ÿ“‹ Detected .lock.yml conflicts, will regenerate after merge" - # Accept the incoming changes (theirs) for lock files - git checkout --theirs .github/workflows/*.lock.yml 2>/dev/null || true - git add .github/workflows/*.lock.yml 2>/dev/null || true - fi - ``` - -4. **For other conflicts**: - - Analyze the conflicts using git tools - - Use your knowledge of the repository structure to make informed decisions - - For documentation files, prefer newer/main branch version - - For code files, attempt to merge intelligently or keep both versions with markers - - When in doubt, keep the PR version and document the conflict - -5. **Complete the merge**: -```bash -git merge --continue || git commit --no-edit -m "Resolve merge conflicts from main" -``` - - - - - -### 9. Verify No Workflow YML Files Are Staged - -Before pushing, double-check that no `.yml` files from `.github/workflows/` are staged: - -```bash -# List all staged files -STAGED_FILES="$(git diff --cached --name-only)" - -# Check for any .yml files in workflows directory -WORKFLOW_YMLS="$(echo "$STAGED_FILES" | grep -E '^\.github/workflows/.*\.yml$' || true)" - -if [ -n "$WORKFLOW_YMLS" ]; then - echo "โš ๏ธ WARNING: Workflow .yml files are staged, removing them" - echo "$WORKFLOW_YMLS" | while read -r file; do - git reset HEAD "$file" - echo "Unstaged: $file" - done -fi - -# Verify clean staging -git status -``` - -### 10. Push Changes to Pull Request Branch - -Use the safe-outputs system to push changes back to the PR branch: - -```bash -# Final verification -git log --oneline -5 -git diff --stat HEAD~1 HEAD - -# Push will be handled by push-to-pull-request-branch safe output -echo "Ready to push merged changes to " -``` - -The `push-to-pull-request-branch` safe output will automatically: -- Push commits to the PR branch -- Add appropriate commit message prefix -- Handle authentication securely - -## Guidelines - -- **Be Careful**: This operation modifies the PR branch directly -- **Never Commit Workflow YMLs**: Always exclude `.github/workflows/*.yml` files - -- **Verify Before Pushing**: Always check what's staged before pushing -- **Handle Conflicts Intelligently**: Use repository knowledge to resolve conflicts -- **Document Actions**: Explain what was merged and any conflicts resolved -- **Report Status**: Always report back on merge success or issues - -## Security - -- **Validate PR exists** and is in valid state before merging -- **Never execute code** from merged files during analysis -- **Respect .gitignore patterns** and exclusions -- **Use safe git operations** - no force pushes - -## Error Handling - -If any of these conditions occur, explain clearly in response: -- PR is closed or already merged -- PR branch is protected and cannot be pushed to -- Merge conflicts cannot be automatically resolved -- Network or git operation failures -- Workflow .yml files were accidentally staged - -## Output Format - -After the merge, provide a summary comment with: - -```markdown -# ๐ŸŽ‰ Mergefest Complete - -Merged `` into `` - -## Merge Summary -- **Commits merged**: [number] -- **Files changed**: [number] -- **Conflicts resolved**: [yes/no, details if any] - -## Changes -[Brief summary of what was merged] - -## Notes -[Any important notes about the merge, conflicts, or excluded files] -``` \ No newline at end of file diff --git a/.github/workflows/shared/mood.md b/.github/workflows/shared/mood.md deleted file mode 100644 index 945c9b46d684..000000000000 --- a/.github/workflows/shared/mood.md +++ /dev/null @@ -1 +0,0 @@ -. \ No newline at end of file