Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce API instance pattern #3

Merged
merged 6 commits into from
Nov 2, 2023
Merged

Conversation

nkzou
Copy link
Collaborator

@nkzou nkzou commented Oct 19, 2023

Refactors all api function calls to be part of an overall <name>API struct, which holds a configuration object. This reduces the amount of config passing needed.
Also introduces the with_http_info pattern so end users can choose to use a less verbose function call without details http response info.

usage example:

use datadog_api_client::datadog::configuration::Configuration;
use datadog_api_client::datadogV2::api::api_fastly_integration::{CreateFastlyAccountParams, FastlyIntegrationAPI};
use datadog_api_client::datadogV2::model::*;

#[tokio::main]
async fn main() {
    let configuration = Configuration::new();
    let fastly_api = FastlyIntegrationAPI::with_config(configuration);

    let params = CreateFastlyAccountParams {
        body: FastlyAccountCreateRequest {
            data: Box::new(FastlyAccountCreateRequestData {
                attributes: Box::new(FastlyAccountCreateRequestAttributes {
                    api_key: "fakesecretkey".to_string(),
                    name: "fastly_account_name".to_string(),
                    services: None,
                }),
                type_: FastlyAccountType::FASTLY_ACCOUNTS,
            }),
        },
    };
    let result = fastly_api.create_fastly_account(params).await;
    println!("{:#?}", result);
}

…th_http_info pattern for less verbose function calls
@nkzou nkzou changed the title Introduce API object pattern Introduce API instance pattern Oct 23, 2023
@nkzou nkzou merged commit aa03ff8 into master Nov 2, 2023
4 checks passed
@nkzou nkzou deleted the kevinzou/api_client_pattern branch November 2, 2023 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants