Edits history of script submission #1395 for ' Update a project for a workspace (bitbucket)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Bitbucket = {
      username: string;
      password: string;
    };
    /**
     * Update a project for a workspace
     * Since this endpoint can be used to both update and to create a
    project, the request body depends on the intent.
     */
    export async function main(
      auth: Bitbucket,
      project_key: string,
      workspace: string,
      body: { type: string; [k: string]: unknown } & {
        links?: {
          html?: { href?: string; name?: string };
          avatar?: { href?: string; name?: string };
        };
        uuid?: string;
        key?: string;
        owner?: ({ type: string; [k: string]: unknown } & {
          links?: {
            avatar?: { href?: string; name?: string };
            [k: string]: unknown;
          };
          created_on?: string;
          display_name?: string;
          username?: string;
          uuid?: string;
          [k: string]: unknown;
        }) & {
          links?: {
            avatar?: { href?: string; name?: string };
            [k: string]: unknown;
          } & {
            self?: { href?: string; name?: string };
            html?: { href?: string; name?: string };
            members?: { href?: string; name?: string };
            projects?: { href?: string; name?: string };
            repositories?: { href?: string; name?: string };
            [k: string]: unknown;
          };
          [k: string]: unknown;
        };
        name?: string;
        description?: string;
        is_private?: boolean;
        created_on?: string;
        updated_on?: string;
        has_publicly_visible_repos?: boolean;
        [k: string]: unknown;
      }
    ) {
      const url = new URL(
        `https://api.bitbucket.org/2.0/workspaces/${workspace}/projects/${project_key}`
      );
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 375 days ago

  • nativets
    type Bitbucket = {
      username: string;
      password: string;
    };
    /**
     * Update a project for a workspace
     * Since this endpoint can be used to both update and to create a
    project, the request body depends on the intent.
     */
    export async function main(
      auth: Bitbucket,
      project_key: string,
      workspace: string,
      body: { type: string; [k: string]: unknown } & {
        links?: {
          html?: { href?: string; name?: string };
          avatar?: { href?: string; name?: string };
        };
        uuid?: string;
        key?: string;
        owner?: ({ type: string; [k: string]: unknown } & {
          links?: {
            avatar?: { href?: string; name?: string };
            [k: string]: unknown;
          };
          created_on?: string;
          display_name?: string;
          username?: string;
          uuid?: string;
          [k: string]: unknown;
        }) & {
          links?: {
            avatar?: { href?: string; name?: string };
            [k: string]: unknown;
          } & {
            self?: { href?: string; name?: string };
            html?: { href?: string; name?: string };
            members?: { href?: string; name?: string };
            projects?: { href?: string; name?: string };
            repositories?: { href?: string; name?: string };
            [k: string]: unknown;
          };
          [k: string]: unknown;
        };
        name?: string;
        description?: string;
        is_private?: boolean;
        created_on?: string;
        updated_on?: string;
        has_publicly_visible_repos?: boolean;
        [k: string]: unknown;
      }
    ) {
      const url = new URL(
        `https://api.bitbucket.org/2.0/workspaces/${workspace}/projects/${project_key}`
      );
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 935 days ago

  • nativets
    type Bitbucket = {
      username: string;
      password: string;
    };
    /**
     * Update a project for a workspace
     * Since this endpoint can be used to both update and to create a
    project, the request body depends on the intent.
    
    #### Creation
    
    See the POST documentation for the project collection for an
    example of the request body.
    
    Note: The `key` should not be specified in the body of request
    (since it is already present in the URL). The `name` is required,
    everything else is optional.
    
    #### Update
    
    See the POST documentation for the project collection for an
    example of the request body.
    
    Note: The key is not required in the body (since it is already in
    the URL). The key may be specified in the body, if the intent is
    to change the key itself. In such a scenario, the location of the
    project is changed and is returned in the `Location` header of the
    response.
     */
    export async function main(
      auth: Bitbucket,
      project_key: string,
      workspace: string,
      body: { type: string; [k: string]: unknown } & {
        links?: {
          html?: { href?: string; name?: string };
          avatar?: { href?: string; name?: string };
        };
        uuid?: string;
        key?: string;
        owner?: ({ type: string; [k: string]: unknown } & {
          links?: {
            avatar?: { href?: string; name?: string };
            [k: string]: unknown;
          };
          created_on?: string;
          display_name?: string;
          username?: string;
          uuid?: string;
          [k: string]: unknown;
        }) & {
          links?: {
            avatar?: { href?: string; name?: string };
            [k: string]: unknown;
          } & {
            self?: { href?: string; name?: string };
            html?: { href?: string; name?: string };
            members?: { href?: string; name?: string };
            projects?: { href?: string; name?: string };
            repositories?: { href?: string; name?: string };
            [k: string]: unknown;
          };
          [k: string]: unknown;
        };
        name?: string;
        description?: string;
        is_private?: boolean;
        created_on?: string;
        updated_on?: string;
        has_publicly_visible_repos?: boolean;
        [k: string]: unknown;
      }
    ) {
      const url = new URL(
        `https://api.bitbucket.org/2.0/workspaces/${workspace}/projects/${project_key}`
      );
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 935 days ago