Skip to content

Latest commit

 

History

History
297 lines (214 loc) · 23.6 KB

File metadata and controls

297 lines (214 loc) · 23.6 KB

Client.Pins

Overview

Available Operations

update

Update an existing user-generated pin.

Example Usage

package hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.components.*;
import com.glean.api_client.glean_api_client.models.operations.EditpinResponse;
import java.lang.Exception;
import java.util.List;

public class Application {

    public static void main(String[] args) throws Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        EditpinResponse res = sdk.client().pins().update()
                .editPinRequest(EditPinRequest.builder()
                    .audienceFilters(List.of(
                        FacetFilter.builder()
                            .fieldName("type")
                            .values(List.of(
                                FacetFilterValue.builder()
                                    .value("Spreadsheet")
                                    .relationType(RelationType.EQUALS)
                                    .build(),
                                FacetFilterValue.builder()
                                    .value("Presentation")
                                    .relationType(RelationType.EQUALS)
                                    .build()))
                            .build()))
                    .build())
                .call();

        if (res.pinDocument().isPresent()) {
            System.out.println(res.pinDocument().get());
        }
    }
}

Parameters

Parameter Type Required Description
locale Optional<String> The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en.
editPinRequest EditPinRequest ✔️ Edit pins request

Response

EditpinResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 4XX, 5XX */*

retrieve

Read pin details given its ID.

Example Usage

package hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.components.GetPinRequest;
import com.glean.api_client.glean_api_client.models.operations.GetpinResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        GetpinResponse res = sdk.client().pins().retrieve()
                .getPinRequest(GetPinRequest.builder()
                    .build())
                .call();

        if (res.getPinResponse().isPresent()) {
            System.out.println(res.getPinResponse().get());
        }
    }
}

Parameters

Parameter Type Required Description
locale Optional<String> The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en.
getPinRequest GetPinRequest ✔️ Get pin request

Response

GetpinResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 4XX, 5XX */*

list

Lists all pins.

Example Usage

package hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.operations.ListpinsRequestBody;
import com.glean.api_client.glean_api_client.models.operations.ListpinsResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        ListpinsResponse res = sdk.client().pins().list()
                .requestBody(ListpinsRequestBody.builder()
                    .build())
                .call();

        if (res.listPinsResponse().isPresent()) {
            System.out.println(res.listPinsResponse().get());
        }
    }
}

Parameters

Parameter Type Required Description
locale Optional<String> The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en.
requestBody ListpinsRequestBody ✔️ List pins request

Response

ListpinsResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 4XX, 5XX */*

create

Pin a document as a result for a given search query.Pin results that are known to be a good match.

Example Usage

package hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.components.*;
import com.glean.api_client.glean_api_client.models.operations.PinResponse;
import java.lang.Exception;
import java.util.List;

public class Application {

    public static void main(String[] args) throws Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        PinResponse res = sdk.client().pins().create()
                .pinRequest(PinRequest.builder()
                    .audienceFilters(List.of(
                        FacetFilter.builder()
                            .fieldName("type")
                            .values(List.of(
                                FacetFilterValue.builder()
                                    .value("Spreadsheet")
                                    .relationType(RelationType.EQUALS)
                                    .build(),
                                FacetFilterValue.builder()
                                    .value("Presentation")
                                    .relationType(RelationType.EQUALS)
                                    .build()))
                            .build()))
                    .build())
                .call();

        if (res.pinDocument().isPresent()) {
            System.out.println(res.pinDocument().get());
        }
    }
}

Parameters

Parameter Type Required Description
locale Optional<String> The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en.
pinRequest PinRequest ✔️ Details about the document and query for the pin.

Response

PinResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 4XX, 5XX */*

remove

Unpin a previously pinned result.

Example Usage

package hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.components.Unpin;
import com.glean.api_client.glean_api_client.models.operations.UnpinResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        UnpinResponse res = sdk.client().pins().remove()
                .unpin(Unpin.builder()
                    .build())
                .call();

        // handle response
    }
}

Parameters

Parameter Type Required Description
locale Optional<String> The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en.
unpin Unpin ✔️ Details about the pin being unpinned.

Response

UnpinResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 4XX, 5XX */*